make_notebook.py — src/10-dimensions

The script src/10-dimensions/make_notebook.py of the validation package of the paper 10-dim, rendered with an anchor per line. ▶ run the predicates on Google Colab.

10-dimensions ledgersrc/10-dimensions/make_notebook.py · 4.3 KBmake_notebook.pyColab
1#!/usr/bin/env python32"""Builds frc-10-dimensions.ipynb, the package's Colab notebook: one cell per witnessed predicate of the paper's ledger, each cell addressable3from the ledger page by the predicate's accession key as its stable id (`p10015`: Colab opens the notebook at that cell with `#scrollTo=p10015`).4A predicate cell states the predicate (its text, from the site's ledger JSON) and runs `predicate("10:C5")`: the script of the5predicate's deciding family runs once per session, the deciding check's source is printed from its marker (`# <paper>:<label> (<key>)`), and every6family record citing the predicate is listed with its verdict. Run: python3 make_notebook.py  (then execute the notebook)."""7import json, re, os8import dimensions as dcommon910PKG = "10-dimensions"; NB = f"frc-{PKG}.ipynb"; PAPER = "10"11LEDGER_URL = f"https://finitering.space/{PKG}/"; APPENDIX = "A"          # the paper's ledger page and the appendix that carries the ledger12CITE = "Akhtman, Preprints 2026"; DOI = "https://doi.org/10.20944/preprints202605.0668.v1"                       # the heading's citation, linked to the article13SCRIPT = "dimensions.py"; SCRIPTS = f"[`{SCRIPT}`](https://finitering.space/src/{PKG}/)"; RUNTIME = "≈ 10 s"      # the one script, linked to its source page14LEDGER = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "docs", PKG, f"{PKG}-ledger.json")15cells = []16def md(s, cid): cells.append({"cell_type": "markdown", "metadata": {"id": cid}, "source": s})17def code(s, cid): cells.append({"cell_type": "code", "metadata": {"id": cid}, "execution_count": None, "outputs": [], "source": s})1819def plain(tex):20    """The predicate\'s text for a code comment: TeX kept, whitespace collapsed, wrapped at 110 columns."""21    words = " ".join(tex.split()).split(" "); lines, cur = [], "#"22    for w in words:23        if len(cur) + 1 + len(w) > 110: lines.append(cur); cur = "#"24        cur += " " + w25    lines.append(cur); return "\n".join(lines)2627data = json.load(open(LEDGER, encoding="utf-8"))28rows = [r for b in data["blocks"] for r in b["rows"]]29witnessed = [r for r in rows if f"{PAPER}:{r['label']}" in dcommon.PREDICATES]3031md(f"""## Dimensional Analysis over Finite Holographic Substrate, [{CITE}]({DOI})3233Each cell below verifies one predicate of the paper's predicate ledger (Appendix {APPENDIX}; [{LEDGER_URL[8:]}]({LEDGER_URL})): it runs the34blocks of {SCRIPTS} whose checks cite the predicate, prints the check and lists every record that cites it with its verdict. Any cell can be run first, or *Runtime → Run all* ({RUNTIME}).""", "header")3536# the package from the site as a named requirement through the site's find-links page (docs/pkg/index.html): pip checks the37# installed set first, so a second call in the session is "Requirement already satisfied" (a URL archive would be rebuilt every time)38INSTALL = "!pip install -q frc-10-dimensions --find-links https://finitering.space/pkg/"39md("""Every cell is self-contained: its first line installs the package from the site (pip reports it already satisfied once it is there), its last runs the predicate.""", "note")4041for r in witnessed:42    lab = f"{PAPER}:{r['label']}"43    code(f"{INSTALL}\n# {lab} ({r['key']}) [{r['tag']}] — the deciding family {dcommon.PREDICATES[lab]}\n{plain(r['predicate'])}\nfrom frc_10_dimensions import predicate; predicate(\"{lab}\")", r['key'])4445md("""## Summary4647The cells above are the paper's python-witnessed predicates; the whole script, family by family, is `python3 dimensions.py`48(13 family checks, 226 exact micro-checks, `results.json`), `python3 -m frc_10_dimensions` once installed.""", "summary")49code(f"""{INSTALL}50from frc_10_dimensions import verify_all51assert verify_all(), "a family check failed"52print("all family checks pass")""", "run-all")5354nb = {"cells": cells, "metadata": {"colab": {"provenance": [], "toc_visible": True}, "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"},55      "language_info": {"name": "python"}}, "nbformat": 4, "nbformat_minor": 5}56for c in nb["cells"]: c["id"] = c["metadata"]["id"]          # nbformat 4.5: the cell id at top level too, the same stable value57with open(NB, "w", encoding="utf-8") as f: json.dump(nb, f, indent=1, ensure_ascii=False); f.write("\n")58print(f"wrote {NB}: {len(cells)} cells, {len(witnessed)} predicate cells")59