make_notebook.py — src/14-entropy

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

14-entropy ledgersrc/14-entropy/make_notebook.py · 4.4 KBmake_notebook.pyColab
1#!/usr/bin/env python32"""Builds frc-14-entropy.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 (`p14022`: Colab opens the notebook at that cell with `#scrollTo=p14022`).4A predicate cell states the predicate (its text, from the site's ledger JSON) and runs `predicate("14:C5")`: the blocks of the5predicate's deciding and citing families run 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 entropy as dcommon910PKG = "14-entropy"; NB = f"frc-{PKG}.ipynb"; PAPER = "14"11LEDGER_URL = f"https://finitering.space/{PKG}/"; SECTION = "5.3"          # the paper's ledger page and the subsection that carries the ledger (Claim status: Predicate ledger)12CITE = "Akhtman & Voether, Preprints 2026"; DOI = "https://doi.org/10.20944/preprints202608.0310.v1"                       # the heading's citation, linked to the article13SCRIPT = "entropy.py"; SCRIPTS = f"[`{SCRIPT}`](https://finitering.space/src/{PKG}/)"; RUNTIME = "≈ 5 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"""## De Sitter Entropy Estimates over Finite Holographic Substrate, [{CITE}]({DOI})3233Each cell below verifies one predicate of the paper's predicate ledger (Section {SECTION}; [{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-14-entropy --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_14_entropy 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 entropy.py`48(19 family checks, 92 micro-checks — EXACT counts on the laboratory Carrier and CHART computations on the published data — `results.json`, the figures in `out/`), `python3 -m frc_14_entropy` once installed.""", "summary")49code(f"""{INSTALL}50from frc_14_entropy 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