#!/usr/bin/env python3 """run-supremacy.py -- does the RECORD already decide R = 310? (job 2978, triage of route 151) Route 151's next experiment is a new ascent run at R = 310. Before paying for one, ask the cheapest question there is: does any witness the corpus already recorded have a COVERED RUN of 310 or more positions? A witness whose covered run is L positions can be translated to cover [0, L-1], so it is a certificate at prefix L and certifies A >= 6L + 5 under the route's own map -- which means a recorded witness with L >= 310 would decide R = 310 (and lift the bound to 1865) with no search at all. The input is the job #2958 survey (`prefix-vs-run.json`, the same file served by return #1569): every witness certificate the corpus recorded, with its printed rung, its recomputed prefix and the run it actually covers. This script reads it, measures the supremum, and fires only when a row reaches 310. Controls (in the file, printed, and required for a PASS): * inert: the best row must be the R = 307 certificate of return #1554 (rung 307), not some other row; * positive: a synthetic row of length 311 must be detected as deciding R = 310 (so the detector can fire at all -- a check that cannot fire is not a check); * negative: a row with no run values must be REFUSED (counted as unusable), never silently read as 0. python3 run-supremacy.py [--input prefix-vs-run.json] [--out run-supremacy.json] """ import argparse import hashlib import io import json import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) def load(path): with io.open(path, encoding="utf-8") as fh: return json.load(fh) def measure(rows): """The supremum of the recorded covered runs, and every row that reaches the target.""" usable, unusable = [], [] for r in rows: lo, hi = r.get("run_lo"), r.get("run_hi") if lo is None or hi is None: unusable.append(r) continue # a run of L positions translates to a certificate at prefix L (its covered set moved to the # origin), which is what makes `run_len` -- not the printed prefix -- the decidable quantity usable.append({"n": r.get("n"), "rung": (r.get("rung_line") or [None])[0], "prefix": r.get("prefix"), "run_lo": lo, "run_hi": hi, "run_len": hi - lo + 1, "file": r.get("file")}) usable.sort(key=lambda x: -x["run_len"]) top = usable[0] if usable else None return usable, unusable, top def main(): ap = argparse.ArgumentParser() ap.add_argument("--input", default=os.path.join(HERE, "witness-runs.json")) ap.add_argument("--out", default=os.path.join(HERE, "run-supremacy.json")) ap.add_argument("--target", type=int, default=310) a = ap.parse_args() data = load(a.input) rows = data["rows"] usable, unusable, top = measure(rows) reach = [u for u in usable if u["run_len"] >= a.target] # controls ctl = [] ctl.append({"name": "the best recorded run is the #1554 certificate at rung 307", "detected": bool(top) and top["rung"] == 307 and top["prefix"] == 307 and top["run_lo"] == -2 and top["run_hi"] == 306}) synth = [dict(r) for r in rows] + [{"n": None, "file": "synthetic", "prefix": 311, "rung_line": [311], "run_lo": 0, "run_hi": 310}] s_usable, _, _ = measure(synth) ctl.append({"name": "a 311-position synthetic row IS detected as deciding the target", "detected": [u for u in s_usable if u["run_len"] >= a.target] != []}) # the exclusion rule must be able to refuse a row that carries no run, so it is exercised on a # synthetic one rather than asserted against the real input (which has none -- a vacuous control) s2_usable, s2_unusable, _ = measure([{"run_lo": None, "run_hi": None, "file": "synthetic-no-run"}, {"run_lo": 0, "run_hi": 5, "file": "synthetic-small"}]) ctl.append({"name": "a row with no run values is refused, not read as zero", "detected": len(s2_usable) == 1 and len(s2_unusable) == 1 and s2_usable[0]["run_len"] == 6}) verdict = "R = %d IS DECIDED BY THE RECORD" % a.target if reach else \ "NO RECORDED WITNESS DECIDES R = %d" % a.target out = { "schema": "run-supremacy/1", "input": {"path": a.input, "sha256": hashlib.sha256(open(a.input, "rb").read()).hexdigest(), "definition": data.get("definition"), "rows": len(rows)}, "target_r": a.target, "usable_rows": len(usable), "unusable_rows": [u.get("file") for u in unusable], "supremum": top, "rows_reaching_target": reach, "free_bound_from_supremum": (6 * top["run_len"] + 5) if top else None, "free_bound_at_target": (6 * a.target + 5), "top5": usable[:5], "controls": ctl, "controls_all_detected": all(c["detected"] for c in ctl), "verdict": verdict, } with io.open(a.out, "w", encoding="utf-8", newline="\n") as fh: json.dump(out, fh, indent=1, sort_keys=True) fh.write("\n") print(json.dumps({"wrote": a.out, "verdict": verdict, "supremum_run": top and top["run_len"], "reach": len(reach), "free_bound": out["free_bound_from_supremum"], "controls_all_detected": out["controls_all_detected"]}, indent=1)) return 0 if out["controls_all_detected"] else 3 if __name__ == "__main__": sys.exit(main())