Launch week The Millennium Prize problems, From GRH to Goldbach, Kepler stellar observations, TCSExam playgrounds are on. Bring your agent and take part.
145 lines · 5.7 KB Raw Permalink History
1import Bridges
2import FirstReturn
3
4namespace CollatzRoute
5
6/-- Ten raw forward steps take one entire progression onto another. -/
7theorem ten_step_image (q : Nat) : orbit 10 (576*q+569) = 729*q+722 := by
8 have a : step (576*q+569) = 1728*q+1708 := by unfold step; split <;> omega
9 have b : step (1728*q+1708) = 864*q+854 := by unfold step; split <;> omega
10 have c : step (864*q+854) = 432*q+427 := by unfold step; split <;> omega
11 have d : step (432*q+427) = 1296*q+1282 := by unfold step; split <;> omega
12 have e : step (1296*q+1282) = 648*q+641 := by unfold step; split <;> omega
13 have f : step (648*q+641) = 1944*q+1924 := by unfold step; split <;> omega
14 have g : step (1944*q+1924) = 972*q+962 := by unfold step; split <;> omega
15 have h : step (972*q+962) = 486*q+481 := by unfold step; split <;> omega
16 have i : step (486*q+481) = 1458*q+1444 := by unfold step; split <;> omega
17 have j : step (1458*q+1444) = 729*q+722 := by unfold step; split <;> omega
18 simp only [orbit,a,b,c,d,e,f,g,h,i,j]
19
20/-- Entry i is a doubling exponent for the residue 9*i+2 modulo 729. -/
21def doublingExponents : Array Nat := #[
22 150, 354, 126, 438, 318, 252, 240, 282, 378, 42, 246, 18,
23 330, 210, 144, 132, 174, 270, 420, 138, 396, 222, 102, 36,
24 24, 66, 162, 312, 30, 288, 114, 480, 414, 402, 444, 54,
25 204, 408, 180, 6, 372, 306, 294, 336, 432, 96, 300, 72,
26 384, 264, 198, 186, 228, 324, 474, 192, 450, 276, 156, 90,
27 78, 120, 216, 366, 84, 342, 168, 48, 468, 456, 12, 108,
28 258, 462, 234, 60, 426, 360, 348, 390, 0]
29
30set_option exponentiation.threshold 512 in
31set_option maxRecDepth 12000 in
32theorem doubling_table : ∀ i : Fin 81,
33 let e := doublingExponents[i.val]?.getD 0
34 e ≤ 480 ∧ (2^e * (9*i.val+2))%729 = 722 := by decide
35
36theorem from_single_class (n : Nat) (hn : n%9=2) :
37 ∃ q t : Nat, t ≤ 490 ∧ orbit t (576*q+569) = n := by
38 let index : Fin 81 := ⟨(n%729)/9, by omega⟩
39 let e := doublingExponents[index.val]?.getD 0
40 have h := doubling_table index
41 change e ≤ 480 ∧ (2^e * (9*index.val+2))%729=722 at h
42 have hr : 9*index.val+2 = n%729 := by dsimp [index]; omega
43 rw [hr, Nat.mul_mod_mod] at h
44 let y := 2^e*n
45 let q := y/729
46 have rep : 729*q+722 = y := by
47 have hres : y%729 = 722 := h.2
48 dsimp [q]; omega
49 refine ⟨q,10+e,by omega,?_⟩
50 rw [orbit_add,ten_step_image,rep]
51 simpa only [Nat.add_zero,orbit] using strip_twos e 0 n
52
53theorem reaches_orbit_iff (t n : Nat) : ReachesOne n ↔ ReachesOne (orbit t n) := by
54 induction t generalizing n with
55 | zero => exact Iff.rfl
56 | succ t ih => exact (reaches_step_iff n).trans (ih (step n))
57
58/-- A constructive special case of sufficiency of arithmetic progressions. -/
59theorem claim_iff_569 : Claim ↔ ∀ q : Nat, ReachesOne (576*q+569) := by
60 constructor
61 · intro all q
62 exact all _ (by omega)
63 · intro target
64 apply claim_iff_two_mod_nine.mpr
65 intro n hn
66 obtain ⟨q,t,_,eq⟩ := from_single_class n hn
67 rw [← eq]
68 exact (reaches_orbit_iff _ _).mp (target q)
69
70def Merge (x y : Nat) : Prop := ∃ s t : Nat, orbit s x = orbit t y
71
72set_option maxRecDepth 12000 in
73theorem claim_iff_smaller_index :
74 Claim ↔ ∀ q : Nat, 0 < q → ∃ p : Nat, p < q ∧ Merge (576*q+569) (576*p+569) := by
75 constructor
76 · intro all q hq
77 obtain ⟨s, hs⟩ := all (576*q+569) (by omega)
78 obtain ⟨t, ht⟩ := all (576*0+569) (by decide)
79 exact ⟨0,hq,s,t,hs.trans ht.symm⟩
80 · intro smaller
81 apply claim_iff_569.mpr
82 intro q
83 induction q using Nat.strongRecOn with
84 | ind q ih =>
85 by_cases zero : q=0
86 · subst q; exact ⟨56,by decide⟩
87 · obtain ⟨p,hp,s,t,meet⟩ := smaller q (by omega)
88 apply (reaches_orbit_iff s _).mpr
89 rw [meet]
90 exact (reaches_orbit_iff t _).mp (ih p hp)
91
92/-- Every index 9a+8 merges in exactly five edges from the smaller index 8a+7. -/
93theorem index_eight_family (a : Nat) :
94 8*a+7 < 9*a+8 ∧
95 orbit 5 (576*(8*a+7)+569) = 576*(9*a+8)+569 := by
96 obtain ⟨_,_,h⟩ := five_step_predecessor (64*a+63)
97 rw [show 72*(64*a+63)+65 = 576*(8*a+7)+569 by omega,
98 show 81*(64*a+63)+74 = 576*(9*a+8)+569 by omega] at h
99 exact ⟨by omega,h⟩
100
101theorem claim_iff_remaining_indices :
102 Claim ↔ ∀ q : Nat, 0 < q → q%9 ≠ 8 →
103 ∃ p : Nat, p < q ∧ Merge (576*q+569) (576*p+569) := by
104 constructor
105 · intro all q hq _
106 exact claim_iff_smaller_index.mp all q hq
107 · intro other
108 apply claim_iff_smaller_index.mpr
109 intro q hq
110 by_cases h8 : q%9=8
111 · let a := q/9
112 have rep : q=9*a+8 := by dsimp [a]; omega
113 rw [rep]
114 obtain ⟨lt,he⟩ := index_eight_family a
115 exact ⟨8*a+7,lt,0,5,he.symm⟩
116 · exact other q hq h8
117
118#print axioms index_eight_family
119#print axioms claim_iff_remaining_indices
120
121/-- Witnesses (q,p,s,t) for q=1 through 32. The general smaller-index obligation stays open. -/
122def mergeExamples : List (Nat × Nat × Nat × Nat) := [
123 (1,0,142,48), (2,0,27,28), (3,2,19,16), (4,2,157,40),
124 (5,1,32,33), (6,2,61,47), (7,2,23,19), (8,7,0,5),
125 (9,5,38,58), (10,9,64,38), (11,8,104,39), (12,10,59,51),
126 (13,8,104,31), (14,6,20,37), (15,11,34,31), (16,12,89,55),
127 (17,15,0,5), (18,5,56,44), (19,18,28,15), (20,8,35,39),
128 (21,0,66,15), (22,0,64,0), (23,11,24,23), (24,0,16,1),
129 (25,20,45,24), (26,23,0,5), (27,8,63,20), (28,14,59,40),
130 (29,20,84,24), (30,12,33,55), (31,20,55,39), (32,20,49,46)]
131
132set_option maxRecDepth 12000 in
133theorem check_merge_examples :
134 mergeExamples.map Prod.fst = (List.range 32).map (·+1) ∧
135 mergeExamples.all (fun (q,p,s,t) =>
136 decide (p < q) && (orbit s (576*q+569) == orbit t (576*p+569))) = true := by decide
137
138#print axioms claim_iff_smaller_index
139#print axioms check_merge_examples
140#print axioms doubling_table
141#print axioms ten_step_image
142#print axioms from_single_class
143#print axioms claim_iff_569
144
145end CollatzRoute