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.Surgery.Singular.RegularLimit.Canonical.Cap.BallClosure |
| 2 | import Mathlib.Topology.UniformSpace.Compact |
| 3 | import Mathlib.Topology.Compactness.LocallyCompact |
| 4 | |
| 5 | /-! |
| 6 | # Compact collars and enlargement of captured balls |
| 7 | |
| 8 | A compact subset has a uniform precompact metric neighborhood. Approximate |
| 9 | distance splitting then enlarges any ball captured by that subset by one |
| 10 | common positive radius, even when the Riemannian metric is incomplete. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | open Set Filter |
| 17 | open scoped Manifold ContDiff Bundle Topology ENNReal |
| 18 | |
| 19 | namespace PoincareMT.RiemannianMetric |
| 20 | |
| 21 | variable {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 22 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 23 | [T3Space M] |
| 24 | |
| 25 | /-- A compact set has one compact superset containing a uniform ball about |
| 26 | each of its points, without a global properness assumption. -/ |
| 27 | theorem exists_compact_ball_neighborhood (g : RiemannianMetric n M) |
| 28 | {A : Set M} (hA : IsCompact A) : |
| 29 | ∃ δ : ℝ, 0 < δ ∧ ∃ K : Set M, IsCompact K ∧ |
| 30 | ∀ p ∈ A, g.ball p δ ⊆ K := by |
| 31 | let : LocallyCompactSpace M := ChartedSpace.locallyCompactSpace |
| 32 | (EuclideanSpace ℝ (Fin n)) M |
| 33 | let : Bundle.RiemannianBundle (TangentSpace (𝓡 n) : M → Type _) := |
| 34 | ⟨g.toRiemannianMetric⟩ |
| 35 | let : IsContinuousRiemannianBundle (EuclideanSpace ℝ (Fin n)) |
| 36 | (TangentSpace (𝓡 n) : M → Type _) := |
| 37 | ⟨⟨g.inner, g.toContinuousRiemannianMetric.continuous, fun _ _ _ => rfl⟩⟩ |
| 38 | let : EMetricSpace M := EMetricSpace.ofRiemannianMetric (𝓡 n) M |
| 39 | obtain ⟨K, hK, hAK⟩ := exists_compact_superset hA |
| 40 | obtain ⟨ε, hε, hεK⟩ := |
| 41 | (hA.nhdsSet_basis_uniformity uniformity_basis_edist).mem_iff.mp |
| 42 | (isOpen_interior.mem_nhdsSet.mpr hAK) |
| 43 | obtain ⟨δ, _, hδ, hδε⟩ := ENNReal.lt_iff_exists_real_btwn.mp hε |
| 44 | refine ⟨δ, ENNReal.ofReal_pos.mp hδ, K, hK, ?_⟩ |
| 45 | intro p hp q hq |
| 46 | apply interior_subset (hεK ?_) |
| 47 | exact mem_iUnion₂_of_mem hp (hq.trans hδε) |
| 48 | |
| 49 | /-- A ball captured by a set enlarges into the union of equal-radius balls |
| 50 | about that set. This uses the length-space property, not completeness. -/ |
| 51 | theorem ball_add_subset_of_ball_subset (g : RiemannianMetric n M) |
| 52 | (p : M) {r δ : ℝ} (hr : 0 < r) (hδ : 0 < δ) |
| 53 | {A B : Set M} (hball : g.ball p r ⊆ A) |
| 54 | (hcollar : ∀ z ∈ A, g.ball z δ ⊆ B) : |
| 55 | g.ball p (r + δ) ⊆ B := by |
| 56 | intro q hq |
| 57 | by_cases hqr : q ∈ g.ball p r |
| 58 | · apply hcollar q (hball hqr) |
| 59 | change g.edist q q < ENNReal.ofReal δ |
| 60 | simpa only [edist, Manifold.riemannianEDist_self] using ENNReal.ofReal_pos.mpr hδ |
| 61 | · have hfinite : g.edist p q ≠ ⊤ := ne_top_of_lt ((show |
| 62 | g.edist p q < ENNReal.ofReal (r + δ) from hq).trans_le le_top) |
| 63 | have hd : (g.edist p q).toReal < r + δ := ENNReal.toReal_lt_of_lt_ofReal hq |
| 64 | have hrd : r ≤ (g.edist p q).toReal := by |
| 65 | have hh : ENNReal.ofReal r ≤ g.edist p q := le_of_not_gt hqr |
| 66 | exact (ENNReal.ofReal_le_iff_le_toReal hfinite).mp hh |
| 67 | obtain ⟨a, ha, har⟩ := exists_between |
| 68 | (max_lt hr (show (g.edist p q).toReal - δ < r by linarith)) |
| 69 | have ha0 : 0 < a := (le_max_left _ _).trans_lt ha |
| 70 | have hgap : 0 < δ - ((g.edist p q).toReal - a) := by |
| 71 | have := (le_max_right (0 : ℝ) ((g.edist p q).toReal - δ)).trans_lt ha |
| 72 | linarith |
| 73 | obtain ⟨z, hzp, hzfinite, hzq⟩ := g.exists_approximate_distance_split p q hfinite |
| 74 | ha0 (half_pos hgap) (har.trans_le hrd) |
| 75 | have hz : z ∈ g.ball p r := by |
| 76 | change g.edist p z < ENNReal.ofReal r |
| 77 | rw [hzp] |
| 78 | exact (ENNReal.ofReal_lt_ofReal_iff hr).mpr har |
| 79 | apply hcollar z (hball hz) |
| 80 | change g.edist z q < ENNReal.ofReal δ |
| 81 | rw [← ENNReal.ofReal_toReal hzfinite] |
| 82 | apply (ENNReal.ofReal_lt_ofReal_iff hδ).mpr |
| 83 | linarith |
| 84 | |
| 85 | /-- One positive enlargement preserves precompactness for every positive |
| 86 | ball captured by a fixed compact set. -/ |
| 87 | theorem exists_uniform_precompact_ball_enlargement (g : RiemannianMetric n M) |
| 88 | {A : Set M} (hA : IsCompact A) : |
| 89 | ∃ δ : ℝ, 0 < δ ∧ ∀ p : M, ∀ r : ℝ, 0 < r → g.ball p r ⊆ A → |
| 90 | IsCompact (closure (g.ball p (r + δ))) := by |
| 91 | obtain ⟨δ, hδ, K, hK, hcollar⟩ := g.exists_compact_ball_neighborhood hA |
| 92 | refine ⟨δ, hδ, ?_⟩ |
| 93 | intro p r hr hball |
| 94 | exact hK.of_isClosed_subset isClosed_closure |
| 95 | (closure_minimal (g.ball_add_subset_of_ball_subset p hr hδ hball hcollar) hK.isClosed) |
| 96 | |
| 97 | end PoincareMT.RiemannianMetric |