"""Job #1913 (pursue route 77 rev 2). QUESTION (#1014's next step): does the anchor's calm survive when Lemma 3's t = 0 branch (natal-cap-19-calm-lemma.md) is re-derived WITHOUT the modulo-W self-pairing step -- is the concatenation a consequence of the Fusion Identity (Lemmas 1-2) alone, and does the refinement condition q | W-2 ever coincide with the class-swap condition q | W? DEFINITIONS (served: anchored-windows.md section 1; natal-cap-13-anchored-calm.js runLevel; calm-lemma.md header): level x, W = x# (30 * prod of primes 7..x); natal set N = {r in [0,W): r = 11 or 17 (mod 30), r != 0, p-2 (mod p) for 7 <= p <= x}; mirror mu(r) = W-2-r, mu(N) = N; scour primes Q = {q prime: x < q, q^2 <= W}; rotation t strikes classes {t, t-2} mod q; n_q[c] = #{r in N: r = c mod q}; G(t,q) = n_q[t mod q] + n_q[(t-2) mod q]; E_q = 2|N|/q; dev(t,q) = G(t,q) - E_q; VR(t) = sum_q dev^2 / sum_q E_q (1 - 2/q) (#1013's normalisation). Dilated sibling A(m) = ind_N[(q m) mod W]; lA = ceil(W/q), lB = floor((W+1)/q); Lemma 2: gross(0,q) = #(A over the cyclic index window m in [-lB, lA-1]). PRE-REGISTERED. (a) FUSION WITHOUT SELF-PAIRING: for every q at @11, @13, @17, G(0,q) equals the fused-window count; the class-(-2) strikes are the mirror images of the natal points r' = W - q m (m = 1..lB), i.e. of the class W mod q, NOT of class 0; hence G(W,q) = G(0,q) for every q (mirror covariance one step past the window) while the pairs {0,-2} and {W mod q, W-2 mod q} differ. The literal (unmirrored) class-(-2) window is [1 - 2q^{-1}, lB - 2q^{-1}] in index space; exact algebra: right-adjacent to the class-0 window iff q | W-2 (the note's refinement), LEFT-adjacent iff q | W+2, in which case it coincides with Lemma 2's mirrored window -- tested per prime; q | W+1 forces r_q = 2 (note's dual remark). (b) PRIME CONDITIONS: for every scour prime, W mod q != 0 (q > x and W = x#, an identity, so the t = 0 pair is mirror-invariant for NO scour prime at ANY level); list the q with W = 2 (mod q) and W = -2 (mod q). (c) CALM FIGURES: dev(0,q) from the fused window equals dev(0,q) from the classes (same integers), VR(0) at @11 = 0.080641207 and percentile 1.839 (rank 43 of 2311 phases on [0,W]) as #1013 recorded; the W/2 duplication n[W/2] = n[W/2-2] for every q; VR(W) = VR(0); W/2 is the census maximum at @11 and rank 198 from the top at @13 (calm-lemma.md's corrected sentence). FALSIFIERS: a q with G(0,q) != fused count; a scour q with q | W; VR(0) not reproducing. Stdout: ledger + JSON.""" import json, math, sys, time import numpy as np t0 = time.time(); led = [] def check(tag, ok, detail): led.append(f"{'PASS' if ok else 'FAIL'} {tag} :: {detail}"); print(led[-1], file=sys.stderr, flush=True) def primes_upto(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 [int(p) for p in np.flatnonzero(s)] def build(x): wheel = [p for p in primes_upto(x) if p >= 7]; W = 30 * math.prod(wheel) ind = np.zeros(W, dtype=bool); ind[11::30] = True; ind[17::30] = True for p in wheel: ind[0::p] = False; ind[p - 2::p] = False N = np.flatnonzero(ind); Q = [q for q in primes_upto(math.isqrt(W) + 1) if q > x and q * q <= W] return W, ind, N, Q out = {'instrument': 'fresh1913.py', 'job': 1913, 'levels': {}} for x in (11, 13, 17): W, ind, N, Q = build(x); Nn = len(N); rec = {'W': W, 'N': Nn, 'K': len(Q), 'Q_range': [Q[0], Q[-1]], 'per_q': {}} mirror_ok = bool(np.all(ind[(W - 2 - N) % W])) fus_bad = []; adj_literal = []; literal_is_mirrored = []; rq_list = {}; cov_bad = []; dup_bad = []; wmod = {0: [], 2: [], -2: []}; inv_bad = [] for q in Q: n = np.bincount(N % q, minlength=q); E = 2 * Nn / q G0 = int(n[0] + n[(-2) % q]); GW = int(n[W % q] + n[(W - 2) % q]) qinv = pow(q, -1, W); lA = -(-W // q); lB = (W + 1) // q ms = np.arange(-lB, lA) % W; fused = int(np.count_nonzero(ind[(q * ms) % W])) if fused != G0: fus_bad.append(q) if GW != G0: cov_bad.append(q) # literal (unmirrored) windows of A for rotation t = 0: class-0 strikes r = q m, m in [0, lA); class-(-2) strikes r = q m - 2, # m in [1, lB], which as points of A(m') = ind[(q m') mod W] sit at m' = m - 2 q^{-1} (mod W): the window [1 - 2q^{-1}, lB - 2q^{-1}]. # Right-adjacent to [0, lA) iff 1 - 2q^{-1} = lA (mod W) <=> q (lA - 1) = W - 2 <=> q | W-2; left-adjacent iff lB - 2q^{-1} = -1 # <=> q (lB + 1) = W + 2 <=> q | W+2, and then the literal window IS the mirrored window [-lB, -1] of Lemma 2. lo = (1 - 2 * qinv) % W; hi = (lB - 2 * qinv) % W right_adj = lo == lA % W; left_adj = hi == (W - 1) adj = right_adj or left_adj if adj: adj_literal.append(q) rq = q * (lA + lB) - 2 * W if left_adj: literal_is_mirrored.append(q) rq_list[q] = rq for k in (0, 2, -2): if (W - k) % q == 0: wmod[k].append(q) pair0 = {0, (q - 2) % q}; img = {(W - 2 - c) % q for c in pair0} if img == pair0: inv_bad.append(q) h = W // 2 if n[h % q] != n[(h - 2) % q]: dup_bad.append(q) rec['per_q'][q] = {'G0': G0, 'fused': fused, 'GW': GW, 'W_mod_q': int(W % q), 'literal_adjacent': bool(adj), 'r_q': rq, 'dev0': round(G0 - E, 4)} check(f'x={x}_mirror_closes_N', mirror_ok, f'|N| = {Nn}, W = {W}, K = {len(Q)} scour primes {Q[0]}..{Q[-1]}') check(f'x={x}_a_fusion_without_self_pairing', not fus_bad, f'G(0,q) = fused cyclic window for all q; mismatches {fus_bad}') check(f'x={x}_a_mirror_covariance_one_step_out', not cov_bad, f'G(W,q) = G(0,q) for all q; mismatches {cov_bad}') check(f'x={x}_a_literal_adjacency_iff_q_divides_W-2_or_W+2', set(adj_literal) == set(wmod[2]) | set(wmod[-2]), f'literal adjacency at q = {adj_literal} (right, q | W-2: {wmod[2]}; left = the mirrored window itself, q | W+2: {wmod[-2]}); literal window equal to the fused window: {literal_is_mirrored}') wp1 = [q for q in Q if (W + 1) % q == 0] check(f'x={x}_a_r_q_bounded_and_q|W+1_forces_r_q=2', all(abs(r) < q for q, r in rq_list.items()) and all(rq_list[q] == 2 for q in wp1), f'q L_q - 2W = r_q, |r_q| < q for all q; q | W+1: {wp1} with r_q = {[rq_list[q] for q in wp1]}; r_q histogram at this level: min {min(rq_list.values())} max {max(rq_list.values())}') check(f'x={x}_b_no_scour_prime_divides_W', not wmod[0] and not inv_bad, f'q | W: {wmod[0]}; t=0 pair mirror-invariant: {inv_bad}; q | W-2: {wmod[2]}; q | W+2: {wmod[-2]}') check(f'x={x}_c_W/2_duplication_n[W/2]=n[W/2-2]', not dup_bad, f'mismatches {dup_bad}') rec.update({'q_dividing_W': wmod[0], 'q_dividing_W_minus_2': wmod[2], 'q_dividing_W_plus_2': wmod[-2], 'literal_adjacent_q': adj_literal, 'literal_window_is_mirrored_window_q': literal_is_mirrored, 'q_dividing_W_plus_1': [q for q in Q if (W + 1) % q == 0], 'r_q': rq_list}) if x <= 13: CNT = {q: np.bincount(N % q, minlength=q) for q in Q} def vr(t): num = den = 0.0 for q in Q: E = 2 * Nn / q; d = CNT[q][t % q] + CNT[q][(t - 2) % q] - E; num += d * d; den += E * (1 - 2 / q) return num / den vrs = np.array([vr(t) for t in range(W + 1)]) # closed ring [0, W] v0, vW, vh = vrs[0], vrs[W], vrs[W // 2] rank0 = int(np.sum(vrs < v0)) + 1; pct0 = 100 * (np.sum(vrs < v0) + 0.5 * np.sum(vrs == v0)) / len(vrs) rec.update({'VR0': v0, 'VRW': vW, 'VR_half': vh, 'rank0_of': [rank0, len(vrs)], 'pct0': round(pct0, 3), 'VR_half_is_max': bool(vh == vrs.max()), 'VR_half_rank': int(np.sum(vrs < vh)) + 1}) check(f'x={x}_c_VR_anchor_and_W_equal', abs(v0 - vW) < 1e-12, f'VR(0) = {v0:.9f} VR(W) = {vW:.9f}') if x == 11: check('x=11_c_VR0_reproduces_1013', abs(v0 - 0.080641207) < 1e-8 and rank0 == 43 and len(vrs) == 2311, f'VR(0) = {v0:.9f}, rank {rank0} of {len(vrs)}, percentile {pct0:.3f} (#1013: 0.080641207, 43 / 2311, 1.839)') from_top = len(vrs) - rec['VR_half_rank'] # 0 = the maximum expect = {11: 0, 13: 198}[x] check(f'x={x}_c_W/2_rank_from_top_as_served', from_top == expect, f"VR(W/2) = {vh:.6f}, rank from top {from_top} of {len(vrs)} phases on [0, W] (calm-lemma.md: {expect}); every dev(W/2,q) is 2 x one class deviation (duplication PASS above)") # the producer's own normalisation (natal-cap-38 quotes VR(W/2) = 1.6652 at @13): try the candidates and report which reproduces devs = lambda t: np.array([CNT[q][t % q] + CNT[q][(t - 2) % q] - 2 * Nn / q for q in Q]); Qa = np.array(Q, dtype=float) cands = {'sum_dev2_over_K': lambda t: float(np.sum(devs(t) ** 2) / len(Q)), 'sum_dev2_over_sumE': lambda t: float(np.sum(devs(t) ** 2) / np.sum(2 * Nn / Qa)), 'mean_dev2_over_E': lambda t: float(np.mean(devs(t) ** 2 / (2 * Nn / Qa))), 'mean_dev2_q_over_2N': lambda t: float(np.mean(devs(t) ** 2 * Qa / (2 * Nn)))} # the producer (natal-cap-13-anchored-calm.js lines 146-151): per prime varRot_q = (1/q) sum over the q classes a of (n[a]+n[a-2]-2N/q)^2, # z2(a) = dev(a)^2 / varRot_q; the level statistic is the sum (or mean) of z2 over primes -- both tried varRot = {q: float(np.sum((CNT[q] + np.roll(CNT[q], 2) - 2 * Nn / q) ** 2) / q) for q in Q} cands['sum_z2'] = lambda t: float(sum(d * d / varRot[q] for d, q in zip(devs(t), Q))) cands['mean_z2'] = lambda t: cands['sum_z2'](t) / len(Q) rec['VR_half_candidates'] = {k: round(f(W // 2), 4) for k, f in cands.items()} rec['anchor_candidates'] = {k: round(f(0), 4) for k, f in cands.items()} if x == 13: led.append(f"INFO x=13_c_producer_VR(W/2)=1.6652 (natal-cap-38, not fetched) reproduced by none of six normalisations: {rec['VR_half_candidates']}; the rank-from-top 198 IS reproduced, which is the served sentence's content") out['levels'][str(x)] = rec print(f'x={x} done ({time.time() - t0:.0f}s)', file=sys.stderr, flush=True) # the arithmetic identity behind (b): a scour prime q > x cannot divide W = x# check('b_identity_q_gt_x_never_divides_x#', True, 'W = x# has no prime factor above x; every scour prime q > x; so q | W is impossible at every level, and the t = 0 pair {0,-2} is never mirror-invariant (invariance needs W = 0 mod q, since the image {W-2, W} mod q equals {0, q-2} only then)') out['ledger'] = led; out['secs'] = round(time.time() - t0, 1) print('\n'.join(led)); print('VERDICT ' + json.dumps({'all_pass': all(l.startswith('PASS') for l in led), 'levels': {x: {k: out['levels'][x][k] for k in ('W', 'N', 'K', 'q_dividing_W', 'q_dividing_W_minus_2', 'q_dividing_W_plus_2', 'literal_adjacent_q')} for x in out['levels']}, 'secs': out['secs']})) json.dump(out, open('fresh1913.json', 'w'), indent=1, default=float)