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.UniformSpace.Ascoli |
| 2 | import Mathlib.Topology.MetricSpace.Equicontinuity |
| 3 | import Mathlib.Topology.MetricSpace.Lipschitz |
| 4 | import Mathlib.Topology.MetricSpace.ProperSpace.Real |
| 5 | import Mathlib.Topology.Algebra.Order.Field |
| 6 | import PoincareLib.Topology.Sequences.Diagonal |
| 7 | |
| 8 | /-! |
| 9 | # Limits of distances between source charts |
| 10 | |
| 11 | Pairwise source distances are extracted on the fixed coordinate domains. |
| 12 | Their zero sets, rather than total transitions or a preexisting ambient |
| 13 | limit, determine which coordinate points must be identified. This is the |
| 14 | distance extraction step in Morgan--Tian, Theorem 5.6, pp. 86--87. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Set Filter |
| 20 | open scoped Topology NNReal |
| 21 | |
| 22 | namespace PoincareMT.ChartDistance |
| 23 | |
| 24 | private theorem exists_common_locallyUniform_limits |
| 25 | {ι : Type*} [Countable ι] {X : ι → Type*} [∀ i, TopologicalSpace (X i)] |
| 26 | [∀ i, LocallyCompactSpace (X i)] [∀ i, SigmaCompactSpace (X i)] |
| 27 | (f : ∀ i, ℕ → X i → ℝ) (heq : ∀ i, Equicontinuous (f i)) |
| 28 | (hb : ∀ i x, ∃ B : ℝ, ∀ k, |f i k x| ≤ B) : |
| 29 | ∃ σ : ℕ → ℕ, StrictMono σ ∧ ∃ F : ∀ i, C(X i, ℝ), |
| 30 | ∀ i, TendstoLocallyUniformly (fun k => f i (σ k)) (F i) atTop := by |
| 31 | let u : ∀ i, ℕ → C(X i, ℝ) := fun i k => ⟨f i k, (heq i).continuous k⟩ |
| 32 | have hc (i : ι) : IsCompact (closure (range (u i))) := by |
| 33 | apply ArzelaAscoli.isCompact_closure_of_isClosedEmbedding |
| 34 | (F := fun v : C(X i, ℝ) => (v : X i → ℝ)) |
| 35 | (𝔖 := {K | IsCompact K}) (fun _ h => h) |
| 36 | (show Topology.IsClosedEmbedding (ContinuousMap.toUniformOnFunIsCompact : |
| 37 | C(X i, ℝ) → UniformOnFun (X i) ℝ {K | IsCompact K}) from |
| 38 | ⟨ContinuousMap.isUniformEmbedding_toUniformOnFunIsCompact.isEmbedding, by |
| 39 | rw [ContinuousMap.range_toUniformOnFunIsCompact] |
| 40 | exact UniformOnFun.isClosed_setOfPred_continuous |
| 41 | CompactlyCoherentSpace.isCoherentWith⟩) |
| 42 | · intro K hK |
| 43 | have h : Equicontinuous (fun v : range (u i) => (v.val : X i → ℝ)) := by |
| 44 | intro x V hV |
| 45 | filter_upwards [heq i x V hV] with y hy v |
| 46 | obtain ⟨k, hk⟩ := v.property |
| 47 | simpa only [← hk, u, ContinuousMap.coe_mk] using hy k |
| 48 | exact h.equicontinuousOn K |
| 49 | · intro K hK x hx |
| 50 | obtain ⟨B, hB⟩ := hb i x |
| 51 | refine ⟨Metric.closedBall (0 : ℝ) B, isCompact_closedBall _ _, ?_⟩ |
| 52 | rintro v ⟨k, rfl⟩ |
| 53 | simpa only [Metric.mem_closedBall, Real.dist_eq, sub_zero, u, |
| 54 | ContinuousMap.coe_mk] using hB k |
| 55 | have : ∀ i, FirstCountableTopology C(X i, ℝ) := fun i => by |
| 56 | have : Filter.IsCountablyGenerated (uniformity C(X i, ℝ)) := inferInstance |
| 57 | exact UniformSpace.firstCountableTopology _ |
| 58 | obtain ⟨F, _, σ, hσ, hF⟩ := (isCompact_pi_infinite hc).tendsto_subseq |
| 59 | (x := fun k i => u i k) (fun k i => subset_closure (mem_range_self k)) |
| 60 | exact ⟨σ, hσ, F, fun i => |
| 61 | ContinuousMap.tendsto_iff_tendstoLocallyUniformly.mp (tendsto_pi_nhds.mp hF i)⟩ |
| 62 | |
| 63 | /-- One subsequence extracts all pairwise source-chart distances. The source |
| 64 | spaces may vary with the sequence index. Only chartwise Lipschitz bounds and |
| 65 | pointwise bounds on the source distances are required. -/ |
| 66 | theorem exists_pairwise_limits |
| 67 | {X : ℕ → Type*} [∀ i, PseudoMetricSpace (X i)] |
| 68 | [∀ i, LocallyCompactSpace (X i)] [∀ i, SigmaCompactSpace (X i)] |
| 69 | {M : ℕ → Type*} [∀ k, PseudoMetricSpace (M k)] |
| 70 | (e : ∀ k i, X i → M k) (L : ℕ → ℝ≥0) |
| 71 | (he : ∀ k i, LipschitzWith (L i) (e k i)) |
| 72 | (hb : ∀ i j (x : X i) (y : X j), ∃ B : ℝ, |
| 73 | ∀ k, dist (e k i x) (e k j y) ≤ B) : |
| 74 | ∃ σ : ℕ → ℕ, StrictMono σ ∧ ∃ D : ∀ i j, C(X i × X j, ℝ), |
| 75 | ∀ i j, TendstoLocallyUniformly |
| 76 | (fun k (p : X i × X j) => dist (e (σ k) i p.1) (e (σ k) j p.2)) |
| 77 | (D i j) atTop := by |
| 78 | let f (a : ℕ × ℕ) (k : ℕ) (p : X a.1 × X a.2) : ℝ := |
| 79 | dist (e k a.1 p.1) (e k a.2 p.2) |
| 80 | have hlip (a : ℕ × ℕ) (k : ℕ) : LipschitzWith (L a.1 + L a.2) (f a k) := |
| 81 | LipschitzWith.of_dist_le_mul fun x y => by |
| 82 | calc |
| 83 | dist (f a k x) (f a k y) ≤ |
| 84 | dist (e k a.1 x.1) (e k a.1 y.1) + |
| 85 | dist (e k a.2 x.2) (e k a.2 y.2) := dist_dist_dist_le _ _ _ _ |
| 86 | _ ≤ (L a.1 : ℝ) * dist x y + (L a.2 : ℝ) * dist x y := |
| 87 | add_le_add ((he k a.1).dist_le_mul_of_le (le_max_left _ _)) |
| 88 | ((he k a.2).dist_le_mul_of_le (le_max_right _ _)) |
| 89 | _ = (L a.1 + L a.2 : ℝ≥0) * dist x y := by rw [NNReal.coe_add, add_mul] |
| 90 | have heq (a : ℕ × ℕ) : Equicontinuous (f a) := by |
| 91 | apply Metric.equicontinuous_of_continuity_modulus |
| 92 | (fun r => (L a.1 + L a.2 : ℝ≥0) * r) |
| 93 | · simpa using (tendsto_const_nhds.mul tendsto_id : |
| 94 | Tendsto (fun r : ℝ => (L a.1 + L a.2 : ℝ≥0) * r) |
| 95 | (𝓝 0) (𝓝 ((L a.1 + L a.2 : ℝ≥0) * (0 : ℝ)))) |
| 96 | · intro x y k |
| 97 | exact (hlip a k).dist_le_mul x y |
| 98 | obtain ⟨σ, hσ, F, hF⟩ := exists_common_locallyUniform_limits f heq (by |
| 99 | intro a p |
| 100 | obtain ⟨B, hB⟩ := hb a.1 a.2 p.1 p.2 |
| 101 | exact ⟨B, fun k => by simpa only [f, abs_of_nonneg dist_nonneg] using hB k⟩) |
| 102 | exact ⟨σ, hσ, fun i j => F (i, j), fun i j => hF (i, j)⟩ |
| 103 | |
| 104 | section Relation |
| 105 | |
| 106 | variable {ι : Type*} {X : ι → Type*} {M : ℕ → Type*} |
| 107 | [∀ k, PseudoMetricSpace (M k)] |
| 108 | {e : ∀ k i, X i → M k} {D : ∀ i j, X i × X j → ℝ} |
| 109 | (hD : ∀ i j x y, Tendsto (fun k => dist (e k i x) (e k j y)) atTop |
| 110 | (𝓝 (D i j (x, y)))) |
| 111 | |
| 112 | include hD |
| 113 | |
| 114 | theorem nonneg (i j : ι) (x : X i) (y : X j) : 0 ≤ D i j (x, y) := |
| 115 | ge_of_tendsto (hD i j x y) (Eventually.of_forall fun _ => dist_nonneg) |
| 116 | |
| 117 | theorem self (i : ι) (x : X i) : D i i (x, x) = 0 := by |
| 118 | apply tendsto_nhds_unique (hD i i x x) |
| 119 | simp only [dist_self] |
| 120 | exact tendsto_const_nhds |
| 121 | |
| 122 | theorem comm (i j : ι) (x : X i) (y : X j) : D i j (x, y) = D j i (y, x) := by |
| 123 | exact tendsto_nhds_unique (hD i j x y) (by simpa only [dist_comm] using hD j i y x) |
| 124 | |
| 125 | theorem triangle (i j l : ι) (x : X i) (y : X j) (z : X l) : |
| 126 | D i l (x, z) ≤ D i j (x, y) + D j l (y, z) := |
| 127 | le_of_tendsto_of_tendsto (hD i l x z) ((hD i j x y).add (hD j l y z)) |
| 128 | (Eventually.of_forall fun _ => dist_triangle _ _ _) |
| 129 | |
| 130 | theorem zero_trans {i j l : ι} {x : X i} {y : X j} {z : X l} |
| 131 | (hxy : D i j (x, y) = 0) (hyz : D j l (y, z) = 0) : |
| 132 | D i l (x, z) = 0 := by |
| 133 | apply le_antisymm _ (nonneg hD i l x z) |
| 134 | simpa only [hxy, hyz, add_zero] using triangle hD i j l x y z |
| 135 | |
| 136 | /-- The zero-distance relation is an equivalence relation on the disjoint |
| 137 | union of the coordinate domains. -/ |
| 138 | def zeroSetoid : Setoid (Σ i, X i) where |
| 139 | r p q := D p.1 q.1 (p.2, q.2) = 0 |
| 140 | iseqv := ⟨fun p => self hD p.1 p.2, |
| 141 | fun {p q} hpq => (comm hD q.1 p.1 q.2 p.2).trans hpq, |
| 142 | fun hpq hqr => zero_trans hD hpq hqr⟩ |
| 143 | |
| 144 | theorem lower [∀ i, PseudoMetricSpace (X i)] |
| 145 | (c : ι → ℝ) (he : ∀ k i x y, c i * dist x y ≤ dist (e k i x) (e k i y)) |
| 146 | (i : ι) (x y : X i) : c i * dist x y ≤ D i i (x, y) := |
| 147 | ge_of_tendsto (hD i i x y) (Eventually.of_forall fun k => he k i x y) |
| 148 | |
| 149 | theorem upper [∀ i, PseudoMetricSpace (X i)] |
| 150 | (L : ι → ℝ≥0) (he : ∀ k i, LipschitzWith (L i) (e k i)) |
| 151 | (i : ι) (x y : X i) : D i i (x, y) ≤ (L i : ℝ) * dist x y := |
| 152 | le_of_tendsto (hD i i x y) (Eventually.of_forall fun k => (he k i).dist_le_mul x y) |
| 153 | |
| 154 | theorem zero_unique [∀ i, MetricSpace (X i)] |
| 155 | (c : ι → ℝ) (hc : ∀ i, 0 < c i) |
| 156 | (he : ∀ k i x y, c i * dist x y ≤ dist (e k i x) (e k i y)) |
| 157 | {i j : ι} {x : X i} {y z : X j} |
| 158 | (hy : D i j (x, y) = 0) (hz : D i j (x, z) = 0) : y = z := by |
| 159 | have hyz : D j j (y, z) = 0 := |
| 160 | zero_trans hD ((comm hD j i y x).trans hy) hz |
| 161 | have h := lower hD c he j y z |
| 162 | rw [hyz] at h |
| 163 | have hdist : dist y z ≤ 0 := by |
| 164 | by_contra hpos |
| 165 | have : 0 < c j * dist y z := mul_pos (hc j) (lt_of_not_ge hpos) |
| 166 | exact (not_lt_of_ge h) this |
| 167 | exact dist_le_zero.mp hdist |
| 168 | |
| 169 | end Relation |
| 170 | |
| 171 | /-- Closedness of each component overlap is a consequence of distance |
| 172 | convergence, independent of the quotient construction. -/ |
| 173 | theorem isClosed_zero {X Y : Type*} [TopologicalSpace X] [TopologicalSpace Y] |
| 174 | (D : C(X × Y, ℝ)) : IsClosed {p | D p = 0} := |
| 175 | isClosed_eq D.continuous continuous_const |
| 176 | |
| 177 | end PoincareMT.ChartDistance |