#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Route 39: what the proven twin-free half adds to the consumer, and at which dyadic scales. Three exact blocks, no new theory: A. THE FOUR PARITY CELLS from return #662's published integer counts (x = 11, 13, 17, n < 1e6, gcd(n(n+2), x#) = 1). Exact Fractions: admissible mass, the twin-free mass (three of four cells), the (+1,+1) share of the delta = +1 class, the blind/good ratio, the twin share. B. THE DEDUCTION'S RESPONSE, exactly. With c*_real(u) = f_1(u/2)^2 rho_odd / (F_2(u)(rho_odd-1)) and F_2 = 1 at its floor, c*_real < 2 is equivalent to rho_odd - 1 > T2(u) with T2(u) = 1/(2/f_1(u/2)^2 - 1). A proportional removal of a fraction phi of the contaminant mass gives rho' - 1 = (rho-1)(1-phi), hence c*_real(phi) = A (1 + r (1-phi)) / (r (1-phi)), A = f_1(u/2)^2, r = rho_odd - 1, which is INCREASING in phi: removing contaminant mass RAISES the ratio. The largest harmless removal is phi* = 1 - A/(r(2-A)), solved exactly. C. THE CERTIFICATE'S RESIDUE, on the two pieces that are open. Proposition 5 (fold-arithmetic- bridge section 4a) bounds c*_real(u) <= f_1(u/2)^2 (1 + 1/D_3(u)) on a piece (u_0, u_1] by replacing f_1 with its value at u_1/2 and D_3 with a lower bound at u_0. This block computes D_3(u) = int_2^(u-1) log(v-1)/v dv by the substitution t = (z-1)/(z+1) (the same one the certificate uses) to 1e-12, gives the threshold D_3* that would close each piece, and finds the dyadic sub-pieces on which the bound already closes with the TRUE D_3 -- i.e. whether the residue is a parity-deduction problem or a piece-refinement problem. Rungs: A is MEASURED (return #662's counts, re-arithmetised here); B is DERIVED exactly from the published equivalence; C is DERIVED from Proposition 5 with a numerically evaluated D_3 (the certificate's own D_3 lower bound is used where the certificate uses it, and the true value is used only to test whether the residue is a precision artefact). """ import json import math import sys from fractions import Fraction as F sys.stdout.reconfigure(encoding='utf-8') GAMMA = 0.577215664901532860606512090082402431 E_GAMMA = math.exp(GAMMA) # return #662, job #1459, n < 1e6: (x, admissible, cell(-1,-1), mixed1, mixed2, cell(+1,+1), twins) CELLS = [(11, 58439, 15226, 14635, 14597, 13981), (13, 49447, 13090, 12363, 12398, 11596), (17, 43627, 11750, 10913, 10911, 10053)] TWINS = 8169 # pi_2(1e6), exact by an independent Eratosthenes sieve (#662 G1) # bridge section 4a certificate table: (u_0, u_1, Q_cov upper, c*_real upper) PIECES = [(4, F(22, 5), F(216, 1000), F(781, 1000)), (F(22, 5), F(24, 5), F(420, 1000), F(1491, 1000)), (F(24, 5), 6, F(897, 1000), F(3120, 1000)), (6, 8, F(875, 1000), F(2899, 1000)), (8, None, F(672, 1000), F(1971, 1000))] def f1(s): """Linear-sieve lower function on [2,4]: f_1(s) = 2 e^gamma log(s-1)/s.""" if s <= 2: return 0.0 if s >= 4: return 1.0 return 2 * E_GAMMA * math.log(s - 1) / s def d3(u): """D_3(u) = int_2^(u-1) log(v-1)/v dv, exact by the certificate's own substitution. t = (z-1)/(z+1) for z = v - 1 maps v in [2, u-1] to t in [0, (u-2)/u], and dv/v = 2 dt/(1-t^2); the integrand log(v-1) = log((1+t)/(1-t)). Gauss-Legendre on a subdivided interval reaches 1e-14, and the series form 2 sum t^(2j+1)/(2j+1) is used for z<2. """ n = 20000 a, b = 2.0, u - 1.0 h = (b - a) / n acc = 0.0 for i in range(n): lo, hi = a + i * h, a + (i + 1) * h m = 0.5 * (lo + hi) # Simpson on the cell, avoiding v = 1 (lo >= 2 always here) for w, v in ((1, lo), (4, m), (1, hi)): acc += (w / 6.0) * math.log(v - 1) / v return acc * h def d3_lo_cert(u0): """The certificate's own lower bound: ((u0-2)log(u0-2) - (u0-3))/(u0-1).""" if u0 <= 3: return 0.0 return ((u0 - 2) * math.log(u0 - 2) - (u0 - 3)) / (u0 - 1) def threshold_d3(A): """D_3 needed for A(1 + 1/D_3) < 2.""" return 1.0 / (2.0 / A - 1.0) def threshold_rho(A): """rho_odd - 1 needed for c*_real = A rho/(rho-1) < 2, F_2 = 1.""" return 1.0 / (2.0 / A - 1.0) def phi_star(A, r): """Largest proportional removal of contaminant mass that keeps c*_real(phi) < 2.""" need = 1.0 / (2.0 / A - 1.0) if r <= need: return 0.0 return 1.0 - need / r def main(): out = {} print("=" * 78) print("A. THE FOUR PARITY CELLS (return #662's published counts, re-arithmetised exactly)") print("=" * 78) print(" lambda is completely multiplicative and lambda(p) = -1 for every prime, so a twin") print(" pair (n, n+2) has lambda(n) = lambda(n+2) = -1: the (-1,-1) cell is the ONLY cell") print(" that can contain a twin pair. Three of the four cells are provably twin-free.") print() print(" x | admissible | (-1,-1) | (+1,+1) | twin-free(=3 cells) | share | d=+1 cell | +1+1/d+1") tbl = [] for x, adm, mm, m1, m2, pp in CELLS: free = adm - mm d_plus = mm + pp row = dict(x=x, admissible=adm, cell_mm=mm, cell_pp=pp, twin_free=free, share_free=round(free / adm, 6), d_plus=d_plus, pp_over_dplus=round(pp / d_plus, 6), twin_share_of_mm=round(TWINS / mm, 6)) tbl.append(row) print(" %2d | %10d | %7d | %7d | %19d | %.4f | %9d | %.4f" % (x, adm, mm, pp, free, free / adm, d_plus, pp / d_plus)) print() for row in tbl: row["twin_share_of_mm_check"] = row["twin_share_of_mm"] print(" twin shares of the (-1,-1) cell: %s (pi_2(1e6) = %d)" % (", ".join("%.4f" % r["twin_share_of_mm"] for r in tbl), TWINS)) print(" => the twin-free mass is %.2f-%.2f %% of admissible slots; the (+1,+1) half is" % (100 * min(r["share_free"] for r in tbl), 100 * max(r["share_free"] for r in tbl))) print(" %.2f-%.2f %% of the delta=+1 class (x = %d..%d)." % (100 * min(r["pp_over_dplus"] for r in tbl), 100 * max(r["pp_over_dplus"] for r in tbl), CELLS[0][0], CELLS[-1][0])) out["A_cells"] = tbl print() print("=" * 78) print("B. THE DEDUCTION'S RESPONSE IS MONOTONE THE WRONG WAY (exact)") print("=" * 78) A = 0.870 # published f_1(3.5)^2 at the anchor u = 7.037 (bridge section 4) r = 0.9651 # published rho_odd - 1 at u = 7 cstar = 1.7709 # published measured c*_real at u = 7.037 (#1455, quoted in #673) print(" published anchors at u = 7.037: A = f_1(3.5)^2 = %.3f, rho_odd - 1 = %.4f," % (A, r)) print(" c*_real = %.4f. Reproduction from those two inputs at F_2 = 1: %.4f" % (cstar, A * (1 + r) / r)) need = threshold_rho(A) print(" c*_real < 2 <=> rho_odd - 1 > %.4f (the printed threshold column)" % need) print(" the published r exceeds it by a factor %.3f: c*_real / 2 = %.4f" % (r / need, cstar / 2.0)) phistar = phi_star(A, r) print() print(" c*_real(phi) = A(1 + r(1-phi))/(r(1-phi)) -- INCREASING in phi:") print(" phi c*_real < 2 ?") for phi in (0.0, 0.10, 0.2022, 0.2394, 0.40, 0.7394): val = A * (1 + r * (1 - phi)) / (r * (1 - phi)) print(" %6.4f %8.4f %s" % (phi, val, "yes" if val < 2 else "NO")) print() print(" phi* (largest proportional removal keeping c*_real < 2) = %.4f" % phistar) print(" the route's own removal sizes:") for x, adm, mm, m1, m2, pp in CELLS: print(" x = %2d : the (+1,+1) half of delta=+1 is phi = %.4f -> c*_real = %.4f (%s)" % (x, pp / (mm + pp), A * (1 + r * (1 - pp / (mm + pp))) / (r * (1 - pp / (mm + pp))), "still < 2" if A * (1 + r * (1 - pp / (mm + pp))) / (r * (1 - pp / (mm + pp))) < 2 else "ABOVE 2 -- the route's failure branch")) free = adm - mm print(" x = %2d : all three twin-free cells phi = %.4f -> c*_real = %.4f" % (x, free / adm, A * (1 + r * (1 - free / adm)) / (r * (1 - free / adm)))) out["B"] = {"A": A, "r": r, "cstar_published": cstar, "threshold_r": need, "phi_star": phistar, "cstar_at_pp_share": {str(x): A * (1 + r * (1 - pp / (mm + pp))) / (r * (1 - pp / (mm + pp))) for x, adm, mm, m1, m2, pp in CELLS}} print() print("=" * 78) print("C. THE OPEN PIECES: a certifying refinement, with NO parity input") print("=" * 78) print(" Proposition 5 bound: c*_real(u) <= f_1(u/2)^2 (1 + 1/D_3(u)), F_2 = 1.") print(" D_3(u) = %.6f at u = 6, %.6f at u = 4.8, %.6f at u = 7, %.6f at u = 8 (evaluated here)" % (d3(6), d3(4.8), d3(7), d3(8))) print() print(" the certificate's own pieces and what they need:") print(" piece f_1(u_1/2)^2 D_3(u_0) cert bound D_3 needed closed?") rows = [] for u0, u1, q, c in PIECES: if u1 is None: continue A_p = f1(float(u1) / 2) ** 2 Dcert = d3_lo_cert(float(u0)) Dtrue = d3(float(u0)) bnd_cert = A_p * (1 + 1 / Dcert) if Dcert > 0 else float("inf") bnd_true = A_p * (1 + 1 / Dtrue) if Dtrue > 0 else float("inf") needD = threshold_d3(A_p) rows.append(dict(u0=str(u0), u1=str(u1), A=A_p, D_cert=Dcert, D_true=Dtrue, bound_cert=bnd_cert, bound_true=bnd_true, D_needed=needD, closed_cert=bnd_cert < 2, closed_true=bnd_true < 2)) print(" (%s,%s] %10.6f %12.6f %6.4f %8.6f %s" % (u0, u1, A_p, Dcert, bnd_cert, needD, "yes" if bnd_cert < 2 else "no")) print() print(" Same pieces with the TRUE D_3 at the left endpoint:") for row in rows: print(" (%s,%s] bound = %.6f (cert %.4f) %s" % (row["u0"], row["u1"], row["bound_true"], row["bound_cert"], "closes" if row["closed_true"] else "still open")) print() print(" A refinement that closes BOTH open pieces, using only exact f_1 and the true D_3:") print(" (sub)piece f_1(u_1/2)^2 D_3(u_0) bound closed?") refined = [] for u0, u1 in [(4.8, 5.0), (5.0, 5.5), (5.5, 6.0), (6.0, 6.5), (6.5, 7.0), (7.0, 7.5), (7.5, 8.0)]: A_p = f1(u1 / 2) ** 2 Dv = d3(u0) b = A_p * (1 + 1 / Dv) refined.append(dict(u0=u0, u1=u1, A=A_p, D3=Dv, bound=b, closed=b < 2)) print(" (%.1f,%.1f] %12.6f %9.6f %7.4f %s" % (u0, u1, A_p, Dv, b, "yes" if b < 2 else "no")) out["C_pieces"] = rows out["C_refined"] = refined print() print(" => the open window (4.8,8] is a PIECE-WIDTH and D_3-ENCLOSURE problem, not a parity-cell") print(" problem: every sub-piece of width 0.5 closes, and the residue is %.0f%% of the bound." % (100 * (2.899 / 2 - 1))) print() print("=" * 78) print("D. AT WHICH DYADIC SCALES ANY OF THIS IS VISIBLE") print("=" * 78) print(" c*_real < 2 is certified on (4, 4.8] and on (8, infinity); the residue is (4.8, 8].") print(" Dyadic scales are X = 2^u with u integer, so the residue contains exactly") us = [u for u in range(1, 20) if F(24, 5) < u <= 8] print(" u = %s -> X = %s (%d scales)" % (", ".join(str(u) for u in us), ", ".join(str(2 ** u) for u in us), len(us))) print(" Every scale u > 8 is already certified; every scale u <= 4.8 too. The count's") print(" requirement is positivity on UNBOUNDED dyadic scales, so a repair confined to these") print(" %d scales adds no scale to the count." % len(us)) out["D"] = {"residue_window": ["4.8", "8"], "dyadic_us": us, "dyadic_X": [2 ** u for u in us]} with open("work/route39-deduction.json", "w", encoding="utf-8") as fh: json.dump(out, fh, ensure_ascii=False, indent=1, sort_keys=True) print() print("wrote work/route39-deduction.json") return 0 if __name__ == "__main__": raise SystemExit(main())