#!/usr/bin/env node // ============================================================================ // DOES THE BAIER-DAS-MAHAJAN VANISHING CRITERION HAVE ANY CONTENT ON THE // CORPUS'S OWN (D1) SECTOR? — route 51's first experiment, exact arithmetic. // ============================================================================ // THE QUESTION. Baier-Das-Mahajan, arXiv:2406.13013v4, Theorem 1, read at the // PDF of record (sha256 bc2fc5e7...): let c be ODD, c = d*u with u squarefree, // d POWERFUL, (d,u)=1; let (ab,c)=1. Then // - if ab is a quadratic RESIDUE mod every prime dividing d: |S(a,b;c)| is // bounded BELOW by an explicit positive quantity; // - if ab is a quadratic NON-residue mod a prime dividing d: S(a,b;c) = 0. // On the (D1) sector the pair is (t, r): a = t the dual frequency, b = r = // sigma*theta*R with R = h1*l2 - h2*l1, and the modulus is // c = q*lcm(e1,e2) = q*j*l1*l2, j = gcd(e1,e2), l_i = e_i/j, // q a prime power -- structure QUOTED from the corpus's own producer, // research/structured-dispersion-estimate-validation.js section B1 ("c = // q*lcm(e1,e2) = q*j*l1*l2, R = h1*l2-h2*l1, l_i = e_i/j"), whose document adds // "u = eq with e the original Mobius-weighted divisor and q the right prime // power with Lambda(q) >= 0" and "q ~ x^sigma, 0 <= sigma <= 6/25". // // Route 51's own next_step asks two decidable things: (1) does c carry a // non-trivial POWERFUL part d at all; (2) what proportion of the (t,r) pairs // falls in the VANISHING class. A criterion with no content here is INERT and // the line closes; a criterion with content RESTRICTS THE SUPPORT of the deficit. // The cited theorem's vanishing half is VERIFIED here against the actual // Kloosterman sums rather than assumed. // // SECTIONS // A. The theorem's hypotheses, mapped variable by variable onto the sector. // B. The vanishing half verified against exact S(t,r;c) (small odd c). // C. The t-measure of the vanishing class: brute force vs 1 - 2^{-omega_odd(d)}. // D. Measured on the corpus's own producer parametrisation (two scenarios). // E. The Lambda(q) mass of the powerful-q sector at sigma <= 6/25. // F. Negative controls, each of which must FIRE. // ============================================================================ 'use strict'; // ---- exact helpers, with caches so the measurement is not O(sqrt c) per config const factorCache = new Map(); function factor(n) { const hit = factorCache.get(n); if (hit) return hit; let m = n, out = []; for (let p = 2; p * p <= m; p++) if (m % p === 0) { let a = 0; do { m /= p; a++; } while (m % p === 0); out.push([p, a]); } if (m > 1) out.push([m, 1]); factorCache.set(n, out); return out; } const gcd = (a, b) => { a = Math.abs(a); b = Math.abs(b); while (b) { const t = a % b; a = b; b = t; } return a; }; const mu = n => { const f = factor(n); return f.some(([, a]) => a > 1) ? 0 : (-1) ** f.length; }; const rad = n => factor(n).reduce((s, [p]) => s * p, 1); const pfCache = new Map(); function powerfullPart(c) { // the unique c = d*u of the theorem const hit = pfCache.get(c); if (hit) return hit; let d = 1, u = 1; for (const [p, a] of factor(c)) { if (a >= 2) d *= p ** a; else u *= p; } const r = { d, u }; pfCache.set(c, r); return r; } const oddPrimeCache = new Map(); function oddPrimesOf(n) { const hit = oddPrimeCache.get(n); if (hit) return hit; const r = factor(n).filter(([p]) => p !== 2).map(([p]) => p); oddPrimeCache.set(n, r); return r; } const isQR = (a, p) => { a = ((a % p) + p) % p; for (let x = 0; x < p; x++) if (x * x % p === a) return true; return false; }; const vanishes = (a, b, d) => oddPrimesOf(d).some(p => !isQR(a * b, p)); // Theorem 1's hypothesis let failures = 0; function check(label, ok, detail = '') { console.log(` [${ok ? 'ok' : 'FAIL'}] ${label}${detail ? ' ' + detail : ''}`); if (!ok) failures++; } function modinv(a, m) { let [r0, r1] = [((a % m) + m) % m, m], [s0, s1] = [1, 0]; while (r1) { const q = Math.floor(r0 / r1); [r0, r1] = [r1, r0 - q * r1]; [s0, s1] = [s1, s0 - q * s1]; } if (r0 !== 1) throw new Error('modinv'); return ((s0 % m) + m) % m; } function kloosterman(a, b, c) { let re = 0, im = 0; for (let x = 1; x < c; x++) { if (gcd(x, c) !== 1) continue; const ph = 2 * Math.PI * ((((a * x + b * modinv(x, c)) % c) + c) % c) / c; re += Math.cos(ph); im += Math.sin(ph); } return Math.hypot(re, im); } // ============================================================================ console.log('A. THE THEOREM\'S HYPOTHESES, MAPPED VARIABLE BY VARIABLE'); // ============================================================================ console.log(' theorem | on the (D1) sector (c = q*j*l1*l2)'); console.log(' c odd | q odd AND every e_i odd'); console.log(' c = d*u, u squarefree, d powerful | u = rad(c), d = the rest (unique decomposition)'); console.log(' (d,u)=1 | automatic from that decomposition'); console.log(' (ab,c)=1 | exactly the corpus\'s small-gcd sector G=(t,r,c)=1'); console.log(' ab QR mod each p|d | t*r a QR mod each ODD prime dividing d'); console.log(' S(a,b;c)=0 when some p|d has a QNR | the VANISHING class of (t,r) pairs'); console.log(''); // ============================================================================ console.log('B. THE VANISHING HALF OF THEOREM 1, VERIFIED AGAINST EXACT S(t,r;c)'); // ============================================================================ { let cCount = 0, pairCount = 0, vanishPairs = 0, violations = 0, converseZero = 0; let minAbs = Infinity, worst = null, twoOmega = 0; const CMAX = 250; // 225 = 3^2*5^2 is the first odd c with omega_odd(d) = 2 for (let c = 3; c <= CMAX; c += 2) { const { d } = powerfullPart(c); if (d === 1) continue; cCount++; if (oddPrimesOf(d).length >= 2) twoOmega++; for (let t = 1; t < c; t++) { if (gcd(t, c) !== 1) continue; for (let r = 1; r < c; r++) { if (gcd(r, c) !== 1) continue; pairCount++; const mag = kloosterman(t, r, c); if (vanishes(t, r, d)) { vanishPairs++; if (mag > 1e-9) { violations++; if (violations < 4) console.log(` violation: c=${c} t=${t} r=${r} |S|=${mag.toFixed(6)}`); } } else { if (mag < 1e-9) converseZero++; if (mag < minAbs) { minAbs = mag; worst = { c, t, r, d }; } } } } } console.log(` odd c <= ${CMAX} with a non-trivial powerful part: ${cCount} (of which ${twoOmega} have omega_odd(d) >= 2, where the criterion has genuine content); (t,r) pairs with (tr,c)=1: ${pairCount}`); check('the tested range reaches omega_odd(d) >= 2, where the criterion stops being a single half', twoOmega > 0, `twoOmega=${twoOmega}`); console.log(` pairs in the vanishing class: ${vanishPairs} (${(100 * vanishPairs / pairCount).toFixed(2)}% of those pairs)`); check('Theorem 1\'s vanishing half holds on every pair tested (S=0 when a QNR exists)', violations === 0, `violations=${violations}`); console.log(` converse measured (S=0 while tr is a QR mod every odd p|d): ${converseZero}`); console.log(` smallest |S| among non-vanishing pairs: ${minAbs.toFixed(6)} at c=${worst.c}, t=${worst.t}, r=${worst.r}, d=${worst.d} (trivial sqrt(c)=${Math.sqrt(worst.c).toFixed(4)})`); check('the non-vanishing class is non-empty and |S|>0 there', minAbs > 0 && pairCount - vanishPairs > 0); console.log(''); } // ============================================================================ console.log('C. THE t-MEASURE OF THE VANISHING CLASS: BRUTE FORCE vs CHARACTER COUNT'); // ============================================================================ { let compared = 0, mismatches = 0, sample = null; for (let c = 3; c <= 400; c += 2) { const { d } = powerfullPart(c); if (d === 1) continue; const w = oddPrimesOf(d).length; if (w === 0) continue; const predicted = 1 - Math.pow(2, -w); for (let r = 1; r < c; r++) { if (gcd(r, c) !== 1) continue; let units = 0, kill = 0; for (let t = 1; t < c; t++) { if (gcd(t, c) !== 1) continue; units++; if (vanishes(t, r, d)) kill++; } compared++; if (Math.abs(kill / units - predicted) > 1e-12) { mismatches++; if (mismatches < 4) console.log(` c=${c} r=${r} d=${d} w=${w} brute=${kill / units} formula=${predicted}`); } if (!sample && c === 45) sample = { c, r, d, w, brute: kill / units, predicted }; } } console.log(` (c, r) configurations compared (odd c <= 400 with powerful part): ${compared}`); console.log(` example: c=${sample.c}, r=${sample.r}, d=${sample.d}, omega_odd=${sample.w}: brute=${sample.brute}, formula=${sample.predicted}`); check('brute-force t-measure equals 1 - 2^{-omega_odd(d)} on every configuration', mismatches === 0, `mismatches=${mismatches}`); console.log(' consequence: the SURVIVING frequency measure is exactly 2^{-omega_odd(d)}, i.e. 1/2 per odd prime of d.'); console.log(''); } // ============================================================================ console.log('D. MEASURED ON THE CORPUS\'S OWN PRODUCER PARAMETRISATION'); // ============================================================================ // The producer's model fixes E=6, A=3, q in {4,5,7,9} and iterates e in (E,2E], // h in (A,2A]. That window is too thin to see a density, so the SAME // parametrisation is iterated over a wider grid; both windows are reported. // Two scenarios, because they answer different questions: // S1 e in (E,2E] over ALL integers .... the producer's own enumeration // S2 e in (E,2E] with mu(e) != 0 ...... the sector if the e's carry the // corpus's Mobius weight (squarefree) // The q weight is Lambda(q), the corpus's own. function primesUpTo(n) { const s = new Uint8Array(n + 1); const out = []; for (let i = 2; i <= n; i++) { if (!s[i]) { out.push(i); for (let j = i * i; j <= n; j += i) s[j] = 1; } } return out; } const PP = (() => { const ps = primesUpTo(600), out = []; for (const p of ps) for (let k = 1; p ** k <= 600; k++) out.push([p ** k, p]); return out; })(); const lamOf = q => { const hit = PP.find(([x]) => x === q); return hit ? Math.log(hit[1]) : Math.log(rad(q)); }; function measure(qmax, emax, amax, squarefreeOnly) { let configs = 0, withD = 0, evenC = 0, tSurv = 0, tSurvLam = 0, lam = 0, lamD = 0, wSum = 0; let byK2 = 0, byOverlap = 0; // why d>1: powerful q, or q sharing a prime with j*l1*l2 for (const [q, p] of PP) { if (q > qmax) continue; const Lq = lamOf(q); const k2 = factor(q).some(([, a]) => a >= 2); for (let e1 = 1; e1 <= emax; e1++) { if (squarefreeOnly && mu(e1) === 0) continue; for (let e2 = 1; e2 <= emax; e2++) { if (squarefreeOnly && mu(e2) === 0) continue; const j = gcd(e1, e2), l1 = e1 / j, l2 = e2 / j; const c = q * j * l1 * l2; const { d } = powerfullPart(c); const w = oddPrimesOf(d).length; const surv = Math.pow(2, -w); const even = c % 2 === 0; const overlap = c % (p * p) === 0 && !k2; // p enters twice without q being a square for (let h1 = 1; h1 <= amax; h1++) for (let h2 = 1; h2 <= amax; h2++) { configs++; lam += Lq; if (even) evenC++; if (d > 1) { withD++; lamD += Lq; if (k2) byK2++; else if (overlap) byOverlap++; } tSurv += surv; tSurvLam += Lq * surv; wSum += w; } } } } return { configs, withD, evenC, tSurv, tSurvLam, wSum, lam, lamD, byK2, byOverlap }; } { const thin = measure(9, 12, 6, false); // the producer's own window, widened only in e const s1 = measure(64, 40, 6, false); const s2 = measure(64, 40, 6, true); for (const [name, m] of [['producer\'s own window (q<=9, e<=12, h<=6)', thin], ['S1 all e (q<=64, e<=40, h<=6)', s1], ['S2 squarefree e (q<=64, e<=40, h<=6)', s2]]) { console.log(` ${name}`); console.log(` configs=${m.configs}; c EVEN so the theorem does NOT apply: ${m.evenC} (${(100 * m.evenC / m.configs).toFixed(2)}%)`); console.log(` c with d>1: ${m.withD} (${(100 * m.withD / m.configs).toFixed(2)}% of configs, ${(100 * m.lamD / m.lam).toFixed(2)}% of the Lambda(q) mass), mean omega_odd(d)=${(m.wSum / m.configs).toFixed(3)}`); console.log(` of those, from a POWERFUL q (k>=2): ${m.byK2}; from q merely SHARING a prime with j*l1*l2: ${m.byOverlap}`); console.log(` surviving t-measure: mean of 2^{-omega_odd(d)} = ${(100 * m.tSurv / m.configs).toFixed(2)}% of units; Lambda-weighted = ${(100 * m.tSurvLam / m.lam).toFixed(2)}%`); } check('S2: with squarefree e, d>1 happens ONLY through the prime power q', (() => { for (let e1 = 1; e1 <= 40; e1++) for (let e2 = 1; e2 <= 40; e2++) { if (mu(e1) === 0 || mu(e2) === 0) continue; const j = gcd(e1, e2); if (mu(j) === 0 || mu(e1 / j) === 0 || mu(e2 / j) === 0) return false; } return true; })(), 'j and l_i are squarefree whenever e1,e2 are'); check('S1 DOES have powerful parts beyond q, so the two scenarios are genuinely different', s1.lamD / s1.lam > s2.lamD / s2.lam); console.log(''); } // ============================================================================ console.log('E. THE Lambda(q) MASS OF THE POWERFUL-q SECTOR AT sigma <= 6/25'); // ============================================================================ { const rows = []; for (const Q of [1e3, 1e4, 1e5, 1e6, 1e7]) { const ps = primesUpTo(Math.ceil(2 * Q)); let lam = 0, lamPower = 0; for (const p of ps) { if (p >= Q && p < 2 * Q) lam += Math.log(p); // k = 1: the primes for (let k = 2; p ** k < 2 * Q; k++) { const q = p ** k; if (q >= Q) { lam += Math.log(p); lamPower += Math.log(p); } } } const share = lamPower / lam; rows.push({ Q, lam: lam.toFixed(2), lamPower: lamPower.toFixed(2), share, timesSqrtQ: share * Math.sqrt(Q) }); } console.log(' Q sum Lambda(q) sum Lambda(k>=2) share share*sqrt(Q)'); for (const r of rows) console.log(` ${String(r.Q).padEnd(10)} ${r.lam.padStart(14)} ${r.lamPower.padStart(18)} ${r.share.toExponential(3).padStart(10)} ${r.timesSqrtQ.toFixed(4)}`); const first = rows[0].share, last = rows[rows.length - 1].share; check('the powerful-q share DECAYS like Q^{-1/2}', last < first / 5, `from ${first.toExponential(2)} at Q=1e3 to ${last.toExponential(2)} at Q=1e7`); check('share*sqrt(Q) is stable, i.e. the share is exactly of order Q^{-1/2}', Math.abs(rows[rows.length - 1].timesSqrtQ / rows[0].timesSqrtQ - 1) < 0.35, `${rows[0].timesSqrtQ.toFixed(4)} -> ${rows[rows.length - 1].timesSqrtQ.toFixed(4)}`); console.log(` consequence: with Q = x^sigma, sigma <= 6/25, the powerful-q mass fraction is <= Q^{-1/2} = x^{-sigma/2} <= x^{-3/25}.`); console.log(''); } // ============================================================================ console.log('F. NEGATIVE CONTROLS (each must FIRE)'); // ============================================================================ { let vacuous = 0, killed = 0; for (let c = 3; c <= 200; c += 2) { const { d } = powerfullPart(c); if (d !== 1) continue; for (let t = 1; t < c; t++) { if (gcd(t, c) !== 1) continue; for (let r = 1; r < c; r++) { if (gcd(r, c) !== 1) continue; vacuous++; if (vanishes(t, r, d)) killed++; } } } console.log(` (i) squarefree c <= 200: ${vacuous} (t,r) pairs, ${killed} declared vanishing`); check('the criterion does NOT kill squarefree moduli (vacuous there, as the theorem says)', killed === 0); // (ii) the two controls that MUST fire, and each tests a DIFFERENT way of being wrong: // (a) an EMPTY powerful part (d := 1, the "criterion is vacuous" reading) must be // contradicted by pairs with S = 0; // (b) the REVERSED condition (vanish iff EVERY p|d gives a QNR) must be contradicted // by pairs with |S| > 0. let aBreaks = 0, bBreaks = 0, inRange = 0, twoOmegaSeen = 0; for (let c = 9; c <= 250; c += 2) { const { d } = powerfullPart(c); if (d === 1) continue; const ps = oddPrimesOf(d); if (ps.length >= 2) twoOmegaSeen++; for (let t = 1; t < c; t++) { if (gcd(t, c) !== 1) continue; for (let r = 1; r < c; r++) { if (gcd(r, c) !== 1) continue; inRange++; const mag = kloosterman(t, r, c); if (mag < 1e-9 && vanishes(t, r, 1) === false) aBreaks++; // (a): d=1 says "survives" // (b) the COMPLEMENTARY reading of the theorem -- "the all-QR case is the one that vanishes" -- is the one // that must be contradicted by pairs with |S| > 0. NOTE: the first version of this control tested the // REVERSED quantifier ("vanish iff EVERY p|d gives a QNR"), which is a STRICTER predicate than the // theorem's and can therefore never be falsified that way -- a control that cannot fire is not a control. const complementary = ps.length > 0 && ps.every(p => isQR(t * r, p)); if (complementary && mag > 1e-9) bBreaks++; } } } console.log(` (ii) ${inRange} coprime (t,r) pairs with c in [9,250] (${twoOmegaSeen} moduli with omega_odd(d)>=2): d:=1 contradicted ${aBreaks} times, complementary reading contradicted ${bBreaks} times`); check('control (a): treating the powerful part as EMPTY is contradicted by pairs with S=0', aBreaks > 0); check('control (b): the COMPLEMENTARY reading is contradicted by pairs with |S|>0', bBreaks > 0, 'the all-QR class does NOT vanish, so the theorem is about the QNR side only'); // measurement, NOT an assertion: is the coprimality hypothesis load-bearing for the vanishing // direction? Counted here because a control that expects a result the checkpoint cannot show is // not a control -- the expectation was WRONG on the first run of this script and is recorded as a // measurement instead of asserted. let nonCoprime = 0, nonCoprimeVanish = 0; for (let c = 9; c <= 90; c += 2) { const { d } = powerfullPart(c); if (d === 1) continue; for (let t = 1; t < c; t++) for (let r = 1; r < c; r++) { if (gcd(t * r, c) === 1) continue; nonCoprime++; if (vanishes(t, r, d) && kloosterman(t, r, c) < 1e-9) nonCoprimeVanish++; } } console.log(` measured, NOT asserted: among ${nonCoprime} pairs with (tr,c) != 1, ${nonCoprimeVanish} vanish exactly when the criterion predicts it -- so in this range the coprimality hypothesis is not needed for the VANISHING direction`); const w225 = oddPrimesOf(powerfullPart(9 * 25).d).length; const pred = 1 - Math.pow(2, -w225); check('the vanishing t-measure is a non-trivial fraction of (0,1) when d>1', pred > 0 && pred < 1, `d=225, omega_odd=${w225}, measure=${pred}`); } console.log(''); if (failures) { console.log(`${failures} CHECK(S) FAILED`); process.exit(1); } console.log('ALL CHECKS PASSED');