Poincaré conjecture: the Lean proof, cleaned up together
The 2026 Lean proof of the Poincaré conjecture after Morgan and Tian, 3 million lines, cleaned up together: smaller, faster to build, more readable, the theorems unchanged

| 1 | import PoincareLib.Analysis.ODE.Uniqueness.Open |
| 2 | import Mathlib.Algebra.Order.Floor.Ring |
| 3 | |
| 4 | /-! # Forward solutions from finite continuation |
| 5 | |
| 6 | Initial-value uniqueness identifies solutions on increasing finite intervals, |
| 7 | giving a single forward solution and preserving any common range constraint. |
| 8 | -/ |
| 9 | |
| 10 | noncomputable section |
| 11 | |
| 12 | namespace Poincare.ODE |
| 13 | |
| 14 | open Set Filter |
| 15 | open scoped ContDiff Topology |
| 16 | |
| 17 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 18 | |
| 19 | /-- Solutions agreeing at one time glue on overlapping open convex intervals. -/ |
| 20 | theorem exists_gluing_of_solutions |
| 21 | {U : Set E} (hU : IsOpen U) {F : E → E} (hF : ContDiffOn ℝ ∞ F U) |
| 22 | {J₁ J₂ : Set ℝ} (hJ₁ : IsOpen J₁) (hJ₂ : IsOpen J₂) |
| 23 | (hc₁ : Convex ℝ J₁) (hc₂ : Convex ℝ J₂) {α β : ℝ → E} |
| 24 | (hα : ∀ t ∈ J₁, α t ∈ U ∧ HasDerivAt α (F (α t)) t) |
| 25 | (hβ : ∀ t ∈ J₂, β t ∈ U ∧ HasDerivAt β (F (β t)) t) |
| 26 | {a : ℝ} (ha : a ∈ J₁ ∩ J₂) (hjoin : α a = β a) : |
| 27 | ∃ γ : ℝ → E, EqOn γ α J₁ ∧ EqOn γ β J₂ ∧ |
| 28 | ∀ t ∈ J₁ ∪ J₂, γ t ∈ U ∧ HasDerivAt γ (F (γ t)) t := by |
| 29 | classical |
| 30 | have hagree := eqOn_of_hasDerivAt hU hF (hJ₁.inter hJ₂) |
| 31 | (hc₁.inter hc₂).isPreconnected (fun t ht => hα t ht.1) |
| 32 | (fun t ht => hβ t ht.2) ha hjoin |
| 33 | let γ : ℝ → E := fun t => if t ∈ J₁ then α t else β t |
| 34 | have heq₁ : EqOn γ α J₁ := fun t ht => if_pos ht |
| 35 | have heq₂ : EqOn γ β J₂ := by |
| 36 | intro t ht |
| 37 | by_cases ht₁ : t ∈ J₁ |
| 38 | · exact (if_pos ht₁).trans (hagree ⟨ht₁, ht⟩) |
| 39 | · exact if_neg ht₁ |
| 40 | refine ⟨γ, heq₁, heq₂, ?_⟩ |
| 41 | intro t ht |
| 42 | rcases ht with ht | ht |
| 43 | · have he : γ =ᶠ[𝓝 t] α := |
| 44 | Filter.Eventually.mono (hJ₁.mem_nhds ht) fun _ hs => heq₁ hs |
| 45 | rw [heq₁ ht] |
| 46 | exact ⟨(hα t ht).1, (hα t ht).2.congr_of_eventuallyEq he⟩ |
| 47 | · have he : γ =ᶠ[𝓝 t] β := |
| 48 | Filter.Eventually.mono (hJ₂.mem_nhds ht) fun _ hs => heq₂ hs |
| 49 | rw [heq₂ ht] |
| 50 | exact ⟨(hβ t ht).1, (hβ t ht).2.congr_of_eventuallyEq he⟩ |
| 51 | |
| 52 | /-- Arbitrarily long finite solutions of a smooth autonomous field glue to one |
| 53 | forward solution, including a short interval before the initial time. -/ |
| 54 | theorem exists_forward_solution_of_finite_solutions |
| 55 | {U K : Set E} (hU : IsOpen U) {F : E → E} (hF : ContDiffOn ℝ ∞ F U) |
| 56 | {x : E} |
| 57 | (hfinite : ∀ k : ℕ, ∃ δ > 0, ∃ α : ℝ → E, α 0 = x ∧ |
| 58 | (∀ t ∈ Ioo (-δ) ((k : ℝ) + 1 + δ), α t ∈ U ∧ HasDerivAt α (F (α t)) t) ∧ |
| 59 | ∀ t ∈ Icc 0 ((k : ℝ) + 1), α t ∈ K) : |
| 60 | ∃ δ > 0, ∃ γ : ℝ → E, γ 0 = x ∧ |
| 61 | (∀ t ∈ Ioi (-δ), γ t ∈ U ∧ HasDerivAt γ (F (γ t)) t) ∧ |
| 62 | ∀ t : ℝ, 0 ≤ t → γ t ∈ K := by |
| 63 | choose δ hδ α hinit hα hK using hfinite |
| 64 | have hagree (i j : ℕ) : EqOn (α i) (α j) |
| 65 | (Ioo (-min (δ i) (δ j)) (min ((i : ℝ) + 1) ((j : ℝ) + 1))) := by |
| 66 | apply eqOn_of_hasDerivAt hU hF isOpen_Ioo (convex_Ioo _ _).isPreconnected |
| 67 | (fun t ht => hα i t ⟨by linarith [min_le_left (δ i) (δ j), ht.1], |
| 68 | by linarith [min_le_left ((i : ℝ) + 1) ((j : ℝ) + 1), ht.2, hδ i]⟩) |
| 69 | (fun t ht => hα j t ⟨by linarith [min_le_right (δ i) (δ j), ht.1], |
| 70 | by linarith [min_le_right ((i : ℝ) + 1) ((j : ℝ) + 1), ht.2, hδ j]⟩) |
| 71 | (a := 0) |
| 72 | · exact ⟨neg_neg_of_pos (lt_min (hδ i) (hδ j)), |
| 73 | lt_min (by positivity) (by positivity)⟩ |
| 74 | · rw [hinit i, hinit j] |
| 75 | let γ : ℝ → E := fun t => if t < 0 then α 0 t else α ⌈t⌉₊ t |
| 76 | have heq (k : ℕ) : EqOn γ (α k) |
| 77 | (Ioo (-min (δ 0) (δ k)) ((k : ℝ) + 1)) := by |
| 78 | intro t ht |
| 79 | dsimp [γ] |
| 80 | split_ifs with ht0 |
| 81 | · exact hagree 0 k ⟨ht.1, lt_min (by simpa using ht0.trans (by norm_num : (0 : ℝ) < 1)) ht.2⟩ |
| 82 | · have ht0' : 0 ≤ t := le_of_not_gt ht0 |
| 83 | exact hagree ⌈t⌉₊ k ⟨by linarith [lt_min (hδ ⌈t⌉₊) (hδ k)], |
| 84 | lt_min (by linarith [Nat.le_ceil t]) ht.2⟩ |
| 85 | refine ⟨δ 0, hδ 0, γ, ?_, ?_, ?_⟩ |
| 86 | · simp [γ, hinit] |
| 87 | · intro t ht |
| 88 | by_cases ht0 : t < 0 |
| 89 | · have hnear : γ =ᶠ[𝓝 t] α 0 := by |
| 90 | filter_upwards [isOpen_Iio.mem_nhds ht0] with s hs |
| 91 | exact if_pos hs |
| 92 | have hd := hα 0 t ⟨ht, by simpa using ht0.trans (by linarith [hδ 0] : (0 : ℝ) < 1 + δ 0)⟩ |
| 93 | rw [hnear.self_of_nhds] |
| 94 | exact ⟨hd.1, hd.2.congr_of_eventuallyEq hnear⟩ |
| 95 | · have ht0' : 0 ≤ t := le_of_not_gt ht0 |
| 96 | have htI : t ∈ Ioo (-min (δ 0) (δ ⌈t⌉₊)) ((⌈t⌉₊ : ℝ) + 1) := |
| 97 | ⟨by linarith [lt_min (hδ 0) (hδ ⌈t⌉₊)], by linarith [Nat.le_ceil t]⟩ |
| 98 | have hnear : γ =ᶠ[𝓝 t] α ⌈t⌉₊ := |
| 99 | Filter.Eventually.mono (isOpen_Ioo.mem_nhds htI) fun _ hs => heq _ hs |
| 100 | have hd := hα ⌈t⌉₊ t ⟨by linarith [hδ ⌈t⌉₊], by linarith [htI.2, hδ ⌈t⌉₊]⟩ |
| 101 | rw [hnear.self_of_nhds] |
| 102 | exact ⟨hd.1, hd.2.congr_of_eventuallyEq hnear⟩ |
| 103 | · intro t ht |
| 104 | rw [show γ t = α ⌈t⌉₊ t from if_neg (not_lt.mpr ht)] |
| 105 | exact hK _ t ⟨ht, by linarith [Nat.le_ceil t]⟩ |
| 106 | |
| 107 | end Poincare.ODE |