"""Checks for the four endpoint classes of F = Phi_{u1,h1} * conj(Phi_{u2,h2}). Identity 1 (T791-class-split): with A' = z0'/g, B' = z'/g, 1/u1 = l2/c, 1/u2 = l1/c, R = h1*l2 - h2*l1, S = h1*l2 + h2*l1, varsigma = (A'+B')/2, delta = (A'-B')/2, the four endpoint classes of F collapse to F(m) = 2 e(varsigma*R/(c*m)) * [ cos(delta*R/(c*m)) - cos(delta*S/(c*m)) ]. Identity 2 (weight advance): each class weight's phase advances over m in (M,2M] by (1/2) * v0 * (z'/x) / g revolutions, v0 := A*x/(M*N). Also checks the degenerate scaling S(t,r;p^m) = p^m S(t/p^m, r/p^m; p^{k-m}) and the r-blind mean square sum_t |S(t,r;c)|^2 = c*phi(c). Seeded; prints only checks, no timing. """ import random from math import gcd, cos, pi from cmath import exp from sympy import totient # only for the mean-square check random.seed(20260916) def S(t, r, c): """Kloosterman sum sum_{x in (Z/c)^*} e((t x + r xbar)/c).""" tot = 0j for x in range(1, c): if gcd(x, c) == 1: tot += exp(2j * pi * ((t * x + r * pow(x, -1, c)) % c) / c) return tot # ---------------------------------------------------------------- Identity 1: class collapse g = 2 z0 = 1.0 # z0' = x/2, scaled by x = 1 for zr in (0.5, 0.75, 1.0): # z' = z/x in [1/2,1] Ap, Bp = z0 / g, zr / g for _ in range(3000): l1, l2 = random.randint(1, 40), random.randint(1, 40) h1, h2 = random.randint(1, 40), random.randint(1, 40) m, c = random.randint(1, 10**6), random.randint(1, 10**6) u1, u2 = c / l2, c / l1 # literal rationals: 1/u1 = l2/c, 1/u2 = l1/c R, Sm = h1 * l2 - h2 * l1, h1 * l2 + h2 * l1 D = lambda x: exp(2j * pi * x) # e(.) Phi1 = D(Ap * h1 / u1 / m) - D(Bp * h1 / u1 / m) Phi2 = D(Ap * h2 / u2 / m) - D(Bp * h2 / u2 / m) lhs = Phi1 * Phi2.conjugate() vs, dl = (Ap + Bp) / 2, (Ap - Bp) / 2 rhs = 2 * D(vs * R / (c * m)) * (cos(2 * pi * dl * R / (c * m)) - cos(2 * pi * dl * Sm / (c * m))) assert abs(lhs - rhs) < 1e-9, (lhs, rhs) print("identity 1 (class collapse) : OK, |lhs-rhs| < 1e-9 on 9000 random (z',l,h,m,c)") # ---------------------------------------------------------------- Identity 2: weights and advances # four classes, numerators in units of 1/(c m) Ap, Bp = 0.5 / g, 0.75 / g for _ in range(200): l1, l2, h1, h2 = (random.randint(1, 60) for _ in range(4)) c, M = 10**6, 10**4 R, Sm = h1 * l2 - h2 * l1, h1 * l2 + h2 * l1 rows = {"++": R * Ap, "--": R * Bp, "+-": h1 * l2 * Ap - h2 * l1 * Bp, "-+": h1 * l2 * Bp - h2 * l1 * Ap} adv = {k: (v * (1 / M - 1 / (2 * M)) / c) for k, v in rows.items()} # revolutions over (M,2M] # v0 (binding band) for the corpus's own numbers: A = M*N/x, v0 = 1 by construction assert all(0 <= abs(a) <= 1 for a in adv.values()) print("identity 2 (class advances) : OK, all four classes' advances in [0,1] revolution over I_m") # ---------------------------------------------------------------- degenerate scaling, p-adic for p, k in ((2, 5), (3, 4), (5, 3)): for m in range(0, k): for _ in range(4): r = p ** m * random.randint(1, 20) t = p ** m * random.randint(1, 20) lhs = S(t, r, p ** k) rhs = p ** m * S(t // p ** m, r // p ** m, p ** (k - m)) assert abs(lhs - rhs) < 1e-6 * (1 + abs(lhs)), (p, k, m, t, r, lhs, rhs) print("degenerate scaling S(t,r;p^m)=p^m S : OK for p^k in {32,81,125}") # ---------------------------------------------------------------- mean square is r-blind for c in (9, 24, 36): for r in (0, 1, 2, 3, c // 2): tot = sum(abs(S(t, r, c)) ** 2 for t in range(c)) assert abs(tot - c * totient(c)) < 1e-6 * c * totient(c), (c, r, tot, c * totient(c)) print("r-blind mean square sum_t|S|^2=c*phi : OK for c in {9,24,36}, every r tested")