#!/usr/bin/env python3 """Phase 8 numerical audit: every quantitative claim in the manuscript prose is mapped to a value in experiments/results/key_numbers.json (or the test suite) and checked within a tolerance. Exits non-zero on mismatch.""" import json, re, sys, os root = os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."); k = json.load(open(os.path.join(root, "experiments", "results", "key_numbers.json"))) text = "".join(open(os.path.join(root, "paper", "sections", f)).read() for f in ["introduction.tex", "setup.tex", "microbenchmarks.tex", "endtoend.tex", "applications.tex", "correctness.tex", "conclusion.tex", "threats.tex"]) abstract = open(os.path.join(root, "paper", "main.tex")).read() def present(s): return s in text or s in abstract checks = [] def chk(claim, value, fmt, tol=None): s = fmt.format(value); ok = present(s); checks.append((claim, s, ok)) P = k["primitives"]; B = k["breakeven"]; E1 = k["E1"]; E2 = k["E2"]; E3 = k["E3"]; E4 = k["E4"]; E5 = k["E5"]; E6 = k["E6"]; E7 = k["E7"] chk("primitives: realized 100x390 speedup", P["realized_fused@100x390"]["speedup"], "{:.1f}$\\times$") chk("primitives: realized max speedup", B["realized_fused"]["max_speedup"], "3.4$\\times$") chk("primitives: regression 1x390000 speedup", P["regression_stats@1x390000"]["speedup"], "{:.1f}$\\times$") chk("primitives: garch P64 max", B["garch_nll_P64"]["max_speedup"], "{:.1f}$\\times$") chk("primitives: garch P64 100x390", P["garch_nll_P64@100x390"]["speedup"], "{:.1f}$\\times$") chk("E1: cpuMT 926 day ms", E1["real_S926_day"]["cpuMT_ms"], "29--30\\,ms") chk("E1: speedup low", min(E1[f"real_S926_{s}"]["speedup_MT"] for s in ["day", "week", "month", "year"]), "{:.2f}--") chk("E1: speedup high", max(E1[f"real_S926_{s}"]["speedup_MT"] for s in ["day", "week", "month", "year"]), "--{:.2f}$\\times$") chk("E1: max rel err daily", E1["real_S926_day"]["max_rel_err"], "$1.6\\times10^{{-7}}$") chk("E1: max rel err yearly", E1["real_S926_year"]["max_rel_err"], "$1.4\\times10^{{-8}}$") chk("E2: HAR qlike h1", E2["accuracy"]["h1"]["har"], "{:.3f}") chk("E2: RW qlike h22", E2["accuracy"]["h22"]["rw"], "{:.3f}") chk("E2: HAR beats RW h1", E2["accuracy"]["h1"]["har_beats_rw_pct"], "{:.0f}\\,\\%") chk("E2: log-HAR h22", E2["accuracy"]["h22"]["loghar"], "{:.3f}") chk("E3: symbols", E3["symbols"], "{} symbols") chk("E3: EGARCH convergence", E3["egarch.n"]["converged_pct"], "{:.1f}\\,\\%") chk("E3: GJR convergence", E3["gjr.n"]["converged_pct"], "{:.1f}\\,\\%") chk("E3: grid metal ms", E3["grid"]["metal_ms"], "{:.0f}\\,ms on Metal") chk("E3: grid cpu ms", E3["grid"]["cpuMT_ms"], "{:.0f}\\,ms on 18 CPU threads") chk("E3: grid speedup", E3["grid"]["cpuMT_ms"] / E3["grid"]["metal_ms"], "({:.1f}$\\times$)") chk("E4: cond N=30", E4["30"]["cond_median"], "{:.0f} ($N = 30$)") chk("E4: dy ms N=100", E4["100"]["dy_ms"], "and {:.0f}\\,ms") chk("E5: beta bias n500", E5["garch_n500"]["beta"]["bias"], "(${:.3f}$)") chk("E5: repro metal vs cpu", E5["repro_realized"]["metal_vs_cpu_max_rel_rv"], "$3.7\\times10^{{-8}}$") chk("E6: RAID cpu s", E6["RAID cpu"]["median_s"], "{:.3f}\\,s") chk("E6: polars s", E6["polars"]["median_s"], "{:.3f}\\,s") chk("E6: duckdb s", E6["duckdb"]["median_s"], "{:.3f}\\,s") chk("E6: pandas s", E6["pandas"]["median_s"], "{:.2f}\\,s") chk("E6: read s", E6["read_s"], "{:.3f}\\,s") chk("E7: M2 RV speedup", E7["m2m8a"]["realized_fused@1000x3900_speedup_MT"], "{:.1f}$\\times$ (M2") chk("E7: M2 Max GARCH", E7["M2M32c"]["garch_nll_P64@1000x390_speedup_MT"], "{:.1f}$\\times$ (M2~Max)") chk("E7: M5 Pro GARCH", E7["m5ma"]["garch_nll_P64@1000x390_speedup_MT"], "{:.1f}$\\times$ (M5~Pro)") bad = [c for c in checks if not c[2]] for c in checks: print(("OK " if c[2] else "MISS"), c[0], "->", c[1]) print(f"{len(checks) - len(bad)}/{len(checks)} claims found verbatim in the prose") sys.exit(1 if bad else 0)