"""job 2958 triage: INDEPENDENT re-check of the R = 307 certificate of return #1554. Written from the definition in the published package (job2767/fresh/0017-DERIVATION.md and 0017-cover_cnf.py), NOT from the engine (jtwin.c) and NOT from the route's witness.py: the object is 0017's paired two-class system for the primes 5..83, the pair for p being {a_p, a_p + c_p} with c_p = 2 * 6^{-1} mod p (coff() in 0017-cover_cnf.py). Claim under test (return #1554): a_p = (1,2,9,0,4,12,9,5,29,2,4,13,31,9,54,35,56,67,37,62,33) * every j in [0, 306] is hit by at least one pair -> the interval [0,306] is covered; * j = 307 is NOT hit -> the prefix pre(a) is exactly 307. Neither the certificate nor the engine's own verify_solution is trusted here; the sum of pair coverages is recomputed from scratch. Prints each failure, if any. """ import json import os PRIMES = [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83] A = [1, 2, 9, 0, 4, 12, 9, 5, 29, 2, 4, 13, 31, 9, 54, 35, 56, 67, 37, 62, 33] HERE = os.path.dirname(os.path.abspath(__file__)) def coff(p): """0017's c_p = 2 * 6^{-1} mod p, recomputed (not imported from their module).""" inv6 = pow(6, -1, p) return (2 * inv6) % p def covered(j): return [p for p, a in zip(PRIMES, A) if j % p == a % p or j % p == (a + coff(p)) % p] def main(): cs = [coff(p) for p in PRIMES] # shape checks: a_p must be a legal residue mod p assert all(0 <= a % p < p for p, a in zip(PRIMES, A)), "a_p out of range" assert len(PRIMES) == len(A) == 21, "expected 21 primes 5..83" hits = {} misses = [] for j in range(0, 307): h = covered(j) if not h: misses.append(j) else: for p in h: hits[p] = hits.get(p, 0) + 1 j307 = covered(307) n_distinct = len(hits) used = sorted(hits) print("primes with at least one hit inside [0,306]: %d of 21" % n_distinct) print("uncovered positions inside [0,306]: %s" % (misses if misses else "[]")) print("position 307 hit by: %s" % (j307 if j307 else "nothing")) pre = 0 while pre <= 400 and covered(pre): pre += 1 print("prefix pre(a) recomputed = %d" % pre) ok = (not misses) and (not j307) and pre == 307 rec = {"claim": "R = 307 certificate of return #1554", "a_p": A, "c_p": cs, "primes": PRIMES, "uncovered_in_0_306": misses, "position_307_hit_by": j307, "prefix_recomputed": pre, "primes_used": used, "agrees_with_claim": bool(ok), "method": "independent re-implementation from 0017's definition; engine and witness.py " "not used", "witness_check_line_reproduced": "witness.py check 21 " + " ".join(map(str, A))} out = os.path.join(HERE, "verify-R307-independent.json") with open(out, "w", encoding="utf-8", newline="\n") as fh: json.dump(rec, fh, indent=1, sort_keys=True) fh.write("\n") print(json.dumps({"agrees_with_claim": bool(ok), "wrote": out}, indent=1)) return 0 if ok else 1 if __name__ == "__main__": raise SystemExit(main())