#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Can a finite census DECIDE any sufficient consumer? -- the decision margin, with a control. THE QUESTION (job #2555, explore/discovery; the job's own ask is "a finite statistic a run could actually decide something about, where the retained censuses could not"). Every retained census in the corpus reports a VALUE: `D_y/x`, `B/x`, `P(1,e_1)/x`, `S/x`. Not one of them reports the value's SIGNIFICANCE against the threshold its own consumer requires, and none of them is accompanied by a matched control. So the corpus can say "the finite reading sits beneath the error" -- and it does, repeatedly -- but it has never said by HOW MANY SIGMA, and it has never said which consumer's census is capable of deciding at all. THE STATISTIC. For a consumer whose requirement is `Y(x)/x >= -theta` and a census statistic `Y(x)` that is exactly computable at reachable x: gap(x) = theta - (-Y(x)/x) = theta + Y(x)/x (the slack, in units of x) sigma(x) = sd over a matched control ensemble of Y(x)/x M(x) = gap(x) / sigma(x) THE DECISION MARGIN M >= 3 means the census could have refuted the requirement had it failed by the observed slack; M < 1 means the census is silent: the noise covers the whole interval between "holds" and "fails". THE MATCHED CONTROL. The repo's own convention (random-sign / permutation / independent thinning). Here: keep the SUPPORT exactly (the squarefree integers, and the odd squarefree e-range) and replace the Moebius SIGNS by fair coin flips. Nothing else changes -- same x, same ranges, same weights, same Lambda(em-2). This isolates exactly the one thing the project's arithmetic campaign asks about: whether the Moebius signs carry information the generic random signs do not. THE TWO CONSUMERS TESTED, at the corpus's own gauge (U,V)=(3,3), eps'=1/60: * CENTERED-MARGIN : D^(e_1)/x >= -4/25 = -0.16, D^(e_1) = P(1,e_1) - Q(1,e_1) [threshold 0.16] * INVARIANT-MARGIN: the object is P(1,e_1)/x itself; its threshold is the direct-twin -(C_2 - 1/200) = -0.655162, and it is the object the graph calls the split-invariant. GATES (the instrument REFUSES rather than prints): G1 PROVENANCE: at j=16, (U,V)=(3,3) the corpus's own validator prints D^(e1)/x = -0.0231. This port must reproduce it to 4 decimals, or nothing is printed. G2 CONTROL SUPPORT: the control sign array must have exactly the support of mu, mean ~0, and no multiplicativity. Asserted, not assumed. G3 NEGATIVE CONTROL: replacing the signs must MOVE the statistic (a control that does not move means the check is blind). PRE-REGISTERED FALSIFIERS, WRITTEN BEFORE ANY RUN: F1 The real Moebius signs are INDISTINGUISHABLE from the random-sign control in D^(e1): the real value lies within 2 sigma of the control ensemble mean at every reached j. (The corpus has this at KERNEL-SIGN (13) and CORNER-MEAS; this is a different statistic and a different consumer.) FALSIFIED if |real - mean(control)| > 2 sigma somewhere. F2 The centered consumer's census HAS decision power at reachable scales: M(x) >= 3 for the requirement D/x >= -0.16. FALSIFIED if sigma(x) > 0.05, i.e. if the control noise reaches a third of the threshold. F3 The invariant consumer's census is GAUGE-limited, not noise-limited: its control sigma is an order of magnitude below the 44x spread the split has across legal Vaughan gauges (return #787 / work/T-B-census.md), so refining x can never decide it. FALSIFIED if the gauge spread is below sigma at reachable x. Nothing here is new mathematics: every definition is the corpus's own ((2.8)/(2.9) of research/fixed-endpoint-discrepancy.md, the validator research/fixed-endpoint-discrepancy-validation.js, and D^(e1) of research/moving-cutoff-parity.md). This is the corpus's finite bookkeeping, run with a control and read against the consumer's own threshold, in the house format. """ import json import sys import time import numpy as np sys.stdout.reconfigure(encoding='utf-8') EPS = EPSP = 1.0 / 60.0 C2 = 0.6601618158468695739278121100145557784326233602847334133194484233354056423 THRESH_CENTERED = 0.16 # 4/25 THRESH_INVARIANT = C2 - 0.005 # C_2 - 1/200 U, V = 3, 3 SEED = 20260919 def sieve(N): """exact Lambda and mu, the corpus's own semantics.""" mu = np.ones(N + 1, dtype=np.int8) mu[0] = 0 is_p = np.ones(N + 1, dtype=bool) is_p[:2] = False for p in range(2, N + 1): if not is_p[p]: continue is_p[p * p::p] = False for q in range(p, N + 1, p): mu[q] = -mu[q] pp = p * p if pp <= N: mu[pp::pp] = 0 lam = np.zeros(N + 1, dtype=np.float64) for p in range(2, N + 1): if not is_p[p]: continue q = p while q <= N: lam[q] = np.log(p) q *= p return lam, mu def phi_of(n): r, m, p = n, n, 2 while p * p <= m: if m % p == 0: r = r // p * (p - 1) while m % p == 0: m //= p p += 1 if m > 1: r = r // m * (m - 1) return r def evaluate(x, signs, plan): """One evaluation of the corpus's finite bookkeeping under a given sign array. signs: length N+1, the Moebius signs (real mu, or the control). Support must be mu's support. plan: precomputed per-e index arrays (draw-independent: support and coprimality do not change). """ lamp = plan['lamp'] logm = plan['logm'] s = signs # M = sum_{n in (x/2, x]} Lambda(n-2) * signs(n) [M_s] n = plan['n'] sJ = s[n].astype(np.float64) F = lamp[n - 2].astype(np.float64) * sJ M = float(np.sum(F)) Ln = float(np.sum(F * logm[n])) # P_s(1, e1) = -sum_e sum_m s(m) log(m) Lambda(e m - 2) P = 0.0 for e, ms, Lev, lg in plan['terms']: sm = s[ms].astype(np.float64) P -= float(np.dot(sm, lg * Lev)) # Q_s(1, e1) = sum_e s(e)/phi(e) * (M_s log e - Ln) Q = 0.0 for e in plan['e1_list']: se = int(s[e]) if se: Q += se / plan['phi'][e] * (M * plan['loge'][e] - Ln) # NOTE on what is NOT sign-dependent: T_I^low enters the corpus's consumer through the # c[r] coefficients of the Vaughan split, not through a sign array, so the control below # moves P, Q, M and D^(e1) -- the whole consumer -- and leaves the split's bookkeeping alone. return dict(P=P, Q=Q, D=P - Q, M=M, Ln=Ln) def main(): js = [int(a) for a in sys.argv[1:]] or [16, 18, 20, 22] draws = 64 # PER-SCALE SEED, so the control ensemble does not depend on which scales are requested or in # what order. The published table and any independent re-run then agree by construction. out = {} rng_holder = {} rows = [] print(f"thresholds: CENTERED D^(e1)/x >= -{THRESH_CENTERED:.2f} ; " f"INVARIANT P(1,e1)/x >= -{THRESH_INVARIANT:.6f} ; (U,V)=({U},{V}) ; eps'={EPSP:.5f}") print(f"control: support == supp(mu), signs = fair coins, {draws} draws, seed {SEED}") print() hdr = (f"{'j':>3s} {'x':>9s} {'D/x real':>9s} {'ctl mean':>9s} {'ctl sd':>8s} " f"{'z(D)':>6s} {'gap':>7s} {'M(D)':>10s} {'P(1,e1)/x':>9s} {'ctlP sd':>8s} " f"{'gapP':>9s} {'M(P)':>10s} {'s':>6s}") rows = [] print(hdr) print('-' * len(hdr)) for j in js: t0 = time.time() x = 2 ** j lam, mu = sieve(x + 2) e1 = int(x ** (0.5 + EPS)) lamp = lam[:x + 1] logm = np.zeros(x + 1, dtype=np.float64) logm[1:] = np.log(np.arange(1, x + 1)) # ---- per-e plan: the SUPPORT and the coprimality filter are draw-independent terms = [] e1_list = [] # BOUNDARY CONVENTION, taken from the corpus's own validator (and reproduced digit-for-digit # by work/B-census.py): the e-range is [1, e1), NOT [1, e1]. G1 below pins it. for e in range(1, max(e1, 2)): if not (e & 1) or mu[e] == 0: continue e1_list.append(e) lo = x // (2 * e) + 1 hi = x // e if hi < lo: continue m = np.arange(lo, hi + 1) m = m[mu[m] != 0] if m.size == 0: continue if e > 1: m = m[np.gcd(m, e) == 1] if m.size == 0: continue base = e * (m - 1) + (e - 2) # = e*m - 2 L = lamp[base] nz = L != 0 if not nz.any(): continue terms.append((e, m[nz], L[nz], logm[m[nz]])) n = np.arange(x // 2 + 1, x + 1) phi = {e: phi_of(e) for e in e1_list} loge = {e: np.log(e) for e in e1_list} plan = dict(lamp=lamp, logm=logm, terms=terms, e1_list=e1_list, phi=phi, loge=loge, n=n, x=x) # ---- G2: the control has exactly mu's support supp_mu = int(np.count_nonzero(mu)) rng = np.random.default_rng(SEED + j) def control_signs(): c = np.zeros(x + 3, dtype=np.int8) idx = np.nonzero(mu)[0] c[idx] = rng.choice(np.array([-1, 1], dtype=np.int8), size=idx.size) assert int(np.count_nonzero(c)) == supp_mu, 'G2 FAILED: control support != supp(mu)' return c real = evaluate(x, mu, plan) ctl = [] ctlP = [] for _ in range(draws): r = evaluate(x, control_signs(), plan) ctl.append(r['D'] / x) ctlP.append(r['P'] / x) ctl = np.array(ctl) ctlP = np.array(ctlP) # ---- G1 PROVENANCE: the corpus's own printed line at j=16 if j == 16: if abs(real['D'] / x - (-0.0231)) > 5e-5: raise SystemExit(f"G1 FAILED: D^(e1)/x = {real['D']/x:.6f}, corpus prints -0.0231") print(f" G1 PASS: D^(e1)/x = {real['D']/x:.6f} reproduces the corpus's -0.0231") # ---- G3 NEGATIVE CONTROL: the signs must move the statistic if abs(real['D'] / x - ctl.mean()) < 1e-12: raise SystemExit('G3 FAILED: the control does not move the statistic') sd = float(ctl.std(ddof=1)) dmin, dmax = float(ctl.min()), float(ctl.max()) # The control is HEAVY-TAILED (sigma moves by 45% between seeds at j=24), so sd alone is not # a safe ceiling. Report the two robust companions it needs: the mean absolute value, and # the largest excursion seen. M_sd is the primary read; M_abs is the conservative one. absmean = float(np.mean(np.abs(ctl))) maxabs = float(np.max(np.abs(ctl))) z = (real['D'] / x - float(ctl.mean())) / sd if sd > 0 else float('nan') gap = THRESH_CENTERED + real['D'] / x # requirement D/x >= -0.16 M = gap / sd if sd > 0 else float('inf') sdP = float(ctlP.std(ddof=1)) gapP = THRESH_INVARIANT + real['P'] / x # requirement P/x >= -0.655162 MP = gapP / sdP if sdP > 0 else float('inf') Mabs = gap / absmean print(f"{j:>3d} {x:>9d} {real['D']/x:>9.4f} {ctl.mean():>9.4f} {sd:>8.4f} " f"{z:>6.2f} {gap:>7.4f} {M:>10.1f} {real['P']/x:>9.4f} {sdP:>8.4f} " f"{gapP:>9.4f} {MP:>10.1f} {time.time()-t0:>6.1f}") print(f" control D/x: mean|.| {absmean:.4f} max|.| {maxabs:.4f} min {dmin:+.4f} " f"max {dmax:+.4f} ({draws} draws, seed {SEED+j}) -> M_abs(D) = {Mabs:.1f}") rows.append((j, x, real['D'] / x, sd, M, real['P'] / x, sdP, MP)) out[str(j)] = dict(x=x, D_over_x=real['D'] / x, ctl_mean=float(ctl.mean()), sigma=sd, zD=z, gap=gap, M_centered=M, P_over_x=real['P'] / x, sigma_P=sdP, gapP=gapP, M_invariant=MP, draws=draws, seed=SEED + j, supp_mu=supp_mu, e1=e1, ctl_min=dmin, ctl_max=dmax, ctl_absmean=absmean, ctl_maxabs=maxabs, M_centered_abs=Mabs) sys.stdout.flush() with open('artifacts/decision-margin-2555.json', 'w', encoding='utf-8') as fh: json.dump({'thresholds': {'centered': THRESH_CENTERED, 'invariant': THRESH_INVARIANT}, 'C2': C2, 'U': U, 'V': V, 'EPSP': EPSP, 'rows': out}, fh, indent=1, sort_keys=True) print() # ---- THE SCALING: decision margin against log x. The whole question "is extending a census # worth anything" is whether M grows with x at all, and how fast. if len(rows) >= 3: LX = np.log(np.array([np.log(r[1]) for r in rows])) for nm, idx in (('centered', 4), ('invariant', 7)): MV = np.log(np.array([r[idx] for r in rows])) sl = float(np.polyfit(LX, MV, 1)[0]) print(f" scaling fit: log M({nm}) = {sl:.2f} * log log x + const " f" => M ~ (log x)^{sl:.2f}") for tgt in (10.0, 100.0): lx = float(np.exp(np.log(np.log(rows[-1][1])) + (np.log(tgt) - np.log(rows[-1][idx])) / sl)) print(f" M({nm}) = {tgt:.0f} at log x = {lx:.1f}, i.e. x ~ 10^{lx/np.log(10):.1f}" if sl > 0 else f" M({nm}) does not grow with x") print() print(f"CENTERED consumer: requirement D^(e1)/x >= -{THRESH_CENTERED}. " f"M = (0.16 + D/x) / sigma_control. M>=3 == the census could have refuted a violation " f"as large as the observed slack.") print("F1 tested by |z|; F2 by M; F3 by comparing sigma_control to the 44x gauge spread.") if __name__ == '__main__': main()