The script src/22-quantum/gravfraction.py of the validation package of the paper 22-qm, rendered with an anchor per line. ▶ run the predicates on Google Colab.
1#!/usr/bin/env python32"""22-quantum gravfraction suite: the coherent-fraction channel law (prop:fcoh), EXACT.3Cells on C_16 (ledger Z[zeta_16] as integer coordinate vectors, zeta^8 = -1).4(F1) coherent sector: m_c synchronised cells give branch-differential phase zeta^{m_c a}5 exactly (amplitudes multiply), for m_c in {2,3,4} and every unit phase a;6(F2) offset-spread sector: the systematic branch phase over a complete offset sector7 vanishes by the complete character sum (nontrivial per-cell phase);8(F3) pairwise product: two clusters give phi_ent = (m_c1 * m_c2) * a exactly;9(F4) the envelope: |offset-sector character sum|^2 computed exactly, < m^2 (strict10 coherent/incoherent separation), = m^2 iff synchronised.11No floats, no RNG."""1213def rep(label, ok):14 print(('PASS ' if ok else 'FAIL ') + label); assert ok, label1516n = 1617def zmul(a, b): # Z[zeta_16], zeta^8 = -1; vectors length 818 res = [0]*1519 for i, x in enumerate(a):20 for j, y in enumerate(b):21 res[i+j] += x*y22 for k in range(14, 7, -1):23 res[k-8] -= res[k]; res[k] = 024 return res[:8]25def zpow_unit(e): # zeta^e as vector26 e %= 1627 v = [0]*828 if e < 8: v[e] = 129 else: v[e-8] = -130 return v31def zadd(a,b): return [x+y for x,y in zip(a,b)]32def zscale(a,c): return [c*x for x in a]33def conj(a): # zeta -> zeta^-1 = -zeta^734 r = [0]*835 for e,x in enumerate(a):36 if x:37 v = zpow_unit((-e) % 16)38 r = zadd(r, zscale(v, x))39 return r40def norm2(a):41 m = zmul(a, conj(a))42 return m4344# F1/F3: coherent products45ok1 = ok3 = True46for a in range(1, 16):47 for mc in (2, 3, 4):48 prod = [1]+[0]*749 for _ in range(mc):50 prod = zmul(prod, zpow_unit(a))51 if prod != zpow_unit(mc*a): ok1 = False52 for mc1 in (2,3):53 for mc2 in (2,4):54 prod = [1]+[0]*755 for _ in range(mc1*mc2):56 prod = zmul(prod, zpow_unit(a))57 if prod != zpow_unit(mc1*mc2*a): ok3 = False58rep('F1: synchronised branch phase = zeta^{m_c a} exactly, m_c in {2,3,4}, all a', ok1)59rep('F3: pairwise entangling phase = zeta^{m_c1 m_c2 a} exactly', ok3)6061# F2: complete offset sector: sum over offsets s of zeta^{a s} = 0 for a != 062ok2 = True63for a in range(1, 16):64 tot = [0]*865 for sft in range(16):66 tot = zadd(tot, zpow_unit(a*sft))67 if any(tot): ok2 = False68rep('F2: offset-spread systematic branch phase vanishes (complete character sum), all a != 0', ok2)6970# F4: envelope strictly below coherent for a genuine spread; equality iff synchronised71m = 472sync = [0,0,0,0] # all same offset73spread = [0,4,8,12] # complete C_4 spread inside C_1674def sector_sum(offsets, a):75 tot = [0]*876 for sft in offsets:77 tot = zadd(tot, zpow_unit(a*sft))78 return tot79a = 180s_sync = sector_sum(sync, a); n_sync = norm2(s_sync)81s_spr = sector_sum(spread, a); n_spr = norm2(s_spr)82rep('F4: |sync sum|^2 = m^2 = 16 exactly; complete spread sum = 0',83 n_sync == [16]+[0]*7 and all(x == 0 for x in s_spr))8485# F5: the reduced channel Gamma = chi_inc * zeta^{m_c a}: per fixed offset configuration86# the branch factor is zeta^{m_c a} * prod(offset-rotated); ensemble average over the87# spread sector factorises exactly: avg_config(branch) = zeta^{m_c a} * avg(spread factors)88a = 3; mc = 289spread_offsets = [0, 4, 8, 12] # complete C_4 spread: chi_inc = 090partial = [0, 0, 4, 8] # nonuniform thermal-like distribution91def ensemble_avg(offsets_list, a, mc):92 tot = [0]*893 for sft in offsets_list:94 term = zmul(zpow_unit(mc*a), zpow_unit(a*sft))95 tot = zadd(tot, term)96 return tot97lhs = ensemble_avg(spread_offsets, a, mc)98chi = sector_sum(spread_offsets, a) # = 0 here99rhs = zmul(zpow_unit(mc*a), chi)100rep('F5: Gamma factorises exactly: ensemble avg = zeta^{m_c a} * chi_inc (complete spread: both zero)',101 lhs == rhs)102# F6: nonuniform thermal distribution: 0 < |chi_inc|^2 < m^2, factorisation still exact103lhs2 = ensemble_avg(partial, a, mc)104chi2 = sector_sum(partial, a)105rhs2 = zmul(zpow_unit(mc*a), chi2)106n2 = norm2(chi2)107rep('F6: nonuniform thermal chi_inc: factorisation exact and 0 < |chi|^2 < m^2 (|chi|^2 coords %s)' % n2,108 lhs2 == rhs2 and any(x != 0 for x in n2) and n2 != [16]+[0]*7)109110# F7: the mixed complementarity identity, exact in the ring: with 4C^2 = (1-G)(1-Gbar),111# 4V^2 = (1+G)(1+Gbar): V^2 + C^2 = (1 + |G|^2)/2 identically; pure |G|=1 gives 1.112def comp_check(Gvec):113 one = [1]+[0]*7114 Gc = conj(Gvec)115 m1 = zmul(zadd(one, zscale(Gvec,-1)), zadd(one, zscale(Gc,-1))) # (1-G)(1-Gbar) = 4C^2116 m2 = zmul(zadd(one, Gvec), zadd(one, Gc)) # (1+G)(1+Gbar) = 4V^2117 lhs = zadd(m1, m2) # 4(V^2+C^2)118 n2 = zmul(Gvec, Gc) # |G|^2119 rhs = zadd(zscale(one,2), zscale(n2,2)) # 2(1+|G|^2)120 return lhs == rhs121ok7 = all(comp_check(zpow_unit(e)) for e in range(16)) # pure instances |G|=1122half = [0]*8; half[0] = 1 # G = 1 (trivial) covered; a mixed instance: G = (1+zeta)/2 not integer-ring; use G = zeta + zeta^-1 form scaled? keep ring: G = zeta^a + zeta^b (|G|<2 mixed, ring element)123mixed = zadd(zpow_unit(1), zpow_unit(6))124ok7b = comp_check(mixed)125rep('F7: 4(V^2+C^2) = 2(1+|Gamma|^2) as a ring identity (all pure phases + a mixed ring instance)',126 ok7 and ok7b)127# F8: pure-limit concurrence: 4C^2 = (1-zeta^e)(1-zeta^-e) = 2 - (zeta^e + zeta^-e): two-way, exact128e = 3129one = [1]+[0]*7130m1 = zmul(zadd(one, zscale(zpow_unit(e),-1)), zadd(one, zscale(zpow_unit(-e),-1)))131expect = zadd(zscale(one,2), zscale(zadd(zpow_unit(e), zpow_unit(-e)), -1))132rep('F8: pure-channel 4C^2 = 2 - (zeta^e + zeta^-e) exactly (the sin^2 chart reading)', m1 == expect)133134# F9: reciprocal channel: complete spread -> every cross-branch coherence is a complete135# character sum -> zero -> rho diagonal -> separable (C = 0). Branch pairs (b,b') with136# distinct branches have spread-differential running over the complete sector.137ok9 = True138for diff_a in range(1, 16): # spread-phase differential rate for a branch pair139 tot = [0]*8140 for sft in range(16): # complete offset sector141 tot = zadd(tot, zpow_unit(diff_a*sft))142 if any(tot): ok9 = False143rep('F9: complete spread kills every cross-branch coherence (rho diagonal, separable, C = 0 at f=0)', ok9)144# F10: exact PPT separability instance (sympy) on the reciprocal-channel state at a rational145# damping: rho = mixture of 4-branch pure states with coherences G on all off-diagonals of the146# |b> basis and systematic phase zero; at G real in [0,1], rho = G*P_{|s>} + (1-G)*I/4-diag mix.147# (PPT is necessary and sufficient in 2x2; Wootters concurrence is not evaluated here.)148from sympy import Matrix, Rational, sqrt as ssqrt149G = Rational(1, 2)150one = Rational(1, 4)151rho = Matrix(4, 4, lambda a, b: one if a == b else one*G)152# rho = (G)*|s><s| + (1-G)*I/4 with |s> = uniform: separable Werner-like diagonal-coherent state153rho_tilde = Matrix(4, 4, lambda a, b: rho[3-a, 3-b].conjugate()) # sigma_y x sigma_y conj in this basis154# For this fully-symmetric real state, concurrence is 0 (it is a mixture of a product pure state155# |+>|+> and the maximally mixed state): verify separability witness = PPT (2x2x... partial transpose)156rho_pt = Matrix(4, 4, lambda a, b: rho[(a//2)*2 + b%2, (b//2)*2 + a%2]) # partial transpose on qubit B157eigs = rho_pt.eigenvals()158ok10 = all(ev >= 0 for ev in eigs)159rep('F10: symmetric damped state (systematic phase 0, G = 1/2) is PPT hence separable (C = 0), exact', ok10)160161# F11: geometry-generated degeneracy classification at complete spread (round-06-2 repair,162# prop:fcoh(v)). Spread phases phi_b(E) = E*theta_b (rate-mismatch reading) with theta_b the163# joint branch phases; complete spread over E in Z_n gives chi_{b,b'} = [theta_b == theta_b'164# mod n] exactly (complete character sums), so rho = (1/4) * partition matrix of the branch165# partition by theta value. ALL 15 set partitions of the four branches (LL,LR,RL,RR) are166# enumerated: the state is NPT (entangled) exactly for partitions containing a block of size167# THREE (the reviewer's counterexample class, min PT eigenvalue exactly (1-sqrt3)/4); every168# other partition is PPT, min eigenvalue exactly 0 or diagonal. Every theta vector maps to a169# partition, so the enumeration is exhaustive over the channel's complete-spread states.170from sympy import sqrt as _ssqrt171from itertools import product as _prod172def rho_partition(labels):173 q = Rational(1, 4)174 return Matrix(4, 4, lambda a, b: q if labels[a] == labels[b] else 0)175def ppt_min_exact(r):176 rpt = Matrix(4, 4, lambda a, b: r[(a//2)*2 + b % 2, (b//2)*2 + a % 2])177 return min(rpt.eigenvals())178def canon_partition(labels):179 seen = {}180 out = []181 for x in labels:182 if x not in seen: seen[x] = len(seen)183 out.append(seen[x])184 return tuple(out)185all_partitions = sorted(set(canon_partition(l) for l in _prod(range(4), repeat=4)))186ok11 = len(all_partitions) == 15187target = (1 - _ssqrt(3))/4188for lab in all_partitions:189 sizes = sorted([lab.count(v) for v in set(lab)], reverse=True)190 m = ppt_min_exact(rho_partition(lab))191 if 3 in sizes:192 if not (m == target or (m - target).simplify() == 0): ok11 = False # exact NPT value193 else:194 if m < 0: ok11 = False # PPT195rep('F11: complete-spread states classified over all 15 branch partitions: NPT exactly at '196 'size-3 blocks (min PT eig = (1-sqrt3)/4 exactly, the counterexample class); all other '197 'partitions PPT (separable)', ok11)198199# F12: the local-additivity theorem and its scope. If the spread phase is locally additive,200# theta_xy = a_x + b_y, every Kraus factor is a product unitary up to global phase, so the201# channel is a mixture of local unitaries and never entangles. Verified structurally: the202# branch partitions ACHIEVABLE by additive theta (level sets of a_x + b_y over Z_n, n<=6)203# never contain a size-3 block -- LL==LR forces b_L==b_R hence RL==RR -- and every achievable204# partition's state is PPT. The entangling size-3 partitions are exactly the non-additive205# (joint spread character) geometries, e.g. theta = (0,0,0,1): r_LL = r_LR = r_RL != r_RR.206achievable = set()207for n in range(2, 7):208 for aL, aR, bL, bR in _prod(range(n), repeat=4):209 th = ((aL+bL) % n, (aL+bR) % n, (aR+bL) % n, (aR+bR) % n)210 achievable.add(canon_partition(th))211ok12 = all(3 not in [lab.count(v) for v in set(lab)] for lab in achievable)212ok12 = ok12 and all(ppt_min_exact(rho_partition(lab)) >= 0 for lab in achievable)213ok12 = ok12 and canon_partition((0, 0, 0, 1)) not in achievable214rep('F12: locally additive spread phases never produce size-3 blocks (LL=LR forces RL=RR) and '215 'every additive partition is PPT; the entangling class is exactly non-additive joint '216 'geometry (theta = (0,0,0,1) not additively achievable)', ok12)217print('gravfraction: all checks passed')218