#!/usr/bin/env python3 """Route 29 / job 2032: re-derive the (D1) small-gcd requirement and price it in the l2 normalisation of the fixed-modulus bilinear Kloosterman bounds. Exact rationals only (fractions.Fraction); a small finite injectivity check with integers. No randomness, no clock. stdout is one JSON object; exit 0 iff all checks pass. All exponents are exponents of x unless the name ends in _c (c-units, c = x^(19/20)). """ import json, sys from fractions import Fraction as Fr from math import gcd checks = [] def check(name, got, want): checks.append({"name": name, "got": str(got), "want": str(want), "ok": got == want}) return got # ---- record top sector (structured-dispersion-estimate s.2, (4)) ---- a, b, sig = Fr(14, 25), Fr(1, 2), Fr(1, 20) alpha = a + b - 1 # harmonic band A = MN/x E = b - sig # e ~ x^E, N = EQ check("R1 alpha", alpha, Fr(3, 50)) check("R2 E", E, Fr(9, 20)) cross = a / 2 + 3 * b / 2 - min(sig, alpha) / 4 check("R3 block cross exponent", cross, Fr(407, 400)) check("R4 block deficit", cross - 1, Fr(7, 400)) cauchy = a + sig # first factor of (6): M*Q check("R5 Cauchy factor", cauchy, Fr(61, 100)) budget = 2 - cauchy # sum_q lambda(q) M_q must be below x^budget check("R6 moment budget", budget, Fr(139, 100)) maj = 3 * E + Fr(3, 2) * sig # E^3 Q^(3/2), (9)+(step 6), q < A check("R7 moment majorant", maj, Fr(57, 40)) D = maj - budget check("R8 moment deficit", D, Fr(7, 200)) # ---- 1. what the deficit is a saving over (mass / l1 normalisation) ---- c = sig + 2 * E # c = q e1 e2 on the binding band j = 1 check("N1 modulus c", c, Fr(19, 20)) # per (e1,e2), sum over (h1,h2) of |c_h1 c_h2| * sqrt(c) * ; sum |c_h| <= C, = x^o(1) (Lemma H, q= max(e1,e2) not injective (e1,e2,A)=(3,4,4)", injective(3, 4, 4), False) sup = 2 * alpha # support size A^2 << range x^(51/100) l1_alpha = Fr(0) # ||alpha||_1 = C^2 l2_alpha = -alpha # ||alpha||_2 = (sum |c_h|^2) = C^2/A at |c_h| = C/A; >= ||alpha||_1/|H| always l1_beta = Fr(0) # ||Ghat||_1 = x^o(1) l2_beta = -Nlen / 2 # |Ghat(k)| ~ M/c = 1/N' on |k| <= N', 1/|k| beyond check("S6 support fraction of R-range", sup - Mlen, Fr(-39, 100)) # ---- 3. trivial bounds in the theorem's l2 normalisation ---- triv_sqrt = l2_alpha + l2_beta + (Mlen + Nlen) / 2 + c / 2 # ||a|| ||b|| sqrt(MN c) triv_c = l2_alpha + l2_beta + c # ||a|| ||b|| c check("T1 l2 trivial sqrt(MNc) over mass bound", triv_sqrt - per_pair_mass_bound, Fr(39, 200)) check("T2 l2 trivial c over mass bound", triv_c - per_pair_mass_bound, Fr(44, 200)) loss = min(triv_sqrt, triv_c) - per_pair_mass_bound check("T3 sparsity loss = R-length/2 - alpha", loss, Mlen / 2 - alpha) req_l2 = loss + D check("T4 required saving over l2 trivial (x)", req_l2, Fr(23, 100)) check("T4c required saving over l2 trivial (c)", req_l2 / c, Fr(23, 95)) sqrt_cancel = l2_alpha + l2_beta + c / 2 - per_pair_mass_bound # ||a|| ||b|| sqrt(c) check("T5 square-root-cancellation ceiling vs mass bound", sqrt_cancel, Fr(-51, 200)) check("T6 ceiling would suffice (heuristic only)", -sqrt_cancel > D, True) check("T7 needed fraction of full bilinear saving sqrt(MN)", req_l2 / ((Mlen + Nlen) / 2), Fr(23, 45)) # ---- 4. price #1080 (sixth moment, d = e1) and the earlier inputs against the corrected requirement ---- Mc, Nc, cc, dc = Mlen / c, Nlen / c, Fr(1), E / c def G(f): t1 = dc + Mc + Nc + 2 * Mc - 3 # d M N (M^2+N^2)/c^3, M > N t2 = f + 2 * Mc - 2 t3 = f - 2 * dc return max(t1, t2, t3) sav_prime_c = (Mc + Nc + 1) / 2 - 1 - G(dc) / 6 # saving of c G^(1/6) over sqrt(MNc) check("P1 #1080 q prime saving (c)", sav_prime_c, Fr(14, 285)) sav_p2_c = (Mc + Nc + 1) / 2 - 1 - G(dc + sig / 2 / c) / 6 check("P2 #1080 q=p^2 saving (c)", sav_p2_c, Fr(17, 380)) s1080 = sav_prime_c * c check("P3 #1080 saving (x)", s1080, Fr(7, 150)) check("P4 #1080 shortfall vs corrected requirement (x)", req_l2 - s1080, Fr(11, 60)) check("P5 #1080 bound over the record's own mass bound (x)", loss - s1080, Fr(89, 600)) others = {"1067 thm5.2 (c)": Fr(7, 608), "629 thm5.5 (c)": Fr(13, 2850), "BP optimum c^(1/32) (c)": Fr(1, 32), "Pascadi c^(1/12) two equal primes, length sqrt(c) (c)": Fr(1, 12)} priced = {k: str(req_l2 - v * c) for k, v in others.items()} check("P6 every located saving < corrected requirement", all(v * c < req_l2 for v in others.values()), True) ok = all(ch["ok"] for ch in checks) out = {"instrument": "route29_baseline_check.py", "checks_passed": sum(ch["ok"] for ch in checks), "checks_total": len(checks), "all_passed": ok, "checks": checks, "findings": {"requirement_over_mass_bound_x": str(D), "sparsity_loss_x": str(loss), "requirement_over_l2_trivial_x": str(req_l2), "requirement_over_l2_trivial_c": str(req_l2 / c), "saving_1080_x": str(s1080), "shortfall_1080_x": str(req_l2 - s1080), "shortfall_others_x": priced}} print(json.dumps(out, indent=1, sort_keys=True)) print(f"{out['checks_passed']}/{out['checks_total']} checks", file=sys.stderr) sys.exit(0 if ok else 1)