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.ReducedGeometry.Calculus.Local.ContinuousFirstExit |
| 2 | |
| 3 | /-! |
| 4 | # The last entry into the actual cap interior |
| 5 | |
| 6 | Proposition 16.13, pp. 377-378. A backward path is parameterized in its |
| 7 | original increasing backward time. Reflection is used only to select |
| 8 | the last entry into an open cylinder image; all returned path and |
| 9 | closure statements use the original parameter. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open Set |
| 15 | |
| 16 | namespace PoincareMT.Proofs.M46 |
| 17 | |
| 18 | /-- A continuous path starting outside and ending inside an open set |
| 19 | has a last entry, followed by a closed segment in its closure. Source: |
| 20 | Proposition 16.13, pp. 377-378. -/ |
| 21 | theorem exists_last_entry_of_continuousOn {X : Type*} [TopologicalSpace X] |
| 22 | {gamma : ℝ → X} {a b : ℝ} (hab : a < b) |
| 23 | (hgamma : ContinuousOn gamma (Icc a b)) |
| 24 | {O : Set X} (hO : IsOpen O) (ha : gamma a ∉ O) (hb : gamma b ∈ O) : |
| 25 | ∃ c ∈ Ico a b, gamma c ∉ O ∧ MapsTo gamma (Ioc c b) O ∧ |
| 26 | MapsTo gamma (Icc c b) (closure O) := by |
| 27 | let reflection : ℝ → ℝ := fun t => a + b - t |
| 28 | have hreflect : MapsTo reflection (Icc a b) (Icc a b) := by |
| 29 | intro t ht |
| 30 | dsimp only [reflection] |
| 31 | constructor <;> linarith [ht.1, ht.2] |
| 32 | have ha' : (gamma ∘ reflection) a ∈ O := by |
| 33 | simpa only [Function.comp_apply, reflection, add_sub_cancel_left] using hb |
| 34 | have hb' : (gamma ∘ reflection) b ∉ O := by |
| 35 | simpa only [Function.comp_apply, reflection, add_sub_cancel_right] using ha |
| 36 | obtain ⟨c, hc, hout, hinside, hclosure⟩ := M14.exists_first_exit_of_continuousOn |
| 37 | (hgamma.comp (continuous_const.sub continuous_id).continuousOn hreflect) hO ha' |
| 38 | ⟨b, ⟨hab.le, le_rfl⟩, hb'⟩ |
| 39 | refine ⟨a + b - c, ⟨by linarith [hc.2], by linarith [hc.1]⟩, hout, ?_, ?_⟩ |
| 40 | · intro t ht |
| 41 | have hrt : reflection t ∈ Ico a c := by |
| 42 | dsimp only [reflection] |
| 43 | constructor <;> linarith [ht.1, ht.2] |
| 44 | have h := hinside hrt |
| 45 | change gamma (a + b - (a + b - t)) ∈ O at h |
| 46 | simpa only [sub_sub_cancel] using h |
| 47 | · intro t ht |
| 48 | have hrt : reflection t ∈ Icc a c := by |
| 49 | dsimp only [reflection] |
| 50 | constructor <;> linarith [ht.1, ht.2] |
| 51 | have h := hclosure hrt |
| 52 | change gamma (a + b - (a + b - t)) ∈ closure O at h |
| 53 | simpa only [sub_sub_cancel] using h |
| 54 | |
| 55 | end PoincareMT.Proofs.M46 |