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.MetricSpace.ProperSpace |
| 2 | import Mathlib.Topology.MetricSpace.Basic |
| 3 | import Mathlib.Topology.MetricSpace.Pseudo.Lemmas |
| 4 | import Mathlib.Topology.Order.Real |
| 5 | import Mathlib.Tactic.Linarith |
| 6 | |
| 7 | /-! |
| 8 | # Compact spatial limits are joint limits at a time endpoint |
| 9 | |
| 10 | Uniform convergence on each compact spatial set, with a continuous |
| 11 | limiting slice, supplies joint continuity from the past. Continuity |
| 12 | from the future then gives continuity across the surgery time. |
| 13 | Morgan--Tian, Lemma 16.8, Corollary 16.9 and Proposition 16.5, |
| 14 | pp. 372-375; see M44 derivation 50. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Set Filter Metric |
| 20 | open scoped Topology |
| 21 | |
| 22 | namespace Poincare |
| 23 | |
| 24 | variable {X Y : Type*} [MetricSpace X] [PseudoMetricSpace Y] |
| 25 | |
| 26 | /-- A compact-uniform spatial limit is a joint limit from the past |
| 27 | when its limiting slice is continuous. Source: the endpoint and |
| 28 | retained-surgery steps of Proposition 16.5; M44 derivation 50. -/ |
| 29 | theorem continuousWithinAt_time_left_of_compact_uniform |
| 30 | [ProperSpace X] |
| 31 | {f : ℝ × X → Y} {U : Set X} {T : ℝ} (hU : IsOpen U) |
| 32 | (hslice : ContinuousOn (fun x => f (T, x)) U) |
| 33 | (hlim : ∀ K : Set X, IsCompact K → K ⊆ U → ∀ eta : ℝ, 0 < eta → |
| 34 | ∃ d : ℝ, 0 < d ∧ ∀ t : ℝ, T - d < t → t < T → |
| 35 | ∀ x ∈ K, dist (f (t, x)) (f (T, x)) < eta) |
| 36 | {x : X} (hx : x ∈ U) : |
| 37 | ContinuousWithinAt f (Iic T ×ˢ U) (T, x) := by |
| 38 | obtain ⟨r, hr, hrU⟩ := Metric.mem_nhds_iff.mp (hU.mem_nhds hx) |
| 39 | have hhalf : 0 < r / 2 := half_pos hr |
| 40 | have hK : closedBall x (r / 2) ⊆ U := |
| 41 | (closedBall_subset_ball (half_lt_self hr)).trans hrU |
| 42 | have hg0 : ContinuousAt (fun y : X => f (T, y)) x := |
| 43 | hslice.continuousAt (hU.mem_nhds hx) |
| 44 | have hg : ContinuousAt (fun p : ℝ × X => f (T, p.2)) (T, x) := |
| 45 | ContinuousAt.comp (f := fun p : ℝ × X => p.2) |
| 46 | (g := fun y : X => f (T, y)) (x := (T, x)) hg0 continuous_snd.continuousAt |
| 47 | apply Metric.tendsto_nhds.mpr |
| 48 | intro eta heta |
| 49 | obtain ⟨d, hd, hbound⟩ := hlim (closedBall x (r / 2)) (isCompact_closedBall _ _) hK |
| 50 | (eta / 2) (half_pos heta) |
| 51 | have htnear : {p : ℝ × X | T - d < p.1} ∈ 𝓝 (T, x) := |
| 52 | continuous_fst.continuousAt.preimage_mem_nhds (Ioi_mem_nhds (sub_lt_self T hd)) |
| 53 | have hxnear : {p : ℝ × X | p.2 ∈ ball x (r / 2)} ∈ 𝓝 (T, x) := |
| 54 | continuous_snd.continuousAt.preimage_mem_nhds (ball_mem_nhds x hhalf) |
| 55 | have hgnear : ∀ᶠ p in 𝓝 (T, x), dist (f (T, p.2)) (f (T, x)) < eta / 2 := |
| 56 | Metric.tendsto_nhds.mp hg (eta / 2) (half_pos heta) |
| 57 | filter_upwards [self_mem_nhdsWithin, mem_nhdsWithin_of_mem_nhds htnear, |
| 58 | mem_nhdsWithin_of_mem_nhds hxnear, hgnear.filter_mono nhdsWithin_le_nhds] |
| 59 | with p hp htp hxp hgp |
| 60 | rcases lt_or_eq_of_le (show p.1 ≤ T from hp.1) with hlt | heq |
| 61 | · exact (dist_triangle (f p) (f (T, p.2)) (f (T, x))).trans_lt |
| 62 | (by |
| 63 | have h := hbound p.1 htp hlt p.2 (ball_subset_closedBall hxp) |
| 64 | linarith) |
| 65 | · calc |
| 66 | dist (f p) (f (T, x)) = dist (f (T, p.2)) (f (T, x)) := |
| 67 | congrArg (fun z => dist (f z) (f (T, x))) (Prod.ext heq rfl) |
| 68 | _ < eta := hgp.trans (half_lt_self heta) |
| 69 | |
| 70 | /-- Continuity from the past and future time half-spaces gives |
| 71 | ordinary joint continuity at a spatial interior point. Source: |
| 72 | the retained surgery step of Proposition 16.5; M44 derivation 50. -/ |
| 73 | theorem continuousAt_of_time_sides |
| 74 | {f : ℝ × X → Y} {U : Set X} {T : ℝ} {x : X} |
| 75 | (hU : IsOpen U) (hx : x ∈ U) |
| 76 | (hleft : ContinuousWithinAt f (Iic T ×ˢ U) (T, x)) |
| 77 | (hright : ContinuousWithinAt f (Ici T ×ˢ U) (T, x)) : |
| 78 | ContinuousAt f (T, x) := by |
| 79 | have h := hleft.union hright |
| 80 | rw [← union_prod, Iic_union_Ici] at h |
| 81 | exact h.continuousAt ((isOpen_univ.prod hU).mem_nhds ⟨mem_univ _, hx⟩) |
| 82 | |
| 83 | /-- Compact convergence from the past joins the two continuous |
| 84 | time pieces on a full open interval. Source: retained surgery |
| 85 | gluing in Proposition 16.5; M44 derivations 50-51. -/ |
| 86 | theorem continuousOn_time_of_compact_uniform |
| 87 | [ProperSpace X] {f : ℝ × X → Y} {U : Set X} {a T b : ℝ} |
| 88 | (hU : IsOpen U) (hTb : T < b) |
| 89 | (hleft : ContinuousOn f (Ioo a T ×ˢ U)) |
| 90 | (hright : ContinuousOn f (Ico T b ×ˢ U)) |
| 91 | (hlim : ∀ K : Set X, IsCompact K → K ⊆ U → ∀ eta : ℝ, 0 < eta → |
| 92 | ∃ d : ℝ, 0 < d ∧ ∀ t : ℝ, T - d < t → t < T → |
| 93 | ∀ x ∈ K, dist (f (t, x)) (f (T, x)) < eta) : |
| 94 | ContinuousOn f (Ioo a b ×ˢ U) := by |
| 95 | rintro ⟨t, x⟩ ⟨ht, hx⟩ |
| 96 | apply ContinuousAt.continuousWithinAt |
| 97 | rcases lt_trichotomy t T with hlt | heq | hgt |
| 98 | · exact hleft.continuousAt ((isOpen_Ioo.prod hU).mem_nhds ⟨⟨ht.1, hlt⟩, hx⟩) |
| 99 | · subst t |
| 100 | apply continuousAt_of_time_sides hU hx |
| 101 | · apply continuousWithinAt_time_left_of_compact_uniform hU _ hlim hx |
| 102 | exact hright.comp (continuousOn_const.prodMk continuousOn_id) |
| 103 | (fun y hy => ⟨⟨le_rfl, hTb⟩, hy⟩) |
| 104 | · apply (hright ⟨T, x⟩ ⟨⟨le_rfl, hTb⟩, hx⟩).mono_of_mem_nhdsWithin |
| 105 | have hnear : {p : ℝ × X | p.1 < b} ∈ 𝓝 (T, x) := |
| 106 | continuous_fst.continuousAt.preimage_mem_nhds (Iio_mem_nhds hTb) |
| 107 | filter_upwards [self_mem_nhdsWithin, mem_nhdsWithin_of_mem_nhds hnear] |
| 108 | with p hp hpb |
| 109 | exact ⟨⟨hp.1, hpb⟩, hp.2⟩ |
| 110 | · apply (hright.mono (prod_mono Ioo_subset_Ico_self Subset.rfl)).continuousAt |
| 111 | exact (isOpen_Ioo.prod hU).mem_nhds ⟨⟨hgt, ht.2⟩, hx⟩ |
| 112 | |
| 113 | end Poincare |