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.BoundedExistence |
| 2 | |
| 3 | /-! |
| 4 | # Complete smooth flows with parameters |
| 5 | |
| 6 | An everywhere-defined family of solutions of a smooth autonomous field is |
| 7 | jointly smooth. Applying this to a field with frozen parameters gives complete |
| 8 | smooth parameter-dependent flows for fields constant outside a compact set. |
| 9 | -/ |
| 10 | |
| 11 | noncomputable section |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open Set Filter |
| 15 | open scoped ContDiff Topology |
| 16 | |
| 17 | namespace Poincare.ODE.Flow |
| 18 | |
| 19 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 20 | [FiniteDimensional ℝ E] |
| 21 | |
| 22 | private theorem contDiffAt_solution_family_of_nonneg |
| 23 | {F : E → E} (hF : ContDiff ℝ ∞ F) {Φ : E × ℝ → E} |
| 24 | (hinit : ∀ x, Φ (x, 0) = x) |
| 25 | (hflow : ∀ x t, HasDerivAt (fun s => Φ (x, s)) (F (Φ (x, t))) t) |
| 26 | (x : E) {t : ℝ} (ht : 0 ≤ t) : ContDiffAt ℝ ∞ Φ (x, t) := by |
| 27 | obtain ⟨V, ε, Ψ, hV, hxV, hε, hΨ, hiΨ, hdΨ⟩ := |
| 28 | LocalFlow.exists_smooth_flow_along_compact_interval |
| 29 | isOpen_univ hF.contDiffOn isOpen_univ convex_univ |
| 30 | (γ := fun s => Φ (x, s)) (fun s _ => ⟨mem_univ _, hflow x s⟩) |
| 31 | ht (subset_univ _) |
| 32 | rw [hinit x] at hxV |
| 33 | have h0 : (0 : ℝ) ∈ Ioo (-ε) (t + ε) := ⟨by linarith, by linarith⟩ |
| 34 | have heq : EqOn Φ Ψ (V ×ˢ Ioo (-ε) (t + ε)) := by |
| 35 | rintro ⟨y, s⟩ ⟨hy, hs⟩ |
| 36 | exact eqOn_of_hasDerivAt isOpen_univ hF.contDiffOn isOpen_Ioo |
| 37 | (convex_Ioo _ _).isPreconnected |
| 38 | (fun r _ => ⟨mem_univ _, hflow y r⟩) (hdΨ y hy) |
| 39 | h0 ((hinit y).trans (hiΨ y hy).symm) hs |
| 40 | have hmem : V ×ˢ Ioo (-ε) (t + ε) ∈ 𝓝 (x, t) := |
| 41 | (hV.prod isOpen_Ioo).mem_nhds ⟨hxV, by constructor <;> linarith⟩ |
| 42 | exact (hΨ.contDiffAt hmem).congr_of_eventuallyEq |
| 43 | (Filter.Eventually.mono hmem fun _ hz => heq hz) |
| 44 | |
| 45 | /-- A family of complete solutions of a smooth autonomous field, with the |
| 46 | identity as its initial slice, is jointly smooth in initial point and time. -/ |
| 47 | theorem contDiff_solution_family |
| 48 | {F : E → E} (hF : ContDiff ℝ ∞ F) {Φ : E × ℝ → E} |
| 49 | (hinit : ∀ x, Φ (x, 0) = x) |
| 50 | (hflow : ∀ x t, HasDerivAt (fun s => Φ (x, s)) (F (Φ (x, t))) t) : |
| 51 | ContDiff ℝ ∞ Φ := by |
| 52 | apply contDiff_iff_contDiffAt.mpr |
| 53 | rintro ⟨x, t⟩ |
| 54 | by_cases ht : 0 ≤ t |
| 55 | · exact contDiffAt_solution_family_of_nonneg hF hinit hflow x ht |
| 56 | · let Ψ : E × ℝ → E := fun z => Φ (z.1, -z.2) |
| 57 | have hiΨ (y : E) : Ψ (y, 0) = y := by simp only [Ψ, neg_zero, hinit] |
| 58 | have hdΨ (y : E) (s : ℝ) : |
| 59 | HasDerivAt (fun r => Ψ (y, r)) ((-F) (Ψ (y, s))) s := by |
| 60 | simpa only [Ψ, Function.comp_def, neg_smul, one_smul, Pi.neg_apply] using |
| 61 | (hflow y (-s)).scomp s (hasDerivAt_neg s) |
| 62 | have hs := contDiffAt_solution_family_of_nonneg hF.neg hiΨ hdΨ x |
| 63 | (neg_nonneg.mpr (le_of_not_ge ht)) |
| 64 | have hr : ContDiff ℝ ∞ (fun z : E × ℝ => (z.1, -z.2)) := |
| 65 | contDiff_fst.prodMk contDiff_snd.neg |
| 66 | simpa only [Ψ, Function.comp_def, neg_neg] using hs.comp (x, t) hr.contDiffAt |
| 67 | |
| 68 | /-- A jointly smooth family of fields, all equal to one constant outside a |
| 69 | fixed compact set, has a complete jointly smooth flow. Time addition gives the |
| 70 | flow composition law, and negating time gives its spatial inverse. -/ |
| 71 | theorem exists_smooth_parametric_flow |
| 72 | {P : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] |
| 73 | [FiniteDimensional ℝ P] |
| 74 | {H : P × E → E} (hH : ContDiff ℝ ∞ H) |
| 75 | {K : Set E} (hK : IsCompact K) {v : E} |
| 76 | (hfix : ∀ p x, x ∉ K → H (p, x) = v) : |
| 77 | ∃ Φ : P → ℝ → E → E, |
| 78 | ContDiff ℝ ∞ (fun z : P × (ℝ × E) => Φ z.1 z.2.1 z.2.2) ∧ |
| 79 | (∀ p x, Φ p 0 x = x) ∧ |
| 80 | (∀ p x t, HasDerivAt (fun s => Φ p s x) (H (p, Φ p t x)) t) ∧ |
| 81 | (∀ p s t x, Φ p (s + t) x = Φ p s (Φ p t x)) ∧ |
| 82 | ∀ p t, Function.LeftInverse (Φ p (-t)) (Φ p t) ∧ |
| 83 | Function.RightInverse (Φ p (-t)) (Φ p t) := by |
| 84 | classical |
| 85 | have hHp (p : P) : ContDiff ℝ ∞ (fun x => H (p, x)) := |
| 86 | hH.comp (contDiff_const.prodMk contDiff_id) |
| 87 | have hex (p : P) (x : E) : ∃ γ : ℝ → E, |
| 88 | γ 0 = x ∧ ∀ t, HasDerivAt γ (H (p, γ t)) t := |
| 89 | exists_global_solution_of_eq_const_off_compact (hHp p) hK (hfix p) x |
| 90 | choose γ hγinit hγflow using hex |
| 91 | let Φ : P → ℝ → E → E := fun p t x => γ p x t |
| 92 | have hiΦ (p : P) (x : E) : Φ p 0 x = x := hγinit p x |
| 93 | have hdΦ (p : P) (x : E) (t : ℝ) : |
| 94 | HasDerivAt (fun s => Φ p s x) (H (p, Φ p t x)) t := hγflow p x t |
| 95 | let F : P × E → P × E := fun z => (0, H z) |
| 96 | let Ψ : (P × E) × ℝ → P × E := fun z => (z.1.1, Φ z.1.1 z.2 z.1.2) |
| 97 | have hF : ContDiff ℝ ∞ F := contDiff_const.prodMk hH |
| 98 | have hiΨ (z : P × E) : Ψ (z, 0) = z := by |
| 99 | exact Prod.ext rfl (hiΦ z.1 z.2) |
| 100 | have hdΨ (z : P × E) (t : ℝ) : |
| 101 | HasDerivAt (fun s => Ψ (z, s)) (F (Ψ (z, t))) t := |
| 102 | (hasDerivAt_const t z.1).prodMk (hdΦ z.1 z.2 t) |
| 103 | have hΨ : ContDiff ℝ ∞ Ψ := contDiff_solution_family hF hiΨ hdΨ |
| 104 | have hsΦ : ContDiff ℝ ∞ (fun z : P × (ℝ × E) => Φ z.1 z.2.1 z.2.2) := by |
| 105 | exact (contDiff_snd.comp hΨ).comp |
| 106 | ((contDiff_fst.prodMk (contDiff_snd.comp contDiff_snd)).prodMk |
| 107 | (contDiff_fst.comp contDiff_snd)) |
| 108 | have hcomp (p : P) (s t : ℝ) (x : E) : |
| 109 | Φ p (s + t) x = Φ p s (Φ p t x) := by |
| 110 | have hdshift (r : ℝ) : HasDerivAt (fun u => Φ p (u + t) x) |
| 111 | (H (p, Φ p (r + t) x)) r := by |
| 112 | simpa only [Function.comp_def, one_smul, id_eq] using |
| 113 | (hdΦ p x (r + t)).scomp r ((hasDerivAt_id r).add_const t) |
| 114 | exact eqOn_of_hasDerivAt isOpen_univ (hHp p).contDiffOn isOpen_univ |
| 115 | (convex_univ (𝕜 := ℝ)).isPreconnected |
| 116 | (fun r _ => ⟨mem_univ _, hdshift r⟩) |
| 117 | (fun r _ => ⟨mem_univ _, hdΦ p (Φ p t x) r⟩) |
| 118 | (mem_univ 0) (by simp only [zero_add, hiΦ]) (mem_univ s) |
| 119 | refine ⟨Φ, hsΦ, hiΦ, hdΦ, hcomp, ?_⟩ |
| 120 | intro p t |
| 121 | constructor |
| 122 | · intro x |
| 123 | rw [← hcomp, neg_add_cancel, hiΦ] |
| 124 | · intro x |
| 125 | rw [← hcomp, add_neg_cancel, hiΦ] |
| 126 | |
| 127 | end Poincare.ODE.Flow |