#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Job 4746 (explore/discovery) — a new finite statistic with a pre-registered falsifier. QUESTION -------- The repaired dyadic identity (research/moving-cutoff-parity.md eq. (12)) is S(x) = C2*x - 2*C2*M(x) + D_y(x) + O_A(x/log^A x), with y=ceil(x^(12/25)), Q=floor(x/y), M(x)=sum_{n in (x/2,x]} Lambda(n-2)mu(n) and the centered shifted-prime discrepancy D_y(x) = sum_{e<=Q, e odd} mu(e) * INT_{(a_e,x]} log(e/t) d Delta_e(t), Delta_e(t) = sum_{x/2= -4x/25 + o(x) on unbounded dyadic scales. The retained finite census to x=2^38 measured D_y but is dominated by the classical term's slow convergence (docs/README.md Status); the corpus itself says "further compute needs a new statistic or falsifier". NEW STATISTIC (this file, to be PRE-REGISTERED before any run) -------------------------------------------------------------- Write D_y = sum_n f(n) K(n), a linear functional of f, with the *arithmetic* kernel K(n) = sum_{e odd<=Q, a_e spf[i] or i * p > n: break ip = i * p spf[ip] = p if p == spf[i]: mu[ip] = 0 phi[ip] = phi[i] * p else: mu[ip] = -mu[i] phi[ip] = phi[i] * (p - 1) if i >= 2 and phi[i] == i: phi[i] = i - 1 # fix phi[1] phi[1] = 1 return mu, phi, spf def von_mangoldt(m, spf): """Lambda(m) for 2<=m<=len(spf)-1; 0 otherwise.""" if m < 2 or m >= len(spf): return 0.0 p = spf[m] q = m while q % p == 0: q //= p return math.log(p) if q == 1 else 0.0 def one_scale(x, mu, phi, spf): """Return (D_y, sigma) for this dyadic scale x.""" y = int(math.ceil(x ** (12.0 / 25.0))) Q = x // y lo = x // 2 + 1 f = [0.0] * (x + 1) # f[n] for n in [lo,x] for n in range(lo, x + 1): f[n] = von_mangoldt(n - 2, spf) * mu[n] K = [0.0] * (x + 1) for e in range(1, Q + 1, 2): a = max(x // 2, e * y) # n > a_e if a >= x: continue me = mu[e] if me == 0: continue invphi = 1.0 / phi[e] for n in range(max(a + 1, lo), x + 1): div = 1.0 if (n % e == 0) else 0.0 K[n] += me * (div - invphi) * math.log(e / n) Dy = 0.0 ss = 0.0 for n in range(lo, x + 1): g = f[n] * K[n] Dy += g ss += g * g return Dy, math.sqrt(ss) def main(): t0 = time.time() xmax = max(PREREG_SCALES) mu, phi, spf = sieve(xmax) rng = random.Random(NULL_SEED) print("# pre-registered scales:", PREREG_SCALES) print("# x D_y d=D_y/x sigma z=d/sigma nullmean nullsd nullmin") rows = [] for x in PREREG_SCALES: Dy, sig = one_scale(x, mu, phi, spf) d = Dy / x # null sd of d is sigma/x; z is scale-free z = (d * x) / sig if sig > 0 else float("nan") # empirical random-sign null for d (should match sigma/x) nd = [] # rebuild g list is expensive twice; approximate null with a fresh linear pass f = [0.0] * (x + 1) lo = x // 2 + 1 for n in range(lo, x + 1): f[n] = von_mangoldt(n - 2, spf) * mu[n] # recompute K once more (kept simple; x small) y = int(math.ceil(x ** (12.0 / 25.0))) Q = x // y K = [0.0] * (x + 1) for e in range(1, Q + 1, 2): a = max(x // 2, e * y) me = mu[e] if me == 0 or a >= x: continue invphi = 1.0 / phi[e] for n in range(max(a + 1, lo), x + 1): K[n] += me * ((1.0 if n % e == 0 else 0.0) - invphi) * math.log(e / n) g = [f[n] * K[n] for n in range(lo, x + 1)] for _ in range(NULL_DRAWS): s = 0.0 for v in g: if rng.getrandbits(1): s += v else: s -= v nd.append(s / x) nm = sum(nd) / len(nd) nsd = math.sqrt(sum((v - nm) ** 2 for v in nd) / (len(nd) - 1)) if len(nd) > 1 else 0.0 zemp = (d / nsd) if nsd > 0 else float("nan") rows.append((x, Dy, d, sig, z, nm, nsd, min(nd))) print("%d %.6f %.10f %.6f %+.4f %+.3e %.3e %+.3e z_emp=%+.3f" % (x, Dy, d, sig, z, nm, nsd, min(nd), zemp)) print("# elapsed_s=%.1f" % (time.time() - t0), file=sys.stderr) # timing off the artifact # pre-registered verdicts bad_f1 = [r for r in rows if r[2] < -4.0 / 25.0] sep = [r for r in rows if r[4] <= -2.0] cal = [r for r in rows if abs(r[6] - r[3] / r[0]) > 0.1 * (r[3] / r[0])] if rows else [] print("# F1 boundary reached:", bad_f1) print("# F2 sign separation (z<=-2):", sep) print("# F3 calibration violations:", cal) # pilot-fitted local scaling of the null sd of d=sig/x (NOT an asymptotic law) if len(rows) >= 2: (x1, _, _, _, _, _, n1, _), (x2, _, _, _, _, _, n2, _) = rows[0], rows[-1] if n1 > 0 and n2 > 0: alpha = math.log(n1 / n2) / math.log(x2 / x1) A = n1 * x1 ** alpha print("# pilot local null-sd(d) = %.4f * x^(-%.4f)" % (A, alpha)) for c in (0.05, 0.02, 0.01): xx = (2.0 * A / c) ** (1.0 / alpha) print("# a one-sided drift |d|=%g reaches z=-2 near x=2^%.1f" % (c, math.log(xx, 2))) if __name__ == "__main__": main()