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.IntermediateValue |
| 2 | import Mathlib.Topology.Instances.Real.Lemmas |
| 3 | import Mathlib.Tactic.Linarith |
| 4 | |
| 5 | /-! |
| 6 | # Relative neighborhoods from the available interval directions |
| 7 | |
| 8 | Morgan-Tian Definition 3.38 and Lemma 6.18, pp. 61, 113-114. |
| 9 | An order-connected set containing a point contains a relative |
| 10 | neighborhood if it has every direction available in the ambient set. |
| 11 | Missing physical endpoint directions impose no extra requirement. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set Filter |
| 17 | open scoped Topology |
| 18 | |
| 19 | namespace PoincareMT.M14 |
| 20 | |
| 21 | /-- An order-connected set contains a relative neighborhood whenever |
| 22 | it contains the point and every direction present in the ambient set. |
| 23 | This is the closed physical endpoint criterion for local gauges in |
| 24 | Definition 3.38 and Lemma 6.18, pp. 61, 113-114. -/ |
| 25 | theorem ordConnected_mem_nhdsWithin_of_directions {C D : Set ℝ} {t : ℝ} |
| 26 | (hC : OrdConnected C) (ht : t ∈ C) |
| 27 | (hleft : (∃ a ∈ D, a < t) → ∃ a ∈ C, a < t) |
| 28 | (hright : (∃ b ∈ D, t < b) → ∃ b ∈ C, t < b) : C ∈ 𝓝[D] t := by |
| 29 | have hl : ∃ a < t, ∀ s ∈ D, a < s → s ≤ t → s ∈ C := by |
| 30 | by_cases hprev : ∃ a ∈ D, a < t |
| 31 | · obtain ⟨a, ha, hat⟩ := hleft hprev |
| 32 | exact ⟨a, hat, fun _ _ has hst => hC.out ha ht ⟨has.le, hst⟩⟩ |
| 33 | · refine ⟨t - 1, by linarith, ?_⟩ |
| 34 | intro s hs _ hst |
| 35 | have heq : s = t := le_antisymm hst (le_of_not_gt (fun hlt => hprev ⟨s, hs, hlt⟩)) |
| 36 | simpa only [heq] using ht |
| 37 | have hr : ∃ b > t, ∀ s ∈ D, t ≤ s → s < b → s ∈ C := by |
| 38 | by_cases hnext : ∃ b ∈ D, t < b |
| 39 | · obtain ⟨b, hb, htb⟩ := hright hnext |
| 40 | exact ⟨b, htb, fun _ _ hts hsb => hC.out ht hb ⟨hts, hsb.le⟩⟩ |
| 41 | · refine ⟨t + 1, by linarith, ?_⟩ |
| 42 | intro s hs hts _ |
| 43 | have heq : s = t := le_antisymm (le_of_not_gt (fun hlt => hnext ⟨s, hs, hlt⟩)) hts |
| 44 | simpa only [heq] using ht |
| 45 | obtain ⟨a, ha, hla⟩ := hl |
| 46 | obtain ⟨b, hb, hrb⟩ := hr |
| 47 | filter_upwards [self_mem_nhdsWithin, mem_nhdsWithin_of_mem_nhds (Ioo_mem_nhds ha hb)] |
| 48 | with s hs hab |
| 49 | rcases le_total s t with hst | hts |
| 50 | · exact hla s hs hab.1 hst |
| 51 | · exact hrb s hs hts hab.2 |
| 52 | |
| 53 | end PoincareMT.M14 |