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 | /- |
| 2 | Provenance and modification notice (recorded 2026-09-29). |
| 3 | Source: https://github.com/qinz1yang/differential-geometry |
| 4 | DifferentialGeometry/Analysis/ODE/Flow/HigherRegularity/ContDiffOnTop.lean |
| 5 | Comparison revision: 1b535dd102b94cc42b107cca27059687888f08b3. |
| 6 | Changes: Imports, module paths, and namespaces were adapted to the subject-organized PoincareLib library. |
| 7 | License: Apache-2.0. Source licenses and notices are retained under |
| 8 | PoincareConjecture/provenance/2026-09-29/licenses/. |
| 9 | See PoincareConjecture/MODIFICATIONS.md for the reviewed source mapping. |
| 10 | -/ |
| 11 | |
| 12 | /- |
| 13 | Copyright (c) 2026 The DifferentialGeometry contributors. |
| 14 | Released under Apache 2.0 license. |
| 15 | |
| 16 | Adapted from DifferentialGeometry/Analysis/ODE/Flow/HigherRegularity/ContDiffOnTop.lean |
| 17 | at revision 1b535dd102b94cc42b107cca27059687888f08b3. |
| 18 | Original SHA-256: 9887d7f3a261b26e634d3d8068770e64a212c57cc0da2813ee8761c291222afa |
| 19 | Changes: library paths and namespaces. |
| 20 | -/ |
| 21 | import PoincareLib.Analysis.ODE.LocalFlow.ParametricLinearODE |
| 22 | import Mathlib.Analysis.Calculus.ContDiff.FiniteDimension |
| 23 | |
| 24 | noncomputable section |
| 25 | |
| 26 | namespace Poincare.ODE.LocalFlow |
| 27 | |
| 28 | open Set Metric Function |
| 29 | open scoped ContDiff NNReal |
| 30 | |
| 31 | theorem contDiffOn_top_of_forall_nat |
| 32 | {𝕜 E F : Type*} [NontriviallyNormedField 𝕜] |
| 33 | [NormedAddCommGroup E] [NormedSpace 𝕜 E] |
| 34 | [NormedAddCommGroup F] [NormedSpace 𝕜 F] |
| 35 | {f : E → F} {S : Set E} |
| 36 | (h : ∀ k : ℕ, ContDiffOn 𝕜 (k : ℕ∞) f S) : |
| 37 | ContDiffOn 𝕜 (∞ : WithTop ℕ∞) f S := |
| 38 | contDiffOn_infty.mpr h |
| 39 | |
| 40 | section CoefficientRegularity |
| 41 | |
| 42 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 43 | variable {f : ℝ → E → E} {t₀ : ℝ} {x₀ : E} {Φ : E × ℝ → E} |
| 44 | |
| 45 | omit [CompleteSpace E] in |
| 46 | private theorem contDiffOn_variational_coeff_aux |
| 47 | {n : ℕ} {T : ℝ} {ρ : ℝ≥0} |
| 48 | (hf_succ : ContDiffOn ℝ ((n : ℕ∞) + 1) (uncurry f) (univ : Set (ℝ × E))) |
| 49 | (hΦ_Cn : ContDiffOn ℝ (n : ℕ∞) Φ ((ball x₀ (ρ : ℝ)) ×ˢ Ioo (t₀ - T) (t₀ + T))) : |
| 50 | ContDiffOn ℝ (n : ℕ∞) |
| 51 | (fun q : E × ℝ => fderiv ℝ (f q.2) (Φ q)) |
| 52 | ((ball x₀ (ρ : ℝ)) ×ˢ Ioo (t₀ - T) (t₀ + T)) := by |
| 53 | set pfD : ℝ × E → (E →L[ℝ] E) := fun p => fderiv ℝ (f p.1) p.2 |
| 54 | set iM : E × ℝ → ℝ × E := fun q => (q.2, Φ q) |
| 55 | set U := (ball x₀ (ρ : ℝ)) ×ˢ Ioo (t₀ - T) (t₀ + T) |
| 56 | suffices h : ContDiffOn ℝ (n : ℕ∞) (pfD ∘ iM) U by exact h.congr (fun _ _ => rfl) |
| 57 | have hpfd : ContDiffOn ℝ (n : ℕ∞) pfD (univ : Set (ℝ × E)) := |
| 58 | contDiffOn_partial_fderiv_of_succ hf_succ |
| 59 | have hiM : ContDiffOn ℝ (n : ℕ∞) iM U := |
| 60 | (contDiff_snd.contDiffOn : ContDiffOn ℝ (n : ℕ∞) Prod.snd U).prodMk hΦ_Cn |
| 61 | exact hpfd.comp hiM (fun _ _ => mem_univ _) |
| 62 | |
| 63 | end CoefficientRegularity |
| 64 | |
| 65 | section HartmanTheorem |
| 66 | |
| 67 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 68 | [FiniteDimensional ℝ E] |
| 69 | variable {f : ℝ → E → E} {t₀ : ℝ} {x₀ : E} {r : ℝ≥0} {tmin tmax : ℝ} {Φ : E × ℝ → E} |
| 70 | |
| 71 | theorem IsLocalFlow.contDiffOn_top |
| 72 | (hΦ : IsLocalFlow f t₀ x₀ r tmin tmax Φ) |
| 73 | (hf_top : ContDiff ℝ ∞ (uncurry f)) |
| 74 | {T_out T_mid T M : ℝ} (hT : 0 < T) (hT_lt_mid : T < T_mid) |
| 75 | (hT_mid_lt_out : T_mid < T_out) (hM : 0 ≤ M) |
| 76 | (hMT_mid : M * T_mid < 1) |
| 77 | (hsub : Icc (t₀ - T_out) (t₀ + T_out) ⊆ Icc tmin tmax) |
| 78 | {ρ_out ρ_mid ρ : ℝ≥0} {r' : ℝ≥0} (hr' : 0 < r') |
| 79 | (hρ_lt_mid : (ρ : ℝ) < (ρ_mid : ℝ)) |
| 80 | (hρ_mid_lt_out : (ρ_mid : ℝ) < (ρ_out : ℝ)) |
| 81 | (hρρ' : (ρ_mid : ℝ) + (r' : ℝ) ≤ (r : ℝ)) |
| 82 | (hρ_out_le_r : (ρ_out : ℝ) ≤ (r : ℝ)) |
| 83 | (hA_bd : ∀ x ∈ closedBall x₀ (ρ_out : ℝ), |
| 84 | ∀ τ ∈ Icc (t₀ - T_out) (t₀ + T_out), |
| 85 | ‖fderiv ℝ (f τ) (Φ ⟨x, τ⟩)‖ ≤ M) : |
| 86 | ContDiffOn ℝ ∞ Φ |
| 87 | ((ball x₀ (ρ : ℝ)) ×ˢ Ioo (t₀ - T) (t₀ + T)) := by |
| 88 | apply contDiffOn_top_of_forall_nat |
| 89 | intro n |
| 90 | set U := (ball x₀ (ρ : ℝ)) ×ˢ Ioo (t₀ - T) (t₀ + T) |
| 91 | have hf_Ck : ∀ k : ℕ, ContDiffOn ℝ (k : ℕ∞) (uncurry f) (univ : Set (ℝ × E)) := |
| 92 | fun k => (hf_top.contDiffOn : ContDiffOn ℝ ∞ (uncurry f) univ).of_le |
| 93 | (by exact_mod_cast (le_top : (k : ℕ∞) ≤ ⊤)) |
| 94 | have hf_C1 : ContDiffOn ℝ 1 (uncurry f) (univ : Set (ℝ × E)) := by simpa using hf_Ck 1 |
| 95 | have hΦ_C1 : ContDiffOn ℝ 1 Φ U := |
| 96 | contDiffOn_flow_of_isLocalFlow hΦ hf_C1 hT hT_lt_mid hT_mid_lt_out hM hMT_mid hsub hr' |
| 97 | hρ_lt_mid hρ_mid_lt_out hρρ' hρ_out_le_r hA_bd |
| 98 | have hT_mid_pos : 0 < T_mid := lt_trans hT hT_lt_mid |
| 99 | have hsub_mid_out : Icc (t₀ - T_mid) (t₀ + T_mid) ⊆ Icc (t₀ - T_out) (t₀ + T_out) := |
| 100 | Icc_subset_Icc (by linarith) (by linarith) |
| 101 | have hsub_mid : Icc (t₀ - T_mid) (t₀ + T_mid) ⊆ Icc tmin tmax := hsub_mid_out.trans hsub |
| 102 | have hA_bd_mid : ∀ x ∈ closedBall x₀ (ρ_mid : ℝ), |
| 103 | ∀ τ ∈ Icc (t₀ - T_mid) (t₀ + T_mid), ‖fderiv ℝ (f τ) (Φ ⟨x, τ⟩)‖ ≤ M := |
| 104 | fun x hx τ hτ => |
| 105 | hA_bd x (closedBall_subset_closedBall (le_of_lt hρ_mid_lt_out) hx) τ (hsub_mid_out hτ) |
| 106 | have hab : t₀ - T < t₀ + T := by linarith |
| 107 | have ht₀_mem : t₀ ∈ Ioo (t₀ - T) (t₀ + T) := ⟨by linarith, by linarith⟩ |
| 108 | induction n with |
| 109 | | zero => exact hΦ_C1.of_le (by decide) |
| 110 | | succ n ih => |
| 111 | have hf_Csucc : ContDiffOn ℝ ((n : ℕ∞) + 1) (uncurry f) (univ : Set (ℝ × E)) := by |
| 112 | simpa using hf_Ck (n + 1) |
| 113 | have hcoeff_Cn : ContDiffOn ℝ (n : ℕ∞) (fun q : E × ℝ => fderiv ℝ (f q.2) (Φ q)) U := |
| 114 | contDiffOn_variational_coeff_aux hf_Csucc ih |
| 115 | set A : E → ℝ → (E →L[ℝ] E) := fun x t => fderiv ℝ (f t) (Φ ⟨x, t⟩) |
| 116 | have hlinear_Cn : ∀ δ : E, ContDiffOn ℝ (n : ℕ∞) |
| 117 | (uncurry (linearODESolution A (t₀ - T) (t₀ + T) t₀ (fun _ => δ))) |
| 118 | (ball x₀ (ρ : ℝ) ×ˢ Ioo (t₀ - T) (t₀ + T)) := |
| 119 | fun δ => linearODESolution_contDiffOn ht₀_mem isOpen_ball n |
| 120 | (hcoeff_Cn : ContDiffOn ℝ (n : ℕ∞) (uncurry A) _) |
| 121 | (contDiffOn_const : ContDiffOn ℝ (n : ℕ∞) (fun (_ : E) => δ) (ball x₀ (ρ : ℝ))) |
| 122 | set Lsp : E × ℝ → E →L[ℝ] E := |
| 123 | fun q => (fderiv ℝ Φ q).comp (ContinuousLinearMap.inl ℝ E ℝ) |
| 124 | have hfderiv_coprod : ∀ q ∈ U, fderiv ℝ Φ q = (Lsp q).coprod (timePieceFn f Φ q) := by |
| 125 | intro ⟨x, t⟩ ⟨hx, ht⟩ |
| 126 | have hx' : dist x x₀ < ↑ρ := mem_ball.mp hx |
| 127 | have hx_cb_mid : x ∈ closedBall x₀ (ρ_mid : ℝ) := |
| 128 | mem_closedBall.mpr (le_of_lt (lt_trans hx' hρ_lt_mid)) |
| 129 | have ht_mid : t ∈ Ioo (t₀ - T_mid) (t₀ + T_mid) := ⟨by linarith [ht.1], by linarith [ht.2]⟩ |
| 130 | have hfd := hasFDerivAt_flow_jointly_at hΦ hf_C1 hT_mid_pos hM hMT_mid hsub_mid |
| 131 | hr' hρρ' hA_bd_mid hx_cb_mid ht_mid |
| 132 | rw [hfd.fderiv] |
| 133 | change (variationalLinearMapAt hT_mid_pos hM hMT_mid _ _ _).coprod |
| 134 | ((ContinuousLinearMap.id ℝ ℝ).smulRight (f t (Φ (x, t)))) |
| 135 | = (Lsp (x, t)).coprod (timePieceFn f Φ (x, t)) |
| 136 | congr 1 |
| 137 | · change _ = (fderiv ℝ Φ (x, t)).comp (ContinuousLinearMap.inl ℝ E ℝ) |
| 138 | rw [hfd.fderiv] |
| 139 | exact (ContinuousLinearMap.coprod_comp_inl _ _).symm |
| 140 | have hLsp_Cn : ContDiffOn ℝ (n : ℕ∞) Lsp U := by |
| 141 | rw [contDiffOn_clm_apply] |
| 142 | intro δ |
| 143 | refine (hlinear_Cn δ).congr (fun q hq => ?_) |
| 144 | obtain ⟨hx_ball, ht_Ioo⟩ := hq |
| 145 | have hx' : dist q.1 x₀ < ↑ρ := mem_ball.mp hx_ball |
| 146 | have hx_cb_mid : q.1 ∈ closedBall x₀ (ρ_mid : ℝ) := |
| 147 | mem_closedBall.mpr (le_of_lt (lt_trans hx' hρ_lt_mid)) |
| 148 | have ht_mid : q.2 ∈ Ioo (t₀ - T_mid) (t₀ + T_mid) := |
| 149 | ⟨by linarith [ht_Ioo.1], by linarith [ht_Ioo.2]⟩ |
| 150 | have hΦ_restr := hΦ.restrict_center_of_norm_le (x₁ := q.1) (r' := r') (by |
| 151 | rw [mem_closedBall] at hx_cb_mid; linarith) |
| 152 | have hA_cont_x := ((hΦ_restr.continuousOn_fderiv_along_orbit hf_C1 q.1 |
| 153 | (mem_closedBall_self (by exact_mod_cast (le_of_lt hr')))).mono hsub_mid) |
| 154 | have hA_bd_x := fun τ hτ => hA_bd_mid q.1 hx_cb_mid τ hτ |
| 155 | have ht_Icc : q.2 ∈ Icc (t₀ - T_mid) (t₀ + T_mid) := Ioo_subset_Icc_self ht_mid |
| 156 | have hfd := hasFDerivAt_flow_jointly_at hΦ hf_C1 hT_mid_pos hM hMT_mid hsub_mid |
| 157 | hr' hρρ' hA_bd_mid hx_cb_mid ht_mid |
| 158 | have hLsp_eq_vlm : Lsp q = |
| 159 | variationalLinearMapAt hT_mid_pos hM hMT_mid hA_cont_x hA_bd_x ht_Icc := by |
| 160 | change (fderiv ℝ Φ q).comp (ContinuousLinearMap.inl ℝ E ℝ) = _ |
| 161 | conv_lhs => rw [show q = (q.1, q.2) from Prod.mk.eta.symm] |
| 162 | rw [hfd.fderiv] |
| 163 | exact ContinuousLinearMap.coprod_comp_inl _ _ |
| 164 | have hvlm_eq := variationalLinearMapAt_apply hT_mid_pos hM hMT_mid hA_cont_x hA_bd_x |
| 165 | ht_Icc δ |
| 166 | have hvsf := variationalSolutionFun_isSolution hT_mid_pos hM hMT_mid hA_cont_x hA_bd_x δ |
| 167 | have hA_cont_Ioo : ContinuousOn (A q.1) (Ioo (t₀ - T) (t₀ + T)) := |
| 168 | hA_cont_x.mono (fun s hs => Ioo_subset_Icc_self |
| 169 | (⟨by linarith [hs.1], by linarith [hs.2]⟩ : s ∈ Ioo (t₀ - T_mid) (t₀ + T_mid))) |
| 170 | have hA_joint_cont : ContinuousOn (uncurry A) |
| 171 | (ball x₀ (ρ : ℝ) ×ˢ Ioo (t₀ - T) (t₀ + T)) := hcoeff_Cn.continuousOn |
| 172 | have h_exists : HasLinearODESolution A (t₀ - T) (t₀ + T) t₀ (fun _ => δ) q.1 := |
| 173 | hasLinearODESolution_of_continuousOn ht₀_mem hA_joint_cont |
| 174 | (mem_ball.mpr hx') |
| 175 | have h_uniq := linearODE_unique_on_Ioo (G := E) ht₀_mem hA_cont_Ioo |
| 176 | (fun s hs => by |
| 177 | have hs_mid : s ∈ Ioo (t₀ - T_mid) (t₀ + T_mid) := |
| 178 | ⟨by linarith [hs.1], by linarith [hs.2]⟩ |
| 179 | exact (hvsf.2 s (Ioo_subset_Icc_self hs_mid)).hasDerivAt (Icc_mem_nhds_iff.mpr hs_mid)) |
| 180 | (fun s hs => linearODESolution_hasDerivAt_of_hasSolution A (t₀ - T) (t₀ + T) t₀ |
| 181 | (fun _ => δ) h_exists hs) |
| 182 | (by rw [hvsf.1, linearODESolution_init]) |
| 183 | simp only [hLsp_eq_vlm, hvlm_eq, uncurry] |
| 184 | have h_eq := h_uniq ht_Ioo |
| 185 | dsimp at h_eq |
| 186 | exact h_eq |
| 187 | exact contDiffOn_flow_succ_of_spatial_smooth hΦ hT hT_lt_mid hT_mid_lt_out hM hMT_mid hsub |
| 188 | hr' hρ_lt_mid hρ_mid_lt_out hρρ' hρ_out_le_r hA_bd |
| 189 | (by simpa using hf_Ck (n + 1)) ih hLsp_Cn hfderiv_coprod |
| 190 | |
| 191 | end HartmanTheorem |
| 192 | |
| 193 | end Poincare.ODE.LocalFlow |
| 194 | |
| 195 | end |