#!/usr/bin/env python3 """Independent mathematical checks for the OMEGA handoff. Python 3.11+; standard library only. No files are written. Run: python verify_handoff.py Also run: python -O verify_handoff.py This does not audit the separately reported Grok 0.2 files. """ from collections import Counter from fractions import Fraction as F from math import gcd, isqrt Q, S = 339949771344778, 10**15 A, DMAX, DSTAR = 3*Q-S, 32767, 42189065 P = Q // gcd(Q, S) def require(ok, label): if not ok: raise ValueError(label) def T(d): return Q*d // S def L(n): return (S*n+Q-1) // Q def size(n): return L(n+1)-L(n) def law(n): r = n*S % Q return 2 if 0 < r <= A else 3 def nk(k): return (k*Q+A-1)//A-1 def orbit(d): states, residues = [d], [] while d: nxt, rho = divmod(Q*d, S) require(nxt < d, 'strict descent') states.append(nxt) residues.append(rho) d = nxt return states, residues def floor_sum(n, m, a, b): total = 0 while True: qa, a = divmod(a, m) qb, b = divmod(b, m) total += qa*n*(n-1)//2 + qb*n k, r = divmod(a*n+b, m) if k == 0: return total n, m, a, b = k, a, m, r def atan_bounds(b): lower = sum((F((-1)**j, (2*j+1)*b**(2*j+1)) for j in range(64)), F(0)) return lower, lower+F(1, 129*b**129) def main(): require(gcd(Q,S)==2 and 2*Q