证明冰雹猜想(Collatz 猜想)
3546165164posted 5 days agofor github.com/kisspeople/collatz-conjecture On the list
Refine to fifteen classes and prove two explicit first-return obstructions
Browse files+97 −23 routes/codex-odd-preimage-issue1/CheckpointDescent.lean View file
| @@ -28,6 +28,38 @@ def checkpointRemaining (words : List (List Move)) : List Nat := | ||
| 28 | 28 | (((List.range 64).filter fun i => !(words.any (checkpointCertificate ⟨576,9*i+11⟩))).map |
| 29 | 29 | fun i => (9*i+11) % 576) |
| 30 | 30 | |
| 31 | +def SmallerCheckpoint (n : Nat) : Prop := | |
| 32 | + ∃ m, m % 9 = 2 ∧ m < n ∧ (ReachesOne n ↔ ReachesOne m) | |
| 33 | + | |
| 34 | +theorem by_checkpoint_induction | |
| 35 | + (rule : ∀ n : Nat, 2 < n → n%9 = 2 → | |
| 36 | + (∀ m : Nat, m < n → m%9 = 2 → ReachesOne m) → ReachesOne n) : Claim := by | |
| 37 | + apply claim_iff_two_mod_nine.mpr | |
| 38 | + intro n hr | |
| 39 | + induction n using Nat.strongRecOn with | |
| 40 | + | ind n ih => | |
| 41 | + by_cases small : n = 2 | |
| 42 | + · subst n; exact ⟨1, by decide⟩ | |
| 43 | + · exact rule n (by omega) hr ih | |
| 44 | + | |
| 45 | +theorem checkpoint_partition (words : List (List Move)) (n : Nat) (hn : 2 < n) (hr : n%9 = 2) : | |
| 46 | + n%576 ∈ checkpointRemaining words ∨ SmallerCheckpoint n := by | |
| 47 | + let i := ((n-11)/9)%64 | |
| 48 | + let q := ((n-11)/9)/64 | |
| 49 | + let x : Line := ⟨576, 9*i+11⟩ | |
| 50 | + have hi : i < 64 := Nat.mod_lt _ (by decide) | |
| 51 | + have repr : x.value q = n := by dsimp [Line.value, x, i, q]; omega | |
| 52 | + cases hc : words.any (checkpointCertificate x) with | |
| 53 | + | true => | |
| 54 | + obtain ⟨w, _, hw⟩ := List.any_eq_true.mp hc | |
| 55 | + exact Or.inr (repr ▸ smaller_checkpoint hw q) | |
| 56 | + | false => | |
| 57 | + left | |
| 58 | + refine List.mem_map.mpr ⟨i, List.mem_filter.mpr ⟨List.mem_range.mpr hi, ?_⟩, ?_⟩ | |
| 59 | + · change Bool.not (words.any (checkpointCertificate x)) = true | |
| 60 | + simp [hc] | |
| 61 | + · dsimp [Line.value, x] at repr; omega | |
| 62 | + | |
| 31 | 63 | theorem claim_iff_checkpoint_remaining (words : List (List Move)) : |
| 32 | 64 | Claim ↔ ∀ n : Nat, n%576 ∈ checkpointRemaining words → ReachesOne n := by |
| 33 | 65 | constructor |
| @@ -35,29 +67,11 @@ theorem claim_iff_checkpoint_remaining (words : List (List Move)) : | ||
| 35 | 67 | obtain ⟨i, _, eq⟩ := List.mem_map.mp mem |
| 36 | 68 | exact goal n (by omega) |
| 37 | 69 | · intro leftover |
| 38 | - apply claim_iff_two_mod_nine.mpr | |
| 39 | - intro n hr | |
| 40 | - induction n using Nat.strongRecOn with | |
| 41 | - | ind n ih => | |
| 42 | - by_cases small : n = 2 | |
| 43 | - · subst n; exact ⟨1, by decide⟩ | |
| 44 | - · let i := ((n-11)/9)%64 | |
| 45 | - let q := ((n-11)/9)/64 | |
| 46 | - let x : Line := ⟨576, 9*i+11⟩ | |
| 47 | - have hi : i < 64 := Nat.mod_lt _ (by decide) | |
| 48 | - have repr : x.value q = n := by dsimp [Line.value, x, i, q]; omega | |
| 49 | - cases hc : words.any (checkpointCertificate x) with | |
| 50 | - | true => | |
| 51 | - obtain ⟨w, _, hw⟩ := List.any_eq_true.mp hc | |
| 52 | - obtain ⟨m, hmod, hlt, equiv⟩ := smaller_checkpoint hw q | |
| 53 | - rw [repr] at hlt equiv | |
| 54 | - exact equiv.mpr (ih m hlt hmod) | |
| 55 | - | false => | |
| 56 | - apply leftover n | |
| 57 | - refine List.mem_map.mpr ⟨i, List.mem_filter.mpr ⟨List.mem_range.mpr hi, ?_⟩, ?_⟩ | |
| 58 | - · change Bool.not (words.any (checkpointCertificate x)) = true | |
| 59 | - simp [hc] | |
| 60 | - · dsimp [Line.value, x] at repr; omega | |
| 70 | + apply by_checkpoint_induction | |
| 71 | + intro n hn hr ih | |
| 72 | + rcases checkpoint_partition words n hn hr with mem | ⟨m, hm, hlt, eq⟩ | |
| 73 | + · exact leftover n mem | |
| 74 | + · exact eq.mpr (ih m hlt hm) | |
| 61 | 75 | |
| 62 | 76 | def checkpointWords : List (List Move) := [ |
| 63 | 77 | [H, U, H], |
| @@ -87,6 +101,66 @@ theorem claim_iff_19_checkpoints : | ||
| 87 | 101 | |
| 88 | 102 | theorem checkpoint_residue_count : checkpointResidues.length = 19 := by decide |
| 89 | 103 | |
| 104 | +private theorem from_refined_class (n modulus base : Nat) (word : List Move) | |
| 105 | + (hc : checkpointCertificate ⟨modulus, base⟩ word = true) (hr : n%modulus=base) : | |
| 106 | + SmallerCheckpoint n := by | |
| 107 | + have hrepr : (Line.mk modulus base).value (n/modulus) = n := by | |
| 108 | + have eq := Nat.mod_add_div n modulus | |
| 109 | + dsimp [Line.value]; omega | |
| 110 | + exact hrepr ▸ smaller_checkpoint hc (n/modulus) | |
| 111 | + | |
| 112 | +/-- Four coarse classes split into two or three certified subclasses each. -/ | |
| 113 | +theorem four_refined {n : Nat} (h : n%576 = 92 ∨ n%576 = 272 ∨ n%576 = 497 ∨ n%576 = 560) : | |
| 114 | + SmallerCheckpoint n := by | |
| 115 | + rcases h with h|h|h|h | |
| 116 | + · have hsub : n%1152=92 ∨ n%1152=668 := by omega | |
| 117 | + rcases hsub with hr|hr | |
| 118 | + · exact from_refined_class n 1152 92 [H, H, U, H, U, H, U, H, H, H] (by decide) hr | |
| 119 | + · exact from_refined_class n 1152 668 [H, H, U, H, U, H, U, H, H, U, H] (by decide) hr | |
| 120 | + · have hsub : n%1152=272 ∨ n%1152=848 := by omega | |
| 121 | + rcases hsub with hr|hr | |
| 122 | + · exact from_refined_class n 1152 272 [H, H, H, H, U, H, H, U, H] (by decide) hr | |
| 123 | + · exact from_refined_class n 1152 848 [H, H, H, H, U, H, H, H] (by decide) hr | |
| 124 | + · have hsub : n%1152=497 ∨ n%1152=1073 := by omega | |
| 125 | + rcases hsub with hr|hr | |
| 126 | + · exact from_refined_class n 1152 497 [U, H, H, U, H, H, H, H, P, D, D] (by decide) hr | |
| 127 | + · exact from_refined_class n 1152 1073 [U, H, H, U, H, H, H, H, U, H] (by decide) hr | |
| 128 | + · have hsub : n%1728=560 ∨ n%1728=1136 ∨ n%1728=1712 := by omega | |
| 129 | + rcases hsub with hr|hr|hr | |
| 130 | + · exact from_refined_class n 1728 560 [H, H, H, P, D, D] (by decide) hr | |
| 131 | + · exact from_refined_class n 1728 1136 [H, H, H, P] (by decide) hr | |
| 132 | + · exact from_refined_class n 1728 1712 [H, H, H, P, D, D, D, D] (by decide) hr | |
| 133 | + | |
| 134 | +def finalResidues : List Nat := | |
| 135 | + checkpointResidues.filter fun r => !(r == 92 || r == 272 || r == 497 || r == 560) | |
| 136 | + | |
| 137 | +theorem final_fifteen : finalResidues = | |
| 138 | + [11,47,137,155,191,209,263,299,335,380,425,443,479,551,569] := by decide | |
| 139 | + | |
| 140 | +theorem claim_iff_15_checkpoints : | |
| 141 | + Claim ↔ ∀ n : Nat, n%576 ∈ finalResidues → ReachesOne n := by | |
| 142 | + constructor | |
| 143 | + · intro goal n mem | |
| 144 | + by_cases hn : n=0 | |
| 145 | + · subst n; simp [final_fifteen] at mem | |
| 146 | + · exact goal n (by omega) | |
| 147 | + · intro leftover | |
| 148 | + apply by_checkpoint_induction | |
| 149 | + intro n hn hr ih | |
| 150 | + rcases checkpoint_partition checkpointWords n hn hr with mem | small | |
| 151 | + · rw [checkpoint_table] at mem | |
| 152 | + by_cases extra : n%576 = 92 ∨ n%576 = 272 ∨ n%576 = 497 ∨ n%576 = 560 | |
| 153 | + · obtain ⟨m, hm, hlt, eq⟩ := four_refined extra | |
| 154 | + exact eq.mpr (ih m hlt hm) | |
| 155 | + · apply leftover | |
| 156 | + apply List.mem_filter.mpr | |
| 157 | + exact ⟨mem, by simpa [and_assoc] using extra⟩ | |
| 158 | + · obtain ⟨m, hm, hlt, eq⟩ := small | |
| 159 | + exact eq.mpr (ih m hlt hm) | |
| 160 | + | |
| 161 | +#print axioms four_refined | |
| 162 | +#print axioms final_fifteen | |
| 163 | +#print axioms claim_iff_15_checkpoints | |
| 90 | 164 | #print axioms smaller_checkpoint |
| 91 | 165 | #print axioms checkpoint_table |
| 92 | 166 | #print axioms claim_iff_19_checkpoints |
+171 −0 routes/codex-odd-preimage-issue1/FirstReturn.lean added View file
| @@ -0,0 +1,171 @@ | ||
| 1 | +import Checkpoint | |
| 2 | + | |
| 3 | +namespace CollatzRoute | |
| 4 | + | |
| 5 | +/-- Starting at 4s-1 performs two odd shortcuts, four raw steps in total. -/ | |
| 6 | +private theorem block_four (s : Nat) (hs : 0 < s) (h3 : s%3 = 0) : | |
| 7 | + orbit 4 (4*s-1) = 9*s-1 ∧ | |
| 8 | + ∀ t : Nat, 0 < t → t ≤ 4 → orbit t (4*s-1) % 9 ≠ 2 := by | |
| 9 | + have a : step (4*s-1) = 12*s-2 := by unfold step; split <;> omega | |
| 10 | + have b : step (12*s-2) = 6*s-1 := by unfold step; split <;> omega | |
| 11 | + have c : step (6*s-1) = 18*s-2 := by unfold step; split <;> omega | |
| 12 | + have d : step (18*s-2) = 9*s-1 := by unfold step; split <;> omega | |
| 13 | + refine ⟨by simp only [orbit, a, b, c, d], ?_⟩ | |
| 14 | + intro t ht hcap | |
| 15 | + have choices : t=1 ∨ t=2 ∨ t=3 ∨ t=4 := by omega | |
| 16 | + rcases choices with h|h|h|h <;> subst t <;> simp only [orbit, a, b, c, d] <;> omega | |
| 17 | + | |
| 18 | +private theorem prefix_four (k c : Nat) (hc : 0 < c) (h3 : c%3 = 0) : | |
| 19 | + orbit (4*k) (4^k*c-1) = 9^k*c-1 ∧ | |
| 20 | + ∀ t : Nat, 0 < t → t ≤ 4*k → orbit t (4^k*c-1) % 9 ≠ 2 := by | |
| 21 | + induction k generalizing c with | |
| 22 | + | zero => exact ⟨by simp [orbit], by intro t a b; omega⟩ | |
| 23 | + | succ k ih => | |
| 24 | + let s := 4^k*c | |
| 25 | + have hs : 0 < s := Nat.mul_pos (Nat.pow_pos (by decide)) hc | |
| 26 | + have hs3 : s%3 = 0 := by simp [s, Nat.mul_mod, h3] | |
| 27 | + have block := block_four s hs hs3 | |
| 28 | + have hstart : 4^(k+1)*c-1 = 4*s-1 := by | |
| 29 | + simp only [s,Nat.pow_succ]; ac_rfl | |
| 30 | + have hnext : 9*s-1 = 4^k*(9*c)-1 := by dsimp [s]; ac_rfl | |
| 31 | + have tail := ih (9*c) (by omega) (by omega) | |
| 32 | + have hend : 9^k*(9*c)-1 = 9^(k+1)*c-1 := by | |
| 33 | + simp only [Nat.pow_succ]; ac_rfl | |
| 34 | + constructor | |
| 35 | + · rw [hstart, show 4*(k+1) = 4+4*k by omega, orbit_add, block.1, hnext, tail.1, hend] | |
| 36 | + · intro t ht hlimit | |
| 37 | + rw [hstart] | |
| 38 | + by_cases early : t≤4 | |
| 39 | + · exact block.2 t ht early | |
| 40 | + · have ht' : t=4+(t-4) := by omega | |
| 41 | + rw [ht', orbit_add, block.1, hnext] | |
| 42 | + exact tail.2 (t-4) (by omega) (by omega) | |
| 43 | + | |
| 44 | +def excursionStart (k : Nat) := 4^k*21-1 | |
| 45 | +def excursionReturn (k : Nat) := (9^k*21-1)/4 | |
| 46 | + | |
| 47 | +private theorem four_pow_mod_three (k : Nat) : 4^k%3 = 1 := by | |
| 48 | + induction k with | |
| 49 | + | zero => decide | |
| 50 | + | succ k ih => simp [Nat.pow_succ, Nat.mul_mod, ih] | |
| 51 | + | |
| 52 | +private theorem nine_pow_mod_four (k : Nat) : 9^k%4 = 1 := by | |
| 53 | + induction k with | |
| 54 | + | zero => decide | |
| 55 | + | succ k ih => simp [Nat.pow_succ, Nat.mul_mod, ih] | |
| 56 | + | |
| 57 | +theorem excursion_start_checkpoint (k : Nat) : excursionStart k % 9 = 2 := by | |
| 58 | + have h := four_pow_mod_three k | |
| 59 | + unfold excursionStart; omega | |
| 60 | + | |
| 61 | +theorem first_checkpoint_return (k : Nat) (hk : 0 < k) : | |
| 62 | + orbit (4*k+2) (excursionStart k) = excursionReturn k ∧ | |
| 63 | + excursionReturn k % 9 = 2 ∧ | |
| 64 | + ∀ t : Nat, 0 < t → t < 4*k+2 → orbit t (excursionStart k) % 9 ≠ 2 := by | |
| 65 | + let y := 9^k*21-1 | |
| 66 | + have h4 := nine_pow_mod_four k | |
| 67 | + have h9 : 9^k % 9 = 0 := by | |
| 68 | + cases k with | |
| 69 | + | zero => omega | |
| 70 | + | succ j => simp [Nat.pow_succ] | |
| 71 | + have step1 : step y = y/2 := by unfold step; split <;> dsimp [y] at * <;> omega | |
| 72 | + have step2 : step (y/2) = y/4 := by unfold step; split <;> dsimp [y] at * <;> omega | |
| 73 | + have hpre := prefix_four k 21 (by decide) (by decide) | |
| 74 | + change orbit (4*k+2) (4^k*21-1) = y/4 ∧ y/4%9=2 ∧ _ | |
| 75 | + constructor | |
| 76 | + · rw [orbit_add, hpre.1] | |
| 77 | + change step (step y) = y/4 | |
| 78 | + rw [step1,step2] | |
| 79 | + constructor | |
| 80 | + · dsimp [y]; omega | |
| 81 | + · intro t ht hlimit | |
| 82 | + by_cases before : t ≤ 4*k | |
| 83 | + · exact hpre.2 t ht before | |
| 84 | + · have htime : t=4*k+1 := by omega | |
| 85 | + rw [htime, orbit_add] | |
| 86 | + change orbit 1 (orbit (4*k) (4^k*21-1)) % 9 ≠ 2 | |
| 87 | + rw [hpre.1] | |
| 88 | + change step y % 9 ≠ 2 | |
| 89 | + rw [step1] | |
| 90 | + dsimp [y]; omega | |
| 91 | + | |
| 92 | +private theorem two_pow_linear (k : Nat) : k+1 ≤ 2^k := by | |
| 93 | + induction k with | |
| 94 | + | zero => decide | |
| 95 | + | succ k ih => rw [Nat.pow_succ]; omega | |
| 96 | + | |
| 97 | +theorem excursion_start_mod576 (k : Nat) (hk : 3 ≤ k) : excursionStart k % 576 = 191 := by | |
| 98 | + have h3 : k=3+(k-3) := by omega | |
| 99 | + have h64 : 4^k%64=0 := by | |
| 100 | + rw [h3,Nat.pow_add] | |
| 101 | + change 64 * 4^(k-3)%64=0 | |
| 102 | + simp | |
| 103 | + have hn := excursion_start_checkpoint k | |
| 104 | + unfold excursionStart at * | |
| 105 | + omega | |
| 106 | + | |
| 107 | +/-- Even on just residue 191, the first positive checkpoint return has unbounded gain. -/ | |
| 108 | +theorem first_return_gain (B k : Nat) (large : 4*B+4 ≤ k) : | |
| 109 | + B * excursionStart k < excursionReturn k := by | |
| 110 | + let a := 4^k*21 | |
| 111 | + have ap : 0 < a := Nat.mul_pos (Nat.pow_pos (by decide)) (by decide) | |
| 112 | + have lg := two_pow_linear k | |
| 113 | + have hsmall : 4*B+4 ≤ 2^k := by omega | |
| 114 | + have scale : (4*B+4)*a ≤ 9^k*21 := by | |
| 115 | + calc | |
| 116 | + (4*B+4)*a ≤ 2^k*a := Nat.mul_le_mul_right a hsmall | |
| 117 | + _ = 8^k*21 := by dsimp [a]; rw [← Nat.mul_assoc, ← Nat.mul_pow] | |
| 118 | + _ ≤ 9^k*21 := Nat.mul_le_mul_right 21 (Nat.pow_le_pow_left (by decide) k) | |
| 119 | + have lhs : 4*(B*a)+4*a ≤ 9^k*21 := by | |
| 120 | + simpa only [Nat.add_mul,Nat.mul_assoc] using scale | |
| 121 | + have lt0 : B*(a-1) ≤ B*a := Nat.mul_le_mul_left _ (by omega) | |
| 122 | + change B*(a-1) < (9^k*21-1)/4 | |
| 123 | + omega | |
| 124 | + | |
| 125 | +theorem unbounded_first_return (B : Nat) : | |
| 126 | + ∃ k, 3 ≤ k ∧ excursionStart k % 576 = 191 ∧ | |
| 127 | + B * excursionStart k < excursionReturn k := by | |
| 128 | + let k := 4*B+4 | |
| 129 | + have hk : 3 ≤ k := by dsimp [k]; omega | |
| 130 | + exact ⟨k,hk,excursion_start_mod576 k hk,first_return_gain B k (Nat.le_refl _)⟩ | |
| 131 | + | |
| 132 | +/-- For 74 modulo 81 the *smaller* checkpoint is an actual predecessor, five raw steps back. -/ | |
| 133 | +theorem five_step_predecessor (q : Nat) : | |
| 134 | + 72*q+65 < 81*q+74 ∧ (72*q+65)%9 = 2 ∧ orbit 5 (72*q+65) = 81*q+74 := by | |
| 135 | + have a : step (72*q+65) = 216*q+196 := by unfold step; split <;> omega | |
| 136 | + have b : step (216*q+196) = 108*q+98 := by unfold step; split <;> omega | |
| 137 | + have c : step (108*q+98) = 54*q+49 := by unfold step; split <;> omega | |
| 138 | + have d : step (54*q+49) = 162*q+148 := by unfold step; split <;> omega | |
| 139 | + have e : step (162*q+148) = 81*q+74 := by unfold step; split <;> omega | |
| 140 | + exact ⟨by omega,by omega,by simp only [orbit,a,b,c,d,e]⟩ | |
| 141 | + | |
| 142 | +theorem subsequence_mod81 (j : Nat) : excursionStart (9*j+6) % 81 = 74 := by | |
| 143 | + have mod27 : 4^(9*j+6) % 27 = 19 := by | |
| 144 | + induction j with | |
| 145 | + | zero => decide | |
| 146 | + | succ j ih => | |
| 147 | + rw [show 9*(j+1)+6 = (9*j+6)+9 by omega, Nat.pow_add, Nat.mul_mod, ih] | |
| 148 | + unfold excursionStart; omega | |
| 149 | + | |
| 150 | +/-- A single infinite subsequence exhibits both effects at once, for any demanded gain. -/ | |
| 151 | +theorem large_return_with_smaller_checkpoint (B : Nat) : | |
| 152 | + ∃ k m, 3 ≤ k ∧ excursionStart k % 576 = 191 ∧ | |
| 153 | + B * excursionStart k < excursionReturn k ∧ | |
| 154 | + m % 9 = 2 ∧ m < excursionStart k ∧ orbit 5 m = excursionStart k := by | |
| 155 | + let k := 9*B+6 | |
| 156 | + have hk : 3 ≤ k := by dsimp [k]; omega | |
| 157 | + have hmod := subsequence_mod81 B | |
| 158 | + change excursionStart k % 81 = 74 at hmod | |
| 159 | + let q := excursionStart k / 81 | |
| 160 | + have repr : 81*q+74 = excursionStart k := by dsimp [q]; omega | |
| 161 | + obtain ⟨lt, checkpoint, orbit5⟩ := five_step_predecessor q | |
| 162 | + rw [repr] at lt orbit5 | |
| 163 | + exact ⟨k,72*q+65,hk,excursion_start_mod576 k hk, | |
| 164 | + first_return_gain B k (by dsimp [k]; omega),checkpoint,lt,orbit5⟩ | |
| 165 | + | |
| 166 | +#print axioms large_return_with_smaller_checkpoint | |
| 167 | +#print axioms first_checkpoint_return | |
| 168 | +#print axioms excursion_start_mod576 | |
| 169 | +#print axioms unbounded_first_return | |
| 170 | + | |
| 171 | +end CollatzRoute | |
+2 −0 routes/codex-odd-preimage-issue1/README.md View file
| @@ -10,6 +10,8 @@ status: working | ||
| 10 | 10 | |
| 11 | 11 | 另已在 [Checkpoint.lean](Checkpoint.lean) 复现 Monks 等人论文推论 5.8 的正向结论,每条轨道都会遇到模 9 余 2 的数。只在这些数之间使用严格下降的方法,得到[另一份 19 类条件](CheckpointDescent.lean)。两份剩余清单服务于不同的归纳,直接取交集会形成循环。例子是 7 的轨道两步就返回 11,而从 11 找到的较小前驱恰为 7。 |
| 12 | 12 | |
| 13 | +进一步细分余数 92、272、497、560 后,第二条归约只剩 15 类。若期待每次回到模 9 余 2 时都变小,[首次返回证明](FirstReturn.lean)显示单次能放大任意倍,[连续返回证明](RepeatedReturns.lean)显示可任意多次接连增大。两者都是对整族整数的 Lean 证明。 | |
| 14 | + | |
| 13 | 15 | ## 可直接查看的结果 |
| 14 | 16 | |
| 15 | 17 | - [推导、样例和复验方法](out/partial-proof.md) |
+87 −0 routes/codex-odd-preimage-issue1/RepeatedReturns.lean added View file
| @@ -0,0 +1,87 @@ | ||
| 1 | +import Inverse | |
| 2 | + | |
| 3 | +namespace CollatzRoute | |
| 4 | + | |
| 5 | +/-- One five-step block starting above the signed cycle -7,-20,-10,-5,-14,-7. | |
| 6 | +All equations and evaluations in the proof itself take place in Nat. -/ | |
| 7 | +private theorem block_five (s : Nat) (hs : 0 < s) (h9 : s%9=0) : | |
| 8 | + orbit 5 (8*s-7) = 9*s-7 ∧ orbit 3 (8*s-7) < 8*s-7 ∧ | |
| 9 | + ∀ t : Nat, t ≤ 5 → (orbit t (8*s-7)%9=2 ↔ t%5=0) := by | |
| 10 | + have a : step (8*s-7) = 24*s-20 := by unfold step; split <;> omega | |
| 11 | + have b : step (24*s-20) = 12*s-10 := by unfold step; split <;> omega | |
| 12 | + have c : step (12*s-10) = 6*s-5 := by unfold step; split <;> omega | |
| 13 | + have d : step (6*s-5) = 18*s-14 := by unfold step; split <;> omega | |
| 14 | + have e : step (18*s-14) = 9*s-7 := by unfold step; split <;> omega | |
| 15 | + refine ⟨by simp only [orbit,a,b,c,d,e], by simp only [orbit,a,b,c]; omega, ?_⟩ | |
| 16 | + intro t ht | |
| 17 | + have ht' : t=0 ∨ t=1 ∨ t=2 ∨ t=3 ∨ t=4 ∨ t=5 := by omega | |
| 18 | + have r0 : (8*s-7)%9=2 := by omega | |
| 19 | + have r1 : (24*s-20)%9=7 := by omega | |
| 20 | + have r2 : (12*s-10)%9=8 := by omega | |
| 21 | + have r3 : (6*s-5)%9=4 := by omega | |
| 22 | + have r4 : (18*s-14)%9=4 := by omega | |
| 23 | + have r5 : (9*s-7)%9=2 := by omega | |
| 24 | + rcases ht' with h|h|h|h|h|h <;> subst t <;> | |
| 25 | + simp only [orbit,a,b,c,d,e,r0,r1,r2,r3,r4,r5] <;> decide | |
| 26 | + | |
| 27 | +private theorem consecutive_prefix (k c : Nat) (hc : 0 < c) (h9 : c%9=0) : | |
| 28 | + (∀ t : Nat, t ≤ 5*k → (orbit t (8^k*c-7)%9=2 ↔ t%5=0)) ∧ | |
| 29 | + (∀ j : Nat, j<k → orbit (5*j) (8^k*c-7) < orbit (5*(j+1)) (8^k*c-7)) := by | |
| 30 | + induction k generalizing c with | |
| 31 | + | zero => | |
| 32 | + constructor | |
| 33 | + · intro t ht | |
| 34 | + have ht0 : t=0 := by omega | |
| 35 | + have r : (c-7)%9 = 2 := by omega | |
| 36 | + simp [ht0,orbit,r] | |
| 37 | + · intro j hj; omega | |
| 38 | + | succ k ih => | |
| 39 | + let s := 8^k*c | |
| 40 | + have hs : 0<s := Nat.mul_pos (Nat.pow_pos (by decide)) hc | |
| 41 | + have hs9 : s%9=0 := by simp [s,Nat.mul_mod,h9] | |
| 42 | + have block := block_five s hs hs9 | |
| 43 | + have start : 8^(k+1)*c-7 = 8*s-7 := by simp only [s,Nat.pow_succ]; ac_rfl | |
| 44 | + have next : 9*s-7 = 8^k*(9*c)-7 := by dsimp [s]; ac_rfl | |
| 45 | + have tail := ih (9*c) (by omega) (by omega) | |
| 46 | + constructor | |
| 47 | + · intro t ht | |
| 48 | + rw [start] | |
| 49 | + by_cases early : t≤5 | |
| 50 | + · exact block.2.2 t early | |
| 51 | + · rw [show t=5+(t-5) by omega,orbit_add,block.1,next, | |
| 52 | + tail.1 (t-5) (by omega)] | |
| 53 | + omega | |
| 54 | + · intro j hj | |
| 55 | + rw [start] | |
| 56 | + cases j with | |
| 57 | + | zero => | |
| 58 | + change 8*s-7 < orbit 5 (8*s-7) | |
| 59 | + rw [block.1]; omega | |
| 60 | + | succ i => | |
| 61 | + rw [show 5*(i+1)=5+5*i by omega, | |
| 62 | + show 5*(i+1+1)=5+5*(i+1) by omega,orbit_add,orbit_add,block.1,next] | |
| 63 | + exact tail.2 i (by omega) | |
| 64 | + | |
| 65 | +/-- For any prescribed number of returns, one positive start in class 569 has | |
| 66 | +exactly those checkpoints every five steps, all rising, despite falling at raw step three. -/ | |
| 67 | +theorem arbitrarily_many_rising_returns (L : Nat) : | |
| 68 | + ∃ n, n%576 = 569 ∧ orbit 3 n < n ∧ | |
| 69 | + (∀ t : Nat, t ≤ 5*L → (orbit t n%9=2 ↔ t%5=0)) ∧ | |
| 70 | + (∀ j : Nat, j<L → orbit (5*j) n < orbit (5*(j+1)) n) := by | |
| 71 | + let c := 8^L | |
| 72 | + let n := 8^(L+2)*9-7 | |
| 73 | + have hc : 0 < c := Nat.pow_pos (by decide) | |
| 74 | + have repr : n=576*c-7 := by | |
| 75 | + dsimp [n,c]; rw [Nat.pow_add]; change 8^L*64*9-7=576*8^L-7 | |
| 76 | + rw [Nat.mul_assoc]; change 8^L*576-7 = 576*8^L-7; rw [Nat.mul_comm] | |
| 77 | + have path := consecutive_prefix (L+2) 9 (by decide) (by decide) | |
| 78 | + have block := block_five (72*c) (by omega) (by omega) | |
| 79 | + refine ⟨n, by omega, ?_, ?_, ?_⟩ | |
| 80 | + · have edge : n=8*(72*c)-7 := by omega | |
| 81 | + exact edge ▸ block.2.1 | |
| 82 | + · intro t ht; exact path.1 t (by omega) | |
| 83 | + · intro j hj; exact path.2 j (by omega) | |
| 84 | + | |
| 85 | +#print axioms arbitrarily_many_rising_returns | |
| 86 | + | |
| 87 | +end CollatzRoute | |