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.Sublevel.Minimum |
| 2 | import Mathlib.Geometry.Manifold.Algebra.LieGroup |
| 3 | |
| 4 | /-! # Critical points and extrema of compact regions -/ |
| 5 | |
| 6 | noncomputable section |
| 7 | set_option autoImplicit false |
| 8 | set_option backward.isDefEq.respectTransparency false |
| 9 | |
| 10 | open Set Filter |
| 11 | open scoped Manifold ContDiff Topology |
| 12 | |
| 13 | namespace Poincare.Geometry.Manifold |
| 14 | |
| 15 | /-- A regular interior point lies strictly between any global minimum and |
| 16 | maximum of the region. -/ |
| 17 | theorem strict_bounds_on_interior_of_regular |
| 18 | {n : Nat} {M : Type*} [TopologicalSpace M] |
| 19 | [ChartedSpace (EuclideanSpace Real (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 20 | {h : M -> Real} (hh : ContMDiff (𝓡 n) 𝓘(Real, Real) ∞ h) |
| 21 | {K : Set M} {p q : M} (hmin : IsMinOn h K p) (hmax : IsMaxOn h K q) |
| 22 | (hreg : ∀ x ∈ K, mfderiv (𝓡 n) 𝓘(Real, Real) h x ≠ 0) : |
| 23 | ∀ x ∈ interior K, h p < h x ∧ h x < h q := by |
| 24 | intro x hx |
| 25 | have hxK := interior_subset hx |
| 26 | have hnhds := mem_interior_iff_mem_nhds.mp hx |
| 27 | constructor |
| 28 | · apply lt_of_le_of_ne (hmin hxK) |
| 29 | intro heq |
| 30 | have hxMin : IsMinOn h K x := by intro y hy; rw [← heq]; exact hmin hy |
| 31 | exact hreg x hxK (mfderiv_eq_zero_of_isLocalMin hh (hxMin.isLocalMin hnhds)) |
| 32 | · apply lt_of_le_of_ne (hmax hxK) |
| 33 | intro heq |
| 34 | have hxMax : IsMaxOn h K x := by intro y hy; rw [heq]; exact hmax hy |
| 35 | have hn := mfderiv_eq_zero_of_isLocalMin hh.neg (hxMax.isLocalMax hnhds).neg |
| 36 | change mfderiv (𝓡 n) 𝓘(Real, Real) (-h) x = 0 at hn |
| 37 | exact hreg x hxK (by simpa only [mfderiv_neg, neg_eq_zero] using hn) |
| 38 | |
| 39 | /-- A compact region without critical points attains both extrema on its |
| 40 | frontier. -/ |
| 41 | theorem exists_boundary_extrema_of_regular |
| 42 | {n : Nat} {M : Type*} [TopologicalSpace M] |
| 43 | [ChartedSpace (EuclideanSpace Real (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 44 | {h : M -> Real} (hh : ContMDiff (𝓡 n) 𝓘(Real, Real) ∞ h) |
| 45 | {K : Set M} (hK : IsCompact K) (hne : K.Nonempty) |
| 46 | (hreg : ∀ p ∈ K, mfderiv (𝓡 n) 𝓘(Real, Real) h p ≠ 0) : |
| 47 | ∃ p ∈ frontier K, ∃ q ∈ frontier K, IsMinOn h K p ∧ IsMaxOn h K q := by |
| 48 | obtain ⟨p, hp, hmin⟩ := hK.exists_isMinOn hne hh.continuous.continuousOn |
| 49 | obtain ⟨q, hq, hmax⟩ := hK.exists_isMaxOn hne hh.continuous.continuousOn |
| 50 | refine ⟨p, ⟨subset_closure hp, ?_⟩, q, ⟨subset_closure hq, ?_⟩, hmin, hmax⟩ |
| 51 | · intro hpi |
| 52 | exact hreg p hp (mfderiv_eq_zero_of_isLocalMin hh |
| 53 | (hmin.isLocalMin (mem_interior_iff_mem_nhds.mp hpi))) |
| 54 | · intro hqi |
| 55 | have hn := mfderiv_eq_zero_of_isLocalMin hh.neg |
| 56 | (hmax.isLocalMax (mem_interior_iff_mem_nhds.mp hqi)).neg |
| 57 | change mfderiv (𝓡 n) 𝓘(Real, Real) (-h) q = 0 at hn |
| 58 | exact hreg q hq (by simpa only [mfderiv_neg, neg_eq_zero] using hn) |
| 59 | |
| 60 | /-- A smooth real function on a nontrivial compact boundaryless manifold has |
| 61 | two distinct critical points, including when the function is constant. -/ |
| 62 | theorem exists_two_distinct_critical_points |
| 63 | {n : Nat} {M : Type*} [TopologicalSpace M] |
| 64 | [ChartedSpace (EuclideanSpace Real (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 65 | [CompactSpace M] [Nontrivial M] |
| 66 | {h : M -> Real} (hh : ContMDiff (𝓡 n) 𝓘(Real, Real) ∞ h) : |
| 67 | ∃ p q : M, p ≠ q ∧ mfderiv (𝓡 n) 𝓘(Real, Real) h p = 0 ∧ |
| 68 | mfderiv (𝓡 n) 𝓘(Real, Real) h q = 0 := by |
| 69 | obtain ⟨p, _, hmin⟩ := isCompact_univ.exists_isMinOn univ_nonempty hh.continuous.continuousOn |
| 70 | obtain ⟨q, _, hmax⟩ := isCompact_univ.exists_isMaxOn univ_nonempty hh.continuous.continuousOn |
| 71 | have hp := mfderiv_eq_zero_of_isLocalMin hh (hmin.isLocalMin univ_mem) |
| 72 | have hq : mfderiv (𝓡 n) 𝓘(Real, Real) h q = 0 := by |
| 73 | have hneg := mfderiv_eq_zero_of_isLocalMin hh.neg (hmax.isLocalMax univ_mem).neg |
| 74 | change mfderiv (𝓡 n) 𝓘(Real, Real) (-h) q = 0 at hneg |
| 75 | simpa only [mfderiv_neg, neg_eq_zero] using hneg |
| 76 | by_cases hpq : p = q |
| 77 | · have hconstant : h = fun _ => h p := by |
| 78 | funext x |
| 79 | exact (hpq ▸ hmax (mem_univ x)).antisymm (hmin (mem_univ x)) |
| 80 | obtain ⟨x, y, hxy⟩ := exists_pair_ne M |
| 81 | refine ⟨x, y, hxy, ?_, ?_⟩ <;> rw [hconstant] <;> exact mfderiv_const |
| 82 | · exact ⟨p, q, hpq, hp, hq⟩ |
| 83 | |
| 84 | end Poincare.Geometry.Manifold |