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.Geometry.Manifold.MFDeriv.Atlas |
| 3 | import Mathlib.Geometry.Manifold.MFDeriv.NormedSpace |
| 4 | |
| 5 | /-! # Constancy from vanishing manifold derivatives -/ |
| 6 | |
| 7 | set_option autoImplicit false |
| 8 | |
| 9 | open Set ChartedSpace |
| 10 | open scoped Manifold Topology |
| 11 | |
| 12 | namespace Poincare.Manifold |
| 13 | |
| 14 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 15 | {H : Type*} [TopologicalSpace H] {I : ModelWithCorners ℝ E H} [I.Boundaryless] |
| 16 | {M : Type*} [TopologicalSpace M] [ChartedSpace H M] [IsManifold I 1 M] |
| 17 | |
| 18 | /-- A differentiable scalar function with vanishing derivative on a manifold without |
| 19 | boundary is locally constant. -/ |
| 20 | theorem isLocallyConstant_of_mvfderiv_eq_zero {f : M → ℝ} |
| 21 | (hf : MDifferentiable I 𝓘(ℝ, ℝ) f) |
| 22 | (hdf : ∀ x v, mvfderiv I f x v = 0) : IsLocallyConstant f := by |
| 23 | intro s |
| 24 | refine isOpen_iff_forall_mem_open.mpr fun x hx => ?_ |
| 25 | let e := extChartAt I x |
| 26 | have he : IsOpen e.target := isOpen_extChartAt_target x |
| 27 | have he' : ∀ y ∈ e.target, MDifferentiableAt 𝓘(ℝ, E) I e.symm y := |
| 28 | fun y hy => (mdifferentiableOn_extChartAt_symm y hy).mdifferentiableAt (he.mem_nhds hy) |
| 29 | have hf' : DifferentiableOn ℝ (f ∘ e.symm) e.target := by |
| 30 | intro y hy |
| 31 | exact ((hf (e.symm y)).comp y (he' y hy)).differentiableAt.differentiableWithinAt |
| 32 | have hdf' : e.target.EqOn (fderiv ℝ (f ∘ e.symm)) 0 := by |
| 33 | intro y hy |
| 34 | ext v |
| 35 | rw [← mfderiv_eq_fderiv] |
| 36 | change mvfderiv 𝓘(ℝ, E) (f ∘ e.symm) y v = 0 |
| 37 | exact (mvfderiv_comp_apply y (hf (e.symm y)) (he' y hy) v).trans (hdf _ _) |
| 38 | have hu := he.isOpen_inter_preimage_of_fderiv_eq_zero hf' hdf' s |
| 39 | refine ⟨e.source ∩ e ⁻¹' (e.target ∩ (f ∘ e.symm) ⁻¹' s), ?_, |
| 40 | isOpen_extChartAt_preimage' x hu, ?_⟩ |
| 41 | · intro y hy |
| 42 | simpa only [mem_preimage, Function.comp_apply, e.left_inv hy.1] using hy.2.2 |
| 43 | · have hx' : x ∈ e.source := mem_extChartAt_source x |
| 44 | refine ⟨hx', e.map_source hx', ?_⟩ |
| 45 | simpa only [mem_preimage, Function.comp_apply, e.left_inv hx'] using hx |
| 46 | |
| 47 | /-- A differentiable scalar function with zero derivative takes equal values at all |
| 48 | points of a preconnected manifold without boundary. -/ |
| 49 | theorem eq_of_mvfderiv_eq_zero [PreconnectedSpace M] {f : M → ℝ} |
| 50 | (hf : MDifferentiable I 𝓘(ℝ, ℝ) f) |
| 51 | (hdf : ∀ x v, mvfderiv I f x v = 0) (x y : M) : f x = f y := |
| 52 | (isLocallyConstant_of_mvfderiv_eq_zero hf hdf).apply_eq_of_preconnectedSpace x y |
| 53 | |
| 54 | /-- A differentiable scalar function with zero derivative is constant on a |
| 55 | preconnected manifold without boundary. -/ |
| 56 | theorem exists_eq_const_of_mvfderiv_eq_zero [PreconnectedSpace M] {f : M → ℝ} |
| 57 | (hf : MDifferentiable I 𝓘(ℝ, ℝ) f) |
| 58 | (hdf : ∀ x v, mvfderiv I f x v = 0) : ∃ c : ℝ, ∀ x, f x = c := by |
| 59 | obtain ⟨c, hc⟩ := (isLocallyConstant_of_mvfderiv_eq_zero hf hdf).exists_eq_const |
| 60 | exact ⟨c, fun x => congrFun hc x⟩ |
| 61 | |
| 62 | end Poincare.Manifold |