Research-Stack/4-Infrastructure/shim/gen_grammar_thread_receipts.py
allaun 77488ac0ae feat(lean): close gaussian_line_integral_unit_dir + consolidate infrastructure
Lean proof fixes:
- N3L_Energy.lean: fully close gaussian_line_integral_unit_dir (nlinarith+hab
  for unit-circle quadratic, sqrt_mul+neg_div for integral_gaussian_1d match,
  exp_sum_of_sq order fix, add_assoc for h_gauss_shift, sq_sqrt for field_simp,
  sq_abs for perpDistance hd)
- Add Adapters/AlphaProofNexus: 12 Erdos/graph adapter stubs (AlphaProof nexus)
- Add Adapters/ErgodicAdditive.lean, SidonMatroid.lean
- Add AntiDiophantine.lean, EffectiveBoundDQ.lean, PVGS_DQ_Bridge.lean
- Add FormalConjectures/Util/ProblemImports.lean
- Add RRC/EntropyCandidates/Candidates.lean
- Add OTOM external project (lakefile.toml, lake-manifest.json, lean-toolchain)

Infrastructure:
- Add 4-Infrastructure/shim/: 17 Python probes (RRC manifold, Sidon kernel,
  Wannier, arxiv harvest, math_symbols DB, coverage density, geometric entropy)
- Add 4-Infrastructure/NoDupeLabs/: Node server + package files
- Add 6-Documentation/docs/specs/DP_RRC_RECEIPT_ENCODING_SPEC.md
- Add fix_offloat.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 16:53:23 -05:00

227 lines
13 KiB
Python

#!/usr/bin/env python3
"""
gen_grammar_thread_receipts.py — Consolidated OTM receipt for the RRC grammar /
math-symbol thread.
Each claim is recorded with: status (CONFIRMED | FALSIFIED | SHIPPED), the named
theorem / established result it is rooted in (OTM provability doctrine), the
quantitative evidence, and sha256 witnesses computed live from the artifact files
on disk (so the receipt is replay-verifiable, not asserted).
Usage: python3 4-Infrastructure/shim/gen_grammar_thread_receipts.py
"""
from __future__ import annotations
import hashlib
import json
import time
from pathlib import Path
ROOT = Path("/home/allaun/Research Stack")
OUT = ROOT / "shared-data/data/rrc_grammar_thread_receipt.json"
def witness(rel: str) -> dict:
p = ROOT / rel
if not p.exists():
return {"path": rel, "present": False}
b = p.read_bytes()
return {"path": rel, "present": True, "bytes": len(b),
"sha256": hashlib.sha256(b).hexdigest()}
def W(*rels: str) -> list[dict]:
return [witness(r) for r in rels]
FINDINGS = [
# ── CONFIRMED ────────────────────────────────────────────────────────────
{
"id": "math_symbol_matrix",
"status": "CONFIRMED",
"claim": "Full math-symbol matrix (2953 symbols, 2437 with LaTeX) + LaTeX/Unicode "
"normalizer; unicode-math binds \\Gamma to a math-italic codepoint, so a "
"curated standard-LaTeX overlay is required.",
"rooted_in": "Unicode math repertoire (category Sm + Greek/Letterlike/Math-Alphanumeric blocks); "
"wspr/unicode-math unicode-math-table.tex",
"evidence": {"symbols": 2953, "with_latex": 2437, "latex_to_char": 2495},
"witnesses": W("shared-data/data/math_symbols_v1.json",
"shared-data/data/unicode-math-table.tex",
"4-Infrastructure/shim/math_symbols.py",
"4-Infrastructure/shim/build_math_symbols_db.py"),
},
{
"id": "ascii_letter_fix",
"status": "CONFIRMED",
"claim": "ASCII letters A-Z a-z were mis-bucketed as role 'symbol' (same math-italic "
"quirk as Greek); reclassified to 'math_letter'. symbol bucket 12567 -> 82.",
"rooted_in": "Unicode general category (Lu/Ll = letters, not Sm symbols)",
"evidence": {"symbol_before": 12567, "symbol_after": 82, "letters_reclassified": 52},
"witnesses": W("4-Infrastructure/shim/rrc_arxiv_kernel_refine.py",
"4-Infrastructure/shim/math_symbols.py",
"shared-data/data/role_kernel_v2.json"),
},
{
"id": "geometry_kernel_v7",
"status": "CONFIRMED",
"claim": "Pure-local geometry/topology kernel (kernel_refine_v7) with 9 subfields + "
"case-sensitive tensor-notation signatures; fills the previously-dead "
"ProjectableGeometryTopology shape in the core RRC tagger. Self-test 10/10.",
"rooted_in": "Named differential-geometry invariants (Christoffel, Riemann, Ricci, "
"Einstein, Gauss-Bonnet, Hodge); OTM provability doctrine",
"evidence": {"subfields": 9, "notation_signatures": 17, "self_test": "10/10",
"note": "v1/v3/v4 SSH-DB stages non-deterministic (9-10/10 flake)"},
"witnesses": W("4-Infrastructure/shim/rrc_arxiv_kernel_refine.py",
"4-Infrastructure/shim/rrc_self_classify.py",
"4-Infrastructure/shim/rrc_ray_tagger.py"),
},
{
"id": "affine_a2_grammar",
"status": "CONFIRMED",
"claim": "Operator-role grammar (2418-paper bootstrap, 15/15 pairs phi>0) has a 5-node "
"partial-correlation graph with a cycle relation-binary_op-arrow + greek/nary "
"pendants on the relation hub: the affine A~2 extended-Dynkin diagram, not a "
"finite Dynkin tree. Effective rank ~6-7.5 (E6-E8 band), reducible.",
"rooted_in": "Extended (affine) Dynkin diagram classification; affine Kac-Moody algebras "
"(cyclic diagram <=> affine type)",
"evidence": {"papers": 2418, "simple_corr_positive": "15/15", "partial_direct_edges": 5,
"effective_rank_operator": 6.09, "effective_rank_full": 7.55, "type": "affine A~2"},
"witnesses": W("shared-data/data/grammar_graph_probe_v2.json",
"shared-data/data/rrc_root_system_probe_receipt.json",
"4-Infrastructure/shim/rrc_root_system_probe.py"),
},
{
"id": "genre_decomposition",
"status": "CONFIRMED",
"claim": "RRC corpus decomposes into 5 irreducible notation-genre sectors; "
"KL(balanced_algebra||dataflow)=2.88 bits = most divergent sectors.",
"rooted_in": "Shannon entropy / Kullback-Leibler divergence; irreducible-component "
"decomposition of the reducible role-coupling",
"evidence": {"sectors": {"balanced_algebra": 0.42, "conditional": 0.12, "dataflow": 0.05,
"analysis": 0.004, "unclassified": 0.41},
"kl_algebra_dataflow_bits": 2.88},
"witnesses": W("4-Infrastructure/shim/rrc_genre_decompose.py",
"shared-data/data/rrc_root_system_probe_receipt.json"),
},
{
"id": "sidon_kernel_hub_weighting",
"status": "CONFIRMED",
"claim": "Sidon generation kernel (kernel_refine_v6, 359 entries) reweighted by the "
"partial-correlation hub structure (relation=4 hub ... operator=0.5 isolated). "
"Sidon notation sits at the grammar core, not a peripheral sector.",
"rooted_in": "Partial-correlation (Gaussian graphical model) degree centrality; "
"affine A~2 hub structure",
"evidence": {"kernel_entries": 359, "sources": {"arxiv": 290, "rrc_eq": 16,
"apn_lean": 12, "openwebmath": 41},
"weights": {"relation": 4.0, "binary_op": 2.0, "arrow": 2.0,
"greek_letter": 1.5, "nary_operator": 1.5, "operator": 0.5}},
"witnesses": W("shared-data/data/sidon_generation_kernel_v1.json",
"4-Infrastructure/shim/rrc_arxiv_kernel_refine.py"),
},
{
"id": "reconstruction_sector",
"status": "PARTIAL — sector wiring CONFIRMED; Lean proofs FAIL TO BUILD; conjecture OPEN",
"claim": "Graph Reconstruction Conjecture wired as a named sector across all layers: "
"genre decomposition (count 2, signature binary_op+relation+arrow), a dedicated "
"kernel (7 arxiv papers + 2 Lean), and BOTH RRC pipelines (batch kernel_refine v0 "
"@ line 859 + interactive self_classify v0, fires first — self_classify gap fixed "
"this session). The conjecture itself remains OPEN; Lean witnesses are "
"sorry/admit/axiom-free SPECIAL CASES (bipartite reconstruction, spanning-tree/leaf "
"lemmas), NOT the general conjecture (which is false for locally-finite trees).",
"rooted_in": "Reconstruction Conjecture (Kelly 1942 / Ulam 1960); Kelly's lemma; "
"counterexample for locally-finite trees (arXiv 1606.02926)",
"evidence": {
"genre_sector": {"count": 2, "pct": 0.8,
"signature": {"binary_op": 0.4, "relation": 0.35, "arrow": 0.25},
"kl_from_balanced_algebra_bits": 2.17, "kl_from_dataflow_bits": 3.67},
"kernel": {"arxiv_papers": 7, "lean_files_claimed": 2, "lean_proofs_verified": 0},
"pipeline_v0_first": {"batch_kernel_refine": True, "self_classify": True},
"lean_build_status": {
"verdict": "BUILD FAILED — both files are 0-sorry in source but DO NOT COMPILE, "
"so neither is a valid proof (cannot be receipted as green)",
"bipartite_reconstruction.lean": "FAILS: simp_all no progress (148), unsolved "
"goals (179), nested simp failures (374,618)",
"graph_conjecture2.lean": "FAILS: missing dep Semantics.FormalConjectures.Util."
"ProblemImports + undefined SimpleGraph.indepNeighbors/Ls",
},
"self_test_safety": "v0 intercepts 0/10 test eqs; 9-10/10 flake is the SSH/DB dependency",
},
"witnesses": W("shared-data/data/reconstruction_kernel_v1.json",
"shared-data/data/rrc_genre_decomposition_v1.json",
"0-Core-Formalism/lean/Semantics/Semantics/Adapters/AlphaProofNexus/bipartite_reconstruction.lean",
"0-Core-Formalism/lean/Semantics/Semantics/Adapters/AlphaProofNexus/graph_conjecture2.lean",
"4-Infrastructure/shim/rrc_arxiv_kernel_refine.py",
"4-Infrastructure/shim/rrc_self_classify.py"),
},
# ── FALSIFIED ────────────────────────────────────────────────────────────
{
"id": "delta_conservation_law",
"status": "FALSIFIED",
"claim": "Hypothesis: the affine delta=(1,1,1) gives a per-equation conserved quantity "
"(role balance) usable as a notation validity check.",
"rooted_in": "Affine Cartan null vector / imaginary root delta; quadratic form "
"Q=(r-b)^2+(b-a)^2+(a-r)^2; multinomial null model",
"evidence": {"conservation_strength": 0.89, "threshold": 1.15,
"centroid": [0.576, 0.391, 0.033], "centroid_to_delta": 0.391,
"reason": "affine cycle is a cross-corpus coupling, not a per-equation "
"invariant (category error); imbalance z-score is a genre "
"detector, not a validity check"},
"witnesses": W("shared-data/data/rrc_affine_conservation_receipt.json",
"4-Infrastructure/shim/rrc_affine_conservation_probe.py"),
},
{
"id": "clean_e8",
"status": "FALSIFIED",
"claim": "Hypothesis: the role-coupling matches a clean E8 (or simplex) structure.",
"rooted_in": "ADE Dynkin classification (finite types are trees; E8 = Gosset 4_21)",
"evidence": {"reason": "graph is reducible and contains a cycle => affine, not finite "
"ADE; effective rank ~6-7.5 reducible, not single irreducible"},
"witnesses": W("shared-data/data/rrc_root_system_probe_receipt.json"),
},
{
"id": "complete_graph",
"status": "FALSIFIED",
"claim": "Hypothesis: all operator roles are directly coupled (complete graph).",
"rooted_in": "Partial correlation vs marginal correlation (Gaussian graphical model)",
"evidence": {"simple_corr_positive": "15/15", "partial_direct_edges": 5,
"reason": "simple correlation 15/15 positive but partial correlation leaves "
"only 5 direct edges; the rest are indirect (mediated)"},
"witnesses": W("shared-data/data/grammar_graph_probe_v2.json"),
},
]
def main() -> None:
counts = {"CONFIRMED": 0, "FALSIFIED": 0}
integrity_ok = True
for f in FINDINGS:
counts[f["status"]] = counts.get(f["status"], 0) + 1
for w in f["witnesses"]:
if not w.get("present"):
integrity_ok = False
receipt = {
"schema": "rrc_grammar_thread_receipt_v1",
"title": "RRC operator-grammar / math-symbol matrix thread",
"generated_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
"doctrine": "OTM: every statement provable, rooted in named theorems or established results",
"summary": {
"confirmed": counts.get("CONFIRMED", 0),
"falsified": counts.get("FALSIFIED", 0),
"all_witnesses_present": integrity_ok,
},
"findings": FINDINGS,
}
OUT.write_text(json.dumps(receipt, indent=2, ensure_ascii=False))
print(f"Wrote {OUT}")
print(f" CONFIRMED: {counts.get('CONFIRMED',0)} FALSIFIED: {counts.get('FALSIFIED',0)} "
f"witnesses_present: {integrity_ok}")
for f in FINDINGS:
miss = [w["path"] for w in f["witnesses"] if not w.get("present")]
flag = "" if not miss else f" MISSING: {miss}"
print(f" [{f['status']:9}] {f['id']:28} {len(f['witnesses'])} witnesses{flag}")
if __name__ == "__main__":
main()