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.Geometry.Manifold.RegularLevel.AdaptedChart |
| 2 | import Mathlib.Geometry.Manifold.Instances.Real |
| 3 | import Mathlib.Analysis.Calculus.LocalExtr.Basic |
| 4 | import Mathlib.Topology.Connected.LocallyConnected |
| 5 | import Mathlib.Topology.Order.Compact |
| 6 | |
| 7 | /-! |
| 8 | # The minimum of a compact sublevel component |
| 9 | |
| 10 | A compact canonical sublevel component with only one critical point has |
| 11 | that point as its unique global minimum. Points below the top level are |
| 12 | interior points, so scalar compactness and Fermat's theorem apply. |
| 13 | -/ |
| 14 | |
| 15 | noncomputable section |
| 16 | set_option autoImplicit false |
| 17 | set_option backward.isDefEq.respectTransparency false |
| 18 | |
| 19 | open Set Filter |
| 20 | open scoped Topology ContDiff Manifold |
| 21 | |
| 22 | namespace Poincare.Geometry.Manifold |
| 23 | |
| 24 | private abbrev E (n : ℕ) := EuclideanSpace ℝ (Fin n) |
| 25 | |
| 26 | /-- Fermat's theorem for a smooth scalar function on a boundaryless manifold. -/ |
| 27 | theorem mfderiv_eq_zero_of_isLocalMin |
| 28 | {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 29 | [ChartedSpace (E n) M] [IsManifold (𝓡 n) ∞ M] |
| 30 | {f : M → ℝ} (hf : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ f) {x : M} |
| 31 | (hmin : IsLocalMin f x) : mfderiv (𝓡 n) 𝓘(ℝ, ℝ) f x = 0 := by |
| 32 | have hchart : IsLocalMin (f ∘ (extChartAt (𝓡 n) x).symm) |
| 33 | (extChartAt (𝓡 n) x x) := by |
| 34 | apply IsLocalMin.comp_continuous _ (continuousAt_extChartAt_symm (I := 𝓡 n) x) |
| 35 | simpa only [(extChartAt (𝓡 n) x).left_inv (mem_extChartAt_source x)] using hmin |
| 36 | exact hchart.hasFDerivAt_eq_zero (RegularLevel.hasFDerivAt_comp_extChartAt_symm hf x) |
| 37 | |
| 38 | /-- A unique critical point is the strict global minimum of its compact cap. -/ |
| 39 | theorem strict_minimum_on_compact_sublevel_component_of_unique_critical |
| 40 | {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 41 | [ChartedSpace (E n) M] [IsManifold (𝓡 n) ∞ M] |
| 42 | {f : M → ℝ} (hf : ContMDiff (𝓡 n) 𝓘(ℝ, ℝ) ∞ f) |
| 43 | {O : Set M} (hO : IsOpen O) {p : M} {b : ℝ} |
| 44 | (hp : p ∈ O) (hpb : f p < b) |
| 45 | (hK : IsCompact (connectedComponentIn (O ∩ f ⁻¹' Iic b) p)) |
| 46 | (hunique : ∀ x ∈ connectedComponentIn (O ∩ f ⁻¹' Iic b) p, |
| 47 | mfderiv (𝓡 n) 𝓘(ℝ, ℝ) f x = 0 → x = p) : |
| 48 | ∀ x ∈ connectedComponentIn (O ∩ f ⁻¹' Iic b) p, x ≠ p → f p < f x := by |
| 49 | let : LocallyConnectedSpace M := ChartedSpace.locallyConnectedSpace (E n) M |
| 50 | let K := connectedComponentIn (O ∩ f ⁻¹' Iic b) p |
| 51 | have hpK : p ∈ K := mem_connectedComponentIn ⟨hp, hpb.le⟩ |
| 52 | have hnhds (x : M) (hx : x ∈ K) (hxb : f x < b) : K ∈ 𝓝 x := by |
| 53 | have hxO := (connectedComponentIn_subset _ _ hx).1 |
| 54 | have ho : O ∩ f ⁻¹' Iic b ∈ 𝓝 x := mem_of_superset |
| 55 | ((hO.inter (hf.continuous.isOpen_preimage _ isOpen_Iio)).mem_nhds ⟨hxO, hxb⟩) |
| 56 | (inter_subset_inter_right O (preimage_mono Iio_subset_Iic_self)) |
| 57 | have hc := connectedComponentIn_mem_nhds ho |
| 58 | rwa [← connectedComponentIn_eq hx] at hc |
| 59 | obtain ⟨q, hqK, hqmin⟩ := hK.exists_isMinOn ⟨p, hpK⟩ hf.continuous.continuousOn |
| 60 | have hqb : f q < b := (hqmin hpK).trans_lt hpb |
| 61 | have hqp : q = p := hunique q hqK |
| 62 | (mfderiv_eq_zero_of_isLocalMin hf (hqmin.isLocalMin (hnhds q hqK hqb))) |
| 63 | subst q |
| 64 | intro x hx hxp |
| 65 | apply lt_of_le_of_ne (hqmin hx) |
| 66 | intro heq |
| 67 | have hxMin : IsMinOn f K x := by |
| 68 | intro y hy |
| 69 | rw [← heq] |
| 70 | exact hqmin hy |
| 71 | exact hxp (hunique x hx (mfderiv_eq_zero_of_isLocalMin hf |
| 72 | (hxMin.isLocalMin (hnhds x hx (heq ▸ hpb))))) |
| 73 | |
| 74 | end Poincare.Geometry.Manifold |