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.RicciFlow.Generalized.BoundedDistance.GeometryImports |
| 2 | import Mathlib.Topology.Order.Compact |
| 3 | import Mathlib.Topology.Instances.Real.Lemmas |
| 4 | import Mathlib.Tactic.Linarith |
| 5 | |
| 6 | /-! |
| 7 | # An open real height with constant boundary excludes compact closure |
| 8 | |
| 9 | A continuous height on a compact closure attains both extrema. If its |
| 10 | image on the open set is open, neither extremum can lie there. Constant |
| 11 | boundary values then force an interior maximum, a contradiction. This |
| 12 | is the compact-side argument in Morgan--Tian Claim 10.8, p. 254, |
| 13 | expanded in M28 derivation 120. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open Set |
| 19 | open scoped Topology |
| 20 | |
| 21 | namespace Poincare |
| 22 | |
| 23 | /-- A nonempty open set with an open real height image and constant |
| 24 | boundary height has noncompact closure. Continuity is required only on |
| 25 | that closure. Source: M28 derivation 120, the open-height extremum proof. -/ |
| 26 | theorem not_isCompact_closure_of_open_height |
| 27 | {X : Type*} [TopologicalSpace X] {C : Set X} (hC : IsOpen C) |
| 28 | (hne : C.Nonempty) {f : X → ℝ} (hf : ContinuousOn f (closure C)) |
| 29 | (himage : IsOpen (f '' C)) {c : ℝ} |
| 30 | (hfront : ∀ x ∈ frontier C, f x = c) : ¬ IsCompact (closure C) := by |
| 31 | intro hcompact |
| 32 | have hmaxout (z : X) (hz : IsMaxOn f (closure C) z) : z ∉ C := by |
| 33 | intro hzC |
| 34 | obtain ⟨a, b, hab, hsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp |
| 35 | (himage.mem_nhds (mem_image_of_mem f hzC)) |
| 36 | have hv : (f z + b) / 2 ∈ Ioo a b := |
| 37 | ⟨by linarith [hab.1, hab.2], by linarith [hab.2]⟩ |
| 38 | obtain ⟨y, hy, heq⟩ := hsub hv |
| 39 | have hle := hz (subset_closure hy) |
| 40 | change f y ≤ f z at hle |
| 41 | rw [heq] at hle |
| 42 | linarith [hab.2] |
| 43 | have hminout (z : X) (hz : IsMinOn f (closure C) z) : z ∉ C := by |
| 44 | intro hzC |
| 45 | obtain ⟨a, b, hab, hsub⟩ := mem_nhds_iff_exists_Ioo_subset.mp |
| 46 | (himage.mem_nhds (mem_image_of_mem f hzC)) |
| 47 | have hv : (a + f z) / 2 ∈ Ioo a b := |
| 48 | ⟨by linarith [hab.1], by linarith [hab.1, hab.2]⟩ |
| 49 | obtain ⟨y, hy, heq⟩ := hsub hv |
| 50 | have hle := hz (subset_closure hy) |
| 51 | change f z ≤ f y at hle |
| 52 | rw [heq] at hle |
| 53 | linarith [hab.1] |
| 54 | obtain ⟨z, hz, hzmax⟩ := hcompact.exists_isMaxOn (hne.mono subset_closure) hf |
| 55 | obtain ⟨w, hw, hwmin⟩ := hcompact.exists_isMinOn (hne.mono subset_closure) hf |
| 56 | have hzc : f z = c := hfront z (hC.frontier_eq.symm ▸ ⟨hz, hmaxout z hzmax⟩) |
| 57 | have hwc : f w = c := hfront w (hC.frontier_eq.symm ▸ ⟨hw, hminout w hwmin⟩) |
| 58 | obtain ⟨x, hx⟩ := hne |
| 59 | have hxc : f x = c := le_antisymm ((hzmax (subset_closure hx)).trans_eq hzc) |
| 60 | (hwc.symm.trans_le (hwmin (subset_closure hx))) |
| 61 | apply hmaxout x _ hx |
| 62 | intro y hy |
| 63 | exact (hzmax hy).trans_eq (hzc.trans hxc.symm) |
| 64 | |
| 65 | end Poincare |