#!/usr/bin/env python3 """verify-run-supremacy.py -- the checker for job #2978's finite claim, offline. The claim: over every witness certificate the corpus recorded (the 22 rows of `witness-runs.json`, which is the survey served by return #1569), the longest COVERED RUN is 309 positions -- the return #1554 certificate at rung 307, covering [-2,306] -- and no row reaches 310. Therefore no recorded witness decides R = 310: the translate family of the record's best certificate covers [0,308] (prefix 309, A >= 1859) and stops one position short of the target (prefix 310 would need a run of 310 and would give A >= 1865). Registered expectations, checked against the raw rows: * 22 rows, all carrying run_lo/run_hi; * supremum run length 309, achieved by exactly one row, and that row is rung 307 / prefix 307 with run_lo -2 and run_hi 306; * rows with run length >= 310: none; * the second-longest run is 291 (the rung-285 witness), so the gap between the best and the next is not the artefact of one odd row. Own controls (a check that cannot fire is not a check): a synthetic row of 310 positions must make the checker report the target as decided; a synthetic row of 309 must not; a row without run values must be refused rather than read as zero. Exit codes: 0 PASS, 2 a registered value differs, 3 a control was not detected. python3 verify-run-supremacy.py --input witness-runs.json [--target 310] """ import argparse import io import json import sys EXPECT_ROWS = 22 EXPECT_SUPREMUM = 309 EXPECT_SECOND = 291 EXPECT_TOP = {"rung": 307, "prefix": 307, "run_lo": -2, "run_hi": 306} EXPECT_REACHING = 0 def runs(rows): out, refused = [], [] for r in rows: lo, hi = r.get("run_lo"), r.get("run_hi") if lo is None or hi is None: refused.append(r) else: out.append((hi - lo + 1, r)) out.sort(key=lambda t: -t[0]) return out, refused def decide(rows, target): rr, _ = runs(rows) return [r for (L, r) in rr if L >= target] def controls(target): c = [] base = [{"run_lo": 0, "run_hi": 8, "rung_line": [9]}] c.append({"name": "a run of exactly the target decides it", "detected": len(decide(base + [{"run_lo": -1, "run_hi": target - 2, "rung_line": [target]}], target)) == 1}) c.append({"name": "a run one position short does NOT decide it", "detected": decide(base + [{"run_lo": 0, "run_hi": target - 2, "rung_line": [target - 1]}], target) == []}) _, refused = runs([{"run_lo": None, "run_hi": None}, {"run_lo": 0, "run_hi": 5}]) c.append({"name": "a row without run values is refused, not counted", "detected": len(refused) == 1}) return c def main(): ap = argparse.ArgumentParser() ap.add_argument("--input", required=True) ap.add_argument("--target", type=int, default=310) a = ap.parse_args() data = json.load(io.open(a.input, encoding="utf-8")) rows = data["rows"] ctl = controls(a.target) if not all(x["detected"] for x in ctl): print(json.dumps({"verdict": "CONTROL-FAILED", "controls": ctl}, indent=1)) return 3 rr, refused = runs(rows) reaching = [r for (L, r) in rr if L >= a.target] top = rr[0] if rr else None derived = { "rows": len(rows), "refused_rows": len(refused), "supremum_run": top[0] if top else None, "supremum_row": ({"rung": (top[1].get("rung_line") or [None])[0], "prefix": top[1].get("prefix"), "run_lo": top[1].get("run_lo"), "run_hi": top[1].get("run_hi")} if top else None), "second_run": rr[1][0] if len(rr) > 1 else None, "rows_reaching_target": len(reaching), "free_bound": 6 * top[0] + 5 if top else None, "target_bound": 6 * a.target + 5, } bad = [] if derived["rows"] != EXPECT_ROWS: bad.append("rows: %d, registered %d" % (derived["rows"], EXPECT_ROWS)) if derived["refused_rows"]: bad.append("%d row(s) carry no run values" % derived["refused_rows"]) if derived["supremum_run"] != EXPECT_SUPREMUM: bad.append("supremum run: %s, registered %d" % (derived["supremum_run"], EXPECT_SUPREMUM)) if derived["second_run"] != EXPECT_SECOND: bad.append("second run: %s, registered %d" % (derived["second_run"], EXPECT_SECOND)) for k, v in EXPECT_TOP.items(): if (derived["supremum_row"] or {}).get(k) != v: bad.append("the top row's %s: %s, registered %s" % (k, (derived["supremum_row"] or {}).get(k), v)) if derived["rows_reaching_target"] != EXPECT_REACHING: bad.append("rows reaching the target: %d, registered %d" % (derived["rows_reaching_target"], EXPECT_REACHING)) out = {"verdict": "PASS" if not bad else "FAIL", "differences": bad, "derived": derived, "controls": ctl, "controls_all_detected": all(x["detected"] for x in ctl), "conclusion": ("no recorded witness decides R = %d; the record's best translate covers " "[0,%d] and certifies A >= %d" % (a.target, EXPECT_SUPREMUM - 1, derived["free_bound"]))} print(json.dumps(out, indent=1, sort_keys=True)) return 0 if not bad else 2 if __name__ == "__main__": sys.exit(main())