#!/usr/bin/env python3 """job 2562 (Leads: new route) -- the actual signed Type II plus band sum B, measured exactly. OBJECT. research/fixed-endpoint-discrepancy.md reduces the twin consumer to D^(e_1)(x) = sum_{eU}gamma_V(b) + 1_{e_0<=eV} mu(k), e_0=floor(x^(1/2-eps')), e_1=floor(x^(1/2+eps')), U=V=3 (the note's validator choice). The OPEN input is (H_B): B >= -(C_2-c_0)x + o(x), fixed c_0>0, on an unbounded set of dyadic scales; the D-margin is B + 2 C_2 M >= -4x/25 + o(x) with M = sum_{n in J} Lambda(n-2) mu(n). WHY THIS RUN. The note exhibits B and never measures it -- "The decompositions inspected here leave the exact B in (2.9) unestimated" -- and the only finite figure on record is T_I^low/x = 4.49 at x=2^16. So the sign, the size, and the distance between the proved majorant O(x log^5 x) and the actual object are all unread. A one-sided bound with a FIXED constant is exactly the shape whose finite readings say how much room a signed method must find. EVERY QUANTITY IS COMPUTED DEFINITIONALLY, IN TWO INDEPENDENT ORDERINGS, AND THE NOTE'S OWN IDENTITIES ARE THE CONTROLS: C1 P_low(def) = T_I^low(2.6) + T_II^low(2.7) [the split (2.5)] C2 B(2.9) = T_II^low(2.7) + P_band(modulus-e arrangement) [B's two definitions] C3 P_band(flip, (2.1)) = P_band(modulus-e arrangement) C4 D^(e_1) = P_low + P_band - (Q_low + Q_band) [definitional consistency] C5 (2.2) reading: Q_low / (-2 C_2 M) -> 1 [the density projection] C6 DELETION CONTROLS: U=V=5 instead of 3, and dropping (ab,e)=1, must each MOVE B. NOT U=V=4: both a and k enter only through mu, so a non-squarefree cutoff moves nothing (the first draft of this control reported 'unchanged' and that is a true reading about the coefficient's support, not a control failure -- recorded, then sharpened to 5). C7 the exact S(x) = sum_{n in J} Lambda(n) Lambda(n-2) and the closure residual R := S - (C_2 x + T_I^low + B - 2 C_2 M - Q_low - Q_band), whose measured size is the finite reading of (12)'s asymptotic density projection. R is EXPECTED to be as large as O(x/log^A x) here: every term of (12) is asymptotic at these cutoffs. PRE-REGISTERED, BEFORE THE RUN. FALSIFIER for this instrument: any of C1-C4 fails at any scale, or a C6 control leaves the value unchanged. Then the numbers are not readings of the note's B and the run exits 2 with the witness printed. CLAIM THIS RUN CANNOT TEST: (H_B) itself. A finite scale says nothing about an asymptotic one-sided bound on an unbounded set of scales, and no number here is evidence for or against the twin-prime target. Claimed at rung MEASURED: the exact B of (2.9) at the stated cutoffs, its sign and size, the split it decomposes into, and the gap to the proved majorant. THE CUTOFFS ARE THE VALIDATOR'S, NOT THE ASYMPTOTIC ONES: x^(eps/3) < 3 for every reachable x. EXIT CODES: 0 controls pass, readings recorded; 2 a control FAILED (witness printed); 3 could not look (a dependency did not resolve). Never 0 for an unobserved control. """ import argparse import json import math import os import sys import time EPS = 1.0 / 60.0 U = V = 3 C2 = 0.660161815846869 # PROD_{p>2}(1 - 1/(p-1)^2), this project's C_2 (2 C_2 = 1.32032363) SCALES = [10, 12, 14, 16, 18] def sieve(n): spf = list(range(n + 1)) i = 2 while i * i <= n: if spf[i] == i: for j in range(i * i, n + 1, i): if spf[j] == j: spf[j] = i i += 1 mu = [1] * (n + 1) lam = [0.0] * (n + 1) for m in range(2, n + 1): p = spf[m] m2 = m // p mu[m] = 0 if m2 % p == 0 else -mu[m2] # von Mangoldt, PRIME POWERS ONLY. The first draft wrote log p to every multiple of p # (lam[m] = log rad(m)), which is not Lambda; the C7 closure residual printed it and the # C0 gate below now makes that class of defect fail loudly instead of silently. for p in range(2, n + 1): if spf[p] == p: lg = math.log(p) pk = p while pk <= n: lam[pk] = lg pk *= p mu[0] = 0 return spf, mu, lam def divisors(n, spf): divs = [1] m = n while m > 1: p = spf[m] c = 0 while m % p == 0: m //= p c += 1 divs = [d * p ** k for d in divs for k in range(c + 1)] return divs def tau4(n, spf): t, m = 1, n while m > 1: p = spf[m] c = 0 while m % p == 0: m //= p c += 1 t *= (c + 1) * (c + 2) * (c + 3) // 6 return t def phi_from_spf(n, spf): r, m = n, n while m > 1: p = spf[m] while m % p == 0: m //= p r -= r // p return r def c_of_r(r, spf, mu, U, V): """c(r) = sum_{dk=r, d<=U, k<=V} mu(d)mu(k), supported on r<=UV.""" if r > U * V: return 0 return sum(mu[d] * mu[r // d] for d in range(1, U + 1) if r % d == 0 and r // d <= V) def measure(x, spf, mu, lam, U, V, coprime=True): e0 = int(math.floor(x ** (0.5 - EPS))) e1 = int(math.floor(x ** (0.5 + EPS))) lo, hi = x // 2 + 1, x logx = math.log(x) cs = {r: c_of_r(r, spf, mu, U, V) for r in range(1, U * V + 1)} P_low = P_band = B29 = TII27 = TI26 = Pband_mod = 0.0 M = F1 = 0.0 maj = 0.0 min_m_low = None for n in range(lo, hi + 1): fn = lam[n - 2] * mu[n] M += fn F1 += fn * math.log(n) for e in range(1, e1): if e % 2 == 0 or mu[e] == 0: continue mlo, mhi = x // (2 * e) + 1, x // e in_band = e >= e0 for m in range(mlo, mhi + 1): n = e * m if n < lo or n > hi: continue f = mu[e] * mu[e * m] La = lam[n - 2] if e < e0: if min_m_low is None or m < min_m_low: min_m_low = m # definitional P_low / P_band: mu(e) * f(n) with f = Lambda(n-2) mu(n), times log(e/n) if f and La: pm = f * La * math.log(e / n) if in_band: P_band += pm else: P_low += pm if coprime and math.gcd(m, e) != 1: continue dm = divisors(m, spf) if in_band: # P_band in the modulus-e arrangement: -sum_e sum_m mu(m) log m Lambda(em-2) if La: Pband_mod -= mu[m] * math.log(m) * La # (2.9) band term: b=1, a=m B29 -= La * mu[m] * math.log(m) else: for a in dm: if a <= U: continue b = m // a if b <= V: continue g = sum(mu[k] for k in dm if k > V and b % k == 0) if g: TII27 -= mu[a] * g * math.log(m) * La B29 -= La * mu[a] * g * math.log(m) for r in range(1, U * V + 1): cr = cs[r] if cr and m % r == 0: TI26 += cr * math.log(m) * La # Q_R = sum_{e in R} (mu(e)/phi(e)) (M log e - F_1); Q_low+Q_band = P - D exactly Q_low = Q_band = 0.0 for e in range(1, e1): if e % 2 == 0 or mu[e] == 0: continue t = (mu[e] / phi_from_spf(e, spf)) * (M * math.log(e) - F1) if e >= e0: Q_band += t else: Q_low += t for n in range(lo, hi + 1): if lam[n - 2]: maj += lam[n - 2] * tau4(n - 2, spf) # the note's majorant, argument n-2 as printed D = P_low + P_band - (Q_low + Q_band) B = B29 S = sum(lam[n] * lam[n - 2] for n in range(lo, hi + 1)) R = S - (C2 * x + TI26 + B - 2 * C2 * M - Q_low - Q_band) return { "x": x, "e0": e0, "e1": e1, "logx": logx, "min_m_low": min_m_low, "S": S, "S_over_x": S / x, "S_over_C2x": S / (C2 * x), "C7_closure_residual": R, "C7_residual_over_x": R / x, "T_I_over_x": TI26 / x, "T_II_over_x": TII27 / x, "P_band_over_x": Pband_mod / x, "B_over_xlog2": B / (x * logx ** 2), "Q_low_over_x": Q_low / x, "Q_band_over_x": Q_band / x, "P_low_def": P_low, "P_band_def": P_band, "Pband_modarr": Pband_mod, "T_I_26": TI26, "T_II_27": TII27, "B_29": B, "split_sum": TI26 + TII27, "C1_Plow_eq_TI_plus_TII": abs(P_low - (TI26 + TII27)), "C2_B_eq_TII_plus_Pband": abs(B - (TII27 + Pband_mod)), "C3_Pband_two_arrangements": abs(P_band - Pband_mod), "C4_definitional_D": D, "C4_residual": abs(D - (P_low + P_band - (Q_low + Q_band))), "Q_low": Q_low, "Q_band": Q_band, "M": M, "F1": F1, "C5_Qlow_over_minus2C2M": (Q_low / (-2 * C2 * M)) if M else None, "maj_TII_over_x": (logx * maj) / x, "maj_TII_over_absB": (logx * maj / abs(B)) if B else None, "B_over_x": B / x, "B_over_xlog5": B / (x * logx ** 5), "M_over_x": M / x, "D_over_x": D / x, "D_margin_over_x": (B + 2 * C2 * M) / x, "threshold_direct_over_x": -(C2 - 0.005), "threshold_Dmargin_over_x": -4.0 / 25.0, "S_over_C2x_target": 1.0, } def main(): ap = argparse.ArgumentParser() here = os.path.dirname(os.path.abspath(__file__)) ap.add_argument("--out", default=os.path.join(here, "bsum-measure.json")) ap.add_argument("--scales", default=",".join(str(s) for s in SCALES)) a = ap.parse_args() scales = [int(s) for s in a.scales.split(",") if s.strip()] t0 = time.time() spf, mu, lam = sieve(2 ** max(scales) + 4) # ---- C0: the sieve itself, before any number of the note's is read off it ---------- X = 2 ** max(scales) psi = sum(lam[m] for m in range(1, X + 1)) fixtures = {1: 0.0, 4: math.log(2), 6: 0.0, 9: math.log(3), 8: math.log(2), 49: math.log(7), 72: 0.0, 97: math.log(97), 1024: math.log(2), 1000: 0.0, # 1000=2^3*5^3 is NOT a prime power 512: math.log(2), 961: math.log(31)} bad = {m: lam[m] for m, want in fixtures.items() if abs(lam[m] - want) > 1e-12} c0 = abs(psi - X) / X < 0.05 and not bad print(json.dumps({"C0_psi_over_x": psi / X, "C0_fixture_failures": bad, "C0_pass": c0}, indent=1), file=sys.stderr) if not c0: print(json.dumps({"ok": False, "failed": "C0 sieve gate", "psi_over_x": psi / X, "fixture_failures": bad}, indent=1)) return 2 rows, controls, failures = [], [], [] for j in scales: x = 2 ** j r = measure(x, spf, mu, lam, U, V, True) r["j"] = j r["C6_U5_delta"] = measure(x, spf, mu, lam, 5, 5, True)["B_29"] - r["B_29"] r["C6_no_coprime_delta"] = measure(x, spf, mu, lam, U, V, False)["B_29"] - r["B_29"] tol = 1e-6 * max(1.0, abs(r["B_29"])) checks = [("C1", r["C1_Plow_eq_TI_plus_TII"], tol), ("C2", r["C2_B_eq_TII_plus_Pband"], tol), ("C3", r["C3_Pband_two_arrangements"], tol), ("C4", r["C4_residual"], tol)] for name, val, t in checks: if not (val <= t): failures.append({"j": j, "control": name, "witness": val}) for name in ("C6_U5_delta", "C6_no_coprime_delta"): if r[name] == 0.0: failures.append({"j": j, "control": name, "witness": "value unchanged"}) controls.append({"j": j, **{k: r[k] for k in ("C1_Plow_eq_TI_plus_TII", "C2_B_eq_TII_plus_Pband", "C3_Pband_two_arrangements", "C4_residual", "C5_Qlow_over_minus2C2M", "min_m_low", "e0", "e1")}}) rows.append(r) print("j=%2d e0=%d e1=%d | B/x=%+.6f B/(x log^5x)=%+.7f | M/x=%+.6f | " "maj/|B|=%.4g | C1 %.2g C2 %.2g C3 %.2g C4 %.2g" % (j, r["e0"], r["e1"], r["B_over_x"], r["B_over_xlog5"], r["M_over_x"], r["maj_TII_over_absB"] or float("nan"), r["C1_Plow_eq_TI_plus_TII"], r["C2_B_eq_TII_plus_Pband"], r["C3_Pband_two_arrangements"], r["C4_residual"]), file=sys.stderr) # ---- C8: reproduce the note's own recorded finite number, in a different codebase ------- # fixed-endpoint-discrepancy.md section 5 records "T_I^low/x = 4.49 at x=2^16 with U=V=3" # from its own validator (another language). Agreement checks that this instrument's T_I^low # is the note's object and not a relabelled neighbour. c8 = None for r in rows: if r["j"] == 16: c8 = {"recorded": 4.49, "measured": r["T_I_over_x"], "rel_gap": abs(r["T_I_over_x"] - 4.49) / 4.49} if c8 is not None and c8["rel_gap"] > 0.02: failures.append({"j": 16, "control": "C8_corpus_T_I_reading", "witness": c8}) # local exponent of |B| between consecutive scales, against the x log^2 x prediction for k in range(1, len(rows)): b0, b1 = rows[k - 1], rows[k] # consecutive scales, 2 doublings apart if b0["B_29"] and b1["B_29"]: rows[k]["local_exponent_per_doubling"] = math.log( abs(b1["B_29"]) / abs(b0["B_29"])) / (2 * math.log(2)) rows[k]["predicted_1_plus_2_over_logx"] = 1 + 2 / b1["logx"] art = { "tool": "job2562/bsum-measure.py", "version": "1.0.0", "C8_corpus_reproduction": c8, "object": "B = T_II^low + P_band of research/fixed-endpoint-discrepancy.md (2.8)-(2.9)", "parameters": {"eps": EPS, "U": U, "V": V, "C_2": C2, "scales": scales, "cutoffs_note": "U=V=3 is the note's validator choice; x^(eps/3) < 3 for " "every reachable x, so these are NOT the asymptotic cutoffs"}, "rung": "measured -- exact finite evaluation of the stated sums at the stated cutoffs", "not_claimed": ["(H_B) or any asymptotic one-sided bound (a finite scale cannot test one)", "any bearing on twin-prime infinitude", "that B(x)/x here predicts the asymptotic size of B"], "controls": controls, "failures": failures, "rows": rows, "elapsed_s": round(time.time() - t0, 3), } with open(a.out, "w", encoding="utf-8") as fh: json.dump(art, fh, indent=1, sort_keys=True) print(json.dumps({"ok": not failures, "artifact": a.out, "failures": failures, "elapsed_s": art["elapsed_s"]}, indent=1)) return 2 if failures else 0 if __name__ == "__main__": sys.exit(main())