"""analyze.py (job 4318): join certk.py's T failures with brute.c's exhaustive results. (a) every certk T failure (x = 7 and 11, k = 5) must be a brute-force exceedance with no killable whole block, and brute max_seam >= the failing length L > brute max_nonwrap; (b) gate at x = 7 over every 4- and 5-subset of the primes 11..43 (H = 0) and every 4-subset plus one large prime (H = 1): no exceedance at k = 4 (certk certified k = 4), and every exceedance at k = 5 contains some certk T-failure set M (the enumeration misses nothing brute force finds). usage: python3 analyze.py (reads x7_fast.out, x11_k5.json, brute_all.jsonl; prints one JSON summary)""" import json rows = [json.loads(l) for l in open("brute_all.jsonl")] B = {(r["x"], r["H"], tuple(r["M"])): r for r in rows} d7 = {d["k"]: d for d in (json.loads(l) for l in open("x7_fast.out") if l.startswith("{"))} fails = {7: d7[5]["T_fail"], 11: json.load(open("x11_k5.json"))["T_fail"]} out = {"a": {}, "b": {}} for x, fl in fails.items(): ok = 0; bad = []; mx = None for f in fl: r = B[(x, 5 - len(f["M"]), tuple(f["M"]))] good = r["exceedance"] and not r["whole_block_killable"] and r["max_seam"] >= f["L"] > r["max_nonwrap"] ok += good if not good: bad.append(f) if mx is None or r["max_seam"] - r["max_nonwrap"] > mx["max_seam"] - mx["max_nonwrap"]: mx = r out["a"][str(x)] = {"T_fail": len(fl), "confirmed": ok, "not_confirmed": bad, "largest_excess": mx} fail5 = [frozenset(f["M"]) for f in fails[7]] for H, n in ((0, 4), (0, 5), (1, 4)): sel = [r for (x, h, M), r in B.items() if x == 7 and h == H and len(M) == n and max(M) <= 43] k = n + H exc = [r for r in sel if r["exceedance"] and not r["whole_block_killable"]] unexplained = [r["M"] for r in exc if not any(m <= frozenset(r["M"]) for m in fail5)] if k == 5 else [r["M"] for r in exc] out["b"][f"k={k} (|M|={n}, H={H})"] = {"sets": len(sel), "exceedances": len(exc), "whole_block_killable": sum(r["whole_block_killable"] for r in sel), "unexplained": unexplained} out["pass"] = all(v["confirmed"] == v["T_fail"] for v in out["a"].values()) and all(not v["unexplained"] for v in out["b"].values()) print(json.dumps(out, sort_keys=True))