// Job #576 (prior-art hunt for return #161). Two checks, no literature: an independent // recomputation of L(T_x,p) for the small tiles, and the reason the object has no // single-modulus counterpart in the covering-function tradition. // // L(T_x,p): the longest run of consecutive slots of the tile T_x = {t mod W : gcd(t(t+2),W)=1}, // W = x#, whose residues mod p all lie in ONE 2-set {a, a+2} (free translate a; wraparound // difference p-2 admitted). Equivalently: a maximal cyclic block of slots in which every // consecutive residue difference is 0, +2 or p-2 (mod p). // // Run: node lruns.mjs 'use strict'; // ---------- part A: the degeneracy on Z ---------- // Two consecutive integers n, n+1 cannot both lie in {a, a+2} mod p for p >= 5. function degeneracy() { let bad = []; for (let p = 5; p <= 1000; p++) { if (!isPrime(p)) continue; for (let a = 0; a < p; a++) { const inSet = (n) => { const r = ((n % p) + p) % p; return r === a || r === (a + 2) % p; }; if (inSet(0) && inSet(1)) bad.push([p, a]); } } return bad; // must be empty } function isPrime(n) { if (n < 2) return false; for (let d = 2; d * d <= n; d++) if (n % d === 0) return false; return true; } // ---------- part B: L on the real tiles ---------- function primorial(x) { let W = 1n; for (let p = 2; p <= x; p++) if (isPrime(p)) W *= BigInt(p); return W; } function gcd(a, b) { while (b) { const t = a % b; a = b; b = t; } return a; } // Build the cyclic gap word: slots t_{i+1} = t_i + g_i (g_i in units of 1 mod W). function tile(x) { const W = primorial(x); const Wn = Number(W); // safe for x <= 23 const slots = []; for (let t = 1; t <= Wn; t++) if (gcd(t, Wn) === 1 && gcd(t + 2, Wn) === 1) slots.push(t); const D = slots.length; const gaps = new Array(D); for (let i = 0; i < D; i++) gaps[i] = i + 1 < D ? slots[i + 1] - slots[i] : Wn - slots[D - 1] + slots[0]; return { W: Wn, x, D, first: slots[0], gaps }; } // Longest cyclic run of consecutive slots with residues in one 2-set {a,a+2} mod p. function Lrun(T, p) { const D = T.D, gaps = T.gaps, W = T.W; // cyclic residues of the slots const r = new Array(D); let cur = T.first % p; for (let i = 0; i < D; i++) { r[i] = cur; cur = (cur + gaps[i]) % p; } // legal step i -> i+1 iff (r[i+1]-r[i]) mod p in {0,2,p-2} const ok = (i) => { const j = (i + 1) % D; const d = ((r[j] - r[i]) % p + p) % p; return d === 0 || d === 2 || d === p - 2; }; const legal = new Array(D); for (let i = 0; i < D; i++) legal[i] = ok(i); if (legal.every(Boolean)) return D; // whole cycle let best = 0, i = 0; const start = legal.findIndex((v) => !v); // break the cycle at a non-legal step for (let k = 0; k < D; k++) { const idx = (start + k) % D; if (legal[idx]) { i++; if (i > best) best = i; } else i = 0; } return best + 1; // run length counts slots, not steps } console.log('== A. single-modulus degeneracy (expect empty) =='); const bad = degeneracy(); console.log(' pairs (p,a) where two consecutive integers are both in {a,a+2} mod p, p in [5,1000]:', bad.length, JSON.stringify(bad)); console.log('\n== B. L(T_x,p) and the smallest p with L = 1 =='); const want = { 5: 11, 7: 11, 11: 23, 13: 37, 17: 59, 19: 71, 23: 107, 29: 127 }; const rows = []; for (const x of [5, 7, 11, 13, 17, 19, 23]) { const T = tile(x); if (T.W > 2 ** 31) { console.log(` T${x}: W=${T.W} too large for the exact slot build here`); continue; } let firstOne = null, maxL = 1, argmax = null; const seen = []; for (let p = x; p <= 1009; p++) { if (!isPrime(p)) continue; const L = Lrun(T, p); if (p <= 140) seen.push(`${p}:${L}`); if (L > maxL) { maxL = L; argmax = p; } if (firstOne === null && L === 1) firstOne = p; } const okwant = want[x] === undefined ? 'n/a' : (want[x] === firstOne ? 'MATCH' : `DIFFERS (want ${want[x]})`); rows.push([x, T.D, firstOne, maxL, argmax, okwant]); console.log(` T${x}: D=${T.D} first p with L=1: ${firstOne} [${okwant}] max L=${maxL} at p=${argmax}`); console.log(` sweep ${seen.join(' ')}`); } console.log('\n return #161 thresholds (T5 from p=11, T7 from 11, T11 from 23, T13 from 37, T17 from 59, T19 from 71, T23 from 107, T29 from 127)');