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.Order.Compact |
| 2 | import Mathlib.Topology.Instances.Real.Lemmas |
| 3 | import PoincareLib.Topology.Connected.BoundaryIncidence |
| 4 | |
| 5 | /-! First and last contacts of a continuous path with a closed region. |
| 6 | The outer portions remain confined, without a finite-crossing assumption. |
| 7 | Source: the boundary-side replacement in MT Claim 19.40, pp. 470-471. -/ |
| 8 | |
| 9 | noncomputable section |
| 10 | set_option autoImplicit false |
| 11 | set_option warningAsError true |
| 12 | |
| 13 | open Set |
| 14 | |
| 15 | namespace PoincareMT |
| 16 | |
| 17 | private theorem mapsTo_of_no_frontier |
| 18 | {X : Type*} [TopologicalSpace X] {K : Set X} {f : ℝ → X} {S : Set ℝ} |
| 19 | (hc : ContinuousOn f S) (hS : IsPreconnected S) |
| 20 | (havoid : ∀ t ∈ S, f t ∉ frontier K) {a : ℝ} (ha : a ∈ S) (hfa : f a ∈ K) : |
| 21 | MapsTo f S K := by |
| 22 | have hfront : Disjoint (f '' S) (frontier K) := by |
| 23 | rw [disjoint_left] |
| 24 | rintro z ⟨t, ht, rfl⟩ hz |
| 25 | exact havoid t ht hz |
| 26 | have hstart : f a ∈ interior K := by |
| 27 | by_contra h |
| 28 | exact havoid a ha ⟨subset_closure hfa, h⟩ |
| 29 | intro t ht |
| 30 | exact interior_subset (Poincare.Topology.preconnected_subset_interior_of_disjoint_frontier |
| 31 | (hS.image f hc) hfront ⟨f a, ⟨a, ha, rfl⟩, hstart⟩ ⟨t, ht, rfl⟩) |
| 32 | |
| 33 | /-- A path with endpoints in a closed region either stays there or has first and last |
| 34 | frontier contacts, with confined outer portions. Source: MT Claim 19.40, pp. 470-471; |
| 35 | derivations/2026-09-27-minimal-contact-regularity.md, Section 4. -/ |
| 36 | theorem m64_path_confined_or_first_last_frontier |
| 37 | {X : Type*} [TopologicalSpace X] {K : Set X} (hK : IsClosed K) |
| 38 | {f : ℝ → X} (hc : ContinuousOn f (Icc 0 1)) (h0 : f 0 ∈ K) (h1 : f 1 ∈ K) : |
| 39 | MapsTo f (Icc 0 1) K ∨ |
| 40 | ∃ a b : ℝ, a ∈ Icc 0 1 ∧ b ∈ Icc 0 1 ∧ a ≤ b ∧ |
| 41 | f a ∈ frontier K ∧ f b ∈ frontier K ∧ |
| 42 | MapsTo f (Icc 0 a) K ∧ MapsTo f (Icc b 1) K := by |
| 43 | let S := Icc (0 : ℝ) 1 ∩ f ⁻¹' frontier K |
| 44 | by_cases hS : S.Nonempty |
| 45 | · have hcompact : IsCompact S := isCompact_Icc.of_isClosed_subset |
| 46 | (hc.preimage_isClosed_of_isClosed isClosed_Icc isClosed_frontier) inter_subset_left |
| 47 | obtain ⟨a, ha, hleast⟩ := hcompact.exists_isLeast hS |
| 48 | obtain ⟨b, hb, hgreatest⟩ := hcompact.exists_isGreatest hS |
| 49 | refine Or.inr ⟨a, b, ha.1, hb.1, hleast hb, ha.2, hb.2, ?_, ?_⟩ |
| 50 | · intro t ht |
| 51 | rcases ht.2.eq_or_lt with rfl | hta |
| 52 | · exact hK.frontier_subset ha.2 |
| 53 | · have hsub : Ico (0 : ℝ) a ⊆ Icc 0 1 := |
| 54 | fun s hs => ⟨hs.1, hs.2.le.trans ha.1.2⟩ |
| 55 | apply mapsTo_of_no_frontier (hc.mono hsub) isPreconnected_Ico |
| 56 | (a := 0) (fun s hs hf => ?_) ⟨le_rfl, lt_of_le_of_lt ht.1 hta⟩ h0 ⟨ht.1, hta⟩ |
| 57 | exact (not_le_of_gt hs.2) (hleast ⟨hsub hs, hf⟩) |
| 58 | · intro t ht |
| 59 | rcases ht.1.eq_or_lt with rfl | hbt |
| 60 | · exact hK.frontier_subset hb.2 |
| 61 | · have hsub : Ioc b (1 : ℝ) ⊆ Icc 0 1 := |
| 62 | fun s hs => ⟨hb.1.1.trans hs.1.le, hs.2⟩ |
| 63 | apply mapsTo_of_no_frontier (hc.mono hsub) isPreconnected_Ioc |
| 64 | (a := 1) (fun s hs hf => ?_) ⟨lt_of_lt_of_le hbt ht.2, le_rfl⟩ h1 ⟨hbt, ht.2⟩ |
| 65 | exact (not_le_of_gt hs.1) (hgreatest ⟨hsub hs, hf⟩) |
| 66 | · left |
| 67 | apply mapsTo_of_no_frontier hc isPreconnected_Icc (a := 0) _ (by simp) h0 |
| 68 | intro t ht hf |
| 69 | exact hS ⟨t, ht, hf⟩ |
| 70 | |
| 71 | end PoincareMT |