"""Question: which parts of return 221 do its checkers actually establish? Replay the unchanged public scripts, then independently use integer divisors and prime-power tables. Exact symbolic probes retain separate prime keys. """ import hashlib import json import math import subprocess import tempfile from fractions import Fraction from pathlib import Path def sha(raw): return hashlib.sha256(raw).hexdigest() def main(): folder = Path(__file__).resolve().parent raw = (folder / 'coefficients-742-inputs.json').read_bytes() assert sha(raw) == '3cbda2d96f1933f2e1ab0da3761b4d20c633e523aeb400eb89a0f19443a38508' data = json.loads(raw) replays = {} for name, record in data['scripts'].items(): assert sha(record['content'].encode()) == record['sha256'] with tempfile.TemporaryDirectory() as scratch: script = Path(scratch) / name script.write_text(record['content']) r = subprocess.run(['node', str(script)], capture_output=True, text=True, timeout=30) assert r.returncode == 0, r.stderr key = 'edges_out' if 'edges' in name else 'smooth_out' assert sha(r.stdout.encode()) == data['return221']['hashes'][key] output_name = 'coefficients-742-original-' + key + '.txt' (folder / output_name).write_text(r.stdout) replays[name] = {'stdout_sha256': sha(r.stdout.encode()), 'original_output_matches': True} # Distinct prime keys preserve the symbolic basis. Replacing log(p) by # coefficient 1 exposes the original implementation's exponent weighting. probe_code = r''' const fs = require('node:fs'); const source = JSON.parse(fs.readFileSync(0, 'utf8')).source; const symbolicMath = Object.create(Math); symbolicMath.log = () => 1; const f = new Function('console', 'Math', source + '\nreturn {LAM,beta,expanded};')({log:()=>{}}, symbolicMath); process.stdout.write(JSON.stringify({Lambda8:f.LAM(8),beta5_8:f.beta(5,8),expanded5_8:f.expanded(5,8)})+'\n'); ''' r = subprocess.run(['node', '-e', probe_code], input=json.dumps({'source': data['scripts']['sah567-edges.mjs']['content']}), capture_output=True, text=True, timeout=30) assert r.returncode == 0, r.stderr probe = json.loads(r.stdout) assert probe == {'Lambda8': {'2': 3}, 'beta5_8': {'2': 3}, 'expanded5_8': {'2': 0}} maximum = 115003 spf = list(range(maximum + 1)) for p in range(2, math.isqrt(maximum) + 1): if spf[p] == p: for k in range(p * p, maximum + 1, p): if spf[k] == k: spf[k] = p primes = [p for p in range(2, maximum + 1) if spf[p] == p] # Independent reference to Lambda: every power of a prime has the SAME # log-prime coefficient, not j times that coefficient at p**j. lambda_base = [0] * (maximum + 1) for p in primes: power = p while power <= maximum: lambda_base[power] = p power *= p largest_prime_power, largest_prime = [1] * (maximum + 1), [1] * (maximum + 1) for k in range(2, maximum + 1): m, largest, largest_p = k, 1, 1 while m > 1: p, power = spf[m], 1 while m % p == 0: m //= p power *= p largest, largest_p = max(largest, power), max(largest_p, p) largest_prime_power[k], largest_prime[k] = largest, largest_p def beta_vector(W, k): coefficients = {} for d in range(1, math.isqrt(k) + 1): if k % d: continue for divisor in ([d] if d * d == k else [d, k // d]): if divisor > W and lambda_base[divisor]: p = lambda_base[divisor] coefficients[p] = coefficients.get(p, 0) + 1 return coefficients checked = 0 for W in [5, 7, 11, 13, 20, 40, 100]: for k in range(W + 1, 4001): assert (not beta_vector(W, k)) == (largest_prime_power[k] <= W) checked += 1 assert checked == 27804 incorrect_prime_only = sum((not beta_vector(W, k)) != (largest_prime[k] <= W) for W in [5, 11, 40] for k in range(W + 1, 2001)) assert incorrect_prime_only == 434 assert beta_vector(5, 8) == {2: 1} windows = [] for V, multiplier in [(149, Fraction(23, 20)), (776, Fraction(23, 20)), (10007, Fraction(23, 20)), (10007, Fraction(21, 20)), (100003, Fraction(23, 20))]: U = (V * multiplier.numerator) // multiplier.denominator zero = sum(largest_prime_power[k] <= V for k in range(V + 1, U + 1)) # At U<2V, a divisor above V must be k itself. This independently # simplifies the reference: the active positions are prime powers. assert zero == sum(lambda_base[k] == 0 for k in range(V + 1, U + 1)) # V=x**(6/25) and multiplier=x**(2eta): eta<1/400 iff m**48