#!/usr/bin/env node // ============================================================================ // THE HINGE, MEASURED ON THE CORPUS'S OWN COEFFICIENT CODE: // is the divisor support SQUAREFREE? — route 51, second half of experiment 1. // ============================================================================ // Why this decides the verdict. The Baier-Das-Mahajan vanishing criterion needs // a non-trivial POWERFUL part d of c = q*j*l1*l2. Sections D of the companion // script (work/route51_bdm_vanishing.js) shows d>1 arises two ways: // (i) from a powerful q = p^k, k >= 2; // (ii) from a prime entering TWICE through j = gcd(e1,e2) and the l_i = e_i/j, // which needs a NON-SQUAREFREE e. // Way (ii) is the only one with non-negligible mass (non-squarefree integers have // natural density 1 - 6/pi^2 = 0.392...), so the whole verdict turns on whether // the corpus's own e-support carries squarefree indices only. // // This script does not read that off the prose: it REPLICATES the served // coefficient construction verbatim -- research/prime-band-completion-validation.js, // function `coefficients(D,W,cut)` -- and measures the mu-support directly. The // replication is checked against the served script's own assertions (its two // deepEqual self-checks are reproduced here), so a misreading of that code would // fail here rather than produce a comfortable number. // ============================================================================ 'use strict'; const fs = require('node:fs'), path = require('node:path'), crypto = require('node:crypto'); const SRC = path.resolve(process.argv[2] || '.', 'job587/pub/research/prime-band-completion-validation.js'); const bytes = fs.readFileSync(SRC); const sha = crypto.createHash('sha256').update(bytes).digest('hex'); console.log(`source: ${SRC.replace(/\\/g, '/')}`); console.log(` sha256=${sha} bytes=${bytes.length}`); // --- the served inputs, read from the served data file (not re-typed) --------- const DATA = path.resolve(process.argv[2] || '.', 'job587/pub/research/data-reuse/factor-windows.json'); const saved = JSON.parse(fs.readFileSync(DATA)); const basePrimes = saved.basePrimes; function factor(n) { const out = []; for (const p of basePrimes) { if (p * p > n) break; if (n % p) continue; let a = 0; do { n /= p; a++; } while (n % p === 0); out.push([p, a]); } if (n > 1) out.push([n, 1]); return out; } const mu = n => { const f = factor(n); return f.some(([, a]) => a > 1) ? 0 : (-1) ** f.length; }; function divisors(n) { let ds = [1]; for (const [p, a] of factor(n)) { const old = ds.slice(); let r = 1; for (let j = 0; j < a; j++) { r *= p; ds.push(...old.map(d => d * r)); } } return ds; } const primesTo = W => basePrimes.filter(p => p <= W); const inside = (n, D) => n > D && n <= 2 * D; function addVector(a, b, scale = 1) { for (const [p, c] of b) { const v = (a.get(p) || 0) + scale * c; if (v) a.set(p, v); else a.delete(p); } } const vectorValue = v => [...v].reduce((s, [p, c]) => s + c * Math.log(p), 0); const sorted = v => [...v].sort((a, b) => a[0] - b[0]); // === REPLICATED VERBATIM from the served file: function coefficients(D,W,cut) === function coefficients(D, W, cut) { const all = Array.from({ length: 2 * D * W + 1 }, () => new Map()), low = all.map(() => new Map()), high = all.map(() => new Map()); for (let d = D + 1; d <= 2 * D; d++) for (const p of primesTo(W)) if (d % p) { const term = new Map([[p, -mu(d)]]); addVector(all[d * p], term); addVector(p <= cut ? low[d * p] : high[d * p], term); } for (let l = 1; l < all.length; l++) { const independent = new Map(); for (const [p] of factor(l)) if (p <= W && inside(l / p, D) && mu(l)) independent.set(p, mu(l)); if (JSON.stringify(sorted(all[l])) !== JSON.stringify(sorted(independent))) { selfCheckFailures++; } const merged = new Map(low[l]); addVector(merged, high[l]); if (JSON.stringify(sorted(all[l])) !== JSON.stringify(sorted(merged))) { selfCheckFailures++; } } return { all, low, high }; } // ============================================================================== let selfCheckFailures = 0; const x = 4096, D = 8, V = 8, V0 = 4, E = 32, Z = 4, Z0 = 2; const left = coefficients(D, V, V0), right = coefficients(E, Z, Z0); const support = table => { let n = 0, sf = 0, nonSf = []; for (let l = 1; l < table.all.length; l++) if (table.all[l].size) { n++; if (mu(l) !== 0) sf++; else nonSf.push(l); } return { n, sf, nonSf }; }; const sl = support(left); console.log(''); console.log('1. THE SERVED CONSTRUCTION, REPLICATED AND SELF-CHECKED'); console.log(` the served file's own two deepEqual checks reproduced here: ${selfCheckFailures} failures`); console.log(` left support (D=${D}, V=${V}, V0=${V0}): ${sl.n} indices, of them SQUAREFREE: ${sl.sf}`); console.log(` right support (E=${E}, Z=${Z}, Z0=${Z0}): ${support(right).n} indices, of them SQUAREFREE: ${support(right).sf}`); // cell pairs, exactly as the served script iterates them let cells = 0, sfCells = 0, nonSfCells = []; for (let l = 1; l < left.all.length; l++) if (left.all[l].size) for (let j = 1; j < right.all.length; j++) if (right.all[j].size) { const g = ((a, b) => { while (b) { const t = a % b; a = b; b = t; } return a; })(l, j); if (2 % g) continue; cells++; if (mu(l) !== 0 && mu(j) !== 0) sfCells++; else nonSfCells.push([l, j]); } console.log(` CRT cell pairs with 2%g==0 (as the served script forms them): ${cells}, of them BOTH SQUAREFREE: ${sfCells}`); console.log(''); console.log('2. WHY THIS SETTLES THE HINGE'); console.log(' Every weight in that construction is a multiple of mu(d) (the served line:'); console.log(' `const term=new Map([[p,-mu(d)]]); addVector(all[d*p],term);`, and the cell form'); console.log(' `const q=l*j/g, ... mu(g*d)`), so a NON-squarefree index can only carry total weight zero:'); console.log(' the support is squarefree BY CONSTRUCTION, not by an assumption of mine.'); console.log(' With e1, e2 squarefree, j = gcd(e1,e2) and l_i = e_i/j are squarefree too (checked in the'); console.log(' companion script), so a prime can enter c = q*j*l1*l2 at most twice, and only when'); console.log(' q = p^2, p^3, ... supplies the first power. Hence:'); console.log(' d > 1 <=> the prime power q has exponent k >= 2.'); console.log(''); console.log('3. NEGATIVE CONTROL: the claim must be FALSE for a non-squarefree support'); { // build a deliberately non-squarefree support and show the same measurement // flips -- i.e. the statistic can distinguish the two cases. const fake = { all: Array.from({ length: 200 }, () => new Map()) }; for (let l = 9; l < 200; l += 6) fake.all[l].set(3, 1); // multiples of 9 const s = support(fake); console.log(` deliberately non-squarefree support: ${s.n} indices, squarefree ${s.sf}, non-squarefree ${s.nonSf.length}`); if (s.sf === s.n) { console.log(' [FAIL] the statistic cannot tell the two cases apart'); process.exitCode = 1; } else console.log(' [ok] the statistic discriminates the two cases'); } console.log(''); if (selfCheckFailures || sl.sf !== sl.n) { console.log('FAILED'); process.exitCode = 1; } else console.log('ALL CHECKS PASSED');