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 | # Capped first exit from an open set |
| 5 | |
| 6 | A continuous curve which enters an open set for small positive times has a |
| 7 | unique first exit, capped at any prescribed positive time. The endpoint is |
| 8 | in the closure of the open set and is either the cap time or a frontier point. |
| 9 | This is the generic stopping argument used for the regional normal rays in |
| 10 | Morgan--Tian, Lemma 19.46, Case (ii), pp. 475-478; see |
| 11 | `proof-work/tasks/M64/derivations/2026-09-25-regional-first-exit-endpoints.md`. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set |
| 17 | |
| 18 | namespace PoincareMT |
| 19 | |
| 20 | /-- A continuous curve which enters an open set has an actual first exit, capped at a |
| 21 | prescribed positive time. Source/construction: |
| 22 | proof-work/tasks/M64/derivations/2026-09-25-regional-first-exit-endpoints.md. -/ |
| 23 | theorem m64_exists_capped_first_exit_open |
| 24 | {X : Type*} [TopologicalSpace X] {q : ℝ → X} (hq : Continuous q) |
| 25 | {U : Set X} (hU : IsOpen U) {R eta : ℝ} (hR : 0 < R) (heta : 0 < eta) |
| 26 | (henter : ∀ t ∈ Ioo (0 : ℝ) eta, q t ∈ U) : |
| 27 | ∃ b : ℝ, 0 < b ∧ b ≤ R ∧ |
| 28 | (∀ t ∈ Ioo (0 : ℝ) b, q t ∈ U) ∧ |
| 29 | q b ∈ closure U ∧ (b = R ∨ q b ∈ frontier U) := by |
| 30 | let d := min (eta / 2) (R / 2) |
| 31 | have hd : 0 < d := lt_min (half_pos heta) (half_pos hR) |
| 32 | have hdEta : d < eta := (min_le_left _ _).trans_lt (half_lt_self heta) |
| 33 | have hdR : d < R := (min_le_right _ _).trans_lt (half_lt_self hR) |
| 34 | have hdU : q d ∈ U := henter d ⟨hd, hdEta⟩ |
| 35 | by_cases hleave : ∃ s ∈ Icc d R, q s ∉ U |
| 36 | · obtain ⟨b, hb, hbout, hbefore, hclosed⟩ := |
| 37 | M14.exists_first_exit_of_continuousOn hq.continuousOn hU hdU hleave |
| 38 | have hprefix (t : ℝ) (ht : t ∈ Ioo (0 : ℝ) b) : q t ∈ U := by |
| 39 | by_cases htd : t < d |
| 40 | · exact henter t ⟨ht.1, htd.trans hdEta⟩ |
| 41 | · exact hbefore ⟨le_of_not_gt htd, ht.2⟩ |
| 42 | have hbclosed : q b ∈ closure U := hclosed ⟨hb.1.le, le_rfl⟩ |
| 43 | refine ⟨b, hd.trans hb.1, hb.2, hprefix, hbclosed, ?_⟩ |
| 44 | by_cases hbR : b = R |
| 45 | · exact Or.inl hbR |
| 46 | · right |
| 47 | rw [frontier, hU.interior_eq] |
| 48 | exact ⟨hbclosed, hbout⟩ |
| 49 | · refine ⟨R, hR, le_rfl, ?_, ?_, Or.inl rfl⟩ |
| 50 | · intro t ht |
| 51 | by_cases htd : t < d |
| 52 | · exact henter t ⟨ht.1, htd.trans hdEta⟩ |
| 53 | · by_contra htU |
| 54 | exact hleave ⟨t, ⟨le_of_not_gt htd, ht.2.le⟩, htU⟩ |
| 55 | · apply subset_closure |
| 56 | by_contra hRU |
| 57 | exact hleave ⟨R, ⟨hdR.le, le_rfl⟩, hRU⟩ |
| 58 | |
| 59 | /-- Strict interior containment before contact makes the capped first-exit time unique. |
| 60 | Continuity and endpoint closure are not needed for uniqueness. Source/construction: |
| 61 | proof-work/tasks/M64/derivations/2026-09-25-regional-first-exit-endpoints.md. -/ |
| 62 | theorem m64_capped_first_exit_open_unique |
| 63 | {X : Type*} [TopologicalSpace X] {q : ℝ → X} {U : Set X} (hU : IsOpen U) |
| 64 | {R b d : ℝ} (hb : 0 < b) (hd : 0 < d) (hbR : b ≤ R) (hdR : d ≤ R) |
| 65 | (hbeforeb : ∀ t ∈ Ioo (0 : ℝ) b, q t ∈ U) |
| 66 | (hbefored : ∀ t ∈ Ioo (0 : ℝ) d, q t ∈ U) |
| 67 | (hcontactb : b = R ∨ q b ∈ frontier U) |
| 68 | (hcontactd : d = R ∨ q d ∈ frontier U) : b = d := by |
| 69 | rcases lt_trichotomy b d with hlt | heq | hlt |
| 70 | · have hinside := hbefored b ⟨hb, hlt⟩ |
| 71 | rcases hcontactb with hcap | hfront |
| 72 | · exact False.elim ((not_lt_of_ge (hcap ▸ hdR)) hlt) |
| 73 | · rw [frontier, hU.interior_eq] at hfront |
| 74 | exact False.elim (hfront.2 hinside) |
| 75 | · exact heq |
| 76 | · have hinside := hbeforeb d ⟨hd, hlt⟩ |
| 77 | rcases hcontactd with hcap | hfront |
| 78 | · exact False.elim ((not_lt_of_ge (hcap ▸ hbR)) hlt) |
| 79 | · rw [frontier, hU.interior_eq] at hfront |
| 80 | exact False.elim (hfront.2 hinside) |
| 81 | |
| 82 | /-- First exit from a smaller open set occurs no later than capped first exit from a larger |
| 83 | open set. Only the before-contact property for the smaller set and the contact alternative |
| 84 | for the larger set are needed. Source/construction: |
| 85 | proof-work/tasks/M64/derivations/2026-09-25-regional-first-exit-endpoints.md. -/ |
| 86 | theorem m64_capped_first_exit_open_mono |
| 87 | {X : Type*} [TopologicalSpace X] {q : ℝ → X} {U V : Set X} |
| 88 | (hUV : U ⊆ V) (hV : IsOpen V) {R b d : ℝ} (hd : 0 < d) |
| 89 | (hbR : b ≤ R) (hbeforeU : ∀ t ∈ Ioo (0 : ℝ) b, q t ∈ U) |
| 90 | (hcontactV : d = R ∨ q d ∈ frontier V) : b ≤ d := by |
| 91 | by_contra hbd |
| 92 | have hdb : d < b := lt_of_not_ge hbd |
| 93 | have hdV : q d ∈ V := hUV (hbeforeU d ⟨hd, hdb⟩) |
| 94 | rcases hcontactV with hcap | hfront |
| 95 | · exact (not_lt_of_ge hbR) (hcap ▸ hdb) |
| 96 | · rw [frontier, hV.interior_eq] at hfront |
| 97 | exact hfront.2 hdV |
| 98 | |
| 99 | end PoincareMT |