#!/usr/bin/env python3 """Validate return #933's block-boundary reduction on a small analogue. Claim (s=7 analogue): K*(7) computed two ways must agree. (direct) longest run of consecutive 7# slots (r, r+2 coprime to 2*3*5*7=210) all killed by Q(7) = {11,13} (q | r or q | r+2). (reduced) max over cyclic 5#-base windows (r, r+2 coprime to 30) that are FULLY covered by {7,11,13} of the number of slots NOT hit by 7 (7 ∤ r and 7 ∤ r+2) — the "survivor count". General statement (#933): for 31# -> 37#, K*(37) = max survivor count (not hit by 37) in an old 31#-base window fully covered by {37,..,73}. Here we test the same shape at 5# -> 7# with promote 7 / add 13. """ from math import gcd def is_slot(r, prim): for p in prim: if r % p == 0 or (r + 2) % p == 0: return False return True def killed(r, Q): return any(r % q == 0 or (r + 2) % q == 0 for q in Q) def longest_run(slots, Q): """Longest cyclic run of consecutive slots all killed by Q.""" n = len(slots) killed_list = [killed(r, Q) for r in slots] # cyclic: duplicate best = 0 cur = 0 for i in range(2 * n): if killed_list[i % n]: cur += 1 best = max(best, cur) else: cur = 0 return best def max_survivor_count(base_slots, Q_full, promoted_prime): """Max survivor count (slots not hit by promoted_prime) over cyclic base windows fully covered by Q_full.""" n = len(base_slots) # killed by Q_full kf = [killed(r, Q_full) for r in base_slots] # survivor = not hit by promoted prime surv = [0 if (r % promoted_prime == 0 or (r + 2) % promoted_prime == 0) else 1 for r in base_slots] best = 0 # scan all cyclic windows (start i, length L); only consider windows fully covered # by Q_full. Use sliding window: a window is valid if all kf == 1 within it. # Since base is small, brute force all windows. for i in range(n): for L in range(1, n + 1): ok = all(kf[(i + j) % n] for j in range(L)) if ok: sc = sum(surv[(i + j) % n] for j in range(L)) best = max(best, sc) return best def main(): # direct: 7# base prim7 = [2, 3, 5, 7] P7 = 210 slots7 = [r for r in range(P7) if is_slot(r, prim7)] Q7 = [11, 13] k_direct = longest_run(slots7, Q7) # reduced: 5# base, Q_full = {7,11,13}, promoted prime 7 prim5 = [2, 3, 5] P5 = 30 slots5 = [r for r in range(P5) if is_slot(r, prim5)] Q_full = [7, 11, 13] k_reduced = max_survivor_count(slots5, Q_full, 7) print(f"7# base: N={len(slots7)} slots, Q(7)={Q7}") print(f"5# base: N={len(slots5)} slots, Q_full={Q_full}") print(f"K*(7) direct = {k_direct}") print(f"K*(7) reduced = {k_reduced}") print("MATCH" if k_direct == k_reduced else "MISMATCH", "(reduction valid)" if k_direct == k_reduced else "(reduction WRONG)") # also report the N-ratio (the claimed ~35x for 31#->37#) print(f"N_ratio (N_37 / N_31) analogue check would be: 7# slots / 5# slots = {len(slots7)}/{len(slots5)} = {len(slots7)/len(slots5):.3f}") # for the real case: N_37/N_31 = 217929355875/6226553025 print(f"real case N_37/N_31 = {217929355875/6226553025:.1f}x") if __name__ == "__main__": main()