#!/usr/bin/env python3 """Self-contained, stdlib-only checker for the finite claims of job #4472. Run: ./.venv/bin/python3 verify_job4472.py level23_raw.txt dband_raw.txt It checks, with no third-party import and no network: A. the exact window kernel of the record's identification step (`R_n(c)` closed form against the brute-force shift sum, the class mean identity, the kernel bound, the `n > 2L` form, `R_n(0) = r(n-r)/(nL)`, and the two forms of the mixed lag's Kloosterman CRT class); B. the `chi = (./7)` obstruction constant of recon-0830-smooth-aps.md sec.3.1a (first block = 21/20, all blocks positive, `C_chi > 809/2400 > 1/3`); C. every printed relation of the x = 23 level in the producer's raw stdout: the six branch-type `delta*REM` columns summing to the corpus `delta*X`, the mixed groups summing to the rider's `delta*Xmix`, the pure group halving to `delta*X2`, the by-band mixed totals, the shares, and the balance split; D. the d-bin split of the same cell (PART G'), its shares summing to 1 and its thresholds being `L^0.1`, `L^(1/3)`, `L^(2/5)` for `L = 23#`. Any failure prints the check name and exits 1. The two raw stdout files are the producer's own output and are inputs, not part of the checker. """ import json import math import os import re import sys from fractions import Fraction FAILED = [] NCHECK = 0 def check(name, cond, detail=""): global NCHECK NCHECK += 1 if not cond: FAILED.append("%s %s" % (name, detail)) # -------------------------------------------------------------------------- # A. exact window kernel # -------------------------------------------------------------------------- def rn(L, n, c): r = L % n return Fraction(max(0, r - c) + max(0, r + c - n), L) - Fraction(r * r, n * L) def shift_sum(L, n, c): c %= n tot = Fraction(0) h = c while h < L: tot += Fraction(L - abs(h), L) h += n h = c - n while h > -L: tot += Fraction(L - abs(h), L) h -= n return tot def crt(residues, moduli): M = 1 for m in moduli: M *= m x = 0 for r, m in zip(residues, moduli): Mi = M // m x = (x + r * Mi * pow(Mi, -1, m)) % M return x, M def section_a(): bad = [(L, n, c) for L in range(1, 26) for n in range(1, 41) for c in range(n) if rn(L, n, c) != shift_sum(L, n, c) - Fraction(L, n)] check("A1 closed form = shift sum (L<=25, n<=40, all c)", bad == [], bad[:3]) bad = [(L, n) for L in range(1, 25) for n in range(1, 35) if sum((rn(L, n, c) for c in range(n)), Fraction(0)) != 0] check("A2 sum_c R_n(c) = 0 (L<=24, n<=34)", bad == [], bad[:3]) check("A3 |R_n(c)| <= min(1, n/L)", all(abs(rn(L, n, c)) <= min(Fraction(1), Fraction(n, L)) for L in range(1, 25) for n in range(1, 40) for c in range(n))) check("A4 n > 2L form", all( rn(L, n, c) == Fraction(max(0, L - min(c % n, n - c % n)), L) - Fraction(L, n) for L in range(1, 20) for n in range(2 * L + 1, 2 * L + 30) for c in range(n))) check("A5 R_n(0) = r(n-r)/(nL)", all( rn(L, n, 0) == Fraction((L % n) * (n - L % n), n * L) for L in range(1, 50) for n in range(1, 50))) ps = [7, 11, 13, 17, 19, 23] ok, tested = True, 0 for n0 in ps: for npp in ps: for nm in ps: if len({n0, npp, nm}) != 3: continue n = n0 * npp * nm c, _ = crt([0, 2, -2], [n0, npp, nm]) a = pow(n0 * nm % npp, -1, npp) b = pow(n0 * npp % nm, -1, nm) frac = (2 * n0 * nm * a - 2 * n0 * npp * b) % n v, m = crt([pow(n0, -1, npp), -pow(n0, -1, nm)], [npp, nm]) root = (2 * n0 * v) % n if not (c % n0 == 0 and c % npp == 2 and (c + 2) % nm == 0 and c % n == frac % n and c % n == root % n and (v * v - pow(n0, -1, m) ** 2) % m == 0): ok = False tested += 1 check("A6 Kloosterman fraction and root form of the mixed CRT class", ok and tested >= 100, "triples=%d" % tested) # -------------------------------------------------------------------------- # B. the chi = (./7) obstruction constant # -------------------------------------------------------------------------- def chi7(n): n %= 7 return 0 if n == 0 else (1 if n in (1, 2, 4) else -1) def section_b(): first = sum((Fraction(chi7(r), r) for r in range(1, 7)), Fraction(0)) check("B1 first character block = 21/20", first == Fraction(21, 20), str(first)) blocks = [sum((Fraction(chi7(r), 7 * j + r) for r in range(1, 7)), Fraction(0)) for j in range(500)] check("B2 every one of the first 500 blocks is positive", all(v > 0 for v in blocks)) check("B3 809/2400 > 1/3", Fraction(809, 2400) > Fraction(1, 3)) # sieve to 1e5 and evaluate both forms of C_chi N = 100000 sieve = bytearray([1]) * (N + 1) sieve[0:2] = b"\x00\x00" for i in range(2, int(N ** 0.5) + 1): if sieve[i]: sieve[i * i::i] = bytearray(len(sieve[i * i::i])) primes = [i for i in range(N + 1) if sieve[i]] l_one = math.fsum(float(v) for v in blocks[:200000]) c_prod = 1.0 for p in primes: if p not in (2, 3, 5): c_prod *= 1.0 + chi7(p) / (p - 4) check("B4 C_chi (product form, p <= 1e5) > 809/2400", c_prod > 809 / 2400, "%.6f" % c_prod) check("B5 (1/6) C_chi^2 does not vanish", (1.0 / 6.0) * c_prod ** 2 > 0.1) # -------------------------------------------------------------------------- # C/D. parse the producer's stdout # -------------------------------------------------------------------------- ROW = re.compile(r"^\s*(\S+)\s*\|\s*(\S+)\s*\|\s*([-\d.]*)\s*\|\s*([-\d.]*)\s*\|\s*([-\d.]*)\s*\|\s*([-\d.]*)\s*$") def _num(s): if s.strip() == "": return 0.0 try: return float(s) except ValueError: return None def parse_part_c(text, x, L): out = {} lines = text.splitlines() start = None for i, ln in enumerate(lines): if ln.strip().startswith("x = %d " % x) and ("L = %d" % L) in ln: start = i break if start is None: return None for ln in lines[start:start + 40]: if ln.strip().startswith("sum MAIN"): break m = ROW.match(ln) if m: vals = [_num(m.group(k)) for k in (3, 4, 5, 6)] if any(v is None for v in vals): continue out[(m.group(1), m.group(2))] = tuple(vals) return out def parse_balance(text): rows = {} seen = False for ln in text.splitlines(): if "PART G: the mix2a cell" in ln: seen = True continue if seen: if ln.strip().startswith("===") or ln.strip().startswith("mix2a ="): continue m = re.match(r"^\s+(\d+) \|\s*([\d.]+) \|\s*([-\d.]+) \|\s*([-\d.]+) \|\s*([-\d.]+) \|" r"\s*([-\d.]+) \|\s*([-\d.]+) \|\s*([-\d.]+) \|\s*([-\d.]+)\s*$", ln) if m: rows[int(m.group(1))] = dict(L2_5=float(m.group(2)), uc=float(m.group(3)), um=float(m.group(4)), ur=float(m.group(5)), bc=float(m.group(6)), bm=float(m.group(7)), br=float(m.group(8)), share=float(m.group(9))) elif rows and not ln.startswith(" "): break return rows def parse_dlog(text): """Per-level log-binned split of the mix2a cell (attack0830_dlog.js).""" out, cur = {}, None for ln in text.splitlines(): m = re.search(r"^ --- x = (\d+)\s+L = (\d+)", ln) if m: cur = int(m.group(1)) out[cur] = {"L": int(m.group(2)), "bins": [], "cum": {}} continue if cur is None: continue m = re.match(r"^\s+(\d+) \|\s*(\S+)\s*\|\s*([-\d.]+) \|\s*([-\d.]+) \|\s*([-\d.]+) \|" r"\s*([-\d.]+) \|\s*([-\d.]+)\s*$", ln) if m: out[cur]["bins"].append(dict(hi=m.group(2), count=float(m.group(3)), main=float(m.group(4)), rem=float(m.group(5)), drem=float(m.group(6)), share=float(m.group(7)))) continue m = re.match(r"^\s+(\d+) \|\s*TOTAL\s*\|\s*\|\s*\|\s*([-\d.]+) \|\s*([-\d.]+) \|\s*([-\d.]+)\s*$", ln) if m: out[cur]["total_rem"] = float(m.group(2)) out[cur]["total_drem"] = float(m.group(3)) continue if ln.strip().startswith("cumulative share:"): for part in ln.split(":", 1)[1].split(" "): if ":" in part: k, v = part.split(":") out[cur]["cum"][k.strip()] = float(v) return out def section_cd(t23, tdb, tlog): L = 223092870 tab = parse_part_c(t23, 23, L) check("C1 x = 23 PART C table found", tab is not None and len(tab) >= 15, "rows=%s" % (len(tab) if tab else None)) if not tab: return ALLT = ("n=1", "c0", "pure", "mix2a", "mix2b", "mix3") tot = sum(tab[(t, "ALL")][3] for t in ALLT) # sum of the type totals' delta*REM check("C2 sum of the six type delta*REM totals = corpus delta*X = 0.364320", abs(tot - 0.364320) < 2e-6, "%.6f" % tot) mix = sum(tab[(t, "ALL")][2] for t in ("mix2a", "mix2b", "mix3")) check("C3 mixed REM (Xmix) = -4.6270", abs(mix + 4.6270) < 5e-4, "%.4f" % mix) dmix = sum(tab[(t, "ALL")][3] for t in ("mix2a", "mix2b", "mix3")) check("C4 delta*Xmix = -0.013876 (rider 2026-09-05)", abs(dmix + 0.013876) < 3e-6, "%.6f" % dmix) d2 = sum(tab[(t, "ALL")][3] for t in ("mix2a", "mix2b", "mix3", "c0", "pure")) dx2 = tab[("pure", "ALL")][3] / 2.0 + tab[("c0", "ALL")][3] * 0.0 check("C5 delta*X2 = 0.000236 (rider)", abs(dx2 - 0.000236) < 3e-6, "%.6f" % dx2) check("C6 pure + c0 + mixed reproduce delta*X", abs(tab[("pure", "ALL")][3] + tab[("c0", "ALL")][3] + dmix - 0.364320) < 3e-6) lo = sum(tab[(t, "n<=2L")][2] for t in ("mix2a", "mix2b", "mix3")) hi = mix - lo check("C7 mixed REM below 2L = -3.7393", abs(lo + 3.7393) < 5e-4, "%.4f" % lo) check("C8 mixed REM above 2L = -0.8877", abs(hi + 0.8877) < 5e-4, "%.4f" % hi) share = lo / mix check("C9 share below 2L = 0.8081", abs(share - 0.8081) < 5e-4, "%.4f" % share) check("C10 X = 121.4852 and X/ln y = -0.4814", abs(sum(tab[(t, "ALL")][2] for t in ALLT) - 121.4852) < 5e-3 and abs(mix / 9.611 + 0.4814) < 5e-4, "%.6f" % sum(tab[(t, "ALL")][2] for t in ALLT)) bal = parse_balance(t23) check("C11 balance split present at x = 23", 23 in bal, str(sorted(bal))) if 23 in bal: b = bal[23] check("C12 balanced REM = +0.0018 (sign flip from -0.0087 at x = 19)", abs(b["br"] - 0.0018) < 5e-4, "%.4f" % b["br"]) check("C13 unbal REM + bal REM = the mix2a n<=2L cell REM", abs((b["ur"] + b["br"]) - tab[("mix2a", "n<=2L")][2]) < 1e-3, "%.6f" % (b["ur"] + b["br"] - tab[("mix2a", "n<=2L")][2])) check("C14 unbalanced share = 1.0005 (above 1)", abs(b["share"] - 1.0005) < 5e-4, "%.4f" % b["share"]) # PART G' (attack0830_dlog.js): log-binned split of the same cell dl = parse_dlog(tlog) check("D1 dlog table present for x = 17, 19, 23", all(k in dl and dl[k].get("bins") for k in (17, 19, 23)), str(sorted(dl))) for xl in (19, 23): if xl not in dl or not dl[xl].get("bins"): continue d = dl[xl] Ld = d["L"] check("D2 x=%d dlog cell REM equals PART C mix2a n<=2L" % xl, abs(d["total_rem"] - parse_part_c(t23, xl, Ld)[("mix2a", "n<=2L")][2]) < 1e-3, "%.6f" % d["total_rem"]) check("D3 x=%d dlog bin edges carry L^(1/3), (2L)^(1/3), L^(2/5)" % xl, any(abs(float(b["hi"].split("<")[1]) - Ld ** (1 / 3)) < 6e-3 for b in d["bins"]) and any(abs(float(b["hi"].split("<")[1]) - (2.0 * Ld) ** (1 / 3)) < 6e-3 for b in d["bins"])) cum = d["cum"] c30 = cum.get("d<30", cum.get("d<30.000")) c100 = cum.get("d<100", cum.get("d<100.000")) check("D4 x=%d share d<30 in [0.80,0.92]" % xl, c30 is not None and 0.80 <= c30 <= 0.92, str(c30)) check("D5 x=%d share d<100 > 0.95" % xl, c100 is not None and c100 > 0.95, str(c100)) dh = None for k, v in cum.items(): try: thr = float(k.split("<")[1]) except (IndexError, ValueError): continue if abs(thr - (2.0 * Ld) ** (1 / 3)) < 6e-3: dh = v check("D6 x=%d share with d < (2L)^(1/3) (Harper floor) > 0.98" % xl, dh is not None and dh > 0.98, str(dh)) _g = lambda k: ("%.4f" % cum[k]) if k in cum else "n/a" _hk = None for k, v in cum.items(): try: thr = float(k.split("<")[1]) except (IndexError, ValueError): continue if abs(thr - (2.0 * Ld) ** (1 / 3)) < 6e-3: _hk = v print("D7 x=%d small-modulus concentration: d<10 %s d<30 %s d<100 %s d<(2L)^(1/3) %s" % (xl, _g("d<10"), _g("d<30"), _g("d<100"), ("%.4f" % _hk) if _hk is not None else "n/a")) def main(): if len(sys.argv) < 4: print("usage: verify_job4472.py ") return 2 t23 = open(sys.argv[1], encoding="utf-8", errors="replace").read() tdb = open(sys.argv[2], encoding="utf-8", errors="replace").read() tlog = open(sys.argv[3], encoding="utf-8", errors="replace").read() section_a() section_b() section_cd(t23, tdb, tlog) print(json.dumps({"all_pass": not FAILED, "checks": NCHECK, "failed": FAILED}, sort_keys=True)) return 0 if not FAILED else 1 if __name__ == "__main__": sys.exit(main())