#!/usr/bin/env python3 """Independent verification for route 146 job #2953. What is checked here, and why it is independent: * c_p = 2 * 6^{-1} mod p is DERIVED from scratch and compared with the engine's pskip table. * A from-source Python transcription of the engine's traversal (`crosscheck_engine.py`) matches the compiled binary at n = 11, 13, 16 on value, best, nodes, records and leaves. That is the check that the compiled engine computes what its served source says; it is not repeated here. * The finite tally of this sprint (the 386 split constant over four levels, the n=17 worker-sum identity, the n=19 replicate band) is checked arithmetically from the parsed logs. * The Lean file Route146.lean carries the same tally as machine-checked theorems. Deliberately NOT claimed: a from-scratch brute-force recomputation of A144311 at n >= 11. The route's own method is that the search IS the computation; this sprint's contribution is a measured node-cost constant and a new n=21 point, not a re-derivation of the ladder. Run: python3 verify_independent.py (exit 0 iff every check passes) """ import re import sys PLIST = [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83] PSKIP = [2, 5, 4, 9, 6, 13, 8, 10, 21, 25, 14, 29, 16, 18, 20, 41, 45, 24, 49, 53, 28] checks = [] def check(name, ok, detail=""): checks.append((name, bool(ok), detail)) print(f"[{'PASS' if ok else 'FAIL'}] {name} {detail}") def c_p(p): return (2 * pow(6, -1, p)) % p def test_c_p(): derived = [c_p(p) for p in PLIST] check("c_p = 2*6^-1 mod p derived from scratch matches the engine's pskip table", derived == PSKIP, f"derived={derived}") check("each c_p satisfies 6*c_p = 2 (mod p)", all(6 * c_p(p) % p == 2 for p in PLIST)) def nodes_of(path): return int(re.search(r"nodes=(\d+)", open(path).read()).group(1)) def best_of(path): return int(re.search(r"best=(\d+)", open(path).read()).group(1)) def value_of(path): return int(re.search(r"value=(\d+)", open(path).read()).group(1)) ARM_NODES = { # n: (N=1 seeded nodes, N=4 seeded nodes, source) 16: (446919, 447305, "#1530, #1551"), 17: (1789137, 1789523, "this sprint, arm 1"), 18: (6538348, 6538734, "#1553, #1551"), 19: (8603850, 8604236, "#1534, #1551"), } def test_split_constant(): diffs = {n: b - a for n, (a, b, _) in ARM_NODES.items()} check("N=4 minus N=1 seeded nodes is 386 at all four levels", all(d == 386 for d in diffs.values()), f"diffs={diffs}") rng = max(a for a, _, _ in ARM_NODES.values()) / min(a for a, _, _ in ARM_NODES.values()) check("the four levels span a >15x node range", rng > 15, f"ratio={rng:.1f}") def test_this_sprint(): n1, n4 = nodes_of("arm1.n17.N1.out"), nodes_of("arm1.n17.N4.out") check("this sprint n=17 N=1 seeded total matches the recorded value", n1 == 1789137, f"nodes={n1}") check("this sprint n=17 N=4 seeded total matches the recorded value", n4 == 1789523, f"nodes={n4}") check("this sprint n=17 difference is exactly 386", n4 - n1 == 386, f"diff={n4-n1}") w = [int(m.group(1)) for m in re.finditer(r"WORKER w=\d+ nodes=(\d+)", open("arm1.n17.N4.err").read())] check("n=17 N=4 per-worker node counts sum to the SHARED total", sum(w) == n4, f"sum={sum(w)} total={n4}") check("n=17 arms report value 965 = published a(17)", value_of("arm1.n17.N1.out") == 965 and value_of("arm1.n17.N4.out") == 965) check("n=17 reported value = 6*best+5", value_of("arm1.n17.N1.out") == 6 * best_of("arm1.n17.N1.out") + 5) def test_n19_replicate(): got = nodes_of("arm2.n19.N4.unseeded.out") check("n=19 N=4 replicate completed a full search (not cut)", "value=1283" in open("arm2.n19.N4.unseeded.out").read(), f"nodes={got}") for label, ref in (("#1542", 26423767), ("#1532", 26537468)): rel = abs(got - ref) / ref check(f"n=19 replicate within 1% of {label}", rel < 0.01, f"delta={rel:.5%}") f1819 = got / 7754620 check("18->19 unseeded factor lies near the recorded 3.42", 3.4 < f1819 < 3.45, f"factor={f1819:.4f}") if __name__ == "__main__": test_c_p() test_split_constant() test_this_sprint() test_n19_replicate() bad = [c for c in checks if not c[1]] print(f"\n{len(checks)-len(bad)}/{len(checks)} checks passed") if bad: print("FAILED:", [c[0] for c in bad]) sys.exit(1) print("ALL INDEPENDENT CHECKS PASS")