import argparse import itertools import json import math from collections import Counter from fractions import Fraction as F from functools import lru_cache from pathlib import Path parser = argparse.ArgumentParser() parser.add_argument("target", nargs="?") args = parser.parse_args() target = Path(args.target).read_bytes() if args.target else None @lru_cache(None) def factors(n): result = {} p = 2 while p*p <= n: while n % p == 0: result[p] = result.get(p, 0) + 1 n //= p p += 1 if n > 1: result[n] = 1 return result def omega(n): return len(factors(n)) def big_omega(n): return sum(factors(n).values()) Z = F(4801, 4800) EPS = F(1, 1200) def ell(p, scale): return min(F(1), F(p, scale)) def weight(n, scale, z=Z): return 2**omega(n)*z**big_omega(n)*math.prod( ell(p, scale) for p in sorted(factors(n))[:3]) counts = Counter() flags = {} assert Z**2400 < 2 assert 3-2*Z == F(2399, 2400) > 0 assert EPS < F(1, 600) assert F(39, 40)+2*EPS == F(293, 300) < 1 t = F(1, 4800) assert 4801*(t-t*t/2) > 1 counts["exact_parameter_checks"] = 5 for n in range(1, 1025): assert 2**big_omega(n) <= n counts["multiplicity_growth_checks"] += 1 for scale, a, b in itertools.product((12, 48, 120), range(1, 49), range(1, 49)): ratio = 2**omega(a)*Z**big_omega(a) assert weight(a*b, scale) <= ratio*weight(b, scale) assert ratio <= (2*Z)**big_omega(a) counts["ordered_coordinate_growth"] += 1 for primes, exponent_cap, scale in itertools.product( ((2, 3, 5), (2, 3, 5, 7), (2, 3, 5, 7, 11)), (1, 2, 3), (5, 30)): atoms = {} for p in primes: r = Z/p atoms[p] = sum(r**j for j in range(1, exponent_cap+1)) assert atoms[p] == r*(1-r**exponent_cap)/(1-r) assert r/(1-r) == Z/(p-Z) counts["prime_power_atoms"] += 1 direct = F(0) for exponents in itertools.product(range(exponent_cap+1), repeat=len(primes)): n = math.prod(p**j for p, j in zip(primes, exponents)) direct += weight(n, scale)/n counts["finite_euler_inputs"] += 1 split = F(1) for size in (1, 2): for subset in itertools.combinations(primes, size): split += math.prod(2*ell(p, scale)*atoms[p] for p in subset) for p, q, r in itertools.combinations(primes, 3): split += ( 8*ell(p, scale)*ell(q, scale)*ell(r, scale) *atoms[p]*atoms[q]*atoms[r] *math.prod(1+2*atoms[s] for s in primes if s > r) ) assert direct == split counts["first_three_prime_splits"] += 1 for scale in (12, 48): values = [(n, weight(n, scale, F(1))*weight(n-2, scale, F(1))) for n in range(3, 129)] moment = sum(Z**(big_omega(n)+big_omega(n-2))*v for n, v in values) for J in range(16): tail = sum(v for n, v in values if big_omega(n)+big_omega(n-2) > J) assert tail <= moment/Z**J counts["finite_shifted_markov"] += 1 for a, b in itertools.product(range(1, 25), repeat=2): modulus = math.lcm(a, b) roots = sum((n-2) % b == 0 for n in range(0, modulus, a)) expected = F(math.gcd(a, b), a*b) if 2 % math.gcd(a, b) == 0 else F(0) assert F(roots, modulus) == expected <= F(2, a*b) counts["crt_density_bounds"] += 1 assert weight(4, 30) == 2*Z**2*ell(2, 30) != 2*Z*ell(2, 30) flags["multiplicity_not_distinct_count"] = True assert Z/(2-Z) != Z/(2-1) flags["prime_power_denominator_not_p_minus_one"] = True assert weight(210, 30) > weight(30, 30)*weight(7, 30) flags["multiplicative_shortcut_rejected"] = True assert F(5, 4)**1200 > 2 flags["large_tilt_fails_fixed_epsilon_class"] = True assert 3-2*F(3, 2) == 0 flags["critical_harmonic_power_not_positive"] = True assert math.gcd(2, 2) == 2 and math.gcd(4, 4) > 2 flags["prime_two_compatibility_retained"] = True assert all(flags.values()) output = json.dumps({ "status": "passed", "z": str(Z), "source_epsilon": str(EPS), "exceptional_exponent": str(F(293, 300)), "counts": dict(counts), "active_controls": flags, "scope": "Exact algebra with rational ordered-coordinate proxies; not a computation of the analytic constants or asymptotic moment", }, sort_keys=True) + "\n" if target is not None: assert target == output.encode(), "published target does not match recomputed checks" print(output, end="")