"""Job #2701 (leads: new statistic with a falsifier). THE STATISTIC. For a level x, W = prod_{p<=x} p, natal set N = {r in [0,W) : r = 11 or 17 (mod 30), p does not divide r or r+2 for 7 <= p <= x}, scour primes qs = {q prime : x < q, q^2 <= W} (definitions verbatim from research/history/staging/xchan-at29-prereg.md section 1). For r in N let D_a(r) = {q in qs : q | r}, D_b(r) = {q in qs : q | r+2}, and Y_r = #{(q1 W} + #{(q1 in D_a, q2 W}, the slot's mixed super-W triples. The census total is T = sum_r Y_r (the prereg's "mixed super-W obs"). The new statistic is the INDEPENDENT-SLOT DISPERSION INDEX I(x) = sum_r Y_r^2 / sum_r Y_r, exact arithmetic, no draws. THE DECISION. The record scores the closed form 1 - J = 4 S_2 with sigma_J = sqrt(T)/CRT, the Poisson proxy (T treated as a count of independent unit events); item-x-offset.md section 4 instead calibrated a "slot-clustered" sigma on seven random-mask control draws and found an inflation of 2.10x (@29), 2.12x (@31) over Poisson, which moves the @31 verdict from 4.93 sigma to 2.32 sigma (return #85, issue 2; return #1343). Under the control's own model, a random mask keeping each natal slot independently with probability lam, the count T_ctrl = sum_r B_r Y_r has E = lam T and Var = lam(1-lam) sum_r Y_r^2, so its dispersion (Var/E) is (1-lam) I(x): the index I(x) is the exact prediction of the calibrated inflation, up to the factor (1-lam) and sampling noise. If I(x) at the levels where a from-scratch census is cheap (@19, @23) matches the record's calibrated inflation, the slot-clustered sigma is derived, not fitted, and the @31 error model is settled in its favour; if it does not, cross-slot structure (the CRT lattice of the natal set) contributes to the fluctuation and neither proxy is right. THE MATCHED CONTROL. The random-mask thinning of the record itself: seeded masks at density lam on the natal set, the control count's dispersion measured over draws and compared with (1-lam) I(x) (sampling check of the identity), plus the corpus's published draws (item-x-offset.md section 4: seven draws inside 1.9 sigma). PRE-REGISTERED FALSIFIERS (written before the run). F1 (identity): over 200 seeded masks at lam = 1/2 the measured Var/E of T_ctrl is within 3 standard errors of (1 - lam) I(x) at both levels (this checks the formula and the code, not the record). F2 (the record's inflation is the independent-slot index): the record's 2.10/2.12 are ratios of sigmas (z_poisson/z_slot), so the comparand is sqrt(I(x)); sqrt(I) at @19 and @23, extrapolated to @29/@31 by its level trend, lies within 0.25 of 2.10/2.12; a value of sqrt(I) outside [1.6, 2.6] at @23 refutes the reading of the record's inflation as pure within-slot clustering. F3 (census custody): T at @19 and @23 reproduces the record's mixed super-W obs where the record prints it (the prereg's sigma_J = sqrt(T)/CRT gives T = (sigma_J * CRT)^2), and the aligned super-W count is exactly 0 (P1, a theorem). Gates: G1 |N| equals 2 * prod_{7<=p<=x}(p-2) * (W/(30 prod_{7<=p<=x} p)) (CRT count); G2 every Y_r is recomputed from scratch from the two divisor lists (no incremental state). Stdout: ledger + JSON; stderr: progress. RUN: python disp2701.py --levels 19,23 --out disp2701.json """ import argparse, json, math, sys, time import numpy as np def primes_to(n): s = np.ones(n + 1, dtype=bool); s[:2] = False for i in range(2, int(n ** 0.5) + 1): if s[i]: s[i * i:: i] = False return np.flatnonzero(s) def natal(x): ps = [int(p) for p in primes_to(x)]; W = 1 for p in ps: W *= p cand = np.concatenate([np.arange(11, W, 30, dtype=np.int64), np.arange(17, W, 30, dtype=np.int64)]); cand.sort() ok = np.ones(len(cand), dtype=bool) for p in ps: if p < 7: continue ok &= (cand % p != 0) & ((cand + 2) % p != 0) return W, ps, cand[ok] def main(): ap = argparse.ArgumentParser(); ap.add_argument('--out', required=True); ap.add_argument('--levels', default='19,23'); ap.add_argument('--draws', type=int, default=200); ap.add_argument('--lam', type=float, default=0.5) a = ap.parse_args(); log = sys.stderr; ledger = [] def check(tag, ok, detail): ledger.append(f"{'PASS' if ok else 'FAIL'} {tag} :: {detail}"); print(ledger[-1], file=log, flush=True) out = {'instrument': 'disp2701.py', 'job': 2701, 'levels': {}, 'ledger': ledger}; rng = np.random.default_rng(2701) for x in [int(v) for v in a.levels.split(',')]: t0 = time.time(); W, ps, N = natal(x) expect = 2 for p in ps: if p >= 7: expect *= (p - 2) expect *= W // (30 * math.prod(p for p in ps if p >= 7)) check(f'G1_natal_count_x{x}', len(N) == expect, f'|N| = {len(N)} vs CRT {expect}; W = {W}') qs = [int(q) for q in primes_to(int(math.isqrt(W))) if q > x] # divisor lists per slot: for each scour prime, mark natal slots with q | r and q | r+2 idx_a = {}; idx_b = {} Na = [[] for _ in range(len(N))]; Nb = [[] for _ in range(len(N))] for q in qs: for arr, target in ((Na, 0), (Nb, 2)): hit = np.flatnonzero((N + target) % q == 0) for i in hit: arr[int(i)].append(q) print(f'x={x}: |N|={len(N)} scour primes {len(qs)} ({time.time()-t0:.1f}s)', file=log, flush=True) Y = np.zeros(len(N), dtype=np.int64); aligned = 0 for i in range(len(N)): A, B = Na[i], Nb[i] if not A or not B: # aligned super-W: q1 W for L in (A, B): n = len(L) for u in range(n): for v in range(u + 1, n): for w in range(v + 1, n): if L[u] * L[v] * L[w] > W: aligned += 1 continue c = 0 for u in range(len(A)): for v in range(u + 1, len(A)): pq = A[u] * A[v] for q3 in B: if pq * q3 > W: c += 1 for q1 in A: for u in range(len(B)): for v in range(u + 1, len(B)): if q1 * B[u] * B[v] > W: c += 1 Y[i] = c for L in (A, B): n = len(L) for u in range(n): for v in range(u + 1, n): for w in range(v + 1, n): if L[u] * L[v] * L[w] > W: aligned += 1 T = int(Y.sum()); S2 = int((Y * Y).sum()); I = S2 / T if T else float('nan') check(f'F3_aligned_zero_x{x}', aligned == 0, f'aligned super-W count {aligned}') # CRT denominator and 1 - J, for custody against the record qarr = np.array(qs, dtype=np.float64); s = 0.0 # tail sum over triples q1 W of 1/(q1 q2 q3): direct triple loop is too slow at @23; use pair loop + vectorised third for u in range(len(qs)): for v in range(u + 1, len(qs)): pq = qs[u] * qs[v]; thr = W / pq sel = qarr[v + 1:] > thr if sel.any(): s += float((1.0 / (pq * qarr[v + 1:][sel])).sum()) CRT = 6 * len(N) * s; J = T / CRT if CRT else float('nan') S2sum = float((1.0 / qarr ** 2).sum()) # control draws lam = a.lam; disp = [] for _ in range(a.draws): m = rng.random(len(N)) < lam; disp.append(float((Y[m]).sum())) disp = np.array(disp); var_e = disp.var() / disp.mean(); pred = (1 - lam) * I se = var_e * math.sqrt(2.0 / (a.draws - 1)) check(f'F1_identity_x{x}', abs(var_e - pred) <= 3 * se, f'control Var/E {var_e:.4f} vs (1-lam) I = {pred:.4f} (se ~ {se:.4f}, {a.draws} draws)') lv = {'W': W, 'natal': len(N), 'scour_primes': len(qs), 'T_mixed_superW': T, 'sum_Y2': S2, 'dispersion_index_I': I, 'Y_hist': {int(k): int(v) for k, v in zip(*np.unique(Y, return_counts=True))}, 'CRT': CRT, 'J': J, 'one_minus_J': 1 - J, 'four_S2': 4 * S2sum, 'sigma_J_poisson': math.sqrt(T) / CRT if CRT else None, 'sigma_J_slot': math.sqrt(S2) / CRT if CRT else None, 'z_poisson': (1 - J - 4 * S2sum) / (math.sqrt(T) / CRT) if CRT else None, 'z_slot': (1 - J - 4 * S2sum) / (math.sqrt(S2) / CRT) if CRT else None, 'control': {'lam': lam, 'draws': a.draws, 'var_over_mean': var_e, 'predicted': pred}, 'secs': round(time.time() - t0, 1)} out['levels'][str(x)] = lv print(f'x={x}: T={T} sumY2={S2} I={I:.4f} | 1-J={1-J:.6f} 4S2={4*S2sum:.6f} z_poisson={lv["z_poisson"]:+.2f} z_slot={lv["z_slot"]:+.2f} | control Var/E {var_e:.3f} vs {pred:.3f} ({time.time()-t0:.1f}s)', file=log, flush=True) json.dump(out, open(a.out, 'w'), indent=1) Is = {x: out['levels'][x]['dispersion_index_I'] for x in out['levels']} v = {'F2_sqrtI_within_0.25_of_record_2.1': all(abs(math.sqrt(i) - 2.11) <= 0.25 for i in Is.values()), 'F2_hard_band_sqrtI_1.6_2.6_at_23': (1.6 <= math.sqrt(Is.get('23', float('nan'))) <= 2.6) if '23' in Is else None, 'I_by_level': Is, 'sqrtI_by_level': {k: math.sqrt(v) for k, v in Is.items()}} out['verdict'] = v; json.dump(out, open(a.out, 'w'), indent=1) print('\n'.join(ledger)); print('VERDICT ' + json.dumps(v, sort_keys=True)); return 0 if __name__ == '__main__': sys.exit(main())