The script src/22-quantum/validate.py of the validation package of the paper 22-qm, rendered with an anchor per line. ▶ run the predicates on Google Colab.
1## Exact arithmetic validation for "Quantum Observation in Finite Ring Continuum"2## Self-contained; integers only. Reproduces every numbered claim of the paper.3from math import gcd, lcm45def order(a, p):6 x, k = 1, 07 while True:8 x, k = (x * a) % p, k + 19 if x == 1:10 return k1112def report(label, ok):13 print(('PASS ' if ok else 'FAIL ') + label)14 assert ok, label1516# ---------- Z[i] ledger arithmetic (exact Gaussian integers) ----------17def gm(z, w): return (z[0]*w[0] - z[1]*w[1], z[0]*w[1] + z[1]*w[0])18def ga(z, w): return (z[0]+w[0], z[1]+w[1])19def gc(z): return (z[0], -z[1])20def gnorm(z): return z[0]*z[0] + z[1]*z[1]21I4 = [(1,0), (0,1), (-1,0), (0,-1)] # i^l in Z[i]2223# ---------- Z[zeta_12] ledger (polys mod x^4 - x^2 + 1) ----------24def zmul(a, b):25 c = [0]*1626 for i, ai in enumerate(a):27 if ai:28 for j, bj in enumerate(b):29 c[i+j] += ai*bj30 for k in range(15, 3, -1):31 if c[k]:32 c[k-2] += c[k]; c[k-4] -= c[k]; c[k] = 033 return c[:4]34Z12 = {0: [1,0,0,0]}35for k in range(1, 12):36 Z12[k] = zmul(Z12[k-1], [0,1,0,0])3738def shell(p, e, nS, nO):39 N = p - 140 gS, gO = pow(e, N//nS, p), pow(e, N//nO, p)41 d = gcd(nS, nO)42 HS = {pow(gS, j, p) for j in range(nS)}43 HO = [pow(gO, j, p) for j in range(nO)]44 core = sorted(HS.intersection(HO))45 return N, gS, gO, d, HS, HO, core4647# ===================== Carrier F_157, Subject 53, Object 13 =====================48p, e, nS, nO = 157, 5, 52, 1249N, gS, gO, d, HS, HO, core = shell(p, e, nS, nO)50ip = pow(e, N//4, p) # oriented core element51report('157: g=5 primitive', order(e, p) == N)52report('157: core = {1,28,129,156}, |core| = 4 = gcd(52,12)',53 core == [1, 28, 129, 156] and d == 4)54report('157: orientation I = g^{-39} = 28, I^2 = -1',55 pow(e, N - 39, p) == 28 and pow(28, 2, p) == p - 1)56report('157: joint span lcm(52,12) = 156', lcm(nS, nO) == N)5758# Fibres: cosets of Q4 in Phi_O; h_alpha = gO^alpha, alpha = 0,1,259fib = {a: [pow(gO, a + 3*l, p) for l in range(4)] for a in range(3)}60report('157: three fibres partition Phi_O',61 sorted(sum(fib.values(), [])) == sorted(HO))6263# Selection rule A(r,s) = 4*[r=s mod 4] over all 52x12 channel pairs64ok = True65for r in range(nS):66 for s in range(nO):67 A = sum(pow(e, ((N//4) * (s - r) * l) % N, p) for l in range(4)) % p68 if A != (4 if (r - s) % 4 == 0 else 0):69 ok = False70report('157: selection rule A(r,s) over all 52x12 channels', ok)7172# Proposition (stationary states): psi_s(u) = u^s, drive u -> gO*u73report('157: drive eigenstates U psi_s = gO^s psi_s, all s',74 all(all(pow((gO*u) % p, s, p) == (pow(gO, s, p)*pow(u, s, p)) % p75 for u in HO) for s in range(nO)))7677# Measurement vectors v_{r,a} in the Z[i] ledger; random Gaussian-integer state78psi = {u: ((i % 13) - 6, (i % 11) - 5) for i, u in enumerate(HO)} # fixed state, no RNG79red = lambda z: (z[0] + ip * z[1]) % p # Z[i] -> F_p, i -> 2880psip = {u: red(z) for u, z in psi.items()}8182def v(r, a):83 w = {u: (0, 0) for u in HO}84 for l in range(4):85 w[pow(gO, a + 3*l, p)] = I4[(r*l) % 4]86 return w87def pair(x, y):88 s = (0, 0)89 for u in HO:90 s = ga(s, gm(gc(x[u]), y[u]))91 return s92def amp(r, a):93 s = (0, 0)94 for l in range(4):95 s = ga(s, gm(gc(I4[(r*l) % 4]), psi[pow(gO, a + 3*l, p)]))96 return s97def amp_fp(r, a):98 s = 099 for l in range(4):100 k = pow(ip, l, p)101 s = (s + pow(k, (4 - r) % 4, p) * psip[pow(gO, a + 3*l, p)]) % p102 return s103104report('157: basis orthogonality <v,v> = 4*delta*delta',105 all(pair(v(r, a), v(r2, a2)) == ((4, 0) if (r, a) == (r2, a2) else (0, 0))106 for r in range(4) for a in range(3)107 for r2 in range(4) for a2 in range(3)))108lhs = sum(gnorm(amp(r, a)) for r in range(4) for a in range(3))109rhs = 4 * sum(gnorm(z) for z in psi.values())110report('157: Parseval sum |Psi|^2 = 4*||psi||^2 (%d = %d)' % (lhs, rhs), lhs == rhs)111report('157: ledger reduction commutes, Z[i] -> F_157 on all channels',112 all(red(amp(r, a)) == amp_fp(r, a) for r in range(4) for a in range(3)))113114def proj(r, a, phi):115 A = (0, 0); vv = v(r, a)116 for l in range(4):117 u = pow(gO, a + 3*l, p)118 A = ga(A, gm(gc(vv[u]), phi[u]))119 return {u: gm(vv[u], A) for u in HO}120phi1 = proj(2, 1, psi); phi2 = proj(2, 1, phi1)121report('157: Lueders idempotence Pi^2 = 4*Pi',122 all(phi2[u] == gm((4, 0), phi1[u]) for u in HO))123124# Z[zeta_12] ledger selection rule and its reduction (zeta -> gO = 22)125okL, okR = True, True126for s in range(12):127 for r in range(4):128 for a in range(3):129 S = [0, 0, 0, 0]130 for l in range(4):131 t = zmul(Z12[(s*(a + 3*l)) % 12], Z12[(-3*r*l) % 12])132 S = [S[i] + t[i] for i in range(4)]133 tgt = [4*x for x in Z12[(s*a) % 12]] if (s - r) % 4 == 0 else [0]*4134 if S != tgt:135 okL = False136 Sp = sum(c * pow(gO, k, p) for k, c in enumerate(S)) % p137 Tp = (4 * pow(gO, s*a, p)) % p if (s - r) % 4 == 0 else 0138 if Sp != Tp:139 okR = False140report('157: ledger selection rule Psi = 4*zeta^{s a} iff r = s mod 4', okL)141report('157: ledger reduction matches carrier amplitudes (zeta -> 22)', okR)142143# ===================== Carrier F_421: two regimes =====================144p2, e2 = 421, 2145N2 = p2 - 1146report('421: g=2 primitive', order(e2, p2) == N2)147# quantum pair: Subject 61 (C60) reads Object 29 (C28)148_, _, gO2, d2, HS2, HO2, core2 = shell(p2, e2, 60, 28)149report('421: quantum pair core = {1,29,392,420}, gcd = 4, lcm = 420',150 core2 == [1, 29, 392, 420] and d2 == 4 and lcm(60, 28) == 420)151report('421: orientation I = g^{-105} = 2^{-105} = 392, I^2 = -1',152 pow(e2, N2 - 105, p2) == 392 and pow(392, 2, p2) == p2 - 1)153ok = True154for r in range(60):155 for s in range(28):156 A = sum(pow(e2, (105 * (s - r) * l) % N2, p2) for l in range(4)) % p2157 if A != (4 if (r - s) % 4 == 0 else 0):158 ok = False159report('421: selection rule over all 60x28 channels', ok)160report('421: seven outcomes C28/Q4 = C7', 28 // d2 == 7)161# classical pair: Subject 61 (C60) absorbs Object 13 (C12)162_, _, _, d3, HS3, HO3, core3 = shell(p2, e2, 60, 12)163report('421: classical pair gcd(60,12) = 12: total absorption, C1',164 d3 == 12 and set(HO3) <= HS3 and 12 // d3 == 1)165166print('all checks passed')167