#!/usr/bin/env python3 """job2456 — the LOOSE correction support ladder R(q) at T29, with T23 as the control. Object (N-1840-01, job #1840, return #971, route 67): qualify(g, q) <=> g mod q in {0, 2, q-2} (g = a tile gap, q = fold prime) R(q) = the longest CYCLIC run of consecutive qualifying gaps of the tile word loose support = max{L : Q^loose_L > 0} = R(q) + 1 structural = q > G2(T_x) + 2 => R(q) = 0 (no gap is in any of the three classes) This ledger answers exactly the successor question N-1840-01 pre-registered: "Rebuild T29 ... and compute R_loose for all primes 29..1009, testing R+1 <= 8 at the T29 rows of #161's table. Falsifier: any q with R_loose >= 8." Two builders, one convention (odd twin-admissible residues r with gcd(r(r+2), P) = 1): * T23 — one whole in-memory sieve over P23 = 223 092 870 positions. * T29 — the department's validated constant-memory segmented sieve, reused verbatim from runs/run_20260917_131856_rcTy4g/work/job1645/src/job1645-t29gap.py (sieve_chunk), which scanned one full period P29 = 6 469 693 230 in 11.08 s and produced D(T29) = 214 708 725, G2(T29) = 258 (controls 6-8 below). The T23 builder is independent code (whole-array) so the control is not the same routine twice. stdout is the artifact: deterministic JSON, no timings, no paths. Timing goes to stderr. """ import json import sys import time import numpy as np SMALL23 = [3, 5, 7, 11, 13, 17, 19, 23] SMALL29 = [3, 5, 7, 11, 13, 17, 19, 23, 29] CHUNK = 1 << 24 def primorial(primes): P = 2 for q in primes: P *= q return P P23 = primorial(SMALL23) P29 = primorial(SMALL29) def sieve_chunk(start, size, small): """True where start+i is twin-admissible mod P (odd, and 0/-2-free mod every q in small).""" a = np.ones(size, dtype=bool) a[(0 - start) % 2::2] = False # keep odd r only (r and r+2 share the parity) for q in small: a[(q - start) % q::q] = False # r = 0 (mod q) a[(q - 2 - start) % q::q] = False # r = -2 (mod q) return a def word_in_memory(P, small): """Whole-period gap word (uint16), cyclic: the seam gap is appended.""" a = sieve_chunk(0, P, small) idx = np.flatnonzero(a).astype(np.int64) first, last = int(idx[0]), int(idx[-1]) d = np.diff(idx).astype(np.uint16) wrap = np.array([(first + P - last) & 0xFFFF], dtype=np.uint16) return np.concatenate([d, wrap]), int(idx.size) def word_segmented(P, small): """Segmented whole-period gap word (uint16), constant memory, cyclic seam appended.""" parts = [] prev = None first = None off = 0 while off < P: size = min(CHUNK, P - off) idx = np.flatnonzero(sieve_chunk(off, size, small)).astype(np.int64) if idx.size: idx += off if prev is None: first = int(idx[0]) else: parts.append(np.array([int(idx[0]) - prev], dtype=np.uint16)) if idx.size > 1: parts.append(np.diff(idx).astype(np.uint16)) prev = int(idx[-1]) off += size g = np.concatenate(parts) return np.concatenate([g, np.array([(first + P - prev) & 0xFFFF], dtype=np.uint16)]), \ int(g.size + 1) def R_of(word, p): """Longest CYCLIC run of consecutive qualifying gaps; rotate the seam to a non-qualifying gap.""" mod = np.mod(word, np.uint16(p)) qual = (mod == np.uint16(0)) | (mod == np.uint16(2)) | (mod == np.uint16(p - 2)) n = int(qual.size) if qual.all(): return n bad = int(np.flatnonzero(~qual)[0]) q2 = np.roll(qual, -bad) idx = np.flatnonzero(q2) if idx.size == 0: return 0 d = np.diff(idx) brk = np.flatnonzero(d != 1) if brk.size == 0: return int(idx.size) lens = np.diff(np.concatenate(([-1], brk, [int(idx.size) - 1]))) return int(lens.max()) def primes_up_to(n): return [q for q in range(2, n + 1) if all(q % d for d in range(2, int(q ** 0.5) + 1))] def qualifying_possible(word_max, p): """True iff some gap value <= word_max can satisfy one of the three classes.""" return (p <= word_max) or (p - 2 <= word_max and p - 2 > 0) or (p + 2 <= word_max) def main(): t0 = time.time() primes = primes_up_to(1009) checks = [] def check(name, ok, detail): checks.append({"name": name, "ok": bool(ok), "detail": detail}) # ---------------- control: T23 ---------------- w23, n23 = word_in_memory(P23, SMALL23) check("T23 residue count D(T23) = 7952175", n23 == 7952175, n23) check("T23 max gap G2(T23) = 204", int(w23.max()) == 204, int(w23.max())) r23 = {p: R_of(w23, p) for p in primes if p >= 29} check("T23 R(29),R(31),R(37) = 2,2,2 (N-1840-01 / #159 recorded run)", (r23[29], r23[31], r23[37]) == (2, 2, 2), (r23[29], r23[31], r23[37])) check("T23 max R over primes 29..1009 = 2 (N-1840-01)", max(r23.values()) == 2, max(r23.values())) struct23 = [p for p in primes if p > 206] check("T23 R(q) = 0 for all 123 primes 206 < q <= 1009 (structural)", len(struct23) == 123 and all(r23[p] == 0 for p in struct23), len(struct23)) # ---------------- new: T29 ---------------- w29, n29 = word_segmented(P29, SMALL29) check("T29 residue count D(T29) = 214708725 (job1645 control)", n29 == 214708725, n29) check("T29 max gap G2(T29) = 258 (job1645 control)", int(w29.max()) == 258, int(w29.max())) uniq = np.unique(w29) check("T29 distinct gap values = 41 and gaps >= 240 = [240,258] (job1645 control)", uniq.size == 41 and [int(v) for v in uniq if v >= 240] == [240, 258], [int(v) for v in uniq if v >= 240]) g2_29 = int(uniq.max()) cand29 = [p for p in primes if p >= 29 and qualifying_possible(g2_29, p)] r29 = {p: R_of(w29, p) for p in cand29} probes = [p for p in (263, 509, 1009) if p not in r29] r29_probe = {p: R_of(w29, p) for p in probes} check("T29 every non-candidate prime is exactly 0 on three measured probes", all(v == 0 for v in r29_probe.values()), r29_probe) q1 = sorted(p for p, v in r29.items() if v >= 1) q2 = sorted(p for p, v in r29.items() if v >= 2) q3 = sorted(p for p, v in r29.items() if v >= 3) maxR29 = max(r29.values()) if r29 else 0 check("T29 falsifier: no prime q <= 1009 has R+1 > 8 (N-1840-01 pre-registered)", maxR29 + 1 <= 8, {"max_R": maxR29, "support_bound": maxR29 + 1}) check("T29 max R attained only at primes q <= G2+2 = 260", all(p <= 260 for p in q1), {"primes_with_R_ge_1": q1}) out = { "job": 2456, "artifact": "loose-support ladder R(q) at T23 (control) and T29 (new)", "convention": "odd twin-admissible residues r mod x#, gcd(r(r+2),x#)=1; gap word = cyclic " "consecutive differences; qualify(g,q) <=> g mod q in {0,2,q-2}; " "R(q) = longest cyclic run of consecutive qualifying gaps; loose support = R+1", "controls_T23": {"D": n23, "G2": int(w23.max()), "R29": r23[29], "R31": r23[31], "R37": r23[37], "max_R_29_to_1009": max(r23.values()), "primes_gt_206_all_zero": True}, "T29": { "P29": P29, "D": n29, "G2": g2_29, "distinct_gap_values": int(uniq.size), "candidate_primes": cand29, "R_by_prime": {str(p): r29[p] for p in cand29}, "max_R": maxR29, "loose_support_bound": maxR29 + 1, "primes_with_R_ge_1": q1, "primes_with_R_ge_2": q2, "primes_with_R_ge_3": q3, "non_candidate_probes": {str(p): r29_probe[p] for p in probes}, "non_candidate_rule": "p > G2+2 = 260 => no gap value (all <= 258) can be 0, +2 or -2 " "(mod p), so R(p) = 0", }, "falsifier": {"pre_registered": "R+1 <= 8 for all primes 29..1009 at T29", "tested": "46 candidate primes (29..257) measured, all others structural 0, " "3 probes", "fired": bool(maxR29 + 1 > 8)}, "checks": checks, "all_pass": all(c["ok"] for c in checks), "wall_s_excluded": True, } print(json.dumps(out, indent=1, sort_keys=True)) print("[stderr] %d checks, all_pass=%s, elapsed %.1fs" % (len(checks), all(c["ok"] for c in checks), time.time() - t0), file=sys.stderr) if __name__ == "__main__": main()