"""Small exact controls for the route107 normalization and local-factor algebra.""" from fractions import Fraction as F import json import math primes = (2, 3, 5, 7, 11, 13, 17, 19) local_cases = 0 for p in primes: twin = F(p-len({0, 2 % p}), p)/(1-F(1, p))**2 values = [] for h in range(p): nu = len({0, 2 % p, h, (h+2) % p}) actual = F(p-nu, p)/(1-F(1, p))**4/twin**2 if p == 2: expected = F(2 if h == 0 else 0) elif p == 3: expected = F(3 if h == 0 else 0) else: expected = F(p*(p-4), (p-2)**2) if h == 0: expected *= F(p-2, p-4) elif h in (2, p-2): expected *= F(p-3, p-4) assert actual == expected values.append(actual) local_cases += 1 assert sum(values)/p == 1 for H in range(1, 101): even_weight = sum(H-abs(h) for h in range(1-H, H) if h and h % 2 == 0) all_weight = sum(H-abs(h) for h in range(1-H, H) if h) assert even_weight == F(H*H, 2)-H+F(H % 2, 2) assert all_weight == H*H-H # Arbitrary even-supported coefficients isolate the centering algebra. total = sum((H-abs(h))*(h*h+1) for h in range(1-H, H) if h and h % 2 == 0) defect = H*H-total assert total-even_weight == -defect+H*H-even_weight assert total-all_weight == -defect+H ap_cases = 0 for H in range(1, 21): for modulus in range(1, 21): for residue in range(modulus): actual = sum(H-h for h in range(1, H) if h % modulus == residue) assert abs(actual-F(H*H, 2*modulus)) <= H ap_cases += 1 def prime_factors(n): answer = [] for p in range(2, n+1): if n % p == 0: answer.append(p) while n % p == 0: n //= p if n == 1: break return answer def coefficient(n): h = 6*n value = F(1) for p in prime_factors(h): if p >= 5: value *= F(p-2, p-4) for p in prime_factors(h*h-4): if p >= 5: value *= F(p-3, p-4) return value assert math.gcd(2, 3) == 1 assert coefficient(1) == 1 assert (coefficient(2), coefficient(3), coefficient(6)) == (F(8, 3), F(2), F(224, 195)) assert coefficient(6) != coefficient(2)*coefficient(3) print(json.dumps({ "exact_local_factor_cases": local_cases, "primewise_average_identities": len(primes), "centering_cases": 100, "triangular_progression_controls": ap_cases, "normalized_coefficients": {str(n): str(coefficient(n)) for n in (1, 2, 3, 6)}, "ordinary_multiplicativity_refuted": True, }, sort_keys=True))