"""job 2958 triage: controls for the R = 307 covering check (a check that cannot fail is not a check). Three families, all on the same 21-prime paired system as verify-R307-independent.py: A. DELETE each prime's pair in turn -> is every one of the 21 classes load-bearing? B. PERTURB each a_p by +1 (mod p) -> how far does the prefix move? C. SHIFT the whole certificate -> prefix under a_p -> a_p + t for a few t. The reading this buys: the certificate is not a lucky accident of a long list of classes; it is tight, and the prefix is measured (not the search target) in the sense 0018's Lemma 1 requires. """ 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__)) CS = [(2 * pow(6, -1, p)) % p for p in PRIMES] LIMIT = 400 def pairs(primes, a_list): return [(p, a % p, (a + c) % p) for p, a, c in zip(primes, a_list, CS)] def prefix(ps): j = 0 while j <= LIMIT: if not any(j % p == r1 or j % p == r2 for p, r1, r2 in ps): return j j += 1 return None # still covered at LIMIT def gaps_in(ps, upto): return [j for j in range(upto + 1) if not any(j % p == r1 or j % p == r2 for p, r1, r2 in ps)] base = pairs(PRIMES, A) print("baseline prefix = %s (claim: 307)" % prefix(base)) deletions = [] for i, p in enumerate(PRIMES): ps = pairs([q for k, q in enumerate(PRIMES) if k != i], [a for k, a in enumerate(A) if k != i]) deletions.append({"dropped_prime": p, "prefix": prefix(ps), "uncovered_in_0_306": len(gaps_in(ps, 306))}) print("A. deleting any single class:") for d in deletions: print(" drop %2d -> prefix %s, uncovered in [0,306]: %d" % (d["dropped_prime"], d["prefix"], d["uncovered_in_0_306"])) all_loaded = all(d["prefix"] is None or d["prefix"] < 307 for d in deletions) print(" every one of the 21 classes is load-bearing: %s" % all_loaded) perturb = [] for i, p in enumerate(PRIMES): alt = list(A) alt[i] = (alt[i] + 1) % p perturb.append({"perturbed_prime": p, "a_before": A[i], "a_after": alt[i], "prefix": prefix(pairs(PRIMES, alt))}) print("B. perturbing each a_p by +1 (mod p): prefix range %s..%s" % (min(x["prefix"] for x in perturb), max(x["prefix"] for x in perturb))) worst = max(perturb, key=lambda x: x["prefix"]) print(" best single-class move: p=%d a=%d->%d gives prefix %s" % (worst["perturbed_prime"], worst["a_before"], worst["a_after"], worst["prefix"])) shifts = [] for t in (1, 2, 3, 6, 12, 30): shifted = [(a + t) for a in A] shifts.append({"shift": t, "prefix": prefix(pairs(PRIMES, shifted))}) print("C. common shift of every a_p: %s" % [(s["shift"], s["prefix"]) for s in shifts]) rec = {"baseline_prefix": prefix(base), "claim_prefix": 307, "deletions": deletions, "every_class_load_bearing": all_loaded, "perturbations": perturb, "shifts": shifts, "reading": "the 21 pairs are all used; no single class can be dropped, and no single-class " "move (a_p -> a_p + 1) reaches 307, so the certified prefix is a local extremum " "of this certificate family, not an artefact of one lucky residue list"} out = os.path.join(HERE, "verify-R307-controls.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("wrote", out)