"""Job #1327 (discover): the tile-budget ratio lambda(s) = m*(T_s) * gbar(s) / Ghat(s), and whether the ARRANGEMENT of the tile's gaps carries it, or only their multiset. QUESTION m*(T_s) = max{ m : maxsum_m(T_s) < 4*Ghat(s) } is the "affordable window length" of the maxsum doubling certificate (return #584; msc(s) < 4 iff K*(s)+1 <= m*(s)). m* is an absolute window LENGTH, so it is not comparable across levels. Divide it by the length the budget buys at the average gap, 4*Ghat/gbar, and what is left is dimensionless. Up to the constant 4 that is lambda(s) = m*(T_s) * gbar(s) / Ghat(s), gbar(s) = s# / phi(s#) i.e. "how many average gaps long is the affordable window, per unit of record gap". lambda is a pure number and it is NOT in any retained census: the censuses retain Ghat (the ladder), D = phi(s#) and the per-step K*/msc table, and #584 added m*, but the ratio has never been formed. If lambda were bounded, m* <= lambda_sup * Ghat/gbar would be a bound on the affordable side computed ENTIRELY from retained data -- no tile pass -- and msc(s) < 4 would become a statement about K* against a known quantity. DECISION IT INFORMS: whether the cheap half of the route-24 race can be predicted at levels where the tile cannot be held (T_31 is 6.2e9 slots). If lambda is bounded and falling, item D's eventual form needs K*(s)+1 <= lambda*Ghat/gbar with lambda shrinking -- a sharper and cheaper statement against it than one more msc value. MATCHED CONTROL (the point of this script) lambda could be a function of the gap MULTISET alone, which the census already determines (D gaps summing to s#, max Ghat). Then nothing new is measured. So recompute m* on a uniformly random circular PERMUTATION of the same tile's own gaps, seeded. Ghat and gbar are permutation-invariant, so lambda_shuffled isolates exactly the effect of ARRANGEMENT. PRE-REGISTERED, written before the run (the 3(pi(x)-3) law of #584 was fitted on five levels and refuted on the sixth; so these are committed here, in the artifact, not afterwards): P1 lambda_real < lambda_shuffled at every level x >= 13, because the tile's large gaps CLUSTER (they sit where many small primes align), so a real window reaches 4*Ghat in fewer gaps than a scattered one. FALSIFIED if lambda_real >= mean(lambda_shuffled) at any level x >= 13, or if the gap |lambda_real - mean_shuf| is under 1 s.d. of the shuffled spread at two or more levels (i.e. arrangement carries nothing). P2 lambda_real is falling in x over 13..29. FALSIFIED if it rises at two consecutive levels. P3 lambda(T_31) < 2.336 = lambda(T_29), continuing the fall. NOT TESTED HERE (T_31 is 6.2e9 slots, out of this assignment's memory); recorded so a later run cannot fit it after the fact. Exact integer arithmetic for every tile quantity; the only randomness is the seeded control. Progress and timing go to stderr; stdout is the artifact. """ import sys, time import numpy as np SEED = 20260915 R_SHUF = 20 # permutations per level T0 = time.time() log = lambda *a: print(*a, file=sys.stderr, flush=True) # Ghat = G2(x#), the published exact ladder (redteam-0830-doubling.js / exact-g2-ladder.js). # Externally reported, reproduced below by assertion at every level we build. GHAT = {7: 30, 11: 42, 13: 66, 17: 108, 19: 150, 23: 204, 29: 258} MSTAR_PUB = {7: 6, 11: 6, 13: 9, 17: 12, 19: 15, 23: 18, 29: 20} # return #584 def primes_upto(n): s = np.ones(n + 1, dtype=bool); s[:2] = False for i in range(2, int(n ** .5) + 1): if s[i]: s[i * i::i] = False return np.flatnonzero(s) def tile_gaps(x): """Circular gap word of the TWIN tile mod x#: residues r with both r and r+2 coprime to x#. That is this project's T_s (the dimension-2 tile), not the reduced residue system -- its census is prod_{p<=x} (p - |{0, -2} mod p|) = 1,1,3,5,9,11,... giving D(7)=15 and D(13)=1485, which is what the record's census column carries. Exact.""" ps = [int(p) for p in primes_upto(x)] P = 1 for p in ps: P *= p sieve = np.ones(P, dtype=bool) for p in ps: sieve[0::p] = False # r = 0 mod p sieve[(-2) % p::p] = False # r = -2 mod p (same class as r=0 when p=2) slots = np.flatnonzero(sieve).astype(np.int64) g = np.diff(slots, append=slots[0] + P) # circular: last wraps to first + P assert int(g.sum()) == P, f"sum(gaps) != {x}#" return g, P, len(slots) def maxsum(g, m): """max over circular windows of m consecutive gaps. Exact int64.""" ext = np.concatenate([g, g[:m]]) c = np.concatenate([[0], np.cumsum(ext, dtype=np.int64)]) return int((c[m:] - c[:-m]).max()) def mstar(g, ghat): """max{ m : maxsum_m < 4*ghat }, by scan from m=1 (maxsum is monotone in m).""" budget = 4 * ghat m = 0 while True: if maxsum(g, m + 1) >= budget: return m m += 1 print(" x D W=x# Ghat gbar Ghat/gbar m* lambda=m*gbar/Ghat") rows = {} for x in (7, 11, 13, 17, 19, 23): g, P, D = tile_gaps(x) ghat = int(g.max()) assert ghat == GHAT[x], f"max gap {ghat} != published Ghat {GHAT[x]} at x={x}" ms = mstar(g, ghat) assert ms == MSTAR_PUB[x], f"m*={ms} != #584's {MSTAR_PUB[x]} at x={x}" gbar = P / D lam = ms * gbar / ghat rows[x] = dict(g=g, D=D, P=P, ghat=ghat, gbar=gbar, mstar=ms, lam=lam) print(f"{x:3d} {D:10d} {P:12d} {ghat:8d} {gbar:8.3f} {ghat/gbar:10.4f} {ms:4d}" f" {lam:.4f}") log(f" built T_{x}: D={D} [{time.time()-T0:.1f}s]") # T_29 by the Copying Theorem lift of T_23 (27 slots per T_23 slot), as #584 did: 29# is # 6.47e9 and cannot be sieved directly here. Custody: slot count, sum(gaps) and max gap are # asserted against the record before m* is read. def lift(g23, P23, q=29): """T_q from T_23 by the Copying Theorem. The q copies r + P23*k (k = 0..q-1) of each slot cover the residues mod q# that are already admissible for every p <= 23; exactly the two with r + P23*k = 0 or -2 (mod q) are then killed, and WHICH k those are depends on r (P23 is invertible mod q), so the survivors cannot be chosen by a fixed set of k. Blocks are emitted in increasing k, and block k spans [P23*k, P23*(k+1)), so the result is already sorted and needs no sort.""" slots23 = np.concatenate([[0], np.cumsum(g23[:-1], dtype=np.int64)]) out = [] for k in range(q): b = slots23 + P23 * k r = b % q out.append(b[(r != 0) & (r != (q - 2) % q)]) s = np.concatenate(out) P = P23 * q return np.diff(s, append=s[0] + P), P, len(s) log(" lifting T_23 -> T_29 ...") g29, P29, D29 = lift(rows[23]["g"], rows[23]["P"]) assert D29 == 214708725, f"T_29 slots {D29} != 214708725" assert int(g29.sum()) == P29 == 6469693230, "T_29 sum(gaps) != 29#" ghat29 = int(g29.max()) assert ghat29 == GHAT[29] == 258, f"T_29 max gap {ghat29} != published 258" ms29 = mstar(g29, ghat29) assert ms29 == MSTAR_PUB[29], f"m*(T_29)={ms29} != #584's {MSTAR_PUB[29]}" gbar29 = P29 / D29 lam29 = ms29 * gbar29 / ghat29 rows[29] = dict(g=g29, D=D29, P=P29, ghat=ghat29, gbar=gbar29, mstar=ms29, lam=lam29) print(f" 29 {D29:10d} {P29:12d} {ghat29:8d} {gbar29:8.3f} {ghat29/gbar29:10.4f}" f" {ms29:4d} {lam29:.4f} [rebuilt here; m*, Ghat, census match return #584]") log(f" T_29 rebuilt and checked [{time.time()-T0:.1f}s]") print("\nP2 -- is lambda falling in x?") xs = [7, 11, 13, 17, 19, 23, 29] seq = [rows[x]["lam"] for x in xs] for a, b in zip(xs, seq): print(f" x={a:3d} lambda={b:.4f}") rises = [xs[i + 1] for i in range(len(seq) - 1) if seq[i + 1] > seq[i]] consec = any(xs.index(rises[i]) + 1 == xs.index(rises[i + 1]) for i in range(len(rises) - 1)) if len(rises) > 1 else False print(f" rises at x = {rises}; two consecutive rises = {consec}" f" -> P2 {'FALSIFIED' if consec else 'stands'}") print("\nP1 -- matched control: the SAME gaps, uniformly permuted (seeded), " f"{R_SHUF} draws per level") print(" x draws lambda_real mean_shuf sd min_shuf max_shuf effect=real-mean" " z P1") verdict = {} for x in (13, 17, 19, 23, 29): r = rows[x] n = R_SHUF if x < 29 else 5 # T_29 is 214.7e6 slots; 5 draws rng = np.random.default_rng(SEED + x) lams = [] for i in range(n): sh = rng.permutation(r["g"]) lams.append(mstar(sh, r["ghat"]) * r["gbar"] / r["ghat"]) log(f" T_{x} draw {i+1}/{n} [{time.time()-T0:.1f}s]") lams = np.array(lams) sd = lams.std(ddof=1) eff = r["lam"] - lams.mean() z = eff / sd if sd > 0 else float("nan") ok = r["lam"] < lams.mean() # P1 as pre-registered verdict[x] = ok print(f" {x:4d} {n:5d} {r['lam']:10.4f} {lams.mean():10.4f} {sd:7.4f}" f" {lams.min():8.4f} {lams.max():8.4f} {eff:+16.4f} {z:+8.2f} " f"{'as predicted' if ok else 'FALSIFIES P1'}") print(f"\n P1 verdict: lambda_real < lambda_shuffled at every level x>=13 = " f"{all(verdict.values())}") print(" Effect size (real - mean_shuf) is reported beside z because sd shrinks with D:") print(" a growing z alone would not establish a growing separation.") print(f"\nP3 (recorded, NOT tested here): lambda(T_31) < {lam29:.4f}. T_31 is 6.2e9 slots.") log(f"total {time.time()-T0:.1f}s")