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 Mathlib.Analysis.Calculus.MeanValue |
| 2 | import Mathlib.Analysis.Calculus.FDeriv.Extend |
| 3 | import Mathlib.Analysis.Normed.Group.Bounded |
| 4 | import Mathlib.Topology.Order.OrderClosed |
| 5 | import Mathlib.Topology.UniformSpace.Cauchy |
| 6 | import PoincareLib.Analysis.ODE.LocalFlow.Smooth |
| 7 | |
| 8 | /-! |
| 9 | # Finite endpoints of compact ODE trajectories |
| 10 | |
| 11 | A trajectory in a compact set has bounded speed when the vector field is |
| 12 | continuous on that set. It is consequently Cauchy at a finite endpoint, and |
| 13 | compactness supplies a limit without completeness of the ambient space. |
| 14 | For a smooth field on an open finite-dimensional domain, this limit supplies |
| 15 | initial data for a continuation past the endpoint. |
| 16 | -/ |
| 17 | |
| 18 | namespace Poincare.ODE |
| 19 | |
| 20 | open Set Metric Filter |
| 21 | open scoped Topology NNReal ContDiff |
| 22 | |
| 23 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 24 | |
| 25 | /-- A trajectory of a continuous vector field confined to a compact set has a |
| 26 | uniform Lipschitz bound on its interval of definition. -/ |
| 27 | theorem exists_lipschitzOnWith_of_compact_trajectory |
| 28 | {F : E → E} {S : Set E} (hS : IsCompact S) (hF : ContinuousOn F S) |
| 29 | {a b : ℝ} {γ : ℝ → E} |
| 30 | (hmem : ∀ t ∈ Ioo a b, γ t ∈ S) |
| 31 | (hγ : ∀ t ∈ Ioo a b, HasDerivAt γ (F (γ t)) t) : |
| 32 | ∃ K : ℝ≥0, LipschitzOnWith K γ (Ioo a b) := by |
| 33 | obtain ⟨K, hK, hbound⟩ := |
| 34 | (hS.image_of_continuousOn hF).isBounded.exists_pos_norm_le |
| 35 | refine ⟨⟨K, hK.le⟩, (convex_Ioo a b).lipschitzOnWith_of_nnnorm_hasDerivWithin_le |
| 36 | (fun t ht => (hγ t ht).hasDerivWithinAt) ?_⟩ |
| 37 | intro t ht |
| 38 | exact_mod_cast hbound (F (γ t)) (mem_image_of_mem F (hmem t ht)) |
| 39 | |
| 40 | /-- A compact ODE trajectory has a limit in the same compact set at its finite |
| 41 | right endpoint. No completeness assumption on the ambient vector space is used. -/ |
| 42 | theorem exists_endpoint_of_compact_trajectory |
| 43 | {F : E → E} {S : Set E} (hS : IsCompact S) (hF : ContinuousOn F S) |
| 44 | {a b : ℝ} (hab : a < b) {γ : ℝ → E} |
| 45 | (hmem : ∀ t ∈ Ioo a b, γ t ∈ S) |
| 46 | (hγ : ∀ t ∈ Ioo a b, HasDerivAt γ (F (γ t)) t) : |
| 47 | ∃ z ∈ S, Tendsto γ (𝓝[<] b) (𝓝 z) := by |
| 48 | obtain ⟨K, hK⟩ := exists_lipschitzOnWith_of_compact_trajectory hS hF hmem hγ |
| 49 | have hinterval : 𝓝[<] b ≤ 𝓟 (Ioo a b) := by |
| 50 | rw [← nhdsWithin_Ioo_eq_nhdsLT hab] |
| 51 | exact inf_le_right |
| 52 | have hc : Cauchy (𝓝[<] b) := cauchy_nhds.mono nhdsWithin_le_nhds |
| 53 | apply hS.isComplete (map γ (𝓝[<] b)) (hc.map_of_le hK.uniformContinuousOn hinterval) |
| 54 | rw [le_principal_iff, mem_map] |
| 55 | exact mem_of_superset (le_principal_iff.mp hinterval) hmem |
| 56 | |
| 57 | /-- A trajectory confined to a compact subset of the domain of a smooth vector |
| 58 | field extends past any finite right endpoint. Only the finite-dimensional model |
| 59 | space is used for local existence; no completeness of the domain is assumed. -/ |
| 60 | theorem exists_continuation_of_compact_trajectory [FiniteDimensional ℝ E] |
| 61 | {U S : Set E} (hU : IsOpen U) (hS : IsCompact S) (hSU : S ⊆ U) |
| 62 | {F : E → E} (hF : ContDiffOn ℝ ∞ F U) |
| 63 | {a b : ℝ} (hab : a < b) {γ : ℝ → E} |
| 64 | (hmem : ∀ t ∈ Ioo a b, γ t ∈ S) |
| 65 | (hγ : ∀ t ∈ Ioo a b, HasDerivAt γ (F (γ t)) t) : |
| 66 | ∃ δ > 0, ∃ η : ℝ → E, |
| 67 | EqOn η γ (Ioo a b) ∧ η b ∈ S ∧ |
| 68 | (∀ t ∈ Ioo a (b + δ), η t ∈ U) ∧ |
| 69 | (∀ t ∈ Ioo a (b + δ), HasDerivAt η (F (η t)) t) := by |
| 70 | obtain ⟨z, hz, hlim⟩ := exists_endpoint_of_compact_trajectory hS |
| 71 | (hF.continuousOn.mono hSU) hab hmem hγ |
| 72 | obtain ⟨V, δ, Φ, _, hzV, _, hδ, _, hinit, hmaps, hflow⟩ := |
| 73 | LocalFlow.exists_smooth_localFlow hU hF (hSU hz) |
| 74 | let β : ℝ → E := fun t => Φ (z, t - b) |
| 75 | have hβb : β b = z := by simpa [β] using hinit z hzV |
| 76 | have hβ : ∀ t ∈ Ioo (b - δ) (b + δ), HasDerivAt β (F (β t)) t := by |
| 77 | intro t ht |
| 78 | have htδ : t - b ∈ Ioo (-δ) δ := ⟨by linarith [ht.1], by linarith [ht.2]⟩ |
| 79 | simpa [β, Function.comp_def] using |
| 80 | (hflow z hzV (t - b) htδ).scomp t ((hasDerivAt_id t).sub_const b) |
| 81 | let η : ℝ → E := fun t => if t < b then γ t else β t |
| 82 | have hηb : η b = z := by simp [η, hβb] |
| 83 | have hηeq : EqOn η γ (Ioo a b) := fun t ht => if_pos ht.2 |
| 84 | have hηleft : ∀ t ∈ Ioo a b, HasDerivAt η (F (η t)) t := by |
| 85 | intro t ht |
| 86 | have heq : η =ᶠ[𝓝 t] γ := by |
| 87 | filter_upwards [isOpen_Iio.mem_nhds ht.2] with s hs |
| 88 | exact if_pos hs |
| 89 | rw [hηeq ht] |
| 90 | exact (hγ t ht).congr_of_eventuallyEq heq |
| 91 | have hηright : ∀ t ∈ Ioo b (b + δ), HasDerivAt η (F (η t)) t := by |
| 92 | intro t ht |
| 93 | have heq : η =ᶠ[𝓝 t] β := by |
| 94 | filter_upwards [isOpen_Ioi.mem_nhds ht.1] with s hs |
| 95 | exact if_neg (not_lt.mpr hs.le) |
| 96 | rw [show η t = β t from if_neg (not_lt.mpr ht.1.le)] |
| 97 | exact (hβ t ⟨by linarith [ht.1], ht.2⟩).congr_of_eventuallyEq heq |
| 98 | have hηlim : Tendsto η (𝓝[<] b) (𝓝 z) := by |
| 99 | apply hlim.congr' |
| 100 | filter_upwards [self_mem_nhdsWithin] with t ht |
| 101 | exact (if_pos ht).symm |
| 102 | have hIoo : Ioo a b ∈ 𝓝[<] b := by |
| 103 | rw [← nhdsWithin_Ioo_eq_nhdsLT hab] |
| 104 | exact self_mem_nhdsWithin |
| 105 | have hleft : HasDerivWithinAt η (F z) (Iic b) b := by |
| 106 | apply hasDerivWithinAt_Iic_of_tendsto_deriv |
| 107 | (fun t ht => (hηleft t ht).differentiableAt.differentiableWithinAt) |
| 108 | · change Tendsto η (𝓝[Ioo a b] b) (𝓝 (η b)) |
| 109 | rw [hηb, nhdsWithin_Ioo_eq_nhdsLT hab] |
| 110 | exact hηlim |
| 111 | · exact hIoo |
| 112 | · have hFz := hF.continuousOn.continuousAt (hU.mem_nhds (hSU hz)) |
| 113 | apply (hFz.tendsto.comp hηlim).congr' |
| 114 | filter_upwards [hIoo] with t ht |
| 115 | exact (hηleft t ht).deriv.symm |
| 116 | have hright : HasDerivWithinAt η (F z) (Ici b) b := by |
| 117 | have hb := (hβ b ⟨by linarith, by linarith⟩).hasDerivWithinAt (s := Ici b) |
| 118 | rw [hβb] at hb |
| 119 | apply hb.congr |
| 120 | · intro t ht |
| 121 | exact if_neg (not_lt.mpr ht) |
| 122 | · exact if_neg (lt_irrefl b) |
| 123 | have hjoin : HasDerivAt η (F (η b)) b := by |
| 124 | rw [hηb] |
| 125 | simpa only [Iic_union_Ici, hasDerivWithinAt_univ] using hleft.union hright |
| 126 | refine ⟨δ, hδ, η, hηeq, by simpa only [hηb] using hz, ?_, ?_⟩ |
| 127 | · intro t ht |
| 128 | by_cases htb : t < b |
| 129 | · rw [hηeq ⟨ht.1, htb⟩] |
| 130 | exact hSU (hmem t ⟨ht.1, htb⟩) |
| 131 | · change (if t < b then γ t else β t) ∈ U |
| 132 | rw [if_neg htb] |
| 133 | exact hmaps z hzV (t - b) ⟨by linarith, by linarith [ht.2]⟩ |
| 134 | · intro t ht |
| 135 | rcases lt_trichotomy t b with htb | rfl | hbt |
| 136 | · exact hηleft t ⟨ht.1, htb⟩ |
| 137 | · exact hjoin |
| 138 | · exact hηright t ⟨hbt, ht.2⟩ |
| 139 | |
| 140 | end Poincare.ODE |