audit_finitism.py โ€” src/27-fields

The file src/27-fields/audit_finitism.py of the validation package of the paper 27-fld, rendered with an anchor per line; the file itself is beside this page.

27-fields ledgersrc/27-fields/audit_finitism.py ยท 7.5 KBaudit_finitism.py
1# framed-rational status: EXACT -- integer / modular-F_p / cyclotomic arithmetic; no float in any asserted check (float, if present, only formats an exact rational for display).2"""3Finitism cross-check: the EM-1 / O1 load-bearing claims established in EXACT4arithmetic, with no random sampling, no FFT, no floating point, no transcendental5functions. Each part stands in an exact construct -- integer F_p, cyclotomic Z[i],6or rational -- so no claim depends on a continuum step.78  A. Gauge invariance & superselection -- exact integers, exhaustive over a basis.9  B. Lattice Coulomb Green's function on the L=4 torus -- exact rationals via the10     quarter-turn DFT in Z[i].11  C. O1 admissible-space dimension -- exact integer rank of the integer Gram.12  D. Wilson action -- exact cyclotomic value 1 - Re(zeta_M^F) in Q(zeta_M).13"""14import itertools15from fractions import Fraction as Fr16import numpy as np17import sympy as sp18import enumerate_maxwell as em1920d = 32122# ----------------------------------------------------------------------23# A. gauge invariance & superselection: exact, exhaustive over a basis24# ----------------------------------------------------------------------25def partA(L=4):26    sites = list(itertools.product(range(L), repeat=d))27    sidx = {s: i for i, s in enumerate(sites)}28    def add(x, z): return tuple((x[i] + z[i]) % L for i in range(d))2930    def grad(lam):                       # (d lambda)_mu(x) = lam(x+e_mu)-lam(x)31        A = {}32        for x in sites:33            for mu in range(d):34                e = tuple(1 if k == mu else 0 for k in range(d))35                A[(x, mu)] = lam[add(x, e)] - lam[x]36        return A3738    def plaq(A):                         # F_{mu<nu}(x) over all plaquettes39        F = {}40        for x in sites:41            for mu in range(d):42                for nu in range(mu + 1, d):43                    emu = tuple(1 if k == mu else 0 for k in range(d))44                    enu = tuple(1 if k == nu else 0 for k in range(d))45                    F[(x, mu, nu)] = (A[(x, mu)] + A[(add(x, emu), nu)]46                                      - A[(add(x, enu), mu)] - A[(x, nu)])47        return F4849    # F(d lambda) = 0 for every basis lambda = delta_s  => for ALL lambda (linearity)50    worst = 051    for s in sites:52        lam = {x: (1 if x == s else 0) for x in sites}53        F = plaq(grad(lam))54        worst = max(worst, max(abs(v) for v in F.values()))55    # superselection: gradient of a constant is exactly zero56    lam_const = {x: 7 for x in sites}57    Ac = grad(lam_const)58    const_ok = all(v == 0 for v in Ac.values())59    return worst, const_ok, len(sites)606162# ----------------------------------------------------------------------63# B. Coulomb Green's function on the L=4 torus, EXACT rationals via Z[i] DFT.64#    On L=4 every Laplacian eigenvalue is an integer (cos(2pi k/4) in {1,0,-1,0}),65#    and the modes are 4th roots of unity = the quarter-turn group Q4 = Z[i].66# ----------------------------------------------------------------------67def partB(L=4):68    N = L ** d69    re_i = [1, 0, -1, 0]                  # Re(i^m), m mod 4   (exact integers)70    ks = list(itertools.product(range(L), repeat=d))71    # integer eigenvalues  lambda_k = sum_i 2(1 - Re(i^{k_i}))72    def lam(k): return sum(2 * (1 - re_i[k[i] % 4]) for i in range(d))73    def G(x):                             # exact rational Green's function74        tot = Fr(0)75        for k in ks:76            if all(c == 0 for c in k):    # skip zero mode (neutralising background)77                continue78            kdotx = sum(k[i] * x[i] for i in range(d)) % 479            tot += Fr(re_i[kdotx], lam(k))80        return tot / N81    # exact potential along an axis, and the two-charge interaction energy82    axis = [(n, G((n, 0, 0))) for n in range(L)]83    sep = 184    U_cross = G((sep, 0, 0))              # q1 q2 G(sep), exact rational85    return axis, U_cross868788# ----------------------------------------------------------------------89# C. O1 admissible-space dimension: EXACT integer rank of the integer Gram90#    (integer Gaussian elimination over F_p).91# ----------------------------------------------------------------------92def _rank_mod_p(Aint, p):93    """Exact rank of an integer matrix over the prime field F_p (vectorised, finite)."""94    A = (Aint.astype(np.int64) % p)95    rows, cols = A.shape; r = 096    for c in range(cols):97        nz = np.nonzero(A[r:, c])[0]98        if nz.size == 0:99            continue100        piv = r + int(nz[0])101        A[[r, piv]] = A[[piv, r]]102        inv = pow(int(A[r, c]), p - 2, p)103        A[r] = (A[r] * inv) % p104        f = A[:, c].copy(); f[r] = 0105        A = (A - np.outer(f, A[r])) % p           # eliminate column c in all other rows106        r += 1107        if r == rows:108            break109    return r110111112def partC(L=4, R=1):113    g = em.build(L)114    Qs = em.param_basis(g, R); n = len(Qs)115    # entries are small integers; matmul in float64 is BLAS-fast and exact here116    # (all Gram values are integers well below 2^53), then rounded back to int.117    Qstack = np.array([Q.reshape(-1) for Q in Qs], dtype=np.float64)118    QB = np.array([(Q @ g['B']).reshape(-1) for Q in Qs], dtype=np.float64)119    Gram = QB @ QB.T                              # gauge block120    for fp, fs in zip(g['flatperm'], g['flatsign']):121        D = Qstack[:, fp] * fs - Qstack122        Gram = Gram + D @ D.T                     # + cubic blocks123    Gram = np.rint(Gram).astype(np.int64)         # exact integer Gram124    rk = max(_rank_mod_p(Gram, 2147483647), _rank_mod_p(Gram, 2147483629))125    return n, n - rk                              # (#params, exact nullity)126127128# ----------------------------------------------------------------------129# D. Wilson action is cyclotomic-exact:  1 - cos(2pi F/M) = 1 - Re(zeta_M^F)130#    is an algebraic number in Q(zeta_M), not a transcendental float.131# ----------------------------------------------------------------------132def partD():133    out = []134    for M, F in [(12, 1), (12, 3), (52, 13), (8, 1)]:135        exact = sp.nsimplify(1 - sp.cos(2 * sp.pi * sp.Integer(F) / M))136        flt = float(exact)137        out.append((M, F, sp.simplify(exact), flt))138    return out139140141if __name__ == "__main__":142    print("=" * 70)143    print("FINITISM CROSS-CHECK -- exact verification of EM-1 / O1 claims")144    print("=" * 70)145146    worst, const_ok, ns = partA(L=4)147    print("\n[A] gauge invariance & superselection (exact integers, exhaustive)")148    print(f"    F(d.lambda) over ALL {ns} basis gauge fields: max|F| = {worst}"149          f"   (exact zero: {worst == 0})")150    print(f"    gradient of a constant is identically zero: {const_ok}")151    print("    => no RNG needed; the identities hold for every configuration.")152153    axis, Ucross = partB(L=4)154    print("\n[B] Coulomb Green's function on the L=4 torus (exact rationals, Z[i] DFT)")155    for n, val in axis:156        print(f"    G(n={n},0,0) = {val}   = {float(val):+.6f}")157    print(f"    two unit charges at separation 1: U = {Ucross} = {float(Ucross):.6f}")158    print("    => the Coulomb object is an exact rational; 1/4pi is its large-L reading.")159160    npar, nullity = partC(L=4, R=1)161    print("\n[C] O1 admissible dimension (exact integer rank, no tolerance)")162    print(f"    range-1 parameters = {npar},  exact nullity = {nullity}"163          f"   (matches the float SVD value 2: {nullity == 2})")164165    print("\n[D] Wilson action is cyclotomic-exact: 1 - cos(2pi F/M) in Q(zeta_M)")166    for M, F, exact, flt in partD():167        print(f"    M={M:3d} F={F}: 1-cos(2pi F/M) = {exact}  = {flt:.6f}")168    print("    => the action is an algebraic (cyclotomic) number, not a float.")169    print("=" * 70)170