framed_koide.py — src/28-flavour

The file src/28-flavour/framed_koide.py of the validation package of the paper 28-flav, rendered with an anchor per line; the file itself is beside this page.

28-flavour ledgersrc/28-flavour/framed_koide.py · 3.6 KBframed_koide.py
1#!/usr/bin/env python32# -*- coding: utf-8 -*-3"""4Koide over FRAMED RATIONALS (1-algebra), the most native FRC arena.5Not cyclotomic Q(omega,sqrt2) -- that is one continuum rung up -- but the finite field6F_p with a frame, where every residue is a framed rational r/s of bounded height, the7cube root omega lives in K=F_{p^2}, Frobenius sigma is the native conjugation, and the8'quarter-turn sqrt2 amplitude' is natively the framed RATIONAL N(b)/a^2 = 1/2 (a norm9condition), no irrational needed.  Q = 2/3 is then an exact identity in F_p.10"""11from math import isqrt1213def ratrecon(x, p):14    """canonical framed rational r/s ≡ x (mod p), |r|,|s| <~ sqrt(p/2)."""15    x %= p; bound = isqrt(p//2)16    r0,r1 = p, x; s0,s1 = 0,117    while r1 > bound:18        q = r0//r119        r0,r1 = r1, r0-q*r120        s0,s1 = s1, s0-q*s121    r,s = r1,s122    if s < 0: r,s = -r,-s23    return (r,s)24def fr(x,p):25    r,s = ratrecon(x,p); return f"{r}" if s==1 else f"{r}/{s}"2627def run(p):28    assert p%12==529    # non-residue n for K=F_{p^2}=F_p[t]/(t^2-n); Frobenius sigma: t->-t (native conjugation)30    n = next(m for m in range(2,p) if pow(m,(p-1)//2,p)==p-1)31    def mul(A,B):                       # (u,v) = u+v t32        (a,b),(c,d)=A,B33        return ((a*c+b*d*n)%p,(a*d+b*c)%p)34    def conj(A): return (A[0],(-A[1])%p)          # sigma = Frobenius35    def norm(A): return (A[0]*A[0]-n*A[1]*A[1])%p  # N(b)=b sigma(b) in F_p36    def order(A):37        o=1;X=A38        while X!=(1,0): X=mul(X,A);o+=139        return o40    # cube root omega in K (order 3; exists since 3 | p+1)41    omega=None42    for u in range(p):43        for v in range(1,p):44            if order((u,v))==3: omega=(u,v); break45        if omega: break46    inv=lambda z: pow(z,p-2,p)47    # choose a in F_p, and b in K with N(b) = a^2 * (1/2)  == the quarter-turn condition48    a=1; target=(a*a*inv(2))%p49    b=None50    for u in range(p):51        for v in range(p):52            if norm((u,v))==target and (u,v)!=(0,0): b=(u,v); break53        if b: break54    # circulant amplitude eigenvalues  lambda_k = a + b omega^k + conj(b) omega^{2k}  in F_p55    A=(a,0)56    lam=[]57    for k in range(3):58        wk=(1,0)59        for _ in range(k): wk=mul(wk,omega)60        w2k=mul(wk,wk)61        val=( (A[0]+mul(b,wk)[0]+mul(conj(b),w2k)[0])%p ,62              (A[1]+mul(b,wk)[1]+mul(conj(b),w2k)[1])%p )63        lam.append(val)64    inF_p = all(L[1]==0 for L in lam)              # eigenvalues are framed rationals in F_p65    l=[L[0] for L in lam]66    Slam=sum(l)%p67    Slam2=sum((x*x)%p for x in l)%p68    Q=(Slam2*inv((Slam*Slam)%p))%p                 # Q = sum(lambda^2)/(sum lambda)^269    Qrat=fr(Q,p); twothirds=(2*inv(3))%p70    print(f"  p={p}  (K=F_{{{p}^2}}, t^2={n}, Frobenius t->-t)")71    print(f"    omega (cube root, order 3) = {omega} = {fr(omega[0],p)} + {fr(omega[1],p)} t")72    print(f"    a = {fr(a,p)} ;  b = ({fr(b[0],p)}) + ({fr(b[1],p)}) t ;  "73          f"N(b)/a^2 = {fr(norm(b)*inv(a*a)%p,p)}  (= 1/2, the quarter-turn, a RATIONAL)")74    print(f"    sqrt-mass eigenvalues (framed rationals in F_p): "75          f"{', '.join(fr(x,p) for x in l)}   in F_p: {inF_p}")76    print(f"    Q = sum(lam^2)/(sum lam)^2 = {Q}  =  {Qrat}   (2/3 = {twothirds}): "77          f"{'EXACT 2/3' if Q==twothirds else 'NO'}")78    return Q==twothirds and inF_p7980print("Koide over framed rationals (F_{p^2}/F_p, Frobenius conjugation), no cyclotomics:")81ok=all(run(p) for p in [17,53,89])82print(f"\n  ALL shells: Q = 2/3 exact over framed rationals  ->  {ok}")83print("  the 'sqrt2 amplitude' is the framed rational N(b)/a^2 = 1/2 ; sqrt2 is its")84print("  continuum reading.  omega is the finite cube root, not zeta_3 in C.")85