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.Analysis.Calculus.Deriv.MeanValue |
| 2 | import Mathlib.Topology.Separation.Regular |
| 3 | import Mathlib.Topology.Sequences |
| 4 | import Mathlib.Topology.Order.IntermediateValue |
| 5 | /-! |
| 6 | # Accumulation and trapping for scalar descent |
| 7 | |
| 8 | A scalar bounded below has arbitrarily late times of small decay. A continuous |
| 9 | trajectory with decreasing scalar and a strict local minimum as an accumulation |
| 10 | point converges to that point; a strict local maximum forces a stationary tail. |
| 11 | The trapping arguments use compact frontiers and apply without a metric. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set Filter |
| 17 | open scoped Topology |
| 18 | namespace Poincare.ODE |
| 19 | |
| 20 | /-- A function bounded below cannot keep a uniformly negative derivative on a tail. -/ |
| 21 | theorem exists_late_small_decay {q a : ℝ → ℝ} {B : ℝ} |
| 22 | (hder : ∀ t, 0 ≤ t → HasDerivAt q (-a t) t) |
| 23 | (hbelow : ∀ t, 0 ≤ t → B ≤ q t) |
| 24 | {T δ : ℝ} (hT : 0 ≤ T) (hδ : 0 < δ) : |
| 25 | ∃ t, T ≤ t ∧ a t < δ := by |
| 26 | by_contra hn |
| 27 | have hlarge : ∀ t, T ≤ t → δ ≤ a t := by |
| 28 | intro t ht |
| 29 | by_contra ha |
| 30 | exact hn ⟨t, ht, lt_of_not_ge ha⟩ |
| 31 | let b := T + (q T - B + 1) / δ |
| 32 | have hb : T < b := by |
| 33 | dsimp [b] |
| 34 | have := hbelow T hT |
| 35 | have : 0 < (q T - B + 1) / δ := div_pos (by linarith) hδ |
| 36 | linarith |
| 37 | have hbound := (convex_Ici T).image_sub_le_mul_sub_of_deriv_le |
| 38 | (fun t ht => (hder t (hT.trans ht)).continuousAt.continuousWithinAt) |
| 39 | (fun t ht => (hder t (hT.trans (interior_subset ht))).differentiableAt.differentiableWithinAt) |
| 40 | (C := -δ) (fun t ht => by |
| 41 | rw [(hder t (hT.trans (interior_subset ht))).deriv] |
| 42 | exact neg_le_neg (hlarge t (interior_subset ht))) |
| 43 | T (show T ≤ T from le_rfl) b (show T ≤ b from hb.le) hb.le |
| 44 | have hbb := hbelow b (hT.trans hb.le) |
| 45 | have heq : -δ * (b - T) = -(q T - B + 1) := by |
| 46 | dsimp [b] |
| 47 | field_simp [ne_of_gt hδ] |
| 48 | ring |
| 49 | rw [heq] at hbound |
| 50 | linarith |
| 51 | |
| 52 | |
| 53 | /-- A compact descending trajectory converges to any strict-minimum accumulation point. -/ |
| 54 | theorem tendsto_of_strict_min_accumulation |
| 55 | {X : Type*} [TopologicalSpace X] [RegularSpace X] |
| 56 | {K : Set X} (hK : IsCompact K) |
| 57 | {f : X → ℝ} (hf : ContinuousOn f K) {p : X} (hpK : p ∈ K) |
| 58 | {γ : ℝ → X} (hγ : ContinuousOn γ (Ici 0)) |
| 59 | (hγK : ∀ t, 0 ≤ t → γ t ∈ K) |
| 60 | (hanti : AntitoneOn (f ∘ γ) (Ici 0)) |
| 61 | {τ : ℕ → ℝ} (hτ : Tendsto τ atTop atTop) |
| 62 | (hlim : Tendsto (γ ∘ τ) atTop (𝓝 p)) |
| 63 | (hmin : ∀ᶠ y in 𝓝 p, y ≠ p → f p < f y) : |
| 64 | Tendsto γ atTop (𝓝 p) := by |
| 65 | apply tendsto_def.mpr |
| 66 | intro U hU |
| 67 | obtain ⟨V, hVp, hVc, hVU⟩ := exists_mem_nhds_isClosed_subset (inter_mem hU hmin) |
| 68 | have hpV : p ∈ interior V := mem_interior_iff_mem_nhds.mpr hVp |
| 69 | let Z := K ∩ frontier V |
| 70 | have hZ : IsCompact Z := hK.inter_right isClosed_frontier |
| 71 | have hbarrier : ∃ c : ℝ, f p < c ∧ ∀ y ∈ Z, c ≤ f y := by |
| 72 | by_cases hne : Z.Nonempty |
| 73 | · obtain ⟨z, hz, hzmin⟩ := hZ.exists_isMinOn hne (hf.mono inter_subset_left) |
| 74 | refine ⟨f z, ?_, fun y hy => hzmin hy⟩ |
| 75 | exact (hVU (hVc.frontier_subset hz.2)).2 |
| 76 | (by intro heq; exact hz.2.2 (heq ▸ hpV)) |
| 77 | · exact ⟨f p + 1, by linarith, fun y hy => (hne ⟨y, hy⟩).elim⟩ |
| 78 | obtain ⟨c, hpc, hc⟩ := hbarrier |
| 79 | have hτK : ∀ᶠ i in atTop, (γ ∘ τ) i ∈ K := |
| 80 | (hτ.eventually (eventually_ge_atTop 0)).mono fun i hi => hγK _ hi |
| 81 | have hflim : Tendsto (f ∘ γ ∘ τ) atTop (𝓝 (f p)) := |
| 82 | (hf p hpK).tendsto.comp (tendsto_nhdsWithin_iff.mpr ⟨hlim, hτK⟩) |
| 83 | obtain ⟨i, hi0, hiV, hic⟩ := |
| 84 | ((hτ.eventually (eventually_ge_atTop 0)).and |
| 85 | ((hlim.eventually (isOpen_interior.mem_nhds hpV)).and |
| 86 | (hflim.eventually (eventually_lt_nhds hpc)))).exists |
| 87 | apply (eventually_ge_atTop (τ i)).mono |
| 88 | intro t ht |
| 89 | have hpath := isPreconnected_Icc.image γ |
| 90 | (hγ.mono (show Icc (τ i) t ⊆ Ici 0 from fun u hu => hi0.trans hu.1)) |
| 91 | have hpathV : γ '' Icc (τ i) t ⊆ interior V := by |
| 92 | apply hpath.subset_of_closure_inter_subset isOpen_interior |
| 93 | ⟨γ (τ i), mem_image_of_mem _ ⟨le_rfl, ht⟩, hiV⟩ |
| 94 | rintro z ⟨hzcl, u, hu, rfl⟩ |
| 95 | by_contra hzV |
| 96 | have hz : γ u ∈ Z := ⟨hγK u (hi0.trans hu.1), |
| 97 | ⟨closure_mono interior_subset hzcl, hzV⟩⟩ |
| 98 | have huc := hc _ hz |
| 99 | have hum := hanti hi0 (hi0.trans hu.1) hu.1 |
| 100 | exact (not_le_of_gt hic) (huc.trans hum) |
| 101 | exact (hVU (interior_subset (hpathV (mem_image_of_mem _ ⟨ht, le_rfl⟩)))).1 |
| 102 | |
| 103 | /-- Accumulation at a strict maximum makes a continuous descending trajectory stationary. -/ |
| 104 | theorem eventually_eq_of_strict_max_accumulation |
| 105 | {X : Type*} [TopologicalSpace X] [T3Space X] {K : Set X} |
| 106 | {f : X → ℝ} (hf : ContinuousOn f K) {p : X} (hpK : p ∈ K) |
| 107 | {γ : ℝ → X} (hγ : ContinuousOn γ (Ici 0)) |
| 108 | (hγK : ∀ t, 0 ≤ t → γ t ∈ K) |
| 109 | (hanti : AntitoneOn (f ∘ γ) (Ici 0)) |
| 110 | {τ : ℕ → ℝ} (hτ : Tendsto τ atTop atTop) |
| 111 | (hlim : Tendsto (γ ∘ τ) atTop (𝓝 p)) |
| 112 | (hmax : ∀ᶠ y in 𝓝 p, y ≠ p → f y < f p) : |
| 113 | ∀ᶠ t in atTop, γ t = p := by |
| 114 | have hτK : ∀ᶠ i in atTop, (γ ∘ τ) i ∈ K := |
| 115 | (hτ.eventually (eventually_ge_atTop 0)).mono fun i hi => hγK _ hi |
| 116 | have hflim : Tendsto (f ∘ γ ∘ τ) atTop (𝓝 (f p)) := |
| 117 | (hf p hpK).tendsto.comp (tendsto_nhdsWithin_iff.mpr ⟨hlim, hτK⟩) |
| 118 | have hbelow (t : ℝ) (ht : 0 ≤ t) : f p ≤ f (γ t) := by |
| 119 | apply le_of_tendsto hflim |
| 120 | exact (hτ.eventually (eventually_ge_atTop t)).mono |
| 121 | (fun i hi => hanti ht (ht.trans hi) hi) |
| 122 | obtain ⟨i, hi0, himax⟩ := |
| 123 | ((hτ.eventually (eventually_ge_atTop 0)).and (hlim.eventually hmax)).exists |
| 124 | have hi : γ (τ i) = p := by |
| 125 | by_contra hn |
| 126 | exact (not_lt_of_ge (hbelow _ hi0)) (himax hn) |
| 127 | refine (eventually_ge_atTop (τ i)).mono fun t ht => ?_ |
| 128 | by_contra hn |
| 129 | have hne : {γ t}ᶜ ∈ 𝓝 p := isOpen_compl_singleton.mem_nhds (by simpa using Ne.symm hn) |
| 130 | obtain ⟨V, hVp, hVc, hVsub⟩ := exists_mem_nhds_isClosed_subset (inter_mem hmax hne) |
| 131 | have hpV : p ∈ interior V := mem_interior_iff_mem_nhds.mpr hVp |
| 132 | have hpath := isPreconnected_Icc.image γ |
| 133 | (hγ.mono (show Icc (τ i) t ⊆ Ici 0 from fun u hu => hi0.trans hu.1)) |
| 134 | have hpathV : γ '' Icc (τ i) t ⊆ interior V := by |
| 135 | apply hpath.subset_of_closure_inter_subset isOpen_interior |
| 136 | ⟨γ (τ i), mem_image_of_mem _ ⟨le_rfl, ht⟩, by simpa only [hi] using hpV⟩ |
| 137 | rintro z ⟨hzcl, u, hu, rfl⟩ |
| 138 | by_contra hzV |
| 139 | have huV : γ u ∈ V := hVc.closure_subset (closure_mono interior_subset hzcl) |
| 140 | have hup : γ u ≠ p := fun heq => hzV (heq ▸ hpV) |
| 141 | exact (not_lt_of_ge (hbelow u (hi0.trans hu.1))) ((hVsub huV).1 hup) |
| 142 | exact (hVsub (interior_subset (hpathV (mem_image_of_mem _ ⟨ht, le_rfl⟩)))).2 rfl |
| 143 | |
| 144 | end Poincare.ODE |