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.Topology.ContinuousOn |
| 2 | import Mathlib.Topology.Order.Monotone |
| 3 | import Mathlib.Topology.Instances.Real.Lemmas |
| 4 | |
| 5 | /-! |
| 6 | # The first exit of a closed continuous curve |
| 7 | |
| 8 | A continuous curve that starts in an open set and later leaves has a |
| 9 | first exit. Its closed initial segment remains in the closure, without |
| 10 | any differentiability assumption. This is the topological step in the |
| 11 | competitor confinement argument of Morgan-Tian Corollary 6.79, |
| 12 | pp. 144-145. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set |
| 18 | |
| 19 | namespace PoincareMT.M14 |
| 20 | |
| 21 | /-- The first exit from an open set has a positive initial prefix in |
| 22 | that set and a closed prefix in its closure. This uses only closed |
| 23 | continuity, as in Corollary 6.79, pp. 144-145. -/ |
| 24 | theorem exists_first_exit_of_continuousOn {X : Type*} [TopologicalSpace X] |
| 25 | {γ : ℝ → X} {a b : ℝ} (hγ : ContinuousOn γ (Icc a b)) |
| 26 | {O : Set X} (hO : IsOpen O) (ha : γ a ∈ O) |
| 27 | (hleave : ∃ s ∈ Icc a b, γ s ∉ O) : |
| 28 | ∃ c ∈ Ioc a b, γ c ∉ O ∧ MapsTo γ (Ico a c) O ∧ |
| 29 | MapsTo γ (Icc a c) (closure O) := by |
| 30 | let S := Icc a b ∩ γ ⁻¹' Oᶜ |
| 31 | have hS : IsClosed S := hγ.preimage_isClosed_of_isClosed isClosed_Icc hO.isClosed_compl |
| 32 | have hnon : S.Nonempty := by |
| 33 | obtain ⟨s, hs, hsO⟩ := hleave |
| 34 | exact ⟨s, hs, hsO⟩ |
| 35 | have hbound : BddBelow S := ⟨a, fun _ hs => hs.1.1⟩ |
| 36 | obtain ⟨hc, hleast⟩ := hS.isLeast_csInf hnon hbound |
| 37 | have hac : a < sInf S := lt_of_le_of_ne hc.1.1 (by |
| 38 | intro h |
| 39 | exact hc.2 (h ▸ ha)) |
| 40 | have hpre : MapsTo γ (Ico a (sInf S)) O := by |
| 41 | intro s hs |
| 42 | by_contra hnot |
| 43 | exact (not_le_of_gt hs.2) (hleast ⟨⟨hs.1, hs.2.le.trans hc.1.2⟩, hnot⟩) |
| 44 | have hcont : ContinuousOn γ (closure (Ico a (sInf S))) := by |
| 45 | rw [closure_Ico hac.ne] |
| 46 | exact hγ.mono (Icc_subset_Icc le_rfl hc.1.2) |
| 47 | refine ⟨sInf S, ⟨hac, hc.1.2⟩, hc.2, hpre, ?_⟩ |
| 48 | have hcl := hpre.closure_of_continuousOn hcont |
| 49 | rwa [closure_Ico hac.ne] at hcl |
| 50 | |
| 51 | end PoincareMT.M14 |