"""verify7.py (job 4318, route 80): independent brute-force check of certk.py's x = 7 findings. Stdlib only. Shares no code with certk.py: slots are recomputed, residues are enumerated over all of prod Z/q, and runs are read off the integer line. (1) Exceedance witness: Q = M + {q0}, q0 = 433 > 2P + 2. For each M given, brute force over every residue vector A_M in prod_{q in M} Z/q: nonwrap(Q) = max over A_M of the longest run of consecutive block-0 slots with at most one slot left alive (q0 kills at most one slot of any window of span < q0 - 2, and any one slot it likes); seam(Q) = max over A_M of the longest run of consecutive slots of blocks 0..1 (the integer line [0, 2P)) containing c = P-1 and slots on both sides of it, with at most one slot left alive (span < 2P < q0-2). Prints both and one explicit residue vector (A_q for every q in Q) realising the seam run, then re-checks that vector directly on the integers. (2) Whole-block cover: the given (q, A) list is checked to kill every slot of block 0 directly. (3) nonwrap >= |Q|: any k primes kill any k consecutive slots, so the in-block max is at least k (sanity). An M list may start with 0 or 1 = the number of large singles (default 1); holes = singles. usage: python3 verify7.py""" import json from itertools import product x, P = 7, 210 def slot(n): return n % 2 == 1 and all(n % p and (n + 2) % p for p in (3, 5, 7)) R = [n for n in range(0, 2 * P) if slot(n)] # slots of blocks 0 and 1 B0 = [n for n in R if n < P]; D = len(B0); c = P - 1 assert D == 15 and B0[-1] == c Q0 = 433 def longest(alive_bits, n, holes=1): """longest run of consecutive positions 0..n-1 with at most `holes` alive positions; returns (length, start)""" best = (0, 0); i = 0; cnt = 0 for j in range(n): cnt += alive_bits >> j & 1 while cnt > holes: cnt -= alive_bits >> i & 1; i += 1 if j - i + 1 > best[0]: best = (j - i + 1, i) return best def seam_longest(alive_bits, holes=1): """longest run over R (blocks 0..1) with <= holes alive, containing c and one slot each side of c""" ic = R.index(c); best = (0, 0, 0) n = len(R) for i in range(ic - 1, -1, -1): cnt = sum(alive_bits >> t & 1 for t in range(i, ic + 2)) if cnt > holes: break j = ic + 1 while j + 1 < n and cnt + (alive_bits >> (j + 1) & 1) <= holes: j += 1; cnt += alive_bits >> j & 1 if j - i + 1 > best[0]: best = (j - i + 1, i, j) return best def kills(q, A, pts): return sum(1 << t for t, n in enumerate(pts) if (n - A) % q in (0, 2)) def check_M(M, holes=1): kb = {q: [kills(q, A, B0) for A in range(q)] for q in M} ks = {q: [kills(q, A, R) for A in range(q)] for q in M} full0, fullR = (1 << D) - 1, (1 << len(R)) - 1 nw = (0, None); sm = (0, None) for As in product(*(range(q) for q in M)): m0 = 0; mR = 0 for q, A in zip(M, As): m0 |= kb[q][A]; mR |= ks[q][A] l = longest(full0 ^ m0, D, holes)[0] if l > nw[0]: nw = (l, As) s = seam_longest(fullR ^ mR, holes) if s[0] > sm[0]: sm = (s[0], As, s[1], s[2]) # explicit witness: residues of M plus q0 on the one alive slot, re-checked on the integers L, As, i, j = sm run = R[i:j + 1] alive = [n for n in run if not any((n - A) % q in (0, 2) for q, A in zip(M, As))] assert len(alive) <= holes QA = dict(zip(M, As)) if holes: QA[Q0] = alive[0] % Q0 if alive else 0 killed = all(any((n - A) % q in (0, 2) for q, A in QA.items()) for n in run) return {"M": list(M), "q0": Q0 if holes else None, "k": len(M) + holes, "nonwrap": nw[0], "nonwrap_residues": list(nw[1]), "seam_run": L, "seam_slots": run, "witness_residues": {str(q): A for q, A in QA.items()}, "witness_rechecked": killed, "exceedance": L > nw[0], "no_whole_block": nw[0] < D} if __name__ == "__main__": import sys Ms = json.loads(sys.argv[1]) if len(sys.argv) > 1 else [[13, 29, 37, 43]] for M in Ms: print(json.dumps(check_M(tuple(M[1:]), M[0]) if M[0] < 2 else check_M(tuple(M))), flush=True) if len(sys.argv) > 2: cov = json.loads(sys.argv[2]) # [[q, A], ...] dead = [n for n in B0 if any((n - A) % q in (0, 2) for q, A in cov)] print(json.dumps({"block_cover": cov, "primes": len(cov), "killed": len(dead), "D": D, "whole_block": len(dead) == D}))