# witness.py - JOB #642. # Verify the two counterexample windows of return #236 from the definitions, using the # served producer's OWN kill convention (prod159.js, trueL): copy k of the old word deletes # the residues {a_k, a_k - 2} mod q with a_k = (-k * W) mod q, walked in order. So a window # of consecutive old slots is a LEGAL kill window at lift k iff every interior slot's residue # lies in {a_k, a_k - 2} (mod q) and neither flanking endpoint's residue does. # A slot of T_x is an integer n with gcd(n(n+2), x#) = 1. from math import gcd def primorial(pmax): W = 1 for p in range(2, pmax + 1): if all(p % d for d in range(2, int(p ** .5) + 1)): W *= p return W def is_slot(n, W): return gcd(n, W) == 1 and gcd(n + 2, W) == 1 def consecutive(slots, W): """is every integer strictly between two listed slots a non-slot?""" gaps = [slots[i + 1] - slots[i] for i in range(len(slots) - 1)] bad = [n for i in range(len(slots) - 1) for n in range(slots[i] + 1, slots[i + 1]) if is_slot(n, W)] return gaps, bad def report(name, Wp, slots, q, expect_k=None): print("=" * 90) print("%s T_%d, q = %d" % (name, Wp, q)) W = primorial(Wp) print(" W(%d) = %d = %d (mod %d)" % (Wp, W, W % q, q)) print(" every listed integer a T_%d slot: %s" % (Wp, [is_slot(n, W) for n in slots])) gaps, bad = consecutive(slots, W) print(" gaps: %s sum = %d multiples of 6: %s" % (gaps, sum(gaps), all(x % 6 == 0 for x in gaps))) print(" intervening T_%d slots (must be empty): %s" % (Wp, bad if bad else "none")) inter, flank = slots[1:-1], [slots[0], slots[-1]] print(" interior slot residues mod %d: %s" % (q, [n % q for n in inter])) print(" flanking slot residues mod %d: %s" % (q, [n % q for n in flank])) print(" interior gaps %s ; mod %d: %s ; all qualify (0,+-2): %s" % (gaps[1:-1], q, [g % q for g in gaps[1:-1]], all(g % q in (0, 2, q - 2) for g in gaps[1:-1]))) print(" interior gap classes (0 / +1 / -1 mod q):", [0 if g % q == 0 else (1 if g % q == 2 else (-1 if g % q == q - 2 else 'X')) for g in gaps[1:-1]]) legal = [] for k in range(q): a = (-k * W) % q kill = {a, (a - 2) % q} if all(n % q in kill for n in inter) and all(n % q not in kill for n in flank): legal.append((k, a, sorted(kill))) print(" lift indices k (0..%d) whose kill set {a_k, a_k-2} hits every interior and no flank:" % (q - 1)) print(" %s" % (legal if legal else "NONE -> the window is not a legal kill run")) if expect_k is not None: print(" return #236 states k = %d ; agreement: %s" % (expect_k, any(k == expect_k for k, _, _ in legal))) G = sum(gaps) print(" window sum G_%d = %d -> contributes at theta = 6,12,...,%d (%d theta values)" % (len(gaps), G, G, G // 6)) return G G1 = report("WITNESS 1 (return #236)", 23, [98099, 98177, 98237, 98297, 98321], 29) print(" => loose Q_3 window, not legal: it refutes #207 s claim that Q_L counts maximal kill runs,") print(" but it does NOT by itself give sum_theta Q_3 > 0 in the legal family.") print() G2 = report("WITNESS 2 (return #236)", 29, [1321026569, 1321026611, 1321026671, 1321026797, 1321026857, 1321026899], 31, expect_k=12) print(" => one LEGAL maximal 4-kill window; it alone contributes %d theta values to Q_4," % (G2 // 6)) print(" against return #207 section 2.2's asserted sum_theta Q_4 <= 4.")