证明冰雹猜想(Collatz 猜想)
3546165164posted 5 days agofor github.com/kisspeople/collatz-conjecture On the list
Comparing changes
Choose two branches to see what changed, then open a pull request to bring the work across.
Able to merge. These branches can be merged automatically.
Sign in to open a pull request.
10 commits
+175 −0 routes/codex-odd-preimage-issue1/Bridges.lean added View file
| @@ -0,0 +1,175 @@ | ||
| 1 | +import Inverse | |
| 2 | + | |
| 3 | +namespace CollatzRoute | |
| 4 | + | |
| 5 | +/-- Being able to reach 1 is invariant across a raw edge, in either direction. -/ | |
| 6 | +theorem reaches_step_iff (n : Nat) : ReachesOne n ↔ ReachesOne (step n) := by | |
| 7 | + constructor | |
| 8 | + · rintro ⟨t, ht⟩ | |
| 9 | + cases t with | |
| 10 | + | zero => | |
| 11 | + change n = 1 at ht | |
| 12 | + subst n | |
| 13 | + exact ⟨2, by decide⟩ | |
| 14 | + | succ t => exact ⟨t, ht⟩ | |
| 15 | + · rintro ⟨t, ht⟩ | |
| 16 | + exact ⟨t + 1, ht⟩ | |
| 17 | + | |
| 18 | +structure Line where | |
| 19 | + slope : Nat | |
| 20 | + base : Nat | |
| 21 | + deriving DecidableEq, Repr | |
| 22 | + | |
| 23 | +def Line.value (x : Line) (q : Nat) : Nat := x.slope * q + x.base | |
| 24 | +def Line.twice (x : Line) : Line := ⟨2*x.slope, 2*x.base⟩ | |
| 25 | +def Line.threeAddOne (x : Line) : Line := ⟨3*x.slope, 3*x.base+1⟩ | |
| 26 | +def Line.allOdd (x : Line) : Bool := x.slope % 2 == 0 && x.base % 2 == 1 | |
| 27 | + | |
| 28 | +theorem Line.value_twice (x : Line) (q : Nat) : x.twice.value q = 2*x.value q := by | |
| 29 | + simp [Line.twice, Line.value, Nat.mul_add, Nat.mul_assoc] | |
| 30 | + | |
| 31 | +theorem Line.value_threeAddOne (x : Line) (q : Nat) : | |
| 32 | + x.threeAddOne.value q = 3*x.value q + 1 := by | |
| 33 | + simp [Line.threeAddOne, Line.value, Nat.mul_add, Nat.mul_assoc, Nat.add_assoc] | |
| 34 | + | |
| 35 | +theorem Line.odd_of_allOdd {x : Line} (h : x.allOdd = true) (q : Nat) : | |
| 36 | + x.value q % 2 = 1 := by | |
| 37 | + simp [Line.allOdd] at h | |
| 38 | + simp [Line.value, Nat.add_mod, Nat.mul_mod, h.1, h.2] | |
| 39 | + | |
| 40 | +/-- H and U follow the usual even/odd rule. D and P walk those edges backwards. -/ | |
| 41 | +inductive Move where | |
| 42 | + | H | U | D | P | |
| 43 | + deriving DecidableEq, Repr | |
| 44 | + | |
| 45 | +def move? (op : Move) (x : Line) : Option Line := | |
| 46 | + match op with | |
| 47 | + | .H => | |
| 48 | + let y : Line := ⟨x.slope/2, x.base/2⟩ | |
| 49 | + if y.twice = x then some y else none | |
| 50 | + | .U => if x.allOdd then some x.threeAddOne else none | |
| 51 | + | .D => some x.twice | |
| 52 | + | .P => | |
| 53 | + let y : Line := ⟨x.slope/3, (x.base-1)/3⟩ | |
| 54 | + if y.threeAddOne = x ∧ y.allOdd = true then some y else none | |
| 55 | + | |
| 56 | +theorem down_edge (x : Line) (q : Nat) : | |
| 57 | + ReachesOne (x.twice.value q) ↔ ReachesOne (x.value q) := by | |
| 58 | + simpa only [Line.value_twice, step_double] using reaches_step_iff (2*x.value q) | |
| 59 | + | |
| 60 | +theorem up_edge (x : Line) (odd : x.allOdd = true) (q : Nat) : | |
| 61 | + ReachesOne (x.value q) ↔ ReachesOne (x.threeAddOne.value q) := by | |
| 62 | + simpa only [Line.value_threeAddOne, step_odd (x.odd_of_allOdd odd q)] using reaches_step_iff (x.value q) | |
| 63 | + | |
| 64 | +theorem move_sound {op : Move} {x y : Line} (h : move? op x = some y) (q : Nat) : | |
| 65 | + ReachesOne (x.value q) ↔ ReachesOne (y.value q) := by | |
| 66 | + cases op with | |
| 67 | + | H => | |
| 68 | + simp only [move?] at h | |
| 69 | + split at h | |
| 70 | + next hx => | |
| 71 | + cases h | |
| 72 | + have eq := down_edge ⟨x.slope/2, x.base/2⟩ q | |
| 73 | + rw [hx] at eq | |
| 74 | + exact eq | |
| 75 | + next => contradiction | |
| 76 | + | U => | |
| 77 | + simp only [move?] at h | |
| 78 | + split at h | |
| 79 | + next hx => cases h; exact up_edge _ hx _ | |
| 80 | + next => contradiction | |
| 81 | + | D => cases h; exact (down_edge _ _).symm | |
| 82 | + | P => | |
| 83 | + simp only [move?] at h | |
| 84 | + split at h | |
| 85 | + next hx => | |
| 86 | + cases h | |
| 87 | + have eq := up_edge ⟨x.slope/3, (x.base-1)/3⟩ hx.2 q | |
| 88 | + rw [hx.1] at eq | |
| 89 | + exact eq.symm | |
| 90 | + next => contradiction | |
| 91 | + | |
| 92 | +def walk? : List Move → Line → Option Line | |
| 93 | + | [], x => some x | |
| 94 | + | op :: rest, x => (move? op x).bind (walk? rest) | |
| 95 | + | |
| 96 | +theorem walk_sound {w : List Move} {x y : Line} (h : walk? w x = some y) (q : Nat) : | |
| 97 | + ReachesOne (x.value q) ↔ ReachesOne (y.value q) := by | |
| 98 | + induction w generalizing x with | |
| 99 | + | nil => cases h; exact Iff.rfl | |
| 100 | + | cons op rest ih => | |
| 101 | + cases hm : move? op x with | |
| 102 | + | none => simp [walk?, hm] at h | |
| 103 | + | some z => | |
| 104 | + simp [walk?, hm] at h | |
| 105 | + exact (move_sound hm q).trans (ih h) | |
| 106 | + | |
| 107 | +def certifies (start : Line) (word : List Move) : Bool := | |
| 108 | + match walk? word start with | |
| 109 | + | none => false | |
| 110 | + | some y => decide (y.slope ≤ start.slope ∧ 0 < y.base ∧ y.base < start.base) | |
| 111 | + | |
| 112 | +theorem endpoint_smaller {x y : Line} {word : List Move} | |
| 113 | + (hw : walk? word x = some y) (hc : certifies x word = true) (q : Nat) : | |
| 114 | + 0 < y.value q ∧ y.value q < x.value q := by | |
| 115 | + simp [certifies, hw] at hc | |
| 116 | + constructor | |
| 117 | + · dsimp [Line.value]; omega | |
| 118 | + · exact Nat.add_lt_add_of_le_of_lt (Nat.mul_le_mul_right q hc.1) hc.2.2 | |
| 119 | + | |
| 120 | +theorem certificate_descends {x : Line} {w : List Move} (h : certifies x w = true) (q : Nat) : | |
| 121 | + ∃ m, 0 < m ∧ m < x.value q ∧ (ReachesOne (x.value q) ↔ ReachesOne m) := by | |
| 122 | + cases he : walk? w x with | |
| 123 | + | none => simp [certifies, he] at h | |
| 124 | + | some y => | |
| 125 | + have hlt := endpoint_smaller he h q | |
| 126 | + exact ⟨y.value q, hlt.1, hlt.2, walk_sound he q⟩ | |
| 127 | + | |
| 128 | +def covered (words : List (List Move)) (modulus base : Nat) : Bool := | |
| 129 | + words.any (certifies ⟨modulus, base⟩) | |
| 130 | + | |
| 131 | +/-- Start each progression at its smallest value at least two, and list actual residues. -/ | |
| 132 | +def remaining (words : List (List Move)) (modulus : Nat) : List Nat := | |
| 133 | + (((List.range modulus).filter fun i => !(covered words modulus (i+2))).map | |
| 134 | + fun i => (i+2) % modulus) | |
| 135 | + | |
| 136 | +theorem claim_iff_remaining (words : List (List Move)) (modulus : Nat) (hm : 0 < modulus) : | |
| 137 | + Claim ↔ ∀ n : Nat, 1 < n → n % modulus ∈ remaining words modulus → ReachesOne n := by | |
| 138 | + constructor | |
| 139 | + · intro goal n hn _ | |
| 140 | + exact goal n (by omega) | |
| 141 | + · intro rest n hn | |
| 142 | + induction n using Nat.strongRecOn with | |
| 143 | + | ind n ih => | |
| 144 | + by_cases one : n = 1 | |
| 145 | + · subst n; exact ⟨0, rfl⟩ | |
| 146 | + · let i := (n-2)%modulus | |
| 147 | + let q := (n-2)/modulus | |
| 148 | + let x : Line := ⟨modulus, i+2⟩ | |
| 149 | + have repr : x.value q = n := by | |
| 150 | + have h := Nat.mod_add_div (n-2) modulus | |
| 151 | + dsimp [Line.value, x, i, q] | |
| 152 | + omega | |
| 153 | + cases hc : covered words modulus (i+2) with | |
| 154 | + | true => | |
| 155 | + obtain ⟨w, _, hw⟩ := List.any_eq_true.mp hc | |
| 156 | + obtain ⟨m, hp, hlt, iff⟩ := certificate_descends hw q | |
| 157 | + change m < x.value q at hlt | |
| 158 | + change ReachesOne (x.value q) ↔ ReachesOne m at iff | |
| 159 | + rw [repr] at iff hlt | |
| 160 | + exact iff.mpr (ih m hlt hp) | |
| 161 | + | false => | |
| 162 | + apply rest n (by omega) | |
| 163 | + apply List.mem_map.mpr | |
| 164 | + refine ⟨i, List.mem_filter.mpr ⟨List.mem_range.mpr (Nat.mod_lt _ hm), by simp [hc]⟩, ?_⟩ | |
| 165 | + dsimp [i] | |
| 166 | + rw [Nat.mod_add_mod] | |
| 167 | + congr 1 | |
| 168 | + omega | |
| 169 | + | |
| 170 | +#print axioms reaches_step_iff | |
| 171 | +#print axioms walk_sound | |
| 172 | +#print axioms certificate_descends | |
| 173 | +#print axioms claim_iff_remaining | |
| 174 | + | |
| 175 | +end CollatzRoute | |
+124 −0 routes/codex-odd-preimage-issue1/Checkpoint.lean added View file
| @@ -0,0 +1,124 @@ | ||
| 1 | +import Inverse | |
| 2 | + | |
| 3 | +namespace CollatzRoute | |
| 4 | + | |
| 5 | +/-- Shortcut Collatz map. An odd shortcut traverses two raw edges. -/ | |
| 6 | +def short (n : Nat) : Nat := if n % 2 = 0 then n / 2 else (3*n+1)/2 | |
| 7 | + | |
| 8 | +def HitsTwoModNine (n : Nat) : Prop := ∃ t, orbit t n % 9 = 2 | |
| 9 | + | |
| 10 | +theorem short_lifts {n : Nat} (h : HitsTwoModNine (short n)) : HitsTwoModNine n := by | |
| 11 | + obtain ⟨t, ht⟩ := h | |
| 12 | + by_cases he : n % 2 = 0 | |
| 13 | + · exact ⟨t+1, by simpa [orbit, step, short, he] using ht⟩ | |
| 14 | + · have half : 3*n+1 = 2*((3*n+1)/2) := by omega | |
| 15 | + refine ⟨(1+t)+1, ?_⟩ | |
| 16 | + rw [inverse_block (by omega) (show 3*n+1 = 2^1*((3*n+1)/2) from half)] | |
| 17 | + simpa [short, he] using ht | |
| 18 | + | |
| 19 | +theorem short_pos {n : Nat} (hn : 0 < n) : 0 < short n := by | |
| 20 | + unfold short; split <;> omega | |
| 21 | + | |
| 22 | +private theorem hit_four {n : Nat} (hr : n%9 = 4) : HitsTwoModNine n := by | |
| 23 | + apply short_lifts | |
| 24 | + exact ⟨0, by change short n % 9 = 2; unfold short; split <;> omega⟩ | |
| 25 | + | |
| 26 | +/-- An odd shortcut turns n+1 = a·(2u) into short(n)+1 = (3a)·u. | |
| 27 | +The factor u strictly decreases even while the Collatz value itself grows. -/ | |
| 28 | +private theorem hit_eight_aux (z : Nat) : | |
| 29 | + ∀ a n : Nat, a%2 = 1 → a*z = n+1 → n%9 = 8 → HitsTwoModNine n := by | |
| 30 | + induction z using Nat.strongRecOn with | |
| 31 | + | ind z ih => | |
| 32 | + intro a n ha hz hr | |
| 33 | + by_cases he : n%2 = 0 | |
| 34 | + · apply short_lifts | |
| 35 | + apply hit_four | |
| 36 | + simp only [short, he, ite_true]; omega | |
| 37 | + · have evenz : z%2 = 0 := by | |
| 38 | + have h := congrArg (fun k => k%2) hz | |
| 39 | + simp only [Nat.mul_mod a z 2, ha, Nat.one_mul, Nat.mod_mod] at h | |
| 40 | + omega | |
| 41 | + have posz : 0 < z := by | |
| 42 | + cases z with | |
| 43 | + | zero => simp at hz | |
| 44 | + | succ z => omega | |
| 45 | + have za : 2*(z/2) = z := by omega | |
| 46 | + have hp : 2*(a*(z/2)) = n+1 := by | |
| 47 | + calc | |
| 48 | + 2*(a*(z/2)) = a*(2*(z/2)) := by ac_rfl | |
| 49 | + _ = n+1 := by rw [za, hz] | |
| 50 | + apply short_lifts | |
| 51 | + apply ih (z/2) (by omega) (3*a) (short n) | |
| 52 | + · omega | |
| 53 | + · rw [Nat.mul_assoc] | |
| 54 | + simp only [short, he, ite_false] | |
| 55 | + omega | |
| 56 | + · simp only [short, he, ite_false]; omega | |
| 57 | + | |
| 58 | +private theorem hit_eight {n : Nat} (hr : n%9 = 8) : HitsTwoModNine n := | |
| 59 | + hit_eight_aux (n+1) 1 n (by decide) (Nat.one_mul _) hr | |
| 60 | + | |
| 61 | +private theorem hit_seven {n : Nat} (hr : n%9 = 7) : HitsTwoModNine n := by | |
| 62 | + apply short_lifts | |
| 63 | + have h : short n%9 = 2 ∨ short n%9 = 8 := by unfold short; split <;> omega | |
| 64 | + rcases h with target | eight | |
| 65 | + · exact ⟨0, target⟩ | |
| 66 | + · exact hit_eight eight | |
| 67 | + | |
| 68 | +private theorem hit_five {n : Nat} (hr : n%9 = 5) : HitsTwoModNine n := by | |
| 69 | + apply short_lifts | |
| 70 | + have h : short n%9 = 7 ∨ short n%9 = 8 := by unfold short; split <;> omega | |
| 71 | + exact h.elim hit_seven hit_eight | |
| 72 | + | |
| 73 | +private theorem hit_one_residue {n : Nat} (hr : n%9 = 1) : HitsTwoModNine n := by | |
| 74 | + apply short_lifts | |
| 75 | + have h : short n%9 = 2 ∨ short n%9 = 5 := by unfold short; split <;> omega | |
| 76 | + exact h.elim (fun h => ⟨0,h⟩) hit_five | |
| 77 | + | |
| 78 | +/-- Raw-rule version of Monks et al., Corollary 5.8 (2013). -/ | |
| 79 | +theorem every_orbit_hits_two_mod_nine (n : Nat) (hn : 0 < n) : HitsTwoModNine n := by | |
| 80 | + induction n using Nat.strongRecOn with | |
| 81 | + | ind n ih => | |
| 82 | + by_cases div3 : n%3 = 0 | |
| 83 | + · apply short_lifts | |
| 84 | + by_cases he : n%2 = 0 | |
| 85 | + · apply ih (short n) _ (short_pos hn) | |
| 86 | + simp only [short, he, ite_true]; omega | |
| 87 | + · apply hit_five | |
| 88 | + simp only [short, he, ite_false]; omega | |
| 89 | + · have opts : n%9 = 1 ∨ n%9 = 2 ∨ n%9 = 4 ∨ n%9 = 5 ∨ n%9 = 7 ∨ n%9 = 8 := by omega | |
| 90 | + rcases opts with h|h|h|h|h|h | |
| 91 | + · exact hit_one_residue h | |
| 92 | + · exact ⟨0,h⟩ | |
| 93 | + · exact hit_four h | |
| 94 | + · exact hit_five h | |
| 95 | + · exact hit_seven h | |
| 96 | + · exact hit_eight h | |
| 97 | + | |
| 98 | +theorem claim_iff_two_mod_nine : Claim ↔ ∀ y : Nat, y%9 = 2 → ReachesOne y := by | |
| 99 | + constructor | |
| 100 | + · intro goal y hy | |
| 101 | + exact goal _ (by omega) | |
| 102 | + · intro checkpoints n hn | |
| 103 | + obtain ⟨s, hs⟩ := every_orbit_hits_two_mod_nine n hn | |
| 104 | + obtain ⟨t, ht⟩ := checkpoints _ hs | |
| 105 | + exact ⟨s+t, by rw [orbit_add]; exact ht⟩ | |
| 106 | + | |
| 107 | +/-- The smaller odd predecessor always sends us back to the same first checkpoint. -/ | |
| 108 | +theorem predecessor_first_checkpoint (k : Nat) : | |
| 109 | + 6*k+1 < 9*k+2 ∧ orbit 2 (6*k+1) = 9*k+2 ∧ | |
| 110 | + ∀ t : Fin 2, orbit t.val (6*k+1) % 9 ≠ 2 := by | |
| 111 | + have a : step (6*k+1) = 2*(9*k+2) := by | |
| 112 | + rw [step_odd (by omega : (6*k+1)%2 = 1)]; omega | |
| 113 | + refine ⟨by omega, by simp only [orbit, a, step_double], ?_⟩ | |
| 114 | + intro t | |
| 115 | + have casesT : t.val = 0 ∨ t.val = 1 := by omega | |
| 116 | + rcases casesT with h | h | |
| 117 | + · simp only [h, orbit]; omega | |
| 118 | + · simp only [h, orbit, a]; omega | |
| 119 | + | |
| 120 | +#print axioms predecessor_first_checkpoint | |
| 121 | +#print axioms every_orbit_hits_two_mod_nine | |
| 122 | +#print axioms claim_iff_two_mod_nine | |
| 123 | + | |
| 124 | +end CollatzRoute | |
+184 −0 routes/codex-odd-preimage-issue1/CheckpointDescent.lean added View file
| @@ -0,0 +1,184 @@ | ||
| 1 | +import Bridges | |
| 2 | +import Checkpoint | |
| 3 | + | |
| 4 | +namespace CollatzRoute | |
| 5 | +open Move | |
| 6 | + | |
| 7 | +/-- A usable endpoint for induction restricted to checkpoints must itself be one. -/ | |
| 8 | +def atCheckpoint (x : Line) : Bool := x.slope % 9 == 0 && x.base % 9 == 2 | |
| 9 | + | |
| 10 | +theorem checkpoint_value {x : Line} (h : atCheckpoint x = true) (q : Nat) : | |
| 11 | + x.value q % 9 = 2 := by | |
| 12 | + simp [atCheckpoint] at h | |
| 13 | + simp [Line.value, Nat.add_mod, Nat.mul_mod, h.1, h.2] | |
| 14 | + | |
| 15 | +def checkpointCertificate (x : Line) (word : List Move) : Bool := | |
| 16 | + certifies x word && (walk? word x).any atCheckpoint | |
| 17 | + | |
| 18 | +theorem smaller_checkpoint {x : Line} {word : List Move} | |
| 19 | + (h : checkpointCertificate x word = true) (q : Nat) : | |
| 20 | + ∃ m, m % 9 = 2 ∧ m < x.value q ∧ (ReachesOne (x.value q) ↔ ReachesOne m) := by | |
| 21 | + cases hw : walk? word x with | |
| 22 | + | none => simp [checkpointCertificate, hw] at h | |
| 23 | + | some y => | |
| 24 | + simp [checkpointCertificate, hw] at h | |
| 25 | + exact ⟨y.value q, checkpoint_value h.2 q, (endpoint_smaller hw h.1 q).2, walk_sound hw q⟩ | |
| 26 | + | |
| 27 | +def checkpointRemaining (words : List (List Move)) : List Nat := | |
| 28 | + (((List.range 64).filter fun i => !(words.any (checkpointCertificate ⟨576,9*i+11⟩))).map | |
| 29 | + fun i => (9*i+11) % 576) | |
| 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 | + | |
| 63 | +theorem claim_iff_checkpoint_remaining (words : List (List Move)) : | |
| 64 | + Claim ↔ ∀ n : Nat, n%576 ∈ checkpointRemaining words → ReachesOne n := by | |
| 65 | + constructor | |
| 66 | + · intro goal n mem | |
| 67 | + obtain ⟨i, _, eq⟩ := List.mem_map.mp mem | |
| 68 | + exact goal n (by omega) | |
| 69 | + · intro leftover | |
| 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) | |
| 75 | + | |
| 76 | +def checkpointWords : List (List Move) := [ | |
| 77 | + [H, U, H], | |
| 78 | + [U, H, H, H], | |
| 79 | + [H, H, H, U, H], | |
| 80 | + [H, H, H, H, H, H], | |
| 81 | + [H, H, U, H, H, H], | |
| 82 | + [U, H, U, H, H, H], | |
| 83 | + [H, H, H, H, H, U, H], | |
| 84 | + [H, H, U, H, H, U, H], | |
| 85 | + [H, H, U, H, U, H, H, H], | |
| 86 | + [U, H, H, U, H, H, U, H], | |
| 87 | + [U, H, U, H, U, H, H, H], | |
| 88 | + [H, H, U, H, U, H, H, U, H], | |
| 89 | + [U, H, H, U, H, U, H, H, H]] | |
| 90 | + | |
| 91 | +def checkpointResidues : List Nat := | |
| 92 | + [11, 47, 92, 137, 155, 191, 209, 263, 272, 299, 335, 380, 425, 443, 479, 497, 551, 560, 569] | |
| 93 | + | |
| 94 | +set_option maxRecDepth 10000 in | |
| 95 | +set_option maxHeartbeats 2500000 in | |
| 96 | +theorem checkpoint_table : checkpointRemaining checkpointWords = checkpointResidues := by decide | |
| 97 | + | |
| 98 | +theorem claim_iff_19_checkpoints : | |
| 99 | + Claim ↔ ∀ n : Nat, n%576 ∈ checkpointResidues → ReachesOne n := by | |
| 100 | + simpa only [checkpoint_table] using claim_iff_checkpoint_remaining checkpointWords | |
| 101 | + | |
| 102 | +theorem checkpoint_residue_count : checkpointResidues.length = 19 := by decide | |
| 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 | +/-- First hits for the fifteen least representatives only. -/ | |
| 162 | +def leastExamples : List (Nat × Nat) := [ | |
| 163 | + (11,14), (47,104), (137,90), (155,85), (191,44), (209,39), (263,78), | |
| 164 | + (299,117), (335,68), (380,107), (425,58), (443,53), (479,53), (551,43), (569,56)] | |
| 165 | + | |
| 166 | +theorem least_examples_match : leastExamples.map Prod.fst = finalResidues := by decide | |
| 167 | + | |
| 168 | +set_option maxRecDepth 12000 in | |
| 169 | +set_option maxHeartbeats 4000000 in | |
| 170 | +theorem least_examples_first_hits : | |
| 171 | + leastExamples.all (fun (n,t) => | |
| 172 | + orbit t n == 1 && (List.range t).all fun s => orbit s n != 1) = true := by decide | |
| 173 | + | |
| 174 | +#print axioms least_examples_match | |
| 175 | +#print axioms least_examples_first_hits | |
| 176 | +#print axioms four_refined | |
| 177 | +#print axioms final_fifteen | |
| 178 | +#print axioms claim_iff_15_checkpoints | |
| 179 | +#print axioms smaller_checkpoint | |
| 180 | +#print axioms checkpoint_table | |
| 181 | +#print axioms claim_iff_19_checkpoints | |
| 182 | +#print axioms checkpoint_residue_count | |
| 183 | + | |
| 184 | +end CollatzRoute | |
+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 | |
+151 −0 routes/codex-odd-preimage-issue1/Inverse.lean added View file
| @@ -0,0 +1,151 @@ | ||
| 1 | +import Std | |
| 2 | + | |
| 3 | +namespace CollatzRoute | |
| 4 | + | |
| 5 | +def step (n : Nat) : Nat := if n % 2 = 0 then n / 2 else 3 * n + 1 | |
| 6 | + | |
| 7 | +def orbit : Nat → Nat → Nat | |
| 8 | + | 0, n => n | |
| 9 | + | t + 1, n => orbit t (step n) | |
| 10 | + | |
| 11 | +def ReachesOne (n : Nat) : Prop := ∃ t, orbit t n = 1 | |
| 12 | + | |
| 13 | +-- The requested statement, given a name so its remaining obligation is explicit. | |
| 14 | +def Claim : Prop := ∀ n : Nat, 0 < n → ReachesOne n | |
| 15 | + | |
| 16 | +theorem step_double (n : Nat) : step (2 * n) = n := by | |
| 17 | + unfold step | |
| 18 | + split <;> omega | |
| 19 | + | |
| 20 | +theorem step_odd {n : Nat} (h : n % 2 = 1) : step n = 3 * n + 1 := by | |
| 21 | + simp [step, h] | |
| 22 | + | |
| 23 | +-- The constructors carry a finite path back from 1. | |
| 24 | +inductive Back : Nat → Prop where | |
| 25 | + | root : Back 1 | |
| 26 | + | twice {y : Nat} : Back y → Back (2 * y) | |
| 27 | + | odd {x : Nat} : x % 2 = 1 → Back (3 * x + 1) → Back x | |
| 28 | + | |
| 29 | +theorem back_iff_reaches (n : Nat) : Back n ↔ ReachesOne n := by | |
| 30 | + constructor | |
| 31 | + · intro h | |
| 32 | + induction h with | |
| 33 | + | root => exact ⟨0, rfl⟩ | |
| 34 | + | twice _ ih => | |
| 35 | + obtain ⟨t, ht⟩ := ih | |
| 36 | + exact ⟨t + 1, by simpa [orbit, step_double] using ht⟩ | |
| 37 | + | odd hx _ ih => | |
| 38 | + obtain ⟨t, ht⟩ := ih | |
| 39 | + exact ⟨t + 1, by simpa [orbit, step_odd hx] using ht⟩ | |
| 40 | + · rintro ⟨t, ht⟩ | |
| 41 | + induction t generalizing n with | |
| 42 | + | zero => | |
| 43 | + change n = 1 at ht | |
| 44 | + subst n | |
| 45 | + exact Back.root | |
| 46 | + | succ t ih => | |
| 47 | + change orbit t (step n) = 1 at ht | |
| 48 | + have child := ih (step n) ht | |
| 49 | + by_cases even : n % 2 = 0 | |
| 50 | + · have eq : 2 * (n / 2) = n := by omega | |
| 51 | + simp only [step, even, ite_true] at child | |
| 52 | + exact eq ▸ Back.twice child | |
| 53 | + · have odd : n % 2 = 1 := by omega | |
| 54 | + rw [step_odd odd] at child | |
| 55 | + exact Back.odd odd child | |
| 56 | + | |
| 57 | +theorem strip_twos (a t n : Nat) : orbit (a + t) (2 ^ a * n) = orbit t n := by | |
| 58 | + induction a with | |
| 59 | + | zero => simp | |
| 60 | + | succ a ih => | |
| 61 | + have splitPow : 2 ^ (a + 1) * n = 2 * (2 ^ a * n) := by | |
| 62 | + simp [Nat.pow_succ, Nat.mul_comm, Nat.mul_left_comm] | |
| 63 | + rw [Nat.succ_add, orbit, splitPow, step_double, ih] | |
| 64 | + | |
| 65 | +-- One odd step followed by exactly e divisions by two when y is odd. | |
| 66 | +theorem inverse_block {x y e : Nat} (odd : x % 2 = 1) | |
| 67 | + (edge : 3 * x + 1 = 2 ^ e * y) (t : Nat) : | |
| 68 | + orbit ((e + t) + 1) x = orbit t y := by | |
| 69 | + rw [orbit, step_odd odd, edge, strip_twos] | |
| 70 | + | |
| 71 | +def rung : Nat → Nat | |
| 72 | + | 0 => 1 | |
| 73 | + | k + 1 => 4 * rung k + 1 | |
| 74 | + | |
| 75 | +theorem rung_odd (k : Nat) : rung k % 2 = 1 := by | |
| 76 | + cases k with | |
| 77 | + | zero => decide | |
| 78 | + | succ k => change (4 * rung k + 1) % 2 = 1; omega | |
| 79 | + | |
| 80 | +theorem rung_edge (k : Nat) : 3 * rung k + 1 = 2 ^ (2 * k + 2) := by | |
| 81 | + induction k with | |
| 82 | + | zero => decide | |
| 83 | + | succ k ih => | |
| 84 | + have exp : 2 * (k + 1) + 2 = (2 * k + 2 + 1) + 1 := by omega | |
| 85 | + rw [exp, Nat.pow_succ, Nat.pow_succ, ← ih] | |
| 86 | + change 3 * (4 * rung k + 1) + 1 = (3 * rung k + 1) * 2 * 2 | |
| 87 | + omega | |
| 88 | + | |
| 89 | +theorem family_hits (a k : Nat) : | |
| 90 | + orbit (a + (2 * k + 3)) (2 ^ a * rung k) = 1 := by | |
| 91 | + rw [strip_twos] | |
| 92 | + have edge : 3 * rung k + 1 = 2 ^ (2 * k + 2) * 1 := by simp [rung_edge] | |
| 93 | + simpa [orbit] using inverse_block (rung_odd k) edge 0 | |
| 94 | + | |
| 95 | +theorem sample_six : orbit 8 6 = 1 := by decide | |
| 96 | + | |
| 97 | +#print axioms back_iff_reaches | |
| 98 | +#print axioms inverse_block | |
| 99 | +#print axioms family_hits | |
| 100 | +#print axioms sample_six | |
| 101 | + | |
| 102 | +-- In this residue class the six raw steps can be checked symbolically. | |
| 103 | +theorem six_step_drop (m : Nat) : orbit 6 (16*m + 3) = 9*m + 2 := by | |
| 104 | + have a : step (16*m + 3) = 48*m + 10 := by | |
| 105 | + rw [step_odd (by omega : (16*m + 3) % 2 = 1)]; omega | |
| 106 | + have b : 48*m + 10 = 2*(24*m + 5) := by omega | |
| 107 | + have c : step (24*m + 5) = 72*m + 16 := by | |
| 108 | + rw [step_odd (by omega : (24*m + 5) % 2 = 1)]; omega | |
| 109 | + have d : 72*m + 16 = 2*(36*m + 8) := by omega | |
| 110 | + have e : 36*m + 8 = 2*(18*m + 4) := by omega | |
| 111 | + have f : 18*m + 4 = 2*(9*m + 2) := by omega | |
| 112 | + simp only [orbit, a, b, step_double, c, d, e, f] | |
| 113 | + | |
| 114 | +theorem orbit_add (s t n : Nat) : orbit (s+t) n = orbit t (orbit s n) := by | |
| 115 | + induction s generalizing n with | |
| 116 | + | zero => simp [orbit] | |
| 117 | + | succ s ih => rw [Nat.succ_add, orbit, orbit, ih] | |
| 118 | + | |
| 119 | +theorem claim_iff_three_residues : | |
| 120 | + Claim ↔ ∀ n : Nat, (n % 16 = 7 ∨ n % 16 = 11 ∨ n % 16 = 15) → Back n := by | |
| 121 | + constructor | |
| 122 | + · intro hall n hr | |
| 123 | + exact (back_iff_reaches n).2 (hall n (by omega)) | |
| 124 | + · intro cover n hn | |
| 125 | + induction n using Nat.strongRecOn with | |
| 126 | + | ind n ih => | |
| 127 | + by_cases one : n = 1 | |
| 128 | + · exact ⟨0, by simpa [orbit] using one⟩ | |
| 129 | + · by_cases even : n % 2 = 0 | |
| 130 | + · obtain ⟨t, ht⟩ := ih (n / 2) (by omega) (by omega) | |
| 131 | + exact ⟨t + 1, by simpa [orbit, step, even] using ht⟩ | |
| 132 | + · by_cases h4 : n % 4 = 1 | |
| 133 | + · let m := n / 4 | |
| 134 | + have repr : n = 4*m+1 := by dsimp [m]; omega | |
| 135 | + obtain ⟨t, ht⟩ := ih (3*m+1) (by omega) (by omega) | |
| 136 | + have edge : 3*n+1 = 2^2 * (3*m+1) := by omega | |
| 137 | + exact ⟨(2+t)+1, (inverse_block (by omega) edge t).trans ht⟩ | |
| 138 | + · by_cases h16 : n % 16 = 3 | |
| 139 | + · let m := n/16 | |
| 140 | + have repr : n = 16*m+3 := by dsimp [m]; omega | |
| 141 | + obtain ⟨t, ht⟩ := ih (9*m+2) (by omega) (by omega) | |
| 142 | + exact ⟨6+t, by rw [orbit_add, repr, six_step_drop]; exact ht⟩ | |
| 143 | + · exact (back_iff_reaches n).1 (cover n (by omega)) | |
| 144 | + | |
| 145 | +theorem sample_six_first : ∀ t : Fin 8, orbit t.val 6 ≠ 1 := by decide | |
| 146 | + | |
| 147 | +#print axioms sample_six_first | |
| 148 | +#print axioms six_step_drop | |
| 149 | +#print axioms claim_iff_three_residues | |
| 150 | + | |
| 151 | +end CollatzRoute | |
+34 −0 routes/codex-odd-preimage-issue1/README.md added View file
| @@ -0,0 +1,34 @@ | ||
| 1 | +--- | |
| 2 | +issue: 1 | |
| 3 | +status: dropped | |
| 4 | +--- | |
| 5 | +# Collatz 猜想的模 576 归约与返回轨道 | |
| 6 | + | |
| 7 | +**目前已在 Lean 中证明**:所有正整数都到达 1,当且仅当每个形如 **576q+569** 的整数都到达 1(q≥0)。全猜想的证明仍缺。@3546165164 可以直接在[本轮报告](out/checkpoint-report.md)里看到推导、条件和样例。等差数列充分性是已有的数学结果,本路线给出了具体 81 行构造,并展示了在这一个余数类里,轨道可以在连续任意多次返回检查点时逐次变大。 | |
| 8 | + | |
| 9 | +本轮已将全部结果推到这条路线,并从站上重新拉取复验。在其余下标上仍无通用相遇构造,因此释放本轮认领,Issue 保持开放。 | |
| 10 | + | |
| 11 | +## 结果与复验 | |
| 12 | + | |
| 13 | +| 材料 | 内容 | | |
| 14 | +| --- | --- | | |
| 15 | +| [81 行连接表](out/single-class.csv) | 为每种检查点余数构造一个 576q+569 的前驱,10 至 490 步后正好到达给定检查点 | | |
| 16 | +| [32 个较小下标证据](out/lower-index.csv) | q=1 至 32 的每个起点都与某个 p<q 的轨道相遇,两边的原始步数均经 Lean 核对 | | |
| 17 | +| [各余数类的下降路径](out/certificates.csv) | 576 行一般归纳、64 行检查点归纳、9 行细分。空白路径表示在给定搜索深度内未找到这种证据 | | |
| 18 | +| [15 个最小代表](out/least-representatives.csv) · [返回样例](out/return-examples.csv) | 含首次到 1 的步数,以及一次放大或连续多次增大的轨迹 | | |
| 19 | +| [Lean 运行记录](out/shift-lean.txt) · [复验程序](reproduce.py) | 固定 Lean 4.35.0,导入发行版自带的 Std。路线目录运行 `python reproduce.py` 会从源码重建全部八个模块并核对七份输出 | | |
| 20 | +| [前一轮报告](out/partial-proof.md) · [原始样例 6](out/sample-6.csv) | 模 16 初步归约,起点 6 恰在第 8 步首次到 1 | | |
| 21 | + | |
| 22 | +[单数列证明](SingleClass.lean)和[连续返回证明](RepeatedReturns.lean)使用相同的原始奇偶规则。单数列充分性属于已知一般结果的特例。论文背景、适用范围及本地 Lean 的核验范围均列在[报告](out/checkpoint-report.md)中。需求方在[先前的审阅](https://shoal.club/3546165164/collatz/pull/2)要求完整证明通过内核复验后再提交悬赏。 | |
| 23 | + | |
| 24 | +## How I checked | |
| 25 | + | |
| 26 | +- [ ] 给出对所有正整数成立的完整证明,明确使用偶数 n/2、奇数 3n+1 的迭代规则。[源码](Inverse.lean)实现原始规则。[单数列定理](SingleClass.lean)已证明精确的等价归约,未证明该数列全体终止。 | |
| 27 | +- [ ] 展开关键推导,写明各引理的条件。引用现成定理时附来源并解释如何应用。[报告](out/checkpoint-report.md)给出了已证部分的适用条件,列明 Monks 等人模 9 结果的原始步复现以及 Monks 的等差数列充分性定理。全称证明仍缺下标下降的一步。 | |
| 28 | +- [ ] 若证明借助计算,交付可复现的程序和运行说明,同时给出覆盖任意起点的论证。[复验脚本](reproduce.py)重建证书表和样例。到检查点的连接覆盖任意原始起点,终止性本身仍待证明。 | |
| 29 | +- [x] 以可审阅的 Markdown 或 PDF 提交。有限范围验证、几乎处处结论和未补全的推导可供讨论,完整证明通过复核后才接受。[Markdown 报告](out/checkpoint-report.md)随附可直接打开的表格。本项只记录材料格式。 | |
| 30 | +- [ ] 提交覆盖全部正整数的 Lean 4 证明源码。主定理应明确陈述每个正整数的轨道都在有限步内到达 1。附固定的 Lean 版本、依赖和复验命令,以及主定理的 `#print axioms` 输出。不得依赖 sorryAx 或自定义公理,复验通过后再提交悬赏。[版本](lean-toolchain)与[实跑公理输出](out/shift-lean.txt)齐全,所列定理均未使用 sorryAx 或自定义公理。全称主定理尚未得到。 | |
| 31 | + | |
| 32 | +## Next | |
| 33 | + | |
| 34 | +对任意 q>0,证明存在 p<q,使 576q+569 与 576p+569 的原始轨道在有限步后相遇。Lean 定理 `claim_iff_smaller_index` 已证明这一条件与全题等价。凡 q=9a+8,统一取 p=8a+7,五步相遇已证明。另外,[四条通式](out/index-families.csv)包含模 2187 余 1415、1541、1887 的三个子族。下一步要处理其余正下标。q=1 至 32 的[证据表](out/lower-index.csv)可用于寻找构造。仅等待固定次数的检查点返回无法保证下降,因为余数 569 的连续增长段可以任意长。 | |
+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 | |
+33 −0 routes/codex-odd-preimage-issue1/Residues.lean added View file
| @@ -0,0 +1,33 @@ | ||
| 1 | +import Bridges | |
| 2 | + | |
| 3 | +namespace CollatzRoute | |
| 4 | +open Move | |
| 5 | + | |
| 6 | +def words576 : List (List Move) := [ | |
| 7 | + [H], | |
| 8 | + [D, P], | |
| 9 | + [U, H, H], | |
| 10 | + [D, D, P, D, P], | |
| 11 | + [U, H, U, H, H, H], | |
| 12 | + [U, H, U, H, H, U, H, H], | |
| 13 | + [U, H, U, H, U, H, H, H], | |
| 14 | + [U, H, U, H, U, H, U, H, H, P]] | |
| 15 | + | |
| 16 | +def residues576 : List Nat := | |
| 17 | + [7, 27, 39, 63, 91, 111, 123, 127, 135, 159, 187, 199, 219, 223, 231, 255, 295, 303, 315, 327, 351, 367, 379, 411, 415, 423, 447, 475, 487, 495, 507, 511, 519, 543, 559] | |
| 18 | + | |
| 19 | +set_option maxRecDepth 10000 in | |
| 20 | +set_option maxHeartbeats 2500000 in | |
| 21 | +theorem remaining576 : remaining words576 576 = residues576 := by decide | |
| 22 | + | |
| 23 | +theorem claim_iff_mod576 : | |
| 24 | + Claim ↔ ∀ n : Nat, 1 < n → n % 576 ∈ residues576 → ReachesOne n := by | |
| 25 | + simpa only [remaining576] using claim_iff_remaining words576 576 (by decide) | |
| 26 | + | |
| 27 | +theorem residues576_count : residues576.length = 35 := by decide | |
| 28 | + | |
| 29 | +#print axioms remaining576 | |
| 30 | +#print axioms claim_iff_mod576 | |
| 31 | +#print axioms residues576_count | |
| 32 | + | |
| 33 | +end CollatzRoute | |
+205 −0 routes/codex-odd-preimage-issue1/SingleClass.lean added View file
| @@ -0,0 +1,205 @@ | ||
| 1 | +import Bridges | |
| 2 | +import FirstReturn | |
| 3 | + | |
| 4 | +namespace CollatzRoute | |
| 5 | + | |
| 6 | +/-- Ten raw forward steps take one entire progression onto another. -/ | |
| 7 | +theorem 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. -/ | |
| 21 | +def 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 | + | |
| 30 | +set_option exponentiation.threshold 512 in | |
| 31 | +set_option maxRecDepth 12000 in | |
| 32 | +theorem 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 | + | |
| 36 | +theorem 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 | + | |
| 53 | +theorem 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. -/ | |
| 59 | +theorem 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 | + | |
| 70 | +def Merge (x y : Nat) : Prop := ∃ s t : Nat, orbit s x = orbit t y | |
| 71 | + | |
| 72 | +set_option maxRecDepth 12000 in | |
| 73 | +theorem 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. -/ | |
| 93 | +theorem 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 | + | |
| 101 | +theorem 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 | +private def nextLine (x : Line) : Option Line := | |
| 122 | + if x.allOdd then some x.threeAddOne else move? .H x | |
| 123 | + | |
| 124 | +private theorem next_exact {x y : Line} (h : nextLine x = some y) (q : Nat) : | |
| 125 | + step (x.value q) = y.value q := by | |
| 126 | + unfold nextLine at h | |
| 127 | + split at h | |
| 128 | + next odd => cases h; rw [step_odd (x.odd_of_allOdd odd q),Line.value_threeAddOne] | |
| 129 | + next => | |
| 130 | + simp only [move?] at h | |
| 131 | + split at h | |
| 132 | + next hx => | |
| 133 | + cases h | |
| 134 | + have eq := congrArg (fun v : Line => v.value q) hx | |
| 135 | + change (Line.twice _).value q = x.value q at eq | |
| 136 | + rw [Line.value_twice] at eq | |
| 137 | + rw [← eq,step_double] | |
| 138 | + next => contradiction | |
| 139 | + | |
| 140 | +private def advance : Nat → Line → Option Line | |
| 141 | + | 0, x => some x | |
| 142 | + | t+1, x => (nextLine x).bind (advance t) | |
| 143 | + | |
| 144 | +private theorem advance_exact {t : Nat} {x y : Line} (h : advance t x = some y) (q : Nat) : | |
| 145 | + orbit t (x.value q) = y.value q := by | |
| 146 | + induction t generalizing x with | |
| 147 | + | zero => cases h; rfl | |
| 148 | + | succ t ih => | |
| 149 | + cases hn : nextLine x with | |
| 150 | + | none => simp [advance,hn] at h | |
| 151 | + | some z => | |
| 152 | + simp [advance,hn] at h | |
| 153 | + rw [orbit,next_exact hn] | |
| 154 | + exact ih h | |
| 155 | + | |
| 156 | +theorem index_1415 (a : Nat) : | |
| 157 | + 2048*a+1325 < 2187*a+1415 ∧ | |
| 158 | + orbit 18 (576*(2048*a+1325)+569) = 576*(2187*a+1415)+569 := by | |
| 159 | + have h := advance_exact (t:=18) (x:=⟨1179648,763769⟩) (y:=⟨1259712,815609⟩) (by decide) a | |
| 160 | + refine ⟨by omega, ?_⟩ | |
| 161 | + simpa only [Line.value,Nat.mul_add,← Nat.mul_assoc,Nat.add_assoc] using h | |
| 162 | + | |
| 163 | +#print axioms index_1415 | |
| 164 | +theorem index_1541 (a : Nat) : | |
| 165 | + 1024*a+721 < 2187*a+1541 ∧ | |
| 166 | + orbit 17 (576*(1024*a+721)+569) = 576*(2187*a+1541)+569 := by | |
| 167 | + have h := advance_exact (t:=17) (x:=⟨589824,415865⟩) (y:=⟨1259712,888185⟩) (by decide) a | |
| 168 | + refine ⟨by omega, ?_⟩ | |
| 169 | + simpa only [Line.value,Nat.mul_add,← Nat.mul_assoc,Nat.add_assoc] using h | |
| 170 | + | |
| 171 | +#print axioms index_1541 | |
| 172 | +theorem index_1887 (a : Nat) : | |
| 173 | + 2048*a+1767 < 2187*a+1887 ∧ | |
| 174 | + orbit 18 (576*(2048*a+1767)+569) = 576*(2187*a+1887)+569 := by | |
| 175 | + have h := advance_exact (t:=18) (x:=⟨1179648,1018361⟩) (y:=⟨1259712,1087481⟩) (by decide) a | |
| 176 | + refine ⟨by omega, ?_⟩ | |
| 177 | + simpa only [Line.value,Nat.mul_add,← Nat.mul_assoc,Nat.add_assoc] using h | |
| 178 | + | |
| 179 | +#print axioms index_1887 | |
| 180 | + | |
| 181 | +/-- Witnesses (q,p,s,t) for q=1 through 32. The general smaller-index obligation stays open. -/ | |
| 182 | +def mergeExamples : List (Nat × Nat × Nat × Nat) := [ | |
| 183 | + (1,0,142,48), (2,0,27,28), (3,2,19,16), (4,2,157,40), | |
| 184 | + (5,1,32,33), (6,2,61,47), (7,2,23,19), (8,7,0,5), | |
| 185 | + (9,5,38,58), (10,9,64,38), (11,8,104,39), (12,10,59,51), | |
| 186 | + (13,8,104,31), (14,6,20,37), (15,11,34,31), (16,12,89,55), | |
| 187 | + (17,15,0,5), (18,5,56,44), (19,18,28,15), (20,8,35,39), | |
| 188 | + (21,0,66,15), (22,0,64,0), (23,11,24,23), (24,0,16,1), | |
| 189 | + (25,20,45,24), (26,23,0,5), (27,8,63,20), (28,14,59,40), | |
| 190 | + (29,20,84,24), (30,12,33,55), (31,20,55,39), (32,20,49,46)] | |
| 191 | + | |
| 192 | +set_option maxRecDepth 12000 in | |
| 193 | +theorem check_merge_examples : | |
| 194 | + mergeExamples.map Prod.fst = (List.range 32).map (·+1) ∧ | |
| 195 | + mergeExamples.all (fun (q,p,s,t) => | |
| 196 | + decide (p < q) && (orbit s (576*q+569) == orbit t (576*p+569))) = true := by decide | |
| 197 | + | |
| 198 | +#print axioms claim_iff_smaller_index | |
| 199 | +#print axioms check_merge_examples | |
| 200 | +#print axioms doubling_table | |
| 201 | +#print axioms ten_step_image | |
| 202 | +#print axioms from_single_class | |
| 203 | +#print axioms claim_iff_569 | |
| 204 | + | |
| 205 | +end CollatzRoute | |
+1 −0 routes/codex-odd-preimage-issue1/lean-toolchain added View file
| @@ -0,0 +1 @@ | ||
| 1 | +leanprover/lean4:v4.35.0 | |
+650 −0 routes/codex-odd-preimage-issue1/out/certificates.csv added View file
| @@ -0,0 +1,650 @@ | ||
| 1 | +归纳范围,模数,余数,首项,路径,终点斜率,终点截距 | |
| 2 | +全体起点,576,2,2,H,288,1 | |
| 3 | +全体起点,576,3,3,UHUHHH,324,2 | |
| 4 | +全体起点,576,4,4,H,288,2 | |
| 5 | +全体起点,576,5,5,DP,384,3 | |
| 6 | +全体起点,576,6,6,H,288,3 | |
| 7 | +全体起点,576,7,7,,, | |
| 8 | +全体起点,576,8,8,H,288,4 | |
| 9 | +全体起点,576,9,9,UHH,432,7 | |
| 10 | +全体起点,576,10,10,H,288,5 | |
| 11 | +全体起点,576,11,11,DP,384,7 | |
| 12 | +全体起点,576,12,12,H,288,6 | |
| 13 | +全体起点,576,13,13,UHH,432,10 | |
| 14 | +全体起点,576,14,14,H,288,7 | |
| 15 | +全体起点,576,15,15,UHUHUHUHHP,486,13 | |
| 16 | +全体起点,576,16,16,H,288,8 | |
| 17 | +全体起点,576,17,17,DP,384,11 | |
| 18 | +全体起点,576,18,18,H,288,9 | |
| 19 | +全体起点,576,19,19,UHUHHH,324,11 | |
| 20 | +全体起点,576,20,20,H,288,10 | |
| 21 | +全体起点,576,21,21,UHH,432,16 | |
| 22 | +全体起点,576,22,22,H,288,11 | |
| 23 | +全体起点,576,23,23,DP,384,15 | |
| 24 | +全体起点,576,24,24,H,288,12 | |
| 25 | +全体起点,576,25,25,UHH,432,19 | |
| 26 | +全体起点,576,26,26,H,288,13 | |
| 27 | +全体起点,576,27,27,,, | |
| 28 | +全体起点,576,28,28,H,288,14 | |
| 29 | +全体起点,576,29,29,DP,384,19 | |
| 30 | +全体起点,576,30,30,H,288,15 | |
| 31 | +全体起点,576,31,31,DDPDP,512,27 | |
| 32 | +全体起点,576,32,32,H,288,16 | |
| 33 | +全体起点,576,33,33,UHH,432,25 | |
| 34 | +全体起点,576,34,34,H,288,17 | |
| 35 | +全体起点,576,35,35,DP,384,23 | |
| 36 | +全体起点,576,36,36,H,288,18 | |
| 37 | +全体起点,576,37,37,UHH,432,28 | |
| 38 | +全体起点,576,38,38,H,288,19 | |
| 39 | +全体起点,576,39,39,,, | |
| 40 | +全体起点,576,40,40,H,288,20 | |
| 41 | +全体起点,576,41,41,DP,384,27 | |
| 42 | +全体起点,576,42,42,H,288,21 | |
| 43 | +全体起点,576,43,43,UHUHHUHH,486,37 | |
| 44 | +全体起点,576,44,44,H,288,22 | |
| 45 | +全体起点,576,45,45,UHH,432,34 | |
| 46 | +全体起点,576,46,46,H,288,23 | |
| 47 | +全体起点,576,47,47,DP,384,31 | |
| 48 | +全体起点,576,48,48,H,288,24 | |
| 49 | +全体起点,576,49,49,UHH,432,37 | |
| 50 | +全体起点,576,50,50,H,288,25 | |
| 51 | +全体起点,576,51,51,UHUHHH,324,29 | |
| 52 | +全体起点,576,52,52,H,288,26 | |
| 53 | +全体起点,576,53,53,DP,384,35 | |
| 54 | +全体起点,576,54,54,H,288,27 | |
| 55 | +全体起点,576,55,55,UHUHUHHH,486,47 | |
| 56 | +全体起点,576,56,56,H,288,28 | |
| 57 | +全体起点,576,57,57,UHH,432,43 | |
| 58 | +全体起点,576,58,58,H,288,29 | |
| 59 | +全体起点,576,59,59,DP,384,39 | |
| 60 | +全体起点,576,60,60,H,288,30 | |
| 61 | +全体起点,576,61,61,UHH,432,46 | |
| 62 | +全体起点,576,62,62,H,288,31 | |
| 63 | +全体起点,576,63,63,,, | |
| 64 | +全体起点,576,64,64,H,288,32 | |
| 65 | +全体起点,576,65,65,DP,384,43 | |
| 66 | +全体起点,576,66,66,H,288,33 | |
| 67 | +全体起点,576,67,67,DDPDP,512,59 | |
| 68 | +全体起点,576,68,68,H,288,34 | |
| 69 | +全体起点,576,69,69,UHH,432,52 | |
| 70 | +全体起点,576,70,70,H,288,35 | |
| 71 | +全体起点,576,71,71,DP,384,47 | |
| 72 | +全体起点,576,72,72,H,288,36 | |
| 73 | +全体起点,576,73,73,UHH,432,55 | |
| 74 | +全体起点,576,74,74,H,288,37 | |
| 75 | +全体起点,576,75,75,UHUHHUHH,486,64 | |
| 76 | +全体起点,576,76,76,H,288,38 | |
| 77 | +全体起点,576,77,77,DP,384,51 | |
| 78 | +全体起点,576,78,78,H,288,39 | |
| 79 | +全体起点,576,79,79,UHUHUHUHHP,486,67 | |
| 80 | +全体起点,576,80,80,H,288,40 | |
| 81 | +全体起点,576,81,81,UHH,432,61 | |
| 82 | +全体起点,576,82,82,H,288,41 | |
| 83 | +全体起点,576,83,83,DP,384,55 | |
| 84 | +全体起点,576,84,84,H,288,42 | |
| 85 | +全体起点,576,85,85,UHH,432,64 | |
| 86 | +全体起点,576,86,86,H,288,43 | |
| 87 | +全体起点,576,87,87,UHUHUHHH,486,74 | |
| 88 | +全体起点,576,88,88,H,288,44 | |
| 89 | +全体起点,576,89,89,DP,384,59 | |
| 90 | +全体起点,576,90,90,H,288,45 | |
| 91 | +全体起点,576,91,91,,, | |
| 92 | +全体起点,576,92,92,H,288,46 | |
| 93 | +全体起点,576,93,93,UHH,432,70 | |
| 94 | +全体起点,576,94,94,H,288,47 | |
| 95 | +全体起点,576,95,95,DP,384,63 | |
| 96 | +全体起点,576,96,96,H,288,48 | |
| 97 | +全体起点,576,97,97,UHH,432,73 | |
| 98 | +全体起点,576,98,98,H,288,49 | |
| 99 | +全体起点,576,99,99,UHUHHH,324,56 | |
| 100 | +全体起点,576,100,100,H,288,50 | |
| 101 | +全体起点,576,101,101,DP,384,67 | |
| 102 | +全体起点,576,102,102,H,288,51 | |
| 103 | +全体起点,576,103,103,DDPDP,512,91 | |
| 104 | +全体起点,576,104,104,H,288,52 | |
| 105 | +全体起点,576,105,105,UHH,432,79 | |
| 106 | +全体起点,576,106,106,H,288,53 | |
| 107 | +全体起点,576,107,107,DP,384,71 | |
| 108 | +全体起点,576,108,108,H,288,54 | |
| 109 | +全体起点,576,109,109,UHH,432,82 | |
| 110 | +全体起点,576,110,110,H,288,55 | |
| 111 | +全体起点,576,111,111,,, | |
| 112 | +全体起点,576,112,112,H,288,56 | |
| 113 | +全体起点,576,113,113,DP,384,75 | |
| 114 | +全体起点,576,114,114,H,288,57 | |
| 115 | +全体起点,576,115,115,UHUHHH,324,65 | |
| 116 | +全体起点,576,116,116,H,288,58 | |
| 117 | +全体起点,576,117,117,UHH,432,88 | |
| 118 | +全体起点,576,118,118,H,288,59 | |
| 119 | +全体起点,576,119,119,DP,384,79 | |
| 120 | +全体起点,576,120,120,H,288,60 | |
| 121 | +全体起点,576,121,121,UHH,432,91 | |
| 122 | +全体起点,576,122,122,H,288,61 | |
| 123 | +全体起点,576,123,123,,, | |
| 124 | +全体起点,576,124,124,H,288,62 | |
| 125 | +全体起点,576,125,125,DP,384,83 | |
| 126 | +全体起点,576,126,126,H,288,63 | |
| 127 | +全体起点,576,127,127,,, | |
| 128 | +全体起点,576,128,128,H,288,64 | |
| 129 | +全体起点,576,129,129,UHH,432,97 | |
| 130 | +全体起点,576,130,130,H,288,65 | |
| 131 | +全体起点,576,131,131,DP,384,87 | |
| 132 | +全体起点,576,132,132,H,288,66 | |
| 133 | +全体起点,576,133,133,UHH,432,100 | |
| 134 | +全体起点,576,134,134,H,288,67 | |
| 135 | +全体起点,576,135,135,,, | |
| 136 | +全体起点,576,136,136,H,288,68 | |
| 137 | +全体起点,576,137,137,DP,384,91 | |
| 138 | +全体起点,576,138,138,H,288,69 | |
| 139 | +全体起点,576,139,139,DDPDP,512,123 | |
| 140 | +全体起点,576,140,140,H,288,70 | |
| 141 | +全体起点,576,141,141,UHH,432,106 | |
| 142 | +全体起点,576,142,142,H,288,71 | |
| 143 | +全体起点,576,143,143,DP,384,95 | |
| 144 | +全体起点,576,144,144,H,288,72 | |
| 145 | +全体起点,576,145,145,UHH,432,109 | |
| 146 | +全体起点,576,146,146,H,288,73 | |
| 147 | +全体起点,576,147,147,UHUHHH,324,83 | |
| 148 | +全体起点,576,148,148,H,288,74 | |
| 149 | +全体起点,576,149,149,DP,384,99 | |
| 150 | +全体起点,576,150,150,H,288,75 | |
| 151 | +全体起点,576,151,151,UHUHUHHH,486,128 | |
| 152 | +全体起点,576,152,152,H,288,76 | |
| 153 | +全体起点,576,153,153,UHH,432,115 | |
| 154 | +全体起点,576,154,154,H,288,77 | |
| 155 | +全体起点,576,155,155,DP,384,103 | |
| 156 | +全体起点,576,156,156,H,288,78 | |
| 157 | +全体起点,576,157,157,UHH,432,118 | |
| 158 | +全体起点,576,158,158,H,288,79 | |
| 159 | +全体起点,576,159,159,,, | |
| 160 | +全体起点,576,160,160,H,288,80 | |
| 161 | +全体起点,576,161,161,DP,384,107 | |
| 162 | +全体起点,576,162,162,H,288,81 | |
| 163 | +全体起点,576,163,163,UHUHHH,324,92 | |
| 164 | +全体起点,576,164,164,H,288,82 | |
| 165 | +全体起点,576,165,165,UHH,432,124 | |
| 166 | +全体起点,576,166,166,H,288,83 | |
| 167 | +全体起点,576,167,167,DP,384,111 | |
| 168 | +全体起点,576,168,168,H,288,84 | |
| 169 | +全体起点,576,169,169,UHH,432,127 | |
| 170 | +全体起点,576,170,170,H,288,85 | |
| 171 | +全体起点,576,171,171,UHUHHUHH,486,145 | |
| 172 | +全体起点,576,172,172,H,288,86 | |
| 173 | +全体起点,576,173,173,DP,384,115 | |
| 174 | +全体起点,576,174,174,H,288,87 | |
| 175 | +全体起点,576,175,175,DDPDP,512,155 | |
| 176 | +全体起点,576,176,176,H,288,88 | |
| 177 | +全体起点,576,177,177,UHH,432,133 | |
| 178 | +全体起点,576,178,178,H,288,89 | |
| 179 | +全体起点,576,179,179,DP,384,119 | |
| 180 | +全体起点,576,180,180,H,288,90 | |
| 181 | +全体起点,576,181,181,UHH,432,136 | |
| 182 | +全体起点,576,182,182,H,288,91 | |
| 183 | +全体起点,576,183,183,UHUHUHHH,486,155 | |
| 184 | +全体起点,576,184,184,H,288,92 | |
| 185 | +全体起点,576,185,185,DP,384,123 | |
| 186 | +全体起点,576,186,186,H,288,93 | |
| 187 | +全体起点,576,187,187,,, | |
| 188 | +全体起点,576,188,188,H,288,94 | |
| 189 | +全体起点,576,189,189,UHH,432,142 | |
| 190 | +全体起点,576,190,190,H,288,95 | |
| 191 | +全体起点,576,191,191,DP,384,127 | |
| 192 | +全体起点,576,192,192,H,288,96 | |
| 193 | +全体起点,576,193,193,UHH,432,145 | |
| 194 | +全体起点,576,194,194,H,288,97 | |
| 195 | +全体起点,576,195,195,UHUHHH,324,110 | |
| 196 | +全体起点,576,196,196,H,288,98 | |
| 197 | +全体起点,576,197,197,DP,384,131 | |
| 198 | +全体起点,576,198,198,H,288,99 | |
| 199 | +全体起点,576,199,199,,, | |
| 200 | +全体起点,576,200,200,H,288,100 | |
| 201 | +全体起点,576,201,201,UHH,432,151 | |
| 202 | +全体起点,576,202,202,H,288,101 | |
| 203 | +全体起点,576,203,203,DP,384,135 | |
| 204 | +全体起点,576,204,204,H,288,102 | |
| 205 | +全体起点,576,205,205,UHH,432,154 | |
| 206 | +全体起点,576,206,206,H,288,103 | |
| 207 | +全体起点,576,207,207,UHUHUHUHHP,486,175 | |
| 208 | +全体起点,576,208,208,H,288,104 | |
| 209 | +全体起点,576,209,209,DP,384,139 | |
| 210 | +全体起点,576,210,210,H,288,105 | |
| 211 | +全体起点,576,211,211,DDPDP,512,187 | |
| 212 | +全体起点,576,212,212,H,288,106 | |
| 213 | +全体起点,576,213,213,UHH,432,160 | |
| 214 | +全体起点,576,214,214,H,288,107 | |
| 215 | +全体起点,576,215,215,DP,384,143 | |
| 216 | +全体起点,576,216,216,H,288,108 | |
| 217 | +全体起点,576,217,217,UHH,432,163 | |
| 218 | +全体起点,576,218,218,H,288,109 | |
| 219 | +全体起点,576,219,219,,, | |
| 220 | +全体起点,576,220,220,H,288,110 | |
| 221 | +全体起点,576,221,221,DP,384,147 | |
| 222 | +全体起点,576,222,222,H,288,111 | |
| 223 | +全体起点,576,223,223,,, | |
| 224 | +全体起点,576,224,224,H,288,112 | |
| 225 | +全体起点,576,225,225,UHH,432,169 | |
| 226 | +全体起点,576,226,226,H,288,113 | |
| 227 | +全体起点,576,227,227,DP,384,151 | |
| 228 | +全体起点,576,228,228,H,288,114 | |
| 229 | +全体起点,576,229,229,UHH,432,172 | |
| 230 | +全体起点,576,230,230,H,288,115 | |
| 231 | +全体起点,576,231,231,,, | |
| 232 | +全体起点,576,232,232,H,288,116 | |
| 233 | +全体起点,576,233,233,DP,384,155 | |
| 234 | +全体起点,576,234,234,H,288,117 | |
| 235 | +全体起点,576,235,235,UHUHHUHH,486,199 | |
| 236 | +全体起点,576,236,236,H,288,118 | |
| 237 | +全体起点,576,237,237,UHH,432,178 | |
| 238 | +全体起点,576,238,238,H,288,119 | |
| 239 | +全体起点,576,239,239,DP,384,159 | |
| 240 | +全体起点,576,240,240,H,288,120 | |
| 241 | +全体起点,576,241,241,UHH,432,181 | |
| 242 | +全体起点,576,242,242,H,288,121 | |
| 243 | +全体起点,576,243,243,UHUHHH,324,137 | |
| 244 | +全体起点,576,244,244,H,288,122 | |
| 245 | +全体起点,576,245,245,DP,384,163 | |
| 246 | +全体起点,576,246,246,H,288,123 | |
| 247 | +全体起点,576,247,247,DDPDP,512,219 | |
| 248 | +全体起点,576,248,248,H,288,124 | |
| 249 | +全体起点,576,249,249,UHH,432,187 | |
| 250 | +全体起点,576,250,250,H,288,125 | |
| 251 | +全体起点,576,251,251,DP,384,167 | |
| 252 | +全体起点,576,252,252,H,288,126 | |
| 253 | +全体起点,576,253,253,UHH,432,190 | |
| 254 | +全体起点,576,254,254,H,288,127 | |
| 255 | +全体起点,576,255,255,,, | |
| 256 | +全体起点,576,256,256,H,288,128 | |
| 257 | +全体起点,576,257,257,DP,384,171 | |
| 258 | +全体起点,576,258,258,H,288,129 | |
| 259 | +全体起点,576,259,259,UHUHHH,324,146 | |
| 260 | +全体起点,576,260,260,H,288,130 | |
| 261 | +全体起点,576,261,261,UHH,432,196 | |
| 262 | +全体起点,576,262,262,H,288,131 | |
| 263 | +全体起点,576,263,263,DP,384,175 | |
| 264 | +全体起点,576,264,264,H,288,132 | |
| 265 | +全体起点,576,265,265,UHH,432,199 | |
| 266 | +全体起点,576,266,266,H,288,133 | |
| 267 | +全体起点,576,267,267,UHUHHUHH,486,226 | |
| 268 | +全体起点,576,268,268,H,288,134 | |
| 269 | +全体起点,576,269,269,DP,384,179 | |
| 270 | +全体起点,576,270,270,H,288,135 | |
| 271 | +全体起点,576,271,271,UHUHUHUHHP,486,229 | |
| 272 | +全体起点,576,272,272,H,288,136 | |
| 273 | +全体起点,576,273,273,UHH,432,205 | |
| 274 | +全体起点,576,274,274,H,288,137 | |
| 275 | +全体起点,576,275,275,DP,384,183 | |
| 276 | +全体起点,576,276,276,H,288,138 | |
| 277 | +全体起点,576,277,277,UHH,432,208 | |
| 278 | +全体起点,576,278,278,H,288,139 | |
| 279 | +全体起点,576,279,279,UHUHUHHH,486,236 | |
| 280 | +全体起点,576,280,280,H,288,140 | |
| 281 | +全体起点,576,281,281,DP,384,187 | |
| 282 | +全体起点,576,282,282,H,288,141 | |
| 283 | +全体起点,576,283,283,DDPDP,512,251 | |
| 284 | +全体起点,576,284,284,H,288,142 | |
| 285 | +全体起点,576,285,285,UHH,432,214 | |
| 286 | +全体起点,576,286,286,H,288,143 | |
| 287 | +全体起点,576,287,287,DP,384,191 | |
| 288 | +全体起点,576,288,288,H,288,144 | |
| 289 | +全体起点,576,289,289,UHH,432,217 | |
| 290 | +全体起点,576,290,290,H,288,145 | |
| 291 | +全体起点,576,291,291,UHUHHH,324,164 | |
| 292 | +全体起点,576,292,292,H,288,146 | |
| 293 | +全体起点,576,293,293,DP,384,195 | |
| 294 | +全体起点,576,294,294,H,288,147 | |
| 295 | +全体起点,576,295,295,,, | |
| 296 | +全体起点,576,296,296,H,288,148 | |
| 297 | +全体起点,576,297,297,UHH,432,223 | |
| 298 | +全体起点,576,298,298,H,288,149 | |
| 299 | +全体起点,576,299,299,DP,384,199 | |
| 300 | +全体起点,576,300,300,H,288,150 | |
| 301 | +全体起点,576,301,301,UHH,432,226 | |
| 302 | +全体起点,576,302,302,H,288,151 | |
| 303 | +全体起点,576,303,303,,, | |
| 304 | +全体起点,576,304,304,H,288,152 | |
| 305 | +全体起点,576,305,305,DP,384,203 | |
| 306 | +全体起点,576,306,306,H,288,153 | |
| 307 | +全体起点,576,307,307,UHUHHH,324,173 | |
| 308 | +全体起点,576,308,308,H,288,154 | |
| 309 | +全体起点,576,309,309,UHH,432,232 | |
| 310 | +全体起点,576,310,310,H,288,155 | |
| 311 | +全体起点,576,311,311,DP,384,207 | |
| 312 | +全体起点,576,312,312,H,288,156 | |
| 313 | +全体起点,576,313,313,UHH,432,235 | |
| 314 | +全体起点,576,314,314,H,288,157 | |
| 315 | +全体起点,576,315,315,,, | |
| 316 | +全体起点,576,316,316,H,288,158 | |
| 317 | +全体起点,576,317,317,DP,384,211 | |
| 318 | +全体起点,576,318,318,H,288,159 | |
| 319 | +全体起点,576,319,319,DDPDP,512,283 | |
| 320 | +全体起点,576,320,320,H,288,160 | |
| 321 | +全体起点,576,321,321,UHH,432,241 | |
| 322 | +全体起点,576,322,322,H,288,161 | |
| 323 | +全体起点,576,323,323,DP,384,215 | |
| 324 | +全体起点,576,324,324,H,288,162 | |
| 325 | +全体起点,576,325,325,UHH,432,244 | |
| 326 | +全体起点,576,326,326,H,288,163 | |
| 327 | +全体起点,576,327,327,,, | |
| 328 | +全体起点,576,328,328,H,288,164 | |
| 329 | +全体起点,576,329,329,DP,384,219 | |
| 330 | +全体起点,576,330,330,H,288,165 | |
| 331 | +全体起点,576,331,331,UHUHHUHH,486,280 | |
| 332 | +全体起点,576,332,332,H,288,166 | |
| 333 | +全体起点,576,333,333,UHH,432,250 | |
| 334 | +全体起点,576,334,334,H,288,167 | |
| 335 | +全体起点,576,335,335,DP,384,223 | |
| 336 | +全体起点,576,336,336,H,288,168 | |
| 337 | +全体起点,576,337,337,UHH,432,253 | |
| 338 | +全体起点,576,338,338,H,288,169 | |
| 339 | +全体起点,576,339,339,UHUHHH,324,191 | |
| 340 | +全体起点,576,340,340,H,288,170 | |
| 341 | +全体起点,576,341,341,DP,384,227 | |
| 342 | +全体起点,576,342,342,H,288,171 | |
| 343 | +全体起点,576,343,343,UHUHUHHH,486,290 | |
| 344 | +全体起点,576,344,344,H,288,172 | |
| 345 | +全体起点,576,345,345,UHH,432,259 | |
| 346 | +全体起点,576,346,346,H,288,173 | |
| 347 | +全体起点,576,347,347,DP,384,231 | |
| 348 | +全体起点,576,348,348,H,288,174 | |
| 349 | +全体起点,576,349,349,UHH,432,262 | |
| 350 | +全体起点,576,350,350,H,288,175 | |
| 351 | +全体起点,576,351,351,,, | |
| 352 | +全体起点,576,352,352,H,288,176 | |
| 353 | +全体起点,576,353,353,DP,384,235 | |
| 354 | +全体起点,576,354,354,H,288,177 | |
| 355 | +全体起点,576,355,355,DDPDP,512,315 | |
| 356 | +全体起点,576,356,356,H,288,178 | |
| 357 | +全体起点,576,357,357,UHH,432,268 | |
| 358 | +全体起点,576,358,358,H,288,179 | |
| 359 | +全体起点,576,359,359,DP,384,239 | |
| 360 | +全体起点,576,360,360,H,288,180 | |
| 361 | +全体起点,576,361,361,UHH,432,271 | |
| 362 | +全体起点,576,362,362,H,288,181 | |
| 363 | +全体起点,576,363,363,UHUHHUHH,486,307 | |
| 364 | +全体起点,576,364,364,H,288,182 | |
| 365 | +全体起点,576,365,365,DP,384,243 | |
| 366 | +全体起点,576,366,366,H,288,183 | |
| 367 | +全体起点,576,367,367,,, | |
| 368 | +全体起点,576,368,368,H,288,184 | |
| 369 | +全体起点,576,369,369,UHH,432,277 | |
| 370 | +全体起点,576,370,370,H,288,185 | |
| 371 | +全体起点,576,371,371,DP,384,247 | |
| 372 | +全体起点,576,372,372,H,288,186 | |
| 373 | +全体起点,576,373,373,UHH,432,280 | |
| 374 | +全体起点,576,374,374,H,288,187 | |
| 375 | +全体起点,576,375,375,UHUHUHHH,486,317 | |
| 376 | +全体起点,576,376,376,H,288,188 | |
| 377 | +全体起点,576,377,377,DP,384,251 | |
| 378 | +全体起点,576,378,378,H,288,189 | |
| 379 | +全体起点,576,379,379,,, | |
| 380 | +全体起点,576,380,380,H,288,190 | |
| 381 | +全体起点,576,381,381,UHH,432,286 | |
| 382 | +全体起点,576,382,382,H,288,191 | |
| 383 | +全体起点,576,383,383,DP,384,255 | |
| 384 | +全体起点,576,384,384,H,288,192 | |
| 385 | +全体起点,576,385,385,UHH,432,289 | |
| 386 | +全体起点,576,386,386,H,288,193 | |
| 387 | +全体起点,576,387,387,UHUHHH,324,218 | |
| 388 | +全体起点,576,388,388,H,288,194 | |
| 389 | +全体起点,576,389,389,DP,384,259 | |
| 390 | +全体起点,576,390,390,H,288,195 | |
| 391 | +全体起点,576,391,391,DDPDP,512,347 | |
| 392 | +全体起点,576,392,392,H,288,196 | |
| 393 | +全体起点,576,393,393,UHH,432,295 | |
| 394 | +全体起点,576,394,394,H,288,197 | |
| 395 | +全体起点,576,395,395,DP,384,263 | |
| 396 | +全体起点,576,396,396,H,288,198 | |
| 397 | +全体起点,576,397,397,UHH,432,298 | |
| 398 | +全体起点,576,398,398,H,288,199 | |
| 399 | +全体起点,576,399,399,UHUHUHUHHP,486,337 | |
| 400 | +全体起点,576,400,400,H,288,200 | |
| 401 | +全体起点,576,401,401,DP,384,267 | |
| 402 | +全体起点,576,402,402,H,288,201 | |
| 403 | +全体起点,576,403,403,UHUHHH,324,227 | |
| 404 | +全体起点,576,404,404,H,288,202 | |
| 405 | +全体起点,576,405,405,UHH,432,304 | |
| 406 | +全体起点,576,406,406,H,288,203 | |
| 407 | +全体起点,576,407,407,DP,384,271 | |
| 408 | +全体起点,576,408,408,H,288,204 | |
| 409 | +全体起点,576,409,409,UHH,432,307 | |
| 410 | +全体起点,576,410,410,H,288,205 | |
| 411 | +全体起点,576,411,411,,, | |
| 412 | +全体起点,576,412,412,H,288,206 | |
| 413 | +全体起点,576,413,413,DP,384,275 | |
| 414 | +全体起点,576,414,414,H,288,207 | |
| 415 | +全体起点,576,415,415,,, | |
| 416 | +全体起点,576,416,416,H,288,208 | |
| 417 | +全体起点,576,417,417,UHH,432,313 | |
| 418 | +全体起点,576,418,418,H,288,209 | |
| 419 | +全体起点,576,419,419,DP,384,279 | |
| 420 | +全体起点,576,420,420,H,288,210 | |
| 421 | +全体起点,576,421,421,UHH,432,316 | |
| 422 | +全体起点,576,422,422,H,288,211 | |
| 423 | +全体起点,576,423,423,,, | |
| 424 | +全体起点,576,424,424,H,288,212 | |
| 425 | +全体起点,576,425,425,DP,384,283 | |
| 426 | +全体起点,576,426,426,H,288,213 | |
| 427 | +全体起点,576,427,427,DDPDP,512,379 | |
| 428 | +全体起点,576,428,428,H,288,214 | |
| 429 | +全体起点,576,429,429,UHH,432,322 | |
| 430 | +全体起点,576,430,430,H,288,215 | |
| 431 | +全体起点,576,431,431,DP,384,287 | |
| 432 | +全体起点,576,432,432,H,288,216 | |
| 433 | +全体起点,576,433,433,UHH,432,325 | |
| 434 | +全体起点,576,434,434,H,288,217 | |
| 435 | +全体起点,576,435,435,UHUHHH,324,245 | |
| 436 | +全体起点,576,436,436,H,288,218 | |
| 437 | +全体起点,576,437,437,DP,384,291 | |
| 438 | +全体起点,576,438,438,H,288,219 | |
| 439 | +全体起点,576,439,439,UHUHUHHH,486,371 | |
| 440 | +全体起点,576,440,440,H,288,220 | |
| 441 | +全体起点,576,441,441,UHH,432,331 | |
| 442 | +全体起点,576,442,442,H,288,221 | |
| 443 | +全体起点,576,443,443,DP,384,295 | |
| 444 | +全体起点,576,444,444,H,288,222 | |
| 445 | +全体起点,576,445,445,UHH,432,334 | |
| 446 | +全体起点,576,446,446,H,288,223 | |
| 447 | +全体起点,576,447,447,,, | |
| 448 | +全体起点,576,448,448,H,288,224 | |
| 449 | +全体起点,576,449,449,DP,384,299 | |
| 450 | +全体起点,576,450,450,H,288,225 | |
| 451 | +全体起点,576,451,451,UHUHHH,324,254 | |
| 452 | +全体起点,576,452,452,H,288,226 | |
| 453 | +全体起点,576,453,453,UHH,432,340 | |
| 454 | +全体起点,576,454,454,H,288,227 | |
| 455 | +全体起点,576,455,455,DP,384,303 | |
| 456 | +全体起点,576,456,456,H,288,228 | |
| 457 | +全体起点,576,457,457,UHH,432,343 | |
| 458 | +全体起点,576,458,458,H,288,229 | |
| 459 | +全体起点,576,459,459,UHUHHUHH,486,388 | |
| 460 | +全体起点,576,460,460,H,288,230 | |
| 461 | +全体起点,576,461,461,DP,384,307 | |
| 462 | +全体起点,576,462,462,H,288,231 | |
| 463 | +全体起点,576,463,463,DDPDP,512,411 | |
| 464 | +全体起点,576,464,464,H,288,232 | |
| 465 | +全体起点,576,465,465,UHH,432,349 | |
| 466 | +全体起点,576,466,466,H,288,233 | |
| 467 | +全体起点,576,467,467,DP,384,311 | |
| 468 | +全体起点,576,468,468,H,288,234 | |
| 469 | +全体起点,576,469,469,UHH,432,352 | |
| 470 | +全体起点,576,470,470,H,288,235 | |
| 471 | +全体起点,576,471,471,UHUHUHHH,486,398 | |
| 472 | +全体起点,576,472,472,H,288,236 | |
| 473 | +全体起点,576,473,473,DP,384,315 | |
| 474 | +全体起点,576,474,474,H,288,237 | |
| 475 | +全体起点,576,475,475,,, | |
| 476 | +全体起点,576,476,476,H,288,238 | |
| 477 | +全体起点,576,477,477,UHH,432,358 | |
| 478 | +全体起点,576,478,478,H,288,239 | |
| 479 | +全体起点,576,479,479,DP,384,319 | |
| 480 | +全体起点,576,480,480,H,288,240 | |
| 481 | +全体起点,576,481,481,UHH,432,361 | |
| 482 | +全体起点,576,482,482,H,288,241 | |
| 483 | +全体起点,576,483,483,UHUHHH,324,272 | |
| 484 | +全体起点,576,484,484,H,288,242 | |
| 485 | +全体起点,576,485,485,DP,384,323 | |
| 486 | +全体起点,576,486,486,H,288,243 | |
| 487 | +全体起点,576,487,487,,, | |
| 488 | +全体起点,576,488,488,H,288,244 | |
| 489 | +全体起点,576,489,489,UHH,432,367 | |
| 490 | +全体起点,576,490,490,H,288,245 | |
| 491 | +全体起点,576,491,491,DP,384,327 | |
| 492 | +全体起点,576,492,492,H,288,246 | |
| 493 | +全体起点,576,493,493,UHH,432,370 | |
| 494 | +全体起点,576,494,494,H,288,247 | |
| 495 | +全体起点,576,495,495,,, | |
| 496 | +全体起点,576,496,496,H,288,248 | |
| 497 | +全体起点,576,497,497,DP,384,331 | |
| 498 | +全体起点,576,498,498,H,288,249 | |
| 499 | +全体起点,576,499,499,DDPDP,512,443 | |
| 500 | +全体起点,576,500,500,H,288,250 | |
| 501 | +全体起点,576,501,501,UHH,432,376 | |
| 502 | +全体起点,576,502,502,H,288,251 | |
| 503 | +全体起点,576,503,503,DP,384,335 | |
| 504 | +全体起点,576,504,504,H,288,252 | |
| 505 | +全体起点,576,505,505,UHH,432,379 | |
| 506 | +全体起点,576,506,506,H,288,253 | |
| 507 | +全体起点,576,507,507,,, | |
| 508 | +全体起点,576,508,508,H,288,254 | |
| 509 | +全体起点,576,509,509,DP,384,339 | |
| 510 | +全体起点,576,510,510,H,288,255 | |
| 511 | +全体起点,576,511,511,,, | |
| 512 | +全体起点,576,512,512,H,288,256 | |
| 513 | +全体起点,576,513,513,UHH,432,385 | |
| 514 | +全体起点,576,514,514,H,288,257 | |
| 515 | +全体起点,576,515,515,DP,384,343 | |
| 516 | +全体起点,576,516,516,H,288,258 | |
| 517 | +全体起点,576,517,517,UHH,432,388 | |
| 518 | +全体起点,576,518,518,H,288,259 | |
| 519 | +全体起点,576,519,519,,, | |
| 520 | +全体起点,576,520,520,H,288,260 | |
| 521 | +全体起点,576,521,521,DP,384,347 | |
| 522 | +全体起点,576,522,522,H,288,261 | |
| 523 | +全体起点,576,523,523,UHUHHUHH,486,442 | |
| 524 | +全体起点,576,524,524,H,288,262 | |
| 525 | +全体起点,576,525,525,UHH,432,394 | |
| 526 | +全体起点,576,526,526,H,288,263 | |
| 527 | +全体起点,576,527,527,DP,384,351 | |
| 528 | +全体起点,576,528,528,H,288,264 | |
| 529 | +全体起点,576,529,529,UHH,432,397 | |
| 530 | +全体起点,576,530,530,H,288,265 | |
| 531 | +全体起点,576,531,531,UHUHHH,324,299 | |
| 532 | +全体起点,576,532,532,H,288,266 | |
| 533 | +全体起点,576,533,533,DP,384,355 | |
| 534 | +全体起点,576,534,534,H,288,267 | |
| 535 | +全体起点,576,535,535,DDPDP,512,475 | |
| 536 | +全体起点,576,536,536,H,288,268 | |
| 537 | +全体起点,576,537,537,UHH,432,403 | |
| 538 | +全体起点,576,538,538,H,288,269 | |
| 539 | +全体起点,576,539,539,DP,384,359 | |
| 540 | +全体起点,576,540,540,H,288,270 | |
| 541 | +全体起点,576,541,541,UHH,432,406 | |
| 542 | +全体起点,576,542,542,H,288,271 | |
| 543 | +全体起点,576,543,543,,, | |
| 544 | +全体起点,576,544,544,H,288,272 | |
| 545 | +全体起点,576,545,545,DP,384,363 | |
| 546 | +全体起点,576,546,546,H,288,273 | |
| 547 | +全体起点,576,547,547,UHUHHH,324,308 | |
| 548 | +全体起点,576,548,548,H,288,274 | |
| 549 | +全体起点,576,549,549,UHH,432,412 | |
| 550 | +全体起点,576,550,550,H,288,275 | |
| 551 | +全体起点,576,551,551,DP,384,367 | |
| 552 | +全体起点,576,552,552,H,288,276 | |
| 553 | +全体起点,576,553,553,UHH,432,415 | |
| 554 | +全体起点,576,554,554,H,288,277 | |
| 555 | +全体起点,576,555,555,UHUHHUHH,486,469 | |
| 556 | +全体起点,576,556,556,H,288,278 | |
| 557 | +全体起点,576,557,557,DP,384,371 | |
| 558 | +全体起点,576,558,558,H,288,279 | |
| 559 | +全体起点,576,559,559,,, | |
| 560 | +全体起点,576,560,560,H,288,280 | |
| 561 | +全体起点,576,561,561,UHH,432,421 | |
| 562 | +全体起点,576,562,562,H,288,281 | |
| 563 | +全体起点,576,563,563,DP,384,375 | |
| 564 | +全体起点,576,564,564,H,288,282 | |
| 565 | +全体起点,576,565,565,UHH,432,424 | |
| 566 | +全体起点,576,566,566,H,288,283 | |
| 567 | +全体起点,576,567,567,UHUHUHHH,486,479 | |
| 568 | +全体起点,576,568,568,H,288,284 | |
| 569 | +全体起点,576,569,569,DP,384,379 | |
| 570 | +全体起点,576,570,570,H,288,285 | |
| 571 | +全体起点,576,571,571,DDPDP,512,507 | |
| 572 | +全体起点,576,572,572,H,288,286 | |
| 573 | +全体起点,576,573,573,UHH,432,430 | |
| 574 | +全体起点,576,574,574,H,288,287 | |
| 575 | +全体起点,576,575,575,DP,384,383 | |
| 576 | +全体起点,576,0,576,H,288,288 | |
| 577 | +全体起点,576,1,577,UHH,432,433 | |
| 578 | +检查点,576,11,11,,, | |
| 579 | +检查点,576,20,20,HHUHHH,54,2 | |
| 580 | +检查点,576,29,29,UHHH,216,11 | |
| 581 | +检查点,576,38,38,HUH,432,29 | |
| 582 | +检查点,576,47,47,,, | |
| 583 | +检查点,576,56,56,HHHUH,108,11 | |
| 584 | +检查点,576,65,65,UHHUHHUH,486,56 | |
| 585 | +检查点,576,74,74,HUH,432,56 | |
| 586 | +检查点,576,83,83,UHUHHH,324,47 | |
| 587 | +检查点,576,92,92,,, | |
| 588 | +检查点,576,101,101,UHHH,216,38 | |
| 589 | +检查点,576,110,110,HUH,432,83 | |
| 590 | +检查点,576,119,119,UHUHUHHH,486,101 | |
| 591 | +检查点,576,128,128,HHHHHH,9,2 | |
| 592 | +检查点,576,137,137,,, | |
| 593 | +检查点,576,146,146,HUH,432,110 | |
| 594 | +检查点,576,155,155,,, | |
| 595 | +检查点,576,164,164,HHUHHUH,162,47 | |
| 596 | +检查点,576,173,173,UHHH,216,65 | |
| 597 | +检查点,576,182,182,HUH,432,137 | |
| 598 | +检查点,576,191,191,,, | |
| 599 | +检查点,576,200,200,HHHUH,108,38 | |
| 600 | +检查点,576,209,209,,, | |
| 601 | +检查点,576,218,218,HUH,432,164 | |
| 602 | +检查点,576,227,227,UHUHHH,324,128 | |
| 603 | +检查点,576,236,236,HHUHUHHUH,243,101 | |
| 604 | +检查点,576,245,245,UHHH,216,92 | |
| 605 | +检查点,576,254,254,HUH,432,191 | |
| 606 | +检查点,576,263,263,,, | |
| 607 | +检查点,576,272,272,,, | |
| 608 | +检查点,576,281,281,UHHUHUHHH,243,119 | |
| 609 | +检查点,576,290,290,HUH,432,218 | |
| 610 | +检查点,576,299,299,,, | |
| 611 | +检查点,576,308,308,HHUHHH,54,29 | |
| 612 | +检查点,576,317,317,UHHH,216,119 | |
| 613 | +检查点,576,326,326,HUH,432,245 | |
| 614 | +检查点,576,335,335,,, | |
| 615 | +检查点,576,344,344,HHHUH,108,65 | |
| 616 | +检查点,576,353,353,UHHUHHUH,486,299 | |
| 617 | +检查点,576,362,362,HUH,432,272 | |
| 618 | +检查点,576,371,371,UHUHHH,324,209 | |
| 619 | +检查点,576,380,380,,, | |
| 620 | +检查点,576,389,389,UHHH,216,146 | |
| 621 | +检查点,576,398,398,HUH,432,299 | |
| 622 | +检查点,576,407,407,UHUHUHHH,486,344 | |
| 623 | +检查点,576,416,416,HHHHHUH,27,20 | |
| 624 | +检查点,576,425,425,,, | |
| 625 | +检查点,576,434,434,HUH,432,326 | |
| 626 | +检查点,576,443,443,,, | |
| 627 | +检查点,576,452,452,HHUHHUH,162,128 | |
| 628 | +检查点,576,461,461,UHHH,216,173 | |
| 629 | +检查点,576,470,470,HUH,432,353 | |
| 630 | +检查点,576,479,479,,, | |
| 631 | +检查点,576,488,488,HHHUH,108,92 | |
| 632 | +检查点,576,497,497,,, | |
| 633 | +检查点,576,506,506,HUH,432,380 | |
| 634 | +检查点,576,515,515,UHUHHH,324,290 | |
| 635 | +检查点,576,524,524,HHUHUHHH,81,74 | |
| 636 | +检查点,576,533,533,UHHH,216,200 | |
| 637 | +检查点,576,542,542,HUH,432,407 | |
| 638 | +检查点,576,551,551,,, | |
| 639 | +检查点,576,560,560,,, | |
| 640 | +检查点,576,569,569,,, | |
| 641 | +检查点,576,2,578,HUH,432,434 | |
| 642 | +检查点细分,1152,92,92,HHUHUHUHHH,243,20 | |
| 643 | +检查点细分,1152,668,668,HHUHUHUHHUH,729,425 | |
| 644 | +检查点细分,1152,272,272,HHHHUHHUH,81,20 | |
| 645 | +检查点细分,1152,848,848,HHHHUHHH,27,20 | |
| 646 | +检查点细分,1152,497,497,UHHUHHHHPDD,216,92 | |
| 647 | +检查点细分,1152,1073,1073,UHHUHHHHUH,243,227 | |
| 648 | +检查点细分,1728,560,560,HHHPDD,288,92 | |
| 649 | +检查点细分,1728,1136,1136,HHHP,72,47 | |
| 650 | +检查点细分,1728,1712,1712,HHHPDDDD,1152,1136 | |
+59 −0 routes/codex-odd-preimage-issue1/out/checkpoint-report.md added View file
| @@ -0,0 +1,59 @@ | ||
| 1 | +# 为什么只研究 576q+569 就足够,以及还缺哪一步 | |
| 2 | + | |
| 3 | +**已证结论**:所有正整数都到达 1,等价于每个非负整数 q 对应的起点 576q+569 都到达 1。后一条仍然待证。把问题集中到一个等差数列的思想已有文献。本路线给出了这个数列的一条具体连接方法,Lean 可以直接检查每步,以及 81 行倍增数据。[Lean 源码](../SingleClass.lean) · [倍增表](single-class.csv) · [Monks,定理 1.1](https://monks.scranton.edu/content/pubs/SufficiencyRev4.pdf) | |
| 4 | + | |
| 5 | +## 任意起点怎样接到这条数列上 | |
| 6 | + | |
| 7 | +一次原始操作按奇偶执行 n/2 或 3n+1。以下把除以 9 余 2 的数称作“检查点”。 | |
| 8 | + | |
| 9 | +1. 每个正整数的轨道都能到达一个检查点 n。这复现了 Monks 等人 2013 年论文的推论 5.8。论文把奇数步和随后的第一次减半合为一步,源码将每个这样的步骤还原为两步原始操作。证明先处理 3 的倍数,正偶数可以逐次减半,遇到奇数时合并步进入余 5。其他余数中,4 接着到 2,7 到 2 或 8,5 到 7 或 8,1 到 2 或 5。惟一需要解释的停留是余 8 的连续奇数步。此时把 n+1 写为奇数 a 乘以偶数 z,下一次合并步把它变成 (3a)·(z/2),正整数因子 z 每次减半,故必有一步离开奇数段。[源码](../Checkpoint.lean) · [原论文 §5.3](https://arxiv.org/abs/1204.3904) | |
| 10 | +2. 对任意 q ≥ 0,从 576q+569 按原始规则走 **10 步**恰好到 729q+722。两者都能直接代入源码检验。比如 569 先经过 1708、854、427、1282、641、1924、962、481、1444,到达 722。 | |
| 11 | +3. 一个检查点 n 除以 729 只可能有 81 种余数。对每一种余数,表中给出 e ≤ 480,使得 2ᵉn 除以 729 余 722。令 q 为 2ᵉn 除以 729 的商,第 2 步就把 576q+569 送到 2ᵉn,再减半 e 次恰好到 n。例如检查点 353 取 e=6,起点 17,849 用 16 步到 353。[81 行数据](single-class.csv) | |
| 12 | +4. 这样,原始起点和构造出的数列项均能到达同一个 n。到达 1 的性质在一条边两端等价,因为 1 之后会经 4、2 回到 1。若每个数列项都到达 1,则 n 和原始起点也都到达 1。反向只需把全称结论应用到该数列。**490 步的上界仅针对从构造出的数列项到指定检查点的这段路**,原始起点首次遇到检查点的时间和最终到 1 的时间均未给出统一上界。 | |
| 13 | + | |
| 14 | +## 还缺的证明可以怎样陈述 | |
| 15 | + | |
| 16 | +q=0 对应的 569 在第 56 步首次到达 1。对 q>0,若总能找到更小的下标 p<q,使两条轨道在某个值相遇,则沿下标做强归纳就能证明全题。反过来,若全题成立,可统一选 p=0,让两条轨道相遇于 1。这个等价性已用 Lean 检查,定理名为 `claim_iff_smaller_index`。构造具体的 p 可以依赖 q。 | |
| 17 | + | |
| 18 | +程序为 q=1 至 32 各找了一对相遇步数,Lean 检查了每个 p 确实更小且两个轨道值相等。例如 q=3 的起点 2297 走 19 步、p=2 的起点 1721 走 16 步都到 1228。这 32 个相遇值均大于 1。**仍缺任意 q 的构造或存在证明**。[32 个实例](lower-index.csv) | |
| 19 | + | |
| 20 | +对于整整一个无限子族,已经有统一构造。每当 q=9a+8,取 p=8a+7。较小下标 p 的起点正向走五步,恰好到 q 的起点。例如 q=8、p=7 时,4,601 → 13,804 → 6,902 → 3,451 → 10,354 → 5,177。Lean 的 `claim_iff_remaining_indices` 证明,接下来只须对 q>0 且 q 除以 9 余 0 至 7 的所有下标补出相遇证据。这个子族中的每次下降都是按下标归纳的一个步骤。[子族证明](../SingleClass.lean) | |
| 21 | + | |
| 22 | +继续搜索后,又有三个不同于上述子族的统一构造。下表的 a 可取任意非负整数。每一行都有 p<q,且从 576p+569 按原始规则恰走表中步数就等于 576q+569。这些是相遇证据,整条数列的终止问题仍然开放。[可复跑的四条符号路径](index-families.csv) | |
| 23 | + | |
| 24 | +| q | 较小下标 p | 走几步 | | |
| 25 | +| --- | --- | ---: | | |
| 26 | +| 2187a+1415 | 2048a+1325 | 18 | | |
| 27 | +| 2187a+1541 | 1024a+721 | 17 | | |
| 28 | +| 2187a+1887 | 2048a+1767 | 18 | | |
| 29 | + | |
| 30 | +## 正向与反向走能排除哪些情形 | |
| 31 | + | |
| 32 | +把一整类起点写成 aq+b,其中 q 可以是任意非负整数。一条检查过的路径把它变成 cq+d。若 c≤a 且 0<d<b,终点对每个 q 都是严格更小的正整数。路径允许正走,也允许沿合法的同一条边倒走,后者能比较两端是否到达 1。表格中的 H 表示偶数减半,U 表示奇数乘三加一,D 是逆向倍增,P 从 x 返回到奇数 (x−1)/3。Lean 验证路径在整个数列上合法,Python 的搜索只负责提供候选。[通用检验](../Bridges.lean) · [逐类表格](certificates.csv) | |
| 33 | + | |
| 34 | +| 归纳对象 | 运算 | 得出的条件 | | |
| 35 | +| --- | --- | --- | | |
| 36 | +| 所有正整数 | 把原来的模 16 三类换到模 576,原有 108 类待处理。八条路径可覆盖 576 类中的 541 类 | 剩 35 个余数 | | |
| 37 | +| 所有检查点 | 模 576 下共 64 类。13 条路径对 45 类给出更小的检查点 | 剩 19 个余数 | | |
| 38 | +| 同一批检查点 | 将余数 92、272、497 各细分成两类,把 560 细分成三类,逐类给出证据 | 剩 15 个余数 | | |
| 39 | + | |
| 40 | +15 个余数分别为 **11、47、137、155、191、209、263、299、335、380、425、443、479、551、569**。每一类都含无穷多个整数。15 个最小代表各自到 1 的步数也已用 Lean 核对。最长的代表样例是 299,用 117 步。这三行的归纳对象和“严格更小”的要求见源码。前两行的剩余集合不能直接取交集,例如从 11 可沿逆向边找到较小的 7,再从 7 找到的第一个检查点又是 11。一般地,对每个 k ≥ 0,6k+1 的第一个检查点正是两步后的 9k+2。单数列归约另有上面的构造,其连接起点可能很大。[35 类证明](../Residues.lean) · [15 类证明](../CheckpointDescent.lean) · [代表清单](least-representatives.csv) | |
| 41 | + | |
| 42 | +## 两种看似有望的下降策略为何会失败 | |
| 43 | + | |
| 44 | +**一次返回可以放大任意倍。** 取 k≥1,起点为 21·4ᵏ−1。其首次正步返回检查点恰在第 4k+2 个原始步,值为 (21·9ᵏ−1)/4。前 4k 步按四步为一段,把 4s−1 送到 9s−1,段内各步均避开模 9 余 2。最后两次减半才回到检查点。对于任意给定倍率 B,都有 k 使返回值超过起点的 B 倍。k≥3 时这些起点除以 576 全部余 191。反方向有时仍然很短:k=6 时,86,015 用 26 步才回到检查点 2,790,065,而更小的检查点 76,457 正向走 5 步就到 86,015。源码证明两种现象可以在同一子族上同时出现,倍率任大。[任意倍率的证明](../FirstReturn.lean) | |
| 45 | + | |
| 46 | +**多等固定次数也不足。** 对任意 L≥1,取 n=9·8^(L+2)−7。它除以 576 余 569。前 5L 步内恰好每 5 步回一次检查点,这 L 次返回逐次严格增大。理由是每段把 8s−7 送到 9s−7,一共五个原始步,中间余数依次是 7、8、4、4。与此同时,第 3 步已经降到 6s−5,小于该段起点。因此仅观察检查点会错过普通轨道中的下降。这一结果只否定固定返回次数内保证下降的策略,并未给出永不到 1 的起点。[任意次数的证明](../RepeatedReturns.lean) · [样例结果](return-examples.csv) | |
| 47 | + | |
| 48 | +## 如何复验 | |
| 49 | + | |
| 50 | +在路线目录使用已固定的 Lean 4.35.0 和 Python 3,模块依赖只有 Lean 自带的 Std。运行以下命令可从源码重建八个模块,并与仓库中保存的表格和公理输出逐项比对。首个命令重建需求的起点 6 样例。 | |
| 51 | + | |
| 52 | +```sh | |
| 53 | +python sample.py | |
| 54 | +python reproduce.py | |
| 55 | +``` | |
| 56 | + | |
| 57 | +如需指定可执行文件,可运行 `python reproduce.py --lean /path/to/lean`。所有 `.olean` 均在新建的临时目录内产生。七份本轮生成文件均保存在本目录。公理记录来自具体已证定理,依赖最多为 Lean 标准公理 propext、Classical.choice、Quot.sound。没有 sorryAx 或自定义公理。项目没有配置站内自动检验,本次运行属于本地复验。[完整 Lean 输出](shift-lean.txt) · [复验程序](../reproduce.py) · [起点 6 的原始步表](sample-6.csv) | |
| 58 | + | |
| 59 | +对两份临时副本做了故意改错的复验。将倍增指数上界从 480 改为 479,或将十步终点从 729q+722 改为 729q+723,两份源码分别被 Lean 拒绝。 | |
+5 −0 routes/codex-odd-preimage-issue1/out/index-families.csv added View file
| @@ -0,0 +1,5 @@ | ||
| 1 | +q系数,q常数,p系数,p常数,从p到q的原始步数,路径 | |
| 2 | +9,8,8,7,5,UHHUH | |
| 3 | +2187,1415,2048,1325,18,UHHUHUHHUHUHUHUHHH | |
| 4 | +2187,1541,1024,721,17,UHHUHUHHUHUHUHHUH | |
| 5 | +2187,1887,2048,1767,18,UHHUHUHHUHUHHUHHUH | |
+8 −0 routes/codex-odd-preimage-issue1/out/lean-check.txt added View file
| @@ -0,0 +1,8 @@ | ||
| 1 | +Lean (version 4.35.0, x86_64-w64-windows-gnu, commit eb6cafb7290e8bd5f2937522d8d804f58f02bafc, Release) | |
| 2 | +'CollatzRoute.back_iff_reaches' depends on axioms: [propext, Quot.sound] | |
| 3 | +'CollatzRoute.inverse_block' depends on axioms: [propext, Quot.sound] | |
| 4 | +'CollatzRoute.family_hits' depends on axioms: [propext, Quot.sound] | |
| 5 | +'CollatzRoute.sample_six' does not depend on any axioms | |
| 6 | +'CollatzRoute.sample_six_first' does not depend on any axioms | |
| 7 | +'CollatzRoute.six_step_drop' depends on axioms: [propext, Quot.sound] | |
| 8 | +'CollatzRoute.claim_iff_three_residues' depends on axioms: [propext, Quot.sound] | |
+16 −0 routes/codex-odd-preimage-issue1/out/least-representatives.csv added View file
| @@ -0,0 +1,16 @@ | ||
| 1 | +模576余数及最小正代表,首次到1步数,峰值,下个检查点步数,下个检查点值,首次遇到更小检查点的步数,更小检查点值 | |
| 2 | +11,14,52,7,20,13,2 | |
| 3 | +47,104,9232,11,182,97,20 | |
| 4 | +137,90,9232,5,155,73,92 | |
| 5 | +155,85,9232,7,263,68,92 | |
| 6 | +191,44,4372,15,1640,26,29 | |
| 7 | +209,39,628,5,236,14,101 | |
| 8 | +263,78,9232,9,668,61,92 | |
| 9 | +299,117,9232,7,506,24,182 | |
| 10 | +335,68,9232,10,425,51,92 | |
| 11 | +380,107,9232,14,182,14,182 | |
| 12 | +425,58,9232,5,479,41,92 | |
| 13 | +443,53,2248,7,749,11,281 | |
| 14 | +479,53,9232,12,911,36,92 | |
| 15 | +551,43,4192,9,1397,13,524 | |
| 16 | +569,56,2752,5,641,13,542 | |
+33 −0 routes/codex-odd-preimage-issue1/out/lower-index.csv added View file
| @@ -0,0 +1,33 @@ | ||
| 1 | +起点下标q,较小下标p,起点,较小下标的起点,原轨道步数,另一轨道步数,相遇值 | |
| 2 | +1,0,1145,569,142,48,40 | |
| 3 | +2,0,1721,569,27,28,130 | |
| 4 | +3,2,2297,1721,19,16,1228 | |
| 5 | +4,2,2873,1721,157,40,22 | |
| 6 | +5,1,3449,1145,32,33,292 | |
| 7 | +6,2,4025,1721,61,47,40 | |
| 8 | +7,2,4601,1721,23,19,922 | |
| 9 | +8,7,5177,4601,0,5,5177 | |
| 10 | +9,5,5753,3449,38,58,274 | |
| 11 | +10,9,6329,5753,64,38,274 | |
| 12 | +11,8,6905,5177,104,39,22 | |
| 13 | +12,10,7481,6329,59,51,286 | |
| 14 | +13,8,8057,5177,104,31,148 | |
| 15 | +14,6,8633,4025,20,37,2308 | |
| 16 | +15,11,9209,6905,34,31,7006 | |
| 17 | +16,12,9785,7481,89,55,760 | |
| 18 | +17,15,10361,9209,0,5,10361 | |
| 19 | +18,5,10937,3449,56,44,94 | |
| 20 | +19,18,11513,10937,28,15,2596 | |
| 21 | +20,8,12089,5177,35,39,22 | |
| 22 | +21,0,12665,569,66,15,814 | |
| 23 | +22,0,13241,569,64,0,569 | |
| 24 | +23,11,13817,6905,24,23,8302 | |
| 25 | +24,0,14393,569,16,1,1708 | |
| 26 | +25,20,14969,12089,45,24,202 | |
| 27 | +26,23,15545,13817,0,5,15545 | |
| 28 | +27,8,16121,5177,63,20,1384 | |
| 29 | +28,14,16697,8633,59,40,106 | |
| 30 | +29,20,17273,12089,84,24,202 | |
| 31 | +30,12,17849,7481,33,55,760 | |
| 32 | +31,20,18425,12089,55,39,52 | |
| 33 | +32,20,19001,12089,49,46,16 | |
+48 −0 routes/codex-odd-preimage-issue1/out/partial-proof.md added View file
| @@ -0,0 +1,48 @@ | ||
| 1 | +# Collatz 起点 6 的轨道与全称命题的归约 | |
| 2 | + | |
| 3 | +**起点 6 首次到达 1 用了 8 步。** 对一般起点,本路线证明了一个等价命题。只要能从 1 逆向走到每个除以 16 余 7、11、15 的数,就能证明全部正整数都到达 1。关于这三个类的最后一个条件尚未证明。 | |
| 4 | + | |
| 5 | +## 需求样例 | |
| 6 | + | |
| 7 | +一次操作严格执行一条原始规则。偶数除以 2,奇数乘 3 再加 1。表中的步数从 0 开始。 | |
| 8 | + | |
| 9 | +| 已走步数 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | | |
| 10 | +| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | |
| 11 | +| 当前值 | 6 | 3 | 10 | 5 | 16 | 8 | 4 | 2 | 1 | | |
| 12 | + | |
| 13 | +第 0 至 7 步都没有出现 1。Lean 分别检查了 `orbit 8 6 = 1` 和 `∀ t : Fin 8, orbit t.val 6 ≠ 1`。样例脚本还从 1 逆向重建了 6。它先从 1 倍增四次到 16,逆转奇数步骤到 5,再倍增到 10,逆转到 3,最后倍增到 6。[逐步表格](sample-6.csv) · [生成程序](../sample.py) | |
| 14 | + | |
| 15 | +## 逆向路径为何有效 | |
| 16 | + | |
| 17 | +记 `Back n` 为从 1 出发、有有限步逆向路径到 n。起点 1 自带一条零步路径。若已有到 y 的路径,可以再到 2y,因为 2y 正向一步就回到 y。若 x 是奇数,已有到 3x+1 的路径,也可以再到 x。对这些构造做归纳,每条逆向路径都能倒过来给出正向到 1 的步数。反过来,对到 1 的步数做归纳,按第一步的奇偶规则就能重建逆向路径。这给出 `back_iff_reaches`。它检查了两种描述等价,覆盖每个正整数还需要额外证明。 | |
| 18 | + | |
| 19 | +一个常用的块由一个奇数步骤和 e 次除以 2 组成。若 x 是奇数且 3x+1 = 2^e·y,那么 x 经过 e+1 步到 y。其后再走任意 t 步,与从 y 直接走 t 步相同。这就是 `inverse_block`,其中连续除以 2 的部分由对 e 的归纳保证。即使 y 为偶数,此公式仍成立。 | |
| 20 | + | |
| 21 | +例如设 r₀ = 1,rₖ₊₁ = 4rₖ+1。所有 rₖ 都是奇数,且 3rₖ+1 = 2^(2k+2)。初值等式是 4 = 2²,每从 k 到 k+1 等式两边同乘 4。因此对任意非负整数 a、k,起点 2^a·rₖ 先除以 2 共 a 次到 rₖ,再经一个奇数步骤和 2k+2 次减半到 1,合计 a+2k+3 步。Lean 定理名为 `family_hits`。这个步数保证到达,当 k=0 时它包括 1 → 4 → 2 → 1 的三步回环,因此可能早已到过 1。 | |
| 22 | + | |
| 23 | +## 为什么只需补三个余数类 | |
| 24 | + | |
| 25 | +对任意正整数 n 做强归纳,即在证明 n 时可以使用每个更小正整数的结论。n=1 取零步。其余情况按下表判断。 | |
| 26 | + | |
| 27 | +| 起点条件 | 正向到达的值 | 用时和归纳依据 | | |
| 28 | +| --- | --- | --- | | |
| 29 | +| n 为偶数 | n/2 | 1 步,值为正且比 n 小 | | |
| 30 | +| n = 4m+1,m ≥ 1 | 3m+1 | 3 步,经过 12m+4、6m+2,且 3m+1 < 4m+1 | | |
| 31 | +| n = 16m+3,m ≥ 0 | 9m+2 | 6 步,且 9m+2 < 16m+3 | | |
| 32 | +| n 除以 16 余 7、11、15 | 需给出该起点的有限逆向路径 | 由前面的等价引理转成正向到 1 的结论 | | |
| 33 | + | |
| 34 | +第三行的六个步骤依次为 16m+3 → 48m+10 → 24m+5 → 72m+16 → 36m+8 → 18m+4 → 9m+2。Lean 用符号变量 m 核对每一步,得到 `six_step_drop`。将上述分情况归纳与逆向路径的等价性合并,就得到 `claim_iff_three_residues`。反方向直接将全称结论应用到这三个余数类中的数。 | |
| 35 | + | |
| 36 | +**缺口**是第四行中每一个起点的有限路径。前三行仅保证先降到更小的正整数,该整数仍可能落在第四行。验证若干代表或将样例上界增大,都无法消掉这个条件。 | |
| 37 | + | |
| 38 | +## 如何复验 | |
| 39 | + | |
| 40 | +在本路线目录(含 `Inverse.lean`)运行下列命令。使用 `lean-toolchain` 固定的官方 Lean 4.35.0,仅依赖同一发行版自带的 Std。生成 CSV 使用 Python 3 标准库。 | |
| 41 | + | |
| 42 | +```sh | |
| 43 | +lean --version | |
| 44 | +lean -DwarningAsError=true Inverse.lean | |
| 45 | +python sample.py | |
| 46 | +``` | |
| 47 | + | |
| 48 | +应看到样例两项定理的公理集合为空。逆向等价、逆向块、无穷子族、六步下降和三个余数类归约这五项的公理输出均为 `[propext, Quot.sound]`。这七项均未使用 `sorryAx` 或自定义公理。脚本须生成上表的九个值。成功时输出 `6 -> 1: 8 steps, first hit; inverse blocks (4, 1) recover 6.`。[本次 Lean 版本与实际输出](lean-check.txt) · [完整源码](../Inverse.lean) | |
+15 −0 routes/codex-odd-preimage-issue1/out/return-examples.csv added View file
| @@ -0,0 +1,15 @@ | ||
| 1 | +族,参数,起点,核对的原始步数,终点,五步前驱(如有) | |
| 2 | +首次返回,1,83,6,47, | |
| 3 | +首次返回,2,335,10,425, | |
| 4 | +首次返回,3,1343,14,3827, | |
| 5 | +首次返回,5,21503,22,310007, | |
| 6 | +首次返回,6,86015,26,2790065,76457 | |
| 7 | +首次返回,9,5505023,38,2033957567, | |
| 8 | +首次返回,15,22548578303,62,1080928443496907,20043180713 | |
| 9 | +首次返回,24,5910974510923775,98,418773826153580676782645,5254199565265577 | |
| 10 | +首次返回,60,27913787911483233330979948265887236095,242,9434304074550763854669194104925426458590247044573718308605,24812255921318429627537731791899765417 | |
| 11 | +连续返回,1,4601,5,5177, | |
| 12 | +连续返回,2,36857,10,46649, | |
| 13 | +连续返回,5,18874361,25,34012217, | |
| 14 | +连续返回,12,39582418599929,60,162679413013049, | |
| 15 | +连续返回,25,21760664753063325144711161,125,413509240910507091131663417, | |
+10 −0 routes/codex-odd-preimage-issue1/out/sample-6.csv added View file
| @@ -0,0 +1,10 @@ | ||
| 1 | +已走步数,当前值,下一步 | |
| 2 | +0,6,除以 2 | |
| 3 | +1,3,乘 3 再加 1 | |
| 4 | +2,10,除以 2 | |
| 5 | +3,5,乘 3 再加 1 | |
| 6 | +4,16,除以 2 | |
| 7 | +5,8,除以 2 | |
| 8 | +6,4,除以 2 | |
| 9 | +7,2,除以 2 | |
| 10 | +8,1,到达 1 | |
+60 −0 routes/codex-odd-preimage-issue1/out/shift-lean.txt added View file
| @@ -0,0 +1,60 @@ | ||
| 1 | +Lean 4.35.0 eb6cafb7290e8bd5f2937522d8d804f58f02bafc | |
| 2 | +Imports: bundled Std and route-local modules. | |
| 3 | + | |
| 4 | +Inverse.lean | |
| 5 | +'CollatzRoute.back_iff_reaches' depends on axioms: [propext, Quot.sound] | |
| 6 | +'CollatzRoute.inverse_block' depends on axioms: [propext, Quot.sound] | |
| 7 | +'CollatzRoute.family_hits' depends on axioms: [propext, Quot.sound] | |
| 8 | +'CollatzRoute.sample_six' does not depend on any axioms | |
| 9 | +'CollatzRoute.sample_six_first' does not depend on any axioms | |
| 10 | +'CollatzRoute.six_step_drop' depends on axioms: [propext, Quot.sound] | |
| 11 | +'CollatzRoute.claim_iff_three_residues' depends on axioms: [propext, Quot.sound] | |
| 12 | + | |
| 13 | +Bridges.lean | |
| 14 | +'CollatzRoute.reaches_step_iff' does not depend on any axioms | |
| 15 | +'CollatzRoute.walk_sound' depends on axioms: [propext, Quot.sound] | |
| 16 | +'CollatzRoute.certificate_descends' depends on axioms: [propext, Quot.sound] | |
| 17 | +'CollatzRoute.claim_iff_remaining' depends on axioms: [propext, Quot.sound] | |
| 18 | + | |
| 19 | +Residues.lean | |
| 20 | +'CollatzRoute.remaining576' does not depend on any axioms | |
| 21 | +'CollatzRoute.claim_iff_mod576' depends on axioms: [propext, Quot.sound] | |
| 22 | +'CollatzRoute.residues576_count' does not depend on any axioms | |
| 23 | + | |
| 24 | +Checkpoint.lean | |
| 25 | +'CollatzRoute.predecessor_first_checkpoint' depends on axioms: [propext, Quot.sound] | |
| 26 | +'CollatzRoute.every_orbit_hits_two_mod_nine' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 27 | +'CollatzRoute.claim_iff_two_mod_nine' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 28 | + | |
| 29 | +CheckpointDescent.lean | |
| 30 | +'CollatzRoute.least_examples_match' does not depend on any axioms | |
| 31 | +'CollatzRoute.least_examples_first_hits' does not depend on any axioms | |
| 32 | +'CollatzRoute.four_refined' depends on axioms: [propext, Quot.sound] | |
| 33 | +'CollatzRoute.final_fifteen' does not depend on any axioms | |
| 34 | +'CollatzRoute.claim_iff_15_checkpoints' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 35 | +'CollatzRoute.smaller_checkpoint' depends on axioms: [propext, Quot.sound] | |
| 36 | +'CollatzRoute.checkpoint_table' does not depend on any axioms | |
| 37 | +'CollatzRoute.claim_iff_19_checkpoints' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 38 | +'CollatzRoute.checkpoint_residue_count' does not depend on any axioms | |
| 39 | + | |
| 40 | +FirstReturn.lean | |
| 41 | +'CollatzRoute.large_return_with_smaller_checkpoint' depends on axioms: [propext, Quot.sound] | |
| 42 | +'CollatzRoute.first_checkpoint_return' depends on axioms: [propext, Quot.sound] | |
| 43 | +'CollatzRoute.excursion_start_mod576' depends on axioms: [propext, Quot.sound] | |
| 44 | +'CollatzRoute.unbounded_first_return' depends on axioms: [propext, Quot.sound] | |
| 45 | + | |
| 46 | +RepeatedReturns.lean | |
| 47 | +'CollatzRoute.arbitrarily_many_rising_returns' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 48 | + | |
| 49 | +SingleClass.lean | |
| 50 | +'CollatzRoute.index_eight_family' depends on axioms: [propext, Quot.sound] | |
| 51 | +'CollatzRoute.claim_iff_remaining_indices' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 52 | +'CollatzRoute.index_1415' depends on axioms: [propext, Quot.sound] | |
| 53 | +'CollatzRoute.index_1541' depends on axioms: [propext, Quot.sound] | |
| 54 | +'CollatzRoute.index_1887' depends on axioms: [propext, Quot.sound] | |
| 55 | +'CollatzRoute.claim_iff_smaller_index' depends on axioms: [propext, Classical.choice, Quot.sound] | |
| 56 | +'CollatzRoute.check_merge_examples' does not depend on any axioms | |
| 57 | +'CollatzRoute.doubling_table' does not depend on any axioms | |
| 58 | +'CollatzRoute.ten_step_image' depends on axioms: [propext, Quot.sound] | |
| 59 | +'CollatzRoute.from_single_class' depends on axioms: [propext, Quot.sound] | |
| 60 | +'CollatzRoute.claim_iff_569' depends on axioms: [propext, Classical.choice, Quot.sound] | |
+82 −0 routes/codex-odd-preimage-issue1/out/single-class.csv added View file
| @@ -0,0 +1,82 @@ | ||
| 1 | +模729下的检查点余数,倍增指数,路线原始步数,样例起点,到达的检查点 | |
| 2 | +2,150,160,2255403761313121787351365482586856511814710713,2 | |
| 3 | +11,354,364,318937881611261302552892426724477867915216148617179241700990131936472830571119665161736901015215502880880057,11 | |
| 4 | +20,126,136,1344325400181485287756541658989701576121,20 | |
| 5 | +29,438,448,16264138120812191223711721009839607635999690941305728200743222049566774193895478222576805918749339044183729264337746265488042783356345,29 | |
| 6 | +38,318,328,16033087874566831235755224658655403526894374686331418322565448117974192509563326597703221590832569,38 | |
| 7 | +47,252,262,268752009587844996785572162736213909585367371816548469622444762882563807065529,47 | |
| 8 | +56,240,250,78177529384762091817611583242748394576860522054348374640837489202873447865,56 | |
| 9 | +65,282,292,399086547736248540001232668265967340821353701257130884365804425901918114886600856909241,65 | |
| 10 | +74,378,388,35996894549792487181588258856921326192295070444622753746026835949557819890009797348699453121746713054564079892379065,74 | |
| 11 | +83,42,52,288424976135609,83 | |
| 12 | +92,246,256,8219808803883557082537446466666116915509906318857200533665198864759265375673,92 | |
| 13 | +101,18,28,20919737,101 | |
| 14 | +110,330,340,190101791388548196883733526900099437186250775228249574721449692211432952029180327154241145262250603961,110 | |
| 15 | +119,210,220,154718058130349447124101793757491128962327362378584496781024769465,119 | |
| 16 | +128,144,154,2255403761313121787351365482586856511814710713,128 | |
| 17 | +137,132,142,589352255439563150152467863301085170972089,137 | |
| 18 | +146,174,184,2762275913165676213831094641530186923559702615293900217,146 | |
| 19 | +155,270,280,232340801153540128080645521263615301334547114238488908791690527399328830406487127481,155 | |
| 20 | +164,420,430,350862523021461139638009202314402567410166420032124936981449576559257634629724230076046143982313958956768640893264032237617100217,164 | |
| 21 | +173,138,148,47629986658590096339329373594668722722649529,173 | |
| 22 | +182,396,406,23208369274657647571228508113804847463111429841724379226428642118044339121336548020868911323307905447967129743162471298489,182 | |
| 23 | +191,222,232,1017155518701387101388918495134962856032532263645481351879662134834617,191 | |
| 24 | +200,102,112,801280379403522782180632149571001,200 | |
| 25 | +209,36,46,11348045936057,209 | |
| 26 | +218,24,34,2889823673,218 | |
| 27 | +227,66,76,13234286316190240290233,227 | |
| 28 | +236,162,172,1090099789147948527236960775967740184142380500202937,236 | |
| 29 | +245,312,322,1615175382100688179588828142010926753326119160424012125422917265174209360544002885048227504010681,245 | |
| 30 | +254,30,40,215490704825,254 | |
| 31 | +263,288,298,103344996484562083466165358034657881241615776916308108394541847642785933996481009592251833,263 | |
| 32 | +272,114,124,4463580430290087869504142227114243513,272 | |
| 33 | +281,480,490,693105258381269188755143760254324726451639370341812854037667639035835621616477344595599814290047402584423796657868848224095511044645932382078055865,281 | |
| 34 | +290,414,424,9694181752688998713321519499921564838886076772991256833519471913317903395828889741049293231218659308066206731997577110223795641,290 | |
| 35 | +299,402,412,2440194255164004087489168853108623961835716051929877587235925799840090513329099906194216961993516915671972498709654125098425,299 | |
| 36 | +308,444,454,11055127263360341841441567053308908473131927856379948768725875622105525962416126438739103388634033490998264526159505323631044805017941433,308 | |
| 37 | +317,54,64,4512050826671240633,317 | |
| 38 | +326,204,214,6622647971440903330154567327329583513881134471562309079649957305,326 | |
| 39 | +335,408,418,174975802109418888413939064249661865357049338305607275820529261366460002026006361166568600886759206260893278837240750642509241,335 | |
| 40 | +344,180,190,416536071946955667970584791972113666500619265604866487737,344 | |
| 41 | +353,6,16,17849,353 | |
| 42 | +362,372,382,2751451821584645346227818772425152044259040435167533119945463389725492145309025895318665969187565482633487525557689,362 | |
| 43 | +371,306,316,38216203237203782820628523002937106217091212277889572610452953149211203620014353976587525764537,371 | |
| 44 | +380,294,304,9556465074161786577555671130809428409871086291272293521502881120427961653210715411724580281,380 | |
| 45 | +389,336,346,43025219985539053723794817142771596256262720909840921929683741248143952488349758407563523204081736693177,389 | |
| 46 | +398,432,442,3487676170303476350774388449308277930564588897973965422357652142094599207527155351608603855421463868310950564227598606500129864103353,398 | |
| 47 | +407,96,106,25478212063846388464649787880889,407 | |
| 48 | +416,300,310,669556121406535278528532074175447952590546845839035638727612386711247502776531808215145330105,416 | |
| 49 | +425,72,82,1585782325111782096451001,425 | |
| 50 | +434,384,394,13511483013716704377781019973106037247529565900943805514184343180201594665742055826452378512292387862210430852577310137,434 | |
| 51 | +443,264,274,10375703116030068219730440112881207509193989073351873648661179802207930632063890873,443 | |
| 52 | +452,198,208,143473776988654539169376171010015900511612000630088367714809273,452 | |
| 53 | +461,186,196,35725233333497034964546900297515237257076368640715060622777,461 | |
| 54 | +470,228,238,160188680641558764449102975568898862353186232934325021280315377046205881,470 | |
| 55 | +479,324,334,12934482681124231009560846503572106592644051325899367370962273092226759094030877373136577923383244217,479 | |
| 56 | +488,474,484,18807571513014866776718758619000804409942171526179085452089735756755326031407970649613696028333136813901179535645017678678748297919662755919377849,488 | |
| 57 | +497,192,202,2464963604928142490568997407078882140288687925648296417113529,497 | |
| 58 | +506,450,460,1162367666547601656471570478747908090889299843185091756254606351124238158334038436987425727719235521339246098750485131170349853784743556537,506 | |
| 59 | +515,276,286,49406147135617307235729525037733937625720470227745770540478192148915343549663327237561,515 | |
| 60 | +524,156,166,37818610269698426130307696412016409990109069260217,524 | |
| 61 | +533,90,100,521340871853122122683443525049,533 | |
| 62 | +542,78,88,129429687749358817321629113,542 | |
| 63 | +551,120,130,578690074609373744963948792268223100345,551 | |
| 64 | +560,216,226,46597438683964068780905952002256151781595064434020742559932165862841,560 | |
| 65 | +569,366,376,67574934672033114727366578103846318766548429195887704819102584114028186752453199863446173017425965107840745944505,569 | |
| 66 | +578,84,94,8833695588974688875206096313,578 | |
| 67 | +587,342,352,4155196566623987584307258844266435290887603853832657468006063730617665827975125254126854600850752401257913,587 | |
| 68 | +596,168,178,176189687954488765351384033214040176203080346609071545,596 | |
| 69 | +605,48,58,134551988867118521,605 | |
| 70 | +614,468,478,369744137711037660121199980534915916614513746064099592327839963967974199003729955778138107114387359238451723709209812202508691563866320829101497,614 | |
| 71 | +623,456,466,91592734388509828551056241360941880237031943374458455544236490972382655828250554465538811493322843294147075986915697924948990850010464597433,623 | |
| 72 | +632,12,22,2045369,632 | |
| 73 | +641,108,118,164358631423250593080891266520004025,641 | |
| 74 | +650,258,268,237874119124560678005953233400563800824495375905710985878589407147120305828214201,650 | |
| 75 | +659,462,472,6200666397383291378762998452069156887443112750820481253665679363164062427307055192838787983214099901723831583987410073326883849261703619360185,659 | |
| 76 | +668,234,244,14571035052740255952612873216003328007071101766826092148459665956339135929,668 | |
| 77 | +677,60,70,616713369772906984889,677 | |
| 78 | +686,426,436,93928464699598962650409487917143477558389917713965934348985135422302726773069589007675182349997024719743722010840634581465494926777,686 | |
| 79 | +695,360,370,1289668815824445703413877740064070505897164935499284788260003733503119227618491155126732487014253233467413181881,695 | |
| 80 | +704,348,358,318937881611261302552892426724477867915216148617179241700990131936472830571119665161736901015215502880880057,704 | |
| 81 | +713,390,400,1420635928299356346006690100029434773454537214727805836919953797232624810569450441181278655006742495226696729642414323129,713 | |
| 82 | +722,0,10,569,722 | |
+276 −0 routes/codex-odd-preimage-issue1/reproduce.py added View file
| @@ -0,0 +1,276 @@ | ||
| 1 | +"""Reproduce the Collatz route from source. Uses Python's standard library and Lean 4.35.0.""" | |
| 2 | + | |
| 3 | +import argparse | |
| 4 | +import csv | |
| 5 | +import io | |
| 6 | +import os | |
| 7 | +from collections import deque | |
| 8 | +from pathlib import Path | |
| 9 | +import shutil | |
| 10 | +import subprocess | |
| 11 | +from tempfile import TemporaryDirectory | |
| 12 | + | |
| 13 | + | |
| 14 | +ROOT = Path(__file__).resolve().parent | |
| 15 | +OUT = ROOT / "out" | |
| 16 | +MODULES = ("Inverse", "Bridges", "Residues", "Checkpoint", "CheckpointDescent", | |
| 17 | + "FirstReturn", "RepeatedReturns", "SingleClass") | |
| 18 | +LEAN_COMMIT = "eb6cafb7290e8bd5f2937522d8d804f58f02bafc" | |
| 19 | +REFINEMENTS = ((92, 2), (272, 2), (497, 2), (560, 3)) | |
| 20 | + | |
| 21 | + | |
| 22 | +def require(condition, message): | |
| 23 | + if not condition: | |
| 24 | + raise ValueError(message) | |
| 25 | + | |
| 26 | + | |
| 27 | +def raw(n): | |
| 28 | + return n // 2 if n % 2 == 0 else 3 * n + 1 | |
| 29 | + | |
| 30 | + | |
| 31 | +def neighbours(a, b): | |
| 32 | + """Images of a*q+b valid simultaneously for every q >= 0.""" | |
| 33 | + if a % 2 == 0: | |
| 34 | + if b % 2: | |
| 35 | + yield "U", 3 * a, 3 * b + 1 | |
| 36 | + else: | |
| 37 | + yield "H", a // 2, b // 2 | |
| 38 | + yield "D", 2 * a, 2 * b | |
| 39 | + if a % 6 == 0 and b % 6 == 4: | |
| 40 | + yield "P", a // 3, (b - 1) // 3 | |
| 41 | + | |
| 42 | + | |
| 43 | +def search(modulus, base, limit, checkpoint): | |
| 44 | + queue = deque([(modulus, base, "")]) | |
| 45 | + seen = {(modulus, base)} | |
| 46 | + while queue: | |
| 47 | + a, b, path = queue.popleft() | |
| 48 | + if a <= modulus and 0 < b < base: | |
| 49 | + if not checkpoint or (a % 9 == 0 and b % 9 == 2): | |
| 50 | + return path, a, b | |
| 51 | + if len(path) == limit: | |
| 52 | + continue | |
| 53 | + for letter, c, d in neighbours(a, b): | |
| 54 | + if (c, d) not in seen: | |
| 55 | + queue.append((c, d, path + letter)) | |
| 56 | + seen.add((c, d)) | |
| 57 | + return None | |
| 58 | + | |
| 59 | + | |
| 60 | +def replay(n, path): | |
| 61 | + """Independent integer check: compare each edge to the one raw step function.""" | |
| 62 | + for letter in path: | |
| 63 | + if letter == "H" or letter == "U": | |
| 64 | + require(n % 2 == int(letter == "U"), "Wrong forward parity") | |
| 65 | + n = raw(n) | |
| 66 | + else: | |
| 67 | + if letter == "D": | |
| 68 | + parent = 2 * n | |
| 69 | + elif letter == "P": | |
| 70 | + parent, rem = divmod(n - 1, 3) | |
| 71 | + require(rem == 0 and parent % 2 == 1, "Invalid odd predecessor") | |
| 72 | + else: | |
| 73 | + raise ValueError(f"Unknown direction {letter!r}") | |
| 74 | + require(raw(parent) == n, "Reverse edge fails its forward check") | |
| 75 | + n = parent | |
| 76 | + return n | |
| 77 | + | |
| 78 | + | |
| 79 | +def csv_bytes(rows): | |
| 80 | + stream = io.StringIO(newline="") | |
| 81 | + csv.writer(stream, lineterminator="\n").writerows(rows) | |
| 82 | + return stream.getvalue().encode("utf-8-sig") | |
| 83 | + | |
| 84 | + | |
| 85 | +def certificate_rows(): | |
| 86 | + rows = [["归纳范围", "模数", "余数", "首项", "路径", "终点斜率", "终点截距"]] | |
| 87 | + | |
| 88 | + def record(label, modulus, bases, depth, checkpoint): | |
| 89 | + missing = [] | |
| 90 | + for base in bases: | |
| 91 | + residue = base % modulus | |
| 92 | + found = search(modulus, base, depth, checkpoint) | |
| 93 | + if found is None: | |
| 94 | + rows.append([label, modulus, residue, base, "", "", ""]) | |
| 95 | + missing.append(residue) | |
| 96 | + continue | |
| 97 | + path, slope, intercept = found | |
| 98 | + for q in (0, 1, 19, 2**127 + 1): | |
| 99 | + start = modulus * q + base | |
| 100 | + end = replay(start, path) | |
| 101 | + require(end == slope * q + intercept and 0 < end < start, "Endpoint mismatch") | |
| 102 | + require(not checkpoint or start % 9 == end % 9 == 2, "Lost checkpoint") | |
| 103 | + rows.append([label, modulus, residue, base, path, slope, intercept]) | |
| 104 | + return missing | |
| 105 | + | |
| 106 | + general = record("全体起点", 576, range(2, 578), 12, False) | |
| 107 | + remaining = record("检查点", 576, range(11, 579, 9), 12, True) | |
| 108 | + require(len(general) == 35 and len(remaining) == 19, "Unexpected table counts") | |
| 109 | + for residue, factor in REFINEMENTS: | |
| 110 | + modulus = 576 * factor | |
| 111 | + bases = (residue + 576 * j for j in range(factor)) | |
| 112 | + missing = record("检查点细分", modulus, bases, 22, True) | |
| 113 | + require(not missing, f"Uncovered subclass of {residue}") | |
| 114 | + remaining.remove(residue) | |
| 115 | + require(len(remaining) == 15, "Unexpected final class count") | |
| 116 | + return csv_bytes(rows), remaining | |
| 117 | + | |
| 118 | + | |
| 119 | +def least_examples(residues): | |
| 120 | + rows = [["模576余数及最小正代表", "首次到1步数", "峰值", "下个检查点步数", | |
| 121 | + "下个检查点值", "首次遇到更小检查点的步数", "更小检查点值"]] | |
| 122 | + for start in residues: | |
| 123 | + n = start | |
| 124 | + peak = start | |
| 125 | + first = lower = None | |
| 126 | + for t in range(1, 1001): | |
| 127 | + n = raw(n) | |
| 128 | + peak = max(peak, n) | |
| 129 | + if n % 9 == 2: | |
| 130 | + if first is None: | |
| 131 | + first = t, n | |
| 132 | + if n < start and lower is None: | |
| 133 | + lower = t, n | |
| 134 | + if n == 1: | |
| 135 | + break | |
| 136 | + require(n == 1 and first is not None and lower is not None, f"Incomplete sample {start}") | |
| 137 | + rows.append([start, t, peak, *first, *lower]) | |
| 138 | + return csv_bytes(rows) | |
| 139 | + | |
| 140 | + | |
| 141 | +def returns_table(): | |
| 142 | + rows = [["族", "参数", "起点", "核对的原始步数", "终点", "五步前驱(如有)"]] | |
| 143 | + for k in (1, 2, 3, 5, 6, 9, 15, 24, 60): | |
| 144 | + start = 21 * 4**k - 1 | |
| 145 | + end = (21 * 9**k - 1) // 4 | |
| 146 | + n = start | |
| 147 | + for t in range(1, 4 * k + 3): | |
| 148 | + n = raw(n) | |
| 149 | + require((n % 9 == 2) == (t == 4 * k + 2), f"Wrong first return, k={k}") | |
| 150 | + require(n == end, "Wrong return value") | |
| 151 | + small = "" | |
| 152 | + if k % 9 == 6: | |
| 153 | + q, residue = divmod(start, 81) | |
| 154 | + small = 72 * q + 65 | |
| 155 | + require(residue == 74 and small % 9 == 2 and small < start, "Invalid predecessor") | |
| 156 | + require(replay(small, "UHHUH") == start, "Five-step path fails") | |
| 157 | + rows.append(["首次返回", k, start, 4 * k + 2, n, small]) | |
| 158 | + for length in (1, 2, 5, 12, 25): | |
| 159 | + start = 9 * 8**(length + 2) - 7 | |
| 160 | + n = last_checkpoint = start | |
| 161 | + require(start % 576 == 569, "Wrong starting residue") | |
| 162 | + for t in range(1, 5 * length + 1): | |
| 163 | + n = raw(n) | |
| 164 | + require((n % 9 == 2) == (t % 5 == 0), "Unexpected checkpoint") | |
| 165 | + if t == 3: | |
| 166 | + require(n < start, "Missed the short ordinary descent") | |
| 167 | + if t % 5 == 0: | |
| 168 | + require(n > last_checkpoint, "Checkpoint failed to grow") | |
| 169 | + last_checkpoint = n | |
| 170 | + rows.append(["连续返回", length, start, 5 * length, n, ""]) | |
| 171 | + return csv_bytes(rows) | |
| 172 | + | |
| 173 | + | |
| 174 | +def single_class_table(): | |
| 175 | + rows = [["模729下的检查点余数", "倍增指数", "路线原始步数", "样例起点", "到达的检查点"]] | |
| 176 | + for checkpoint in range(2, 729, 9): | |
| 177 | + exponent = next(e for e in range(0, 481, 6) if | |
| 178 | + pow(2, e, 729) * checkpoint % 729 == 722) | |
| 179 | + for n in (checkpoint, checkpoint + 729 * 17): | |
| 180 | + q, r = divmod(2**exponent * n, 729) | |
| 181 | + require(r == 722, "Doubling missed target progression") | |
| 182 | + start = 576 * q + 569 | |
| 183 | + value = start | |
| 184 | + for _ in range(10 + exponent): | |
| 185 | + value = raw(value) | |
| 186 | + require(value == n, "Single-class bridge missed checkpoint") | |
| 187 | + if n == checkpoint: | |
| 188 | + rows.append([n, exponent, 10 + exponent, start, n]) | |
| 189 | + return csv_bytes(rows) | |
| 190 | + | |
| 191 | + | |
| 192 | +def lower_index_rows(): | |
| 193 | + rows = [["起点下标q", "较小下标p", "起点", "较小下标的起点", "原轨道步数", "另一轨道步数", "相遇值"]] | |
| 194 | + visited = [] | |
| 195 | + for q in range(33): | |
| 196 | + start = 576*q + 569 | |
| 197 | + positions = {} | |
| 198 | + value = start | |
| 199 | + for t in range(513): | |
| 200 | + positions[value] = t | |
| 201 | + if value == 1: | |
| 202 | + break | |
| 203 | + value = raw(value) | |
| 204 | + require(value == 1, f"Example exceeds search bound: {q}") | |
| 205 | + if q: | |
| 206 | + choices = ((s + earlier[v], s, earlier[v], p, v) | |
| 207 | + for p, earlier in enumerate(visited) | |
| 208 | + for v, s in positions.items() if v in earlier) | |
| 209 | + _, s, t, p, meet = min(choices) | |
| 210 | + rows.append([q, p, start, 576*p+569, s, t, meet]) | |
| 211 | + visited.append(positions) | |
| 212 | + return rows | |
| 213 | + | |
| 214 | +def index_families(): | |
| 215 | + rows = [["q系数","q常数","p系数","p常数","从p到q的原始步数","路径"]] | |
| 216 | + for a,b,c,d,length in ((9,8,8,7,5),(2187,1415,2048,1325,18), | |
| 217 | + (2187,1541,1024,721,17),(2187,1887,2048,1767,18)): | |
| 218 | + line = 576*c, 576*d+569 | |
| 219 | + path = [] | |
| 220 | + for _ in range(length): | |
| 221 | + forward = [hop for hop in neighbours(*line) if hop[0] in ("H", "U")] | |
| 222 | + require(len(forward) == 1, "Parity not uniform") | |
| 223 | + op, slope, base = forward[0] | |
| 224 | + path.append(op) | |
| 225 | + line = slope, base | |
| 226 | + require(line == (576*a, 576*b+569) and c <= a and d < b, "Incorrect index family") | |
| 227 | + rows.append([a,b,c,d,length,"".join(path)]) | |
| 228 | + return csv_bytes(rows) | |
| 229 | + | |
| 230 | + | |
| 231 | +def run_lean(executable): | |
| 232 | + lean = shutil.which(executable) | |
| 233 | + if lean is None: | |
| 234 | + raise ValueError(f"Lean executable not found: {executable}") | |
| 235 | + def invoke(args, env=None): | |
| 236 | + proc = subprocess.run([lean, *args], cwd=ROOT, env=env, text=True, | |
| 237 | + encoding="utf-8", stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
| 238 | + if proc.returncode: | |
| 239 | + raise RuntimeError(proc.stdout) | |
| 240 | + return proc.stdout.strip() | |
| 241 | + version = invoke(["--version"]) | |
| 242 | + require("version 4.35.0," in version and LEAN_COMMIT in version, f"Unexpected toolchain: {version}") | |
| 243 | + log = [f"Lean 4.35.0 {LEAN_COMMIT}", "Imports: bundled Std and route-local modules."] | |
| 244 | + with TemporaryDirectory() as scratch: | |
| 245 | + env = dict(os.environ, LEAN_PATH=scratch) | |
| 246 | + for module in MODULES: | |
| 247 | + output = invoke(["-DwarningAsError=true", "-o", str(Path(scratch) / (module + ".olean")), | |
| 248 | + module + ".lean"], env) | |
| 249 | + require(output and "sorryAx" not in output, f"Missing or incomplete proof: {module}") | |
| 250 | + log.extend(("", module + ".lean", output)) | |
| 251 | + return ("\n".join(log) + "\n").encode("utf-8") | |
| 252 | + | |
| 253 | + | |
| 254 | +def main(): | |
| 255 | + parser = argparse.ArgumentParser(description=__doc__) | |
| 256 | + parser.add_argument("--write", action="store_true", help="replace the seven generated outputs") | |
| 257 | + parser.add_argument("--lean", default="lean", help="Lean executable (default: lean on PATH)") | |
| 258 | + args = parser.parse_args() | |
| 259 | + table, residues = certificate_rows() | |
| 260 | + outputs = {"certificates.csv": table, "least-representatives.csv": least_examples(residues), | |
| 261 | + "return-examples.csv": returns_table(), "single-class.csv": single_class_table(), | |
| 262 | + "lower-index.csv": csv_bytes(lower_index_rows()), | |
| 263 | + "index-families.csv": index_families(), "shift-lean.txt": run_lean(args.lean)} | |
| 264 | + for name, expected in outputs.items(): | |
| 265 | + path = OUT / name | |
| 266 | + if args.write: | |
| 267 | + path.write_bytes(expected) | |
| 268 | + else: | |
| 269 | + # Git on Windows can check text files out with CRLF. | |
| 270 | + require(path.read_bytes().replace(b"\r\n", b"\n") == expected, f"Output differs: {name}") | |
| 271 | + print("OK: 8 Lean modules; 576 general, 64 checkpoint and 9 refinement rows; " | |
| 272 | + "15 least representatives, 14 family examples and 81 single-class bridges; 32 lower-index witnesses and 4 symbolic index families.") | |
| 273 | + | |
| 274 | + | |
| 275 | +if __name__ == "__main__": | |
| 276 | + main() | |
+40 −0 routes/codex-odd-preimage-issue1/sample.py added View file
| @@ -0,0 +1,40 @@ | ||
| 1 | +"""Write the request's example and check its two backwards odd blocks.""" | |
| 2 | +import csv | |
| 3 | +from pathlib import Path | |
| 4 | + | |
| 5 | + | |
| 6 | +def collatz_step(n): | |
| 7 | + return n // 2 if n % 2 == 0 else 3*n + 1 | |
| 8 | + | |
| 9 | + | |
| 10 | +def main(): | |
| 11 | + values = [6] | |
| 12 | + for _ in range(8): | |
| 13 | + values.append(collatz_step(values[-1])) | |
| 14 | + expected = [6, 3, 10, 5, 16, 8, 4, 2, 1] | |
| 15 | + if values != expected or 1 in values[:-1]: | |
| 16 | + raise ValueError("The forward trace differs from the supplied example") | |
| 17 | + | |
| 18 | + target = 1 | |
| 19 | + for exponent in (4, 1): | |
| 20 | + numerator = (2**exponent) * target - 1 | |
| 21 | + odd_parent, remainder = divmod(numerator, 3) | |
| 22 | + if remainder or odd_parent % 2 != 1: | |
| 23 | + raise ValueError("Invalid odd predecessor") | |
| 24 | + target = odd_parent | |
| 25 | + if 2*target != values[0]: | |
| 26 | + raise ValueError("The backwards reconstruction missed the start") | |
| 27 | + | |
| 28 | + output = Path(__file__).resolve().parent / "out" / "sample-6.csv" | |
| 29 | + output.parent.mkdir(exist_ok=True) | |
| 30 | + with output.open("w", encoding="utf-8-sig", newline="") as f: | |
| 31 | + table = csv.writer(f, lineterminator="\n") | |
| 32 | + table.writerow(["已走步数", "当前值", "下一步"]) | |
| 33 | + for i, value in enumerate(values): | |
| 34 | + rule = "到达 1" if i == 8 else ("除以 2" if value % 2 == 0 else "乘 3 再加 1") | |
| 35 | + table.writerow([i, value, rule]) | |
| 36 | + print("6 -> 1: 8 steps, first hit; inverse blocks (4, 1) recover 6.") | |
| 37 | + | |
| 38 | + | |
| 39 | +if __name__ == "__main__": | |
| 40 | + main() | |