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.Thickening |
| 3 | import Mathlib.Topology.Order.Compact |
| 4 | import Mathlib.Topology.UniformSpace.HeineCantor |
| 5 | import Mathlib.Tactic |
| 6 | |
| 7 | /-! |
| 8 | # Continuous scalar maxima on varying metric balls |
| 9 | |
| 10 | Approximate radial projection makes closed-ball scalar maxima continuous |
| 11 | in the nonnegative radius. Positive-radius open and closed balls have the |
| 12 | same scalar supremum. This is the metric-space step in the normalized |
| 13 | core-ball construction of Morgan-Tian Definition 9.72, pp. 230-231, and |
| 14 | Theorem 12.28, pp. 323-324; see cap-persistence-implementation.md, section 4. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Set Metric |
| 20 | |
| 21 | namespace Metric |
| 22 | |
| 23 | variable {X : Type*} [PseudoMetricSpace X] {x : X} |
| 24 | |
| 25 | /-- Approximate radial projection fills the positive-radius closed ball |
| 26 | by the closure of the open ball (normalized core balls, Definition 9.72). -/ |
| 27 | theorem closure_ball_eq_closedBall_of_approximate_radial_projection |
| 28 | (hproject : ∀ R r ε : ℝ, 0 ≤ r → r ≤ R → 0 < ε → |
| 29 | closedBall x R ⊆ thickening (R - r + ε) (closedBall x r)) |
| 30 | {r : ℝ} (hr : 0 < r) : closure (ball x r) = closedBall x r := by |
| 31 | apply Subset.antisymm closure_ball_subset_closedBall |
| 32 | intro y hy |
| 33 | apply Metric.mem_closure_iff.mpr |
| 34 | intro ε hε |
| 35 | let s := max 0 (r - ε / 2) |
| 36 | have hs : 0 ≤ s := le_max_left _ _ |
| 37 | have hsr : s < r := max_lt hr (by linarith) |
| 38 | obtain ⟨z, hz, hyz⟩ := Metric.mem_thickening_iff.mp |
| 39 | (hproject r s (ε / 2) hs hsr.le (half_pos hε) hy) |
| 40 | refine ⟨z, hz.trans_lt hsr, hyz.trans_le ?_⟩ |
| 41 | have hgap : r - ε / 2 ≤ s := le_max_right _ _ |
| 42 | linarith |
| 43 | |
| 44 | variable [ProperSpace X] |
| 45 | |
| 46 | /-- Scalar maxima on actual closed balls vary continuously with every |
| 47 | nonnegative radius, including zero (normalized core balls, Definition 9.72). |
| 48 | Only the radial approximation property at the fixed center is required. -/ |
| 49 | theorem continuousOn_sSup_image_closedBall_of_approximate_radial_projection |
| 50 | (hproject : ∀ R r ε : ℝ, 0 ≤ r → r ≤ R → 0 < ε → |
| 51 | closedBall x R ⊆ thickening (R - r + ε) (closedBall x r)) |
| 52 | {f : X → ℝ} (hf : Continuous f) : |
| 53 | ContinuousOn (fun r : ℝ => sSup (f '' closedBall x r)) (Ici 0) := by |
| 54 | let S := fun r : ℝ => sSup (f '' closedBall x r) |
| 55 | have hb (r : ℝ) : BddAbove (f '' closedBall x r) := |
| 56 | (isCompact_closedBall x r).bddAbove_image hf.continuousOn |
| 57 | intro r hr |
| 58 | apply Metric.continuousWithinAt_iff.mpr |
| 59 | intro ε hε |
| 60 | obtain ⟨δ, hδ, hδf⟩ := Metric.uniformContinuousOn_iff.mp |
| 61 | ((isCompact_closedBall x (r + 1)).uniformContinuousOn_of_continuous |
| 62 | hf.continuousOn) (ε / 2) (half_pos hε) |
| 63 | have hcompare (s t : ℝ) (hs : 0 ≤ s) (ht : 0 ≤ t) |
| 64 | (hsR : s ≤ r + 1) (htR : t ≤ r + 1) (hst : |t - s| < δ / 4) : |
| 65 | S t < S s + ε / 2 := by |
| 66 | obtain ⟨y, hy, hSy⟩ := (isCompact_closedBall x t).exists_sSup_image_eq |
| 67 | ⟨x, mem_closedBall_self ht⟩ hf.continuousOn |
| 68 | have hyR : y ∈ closedBall x (r + 1) := closedBall_subset_closedBall htR hy |
| 69 | by_cases hts : t ≤ s |
| 70 | · have hys : y ∈ closedBall x s := closedBall_subset_closedBall hts hy |
| 71 | have hle : f y ≤ S s := le_csSup (hb s) (mem_image_of_mem f hys) |
| 72 | dsimp [S] |
| 73 | rw [hSy] |
| 74 | dsimp [S] at hle |
| 75 | linarith |
| 76 | · have hst' : s ≤ t := le_of_lt (lt_of_not_ge hts) |
| 77 | obtain ⟨z, hz, hyz⟩ := Metric.mem_thickening_iff.mp |
| 78 | (hproject t s (δ / 4) hs hst' (by positivity) hy) |
| 79 | have hzR : z ∈ closedBall x (r + 1) := closedBall_subset_closedBall hsR hz |
| 80 | have hd : dist y z < δ := by |
| 81 | have hd' := (abs_lt.mp hst).2 |
| 82 | linarith |
| 83 | have hv := hδf y hyR z hzR hd |
| 84 | rw [Real.dist_eq] at hv |
| 85 | have hle : f z ≤ S s := le_csSup (hb s) (mem_image_of_mem f hz) |
| 86 | change sSup (f '' closedBall x t) < S s + ε / 2 |
| 87 | rw [hSy] |
| 88 | have hsmall := (abs_lt.mp hv).2 |
| 89 | linarith |
| 90 | refine ⟨min (1 / 2) (δ / 4), by positivity, ?_⟩ |
| 91 | intro s hs hsr |
| 92 | rw [Real.dist_eq] at hsr |
| 93 | have hsmall := lt_of_lt_of_le hsr (min_le_right _ _) |
| 94 | have hsR : s ≤ r + 1 := by |
| 95 | have hhalf := (abs_lt.mp (lt_of_lt_of_le hsr (min_le_left _ _))).2 |
| 96 | linarith |
| 97 | have h1 := hcompare r s hr hs (by linarith) hsR hsmall |
| 98 | have h2 := hcompare s r hs hr hsR (by linarith) (by simpa only [abs_sub_comm] using hsmall) |
| 99 | rw [Real.dist_eq] |
| 100 | apply abs_lt.mpr |
| 101 | change -ε < S s - S r ∧ S s - S r < ε |
| 102 | constructor <;> linarith |
| 103 | |
| 104 | /-- The actual open-ball scalar supremum equals the compact closed-ball |
| 105 | maximum at every positive radius (normalized core balls, Definition 9.72). -/ |
| 106 | theorem sSup_image_ball_eq_closedBall_of_approximate_radial_projection |
| 107 | (hproject : ∀ R r ε : ℝ, 0 ≤ r → r ≤ R → 0 < ε → |
| 108 | closedBall x R ⊆ thickening (R - r + ε) (closedBall x r)) |
| 109 | {f : X → ℝ} (hf : Continuous f) {r : ℝ} (hr : 0 < r) : |
| 110 | sSup (f '' ball x r) = sSup (f '' closedBall x r) := by |
| 111 | have hb : BddAbove (f '' closedBall x r) := |
| 112 | (isCompact_closedBall x r).bddAbove_image hf.continuousOn |
| 113 | have hbo : BddAbove (f '' ball x r) := hb.mono (image_mono ball_subset_closedBall) |
| 114 | have hlo : ∀ y ∈ ball x r, f y ≤ sSup (f '' ball x r) := |
| 115 | fun y hy => le_csSup hbo (mem_image_of_mem f hy) |
| 116 | have hcl : closedBall x r ⊆ {y | f y ≤ sSup (f '' ball x r)} := by |
| 117 | rw [← closure_ball_eq_closedBall_of_approximate_radial_projection hproject hr] |
| 118 | exact closure_minimal hlo (isClosed_le hf continuous_const) |
| 119 | apply le_antisymm |
| 120 | · exact csSup_le ⟨f x, mem_image_of_mem f (mem_ball_self hr)⟩ (by |
| 121 | rintro _ ⟨y, hy, rfl⟩ |
| 122 | exact le_csSup hb (mem_image_of_mem f (ball_subset_closedBall hy))) |
| 123 | · exact csSup_le ⟨f x, mem_image_of_mem f (mem_closedBall_self hr.le)⟩ (by |
| 124 | rintro _ ⟨y, hy, rfl⟩ |
| 125 | exact hcl hy) |
| 126 | |
| 127 | end Metric |