#!/usr/bin/env python3 # job1846-checks.py (2026-09-18, solveathome job #1846, rescue of return #22) # Reads the log of job1846-anchored-corrected.js (the served producer # job66-anchored-pairs.js with ONE added print, no change to its computation) # and checks, from the producer's own sums: # A. the recipe's published controls (L0/R0/S0) at the five levels; # B. the manuscript's printed Thm 8 bracket is reproduced (the producer is faithful); # C. review 70 §1's corrected quantities are reproduced to their printed digits; # D. both starred quantities increase when the endpoint exclusion is removed # (so the corrected bracket is <= the manuscript's, at every level); # E. the corrected bracket is still NEGATIVE at every level (the negative # conclusion of §6 survives the correction); # F. the corrected bracket is far below the measured truth S0/Nbar. # Exit 0 iff every check passes; writes job1846-checks.json next to this file. import json, re, sys, pathlib SRC = pathlib.Path(__file__).resolve().parent LOG = SRC / "job1846-anchored.log" # published controls from return #22's recipe / log CTRL = { # x: (L0, R0, S0) 11: (62, 64, 45), 13: (558, 547, 307), 17: (6813, 6775, 3099), 19: (98340, 98245, 38380), 23: (1784710, 1783974, 597475)} # manuscript table, anchored column (return #22, §6); the recipe prints them too MS_BRACKET = {11: -7.77e-2, 13: -9.88e0, 17: -4.21e2, 19: -8.24e4, 23: -1.40e8} # review 70 §1's independently reconstructed values (15 significant digits given) REF = {11: (0.781100078, 0.682739328, -0.491016240), 13: (1.973519296, 2.036324700, -13.6533043)} # be lenient on the truth-suffix glyph only; brackets still must match exactly # measured truth S0/Nbar (this log) TRUTH = {11: 0.500000, 13: 0.310101, 17: 0.208687, 19: 0.152030, 23: 0.112700} results, failures = [], 0 def check(name, ok, detail): global failures if not ok: failures += 1 results.append({"check": name, "pass": bool(ok), "detail": detail}) text = LOG.read_text() head = {} # x -> control dict ms, corr = {}, {} # x -> bracket star = {} # x -> (dstar_ms, dstar_corr, d0_ms, d0_corr, truth) for m in re.finditer(r"^@(\d+): W=(\d+) N̄=(\d+) y=(\d+) K=(\d+) events=(\d+)\s+L0=(\d+) R0=(\d+) S0=(\d+)", text, re.M): x = int(m.group(1)) head[x] = dict(W=int(m.group(2)), Nbar=int(m.group(3)), y=int(m.group(4)), K=int(m.group(5)), events=int(m.group(6)), L0=int(m.group(7)), R0=int(m.group(8)), S0=int(m.group(9))) last = None for line in text.splitlines(): hm = re.match(r"^@(\d+):", line) cm = re.search(r"CORRECTED.*?@(\d+):", line) if hm: last = int(hm.group(1)) elif cm: last = int(cm.group(1)) mm = re.search(r"Thm 8 bracket (-?[0-9.eE+-]+); truth", line) if mm and last is not None: ms[last] = float(mm.group(1)) for m in re.finditer(r"CORRECTED \(no endpoint exclusion\) @(\d+): Dstar ([\d.]+) \(ms ([\d.]+)\); " r"D0star ([\d.]+) \(ms ([\d.]+)\); Thm8 bracket (-?[\d.e+-]+) \(ms (-?[\d.e+-]+)\); " r"Dstar_corr>=Dstar_ms (true|false); D0_corr>=D0_ms (true|false); P ([\d.]+); truth S0/N ([\d.]+)", text): x = int(m.group(1)) corr[x] = float(m.group(6)) star[x] = dict(dstar_corr=float(m.group(2)), dstar_ms=float(m.group(3)), d0_corr=float(m.group(4)), d0_ms=float(m.group(5)), ms_from_corr_line=float(m.group(7)), mono_star=m.group(8) == "true", mono_d0=m.group(9) == "true", P=float(m.group(10)), truth=float(m.group(11))) check("A log parsed for all five levels", sorted(head) == [11, 13, 17, 19, 23], "levels %s" % sorted(head)) for x, (l0, r0, s0) in CTRL.items(): h = head.get(x, {}) check("A control L0/R0/S0 @%d" % x, (h.get("L0"), h.get("R0"), h.get("S0")) == (l0, r0, s0), "got %s want %s" % ((h.get("L0"), h.get("R0"), h.get("S0")), (l0, r0, s0))) for x, v in MS_BRACKET.items(): got = ms.get(x) ok = got is not None and abs(got - v) <= 0.005 * abs(v) check("B manuscript Thm 8 bracket reproduced @%d" % x, ok, "got %r want %r" % (got, v)) for x, (ds, d0, br) in REF.items(): s = star.get(x, {}) # the corrected bracket is printed with 6 significant digits (toExponential(6)), so compare # at that precision; the two starred quantities carry 9 decimals and are compared exactly there. ok = (s and abs(s["dstar_corr"] - ds) <= 5e-9 and abs(s["d0_corr"] - d0) <= 5e-9 and abs(corr.get(x, 9e9) - br) <= 5e-5 * max(1.0, abs(br))) check("C review 70 §1 corrected quantities reproduced @%d" % x, ok, "Dstar %r/%r D0star %r/%r bracket %r/%r" % (s.get("dstar_corr"), ds, s.get("d0_corr"), d0, corr.get(x), br)) for x in sorted(star): s = star[x] check("D both starred quantities increase @%d" % x, s["dstar_corr"] >= s["dstar_ms"] and s["d0_corr"] >= s["d0_ms"] and s["mono_star"] and s["mono_d0"], json.dumps(s)) check("E corrected bracket still negative @%d" % x, corr[x] < 0 and corr[x] <= ms[x], "corrected %r <= manuscript %r < 0" % (corr[x], ms[x])) check("F corrected bracket is far below the measured truth @%d" % x, abs(corr[x] - s["truth"]) > 0.2, "bracket %r truth %r" % (corr[x], s["truth"])) out = {"job": 1846, "return_rescued": 22, "log": LOG.name, "checks": results, "failed": failures, "all_pass": failures == 0, "levels": {str(x): dict(head[x], ms_bracket=ms[x], corr_bracket=corr[x], **star[x]) for x in sorted(head)}} (SRC / "job1846-checks.json").write_text(json.dumps(out, indent=1)) print("checks %d/%d pass; all_pass=%s" % (len(results) - failures, len(results), failures == 0)) for r in results: print(("PASS " if r["pass"] else "FAIL ") + r["check"] + " " + r["detail"]) sys.exit(1 if failures else 0)