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.Generalized.BoundedDistance.GeometryImports |
| 2 | import Mathlib.Order.Filter.Ultrafilter.Basic |
| 3 | import Mathlib.Topology.Compactness.Compact |
| 4 | import Mathlib.Topology.MetricSpace.Isometry |
| 5 | import Mathlib.Topology.Instances.Real.Lemmas |
| 6 | import Mathlib.Topology.Order.Basic |
| 7 | import Mathlib.Tactic.Linarith |
| 8 | |
| 9 | /-! |
| 10 | # Metric ray limits from compact proper prefixes |
| 11 | |
| 12 | One common ultrafilter preserves pointwise limits and all pairwise |
| 13 | distance identities without imposing properness on the ambient space. |
| 14 | Source: Morgan--Tian Claims 10.13-10.14 and Lemma 10.16, pp. 256-258; |
| 15 | M28 derivation 130. The proof adapts the Mathlib-only compactness argument |
| 16 | of M32/Mathlib/BoundedAnchorLine to the weaker compact-prefix hypothesis. |
| 17 | -/ |
| 18 | |
| 19 | set_option autoImplicit false |
| 20 | |
| 21 | open Set Filter |
| 22 | open scoped Topology |
| 23 | |
| 24 | /-- One fixed ultrafilter retains every pairwise distance limit on an |
| 25 | arbitrary parameter set. No completeness or countability is required. |
| 26 | Source: Claims 10.13-10.14; M28 derivation 130. -/ |
| 27 | theorem exists_pointwise_metric_limit_of_eventually_compact |
| 28 | {A X : Type*} [MetricSpace X] |
| 29 | (S : Set A) (f : ℕ → A → X) (d : A → A → ℝ) |
| 30 | (hcompact : ∀ x ∈ S, ∃ K : Set X, IsCompact K ∧ |
| 31 | ∀ᶠ n in atTop, f n x ∈ K) |
| 32 | (hdist : ∀ x ∈ S, ∀ y ∈ S, |
| 33 | Tendsto (fun n => dist (f n x) (f n y)) atTop (𝓝 (d x y))) : |
| 34 | ∃ g : A → X, |
| 35 | (∀ x ∈ S, Tendsto (fun n => f n x) |
| 36 | (hyperfilter ℕ : Filter ℕ) (𝓝 (g x))) ∧ |
| 37 | ∀ x ∈ S, ∀ y ∈ S, dist (g x) (g y) = d x y := by |
| 38 | classical |
| 39 | have hpoint (x : A) (hx : x ∈ S) : |
| 40 | ∃ y : X, Tendsto (fun n => f n x) |
| 41 | (hyperfilter ℕ : Filter ℕ) (𝓝 y) := by |
| 42 | obtain ⟨K, hK, hf⟩ := hcompact x hx |
| 43 | have hF : ∀ᶠ n in (hyperfilter ℕ : Filter ℕ), f n x ∈ K := |
| 44 | hf.filter_mono Nat.hyperfilter_le_atTop |
| 45 | obtain ⟨y, _hyK, hy⟩ := hK.ultrafilter_le_nhds' |
| 46 | ((hyperfilter ℕ).map fun n => f n x) hF |
| 47 | rw [Ultrafilter.coe_map] at hy |
| 48 | exact ⟨y, hy⟩ |
| 49 | let g : A → X := fun x => |
| 50 | if hx : x ∈ S then Classical.choose (hpoint x hx) else f 0 x |
| 51 | have hg (x : A) (hx : x ∈ S) : |
| 52 | Tendsto (fun n => f n x) |
| 53 | (hyperfilter ℕ : Filter ℕ) (𝓝 (g x)) := by |
| 54 | simpa only [g, dif_pos hx] using Classical.choose_spec (hpoint x hx) |
| 55 | refine ⟨g, hg, ?_⟩ |
| 56 | intro x hx y hy |
| 57 | exact tendsto_nhds_unique ((hg x hx).dist (hg y hy)) |
| 58 | ((hdist x hx y hy).mono_left Nat.hyperfilter_le_atTop) |
| 59 | |
| 60 | /-- Compact proper prefixes and exact source segments give one finite |
| 61 | isometric ray with its original anchor. The missing endpoint is excluded. |
| 62 | Source: Claims 10.13-10.14; M28 derivation 130. -/ |
| 63 | theorem exists_isometric_finite_ray_of_compact_prefixes |
| 64 | {X : Type*} [MetricSpace X] {p : X} {a : ℝ} |
| 65 | {arc : ℕ → ℝ → X} {length : ℕ → ℝ} |
| 66 | (ha : 0 < a) (hlength : Tendsto length atTop (𝓝 a)) |
| 67 | (hanchor : ∀ᶠ n in atTop, arc n 0 = p) |
| 68 | (hprefix : ∀ T : ℝ, 0 < T → T < a → |
| 69 | ∃ K : Set X, IsCompact K ∧ |
| 70 | ∀ᶠ n in atTop, ∀ t ∈ Icc (0 : ℝ) T, arc n t ∈ K) |
| 71 | (hdist : ∀ n, ∀ s ∈ Icc (0 : ℝ) (length n), |
| 72 | ∀ t ∈ Icc (0 : ℝ) (length n), |
| 73 | dist (arc n s) (arc n t) = |s - t|) : |
| 74 | ∃ gamma : ℝ → X, |
| 75 | gamma 0 = p ∧ |
| 76 | Isometry (fun t : Ico (0 : ℝ) a => gamma t.1) ∧ |
| 77 | (∀ s ∈ Ico (0 : ℝ) a, ∀ t ∈ Ico (0 : ℝ) a, |
| 78 | dist (gamma s) (gamma t) = |s - t|) ∧ |
| 79 | ∀ t ∈ Ico (0 : ℝ) a, Tendsto (fun n => arc n t) |
| 80 | (hyperfilter ℕ : Filter ℕ) (𝓝 (gamma t)) := by |
| 81 | have hcompact (t : ℝ) (ht : t ∈ Ico (0 : ℝ) a) : |
| 82 | ∃ K : Set X, IsCompact K ∧ ∀ᶠ n in atTop, arc n t ∈ K := by |
| 83 | have hTpos : 0 < (t + a) / 2 := by linarith [ht.1] |
| 84 | have hTlt : (t + a) / 2 < a := by linarith [ht.2] |
| 85 | have htT : t ≤ (t + a) / 2 := by linarith [ht.2] |
| 86 | obtain ⟨K, hK, hcapture⟩ := hprefix ((t + a) / 2) hTpos hTlt |
| 87 | exact ⟨K, hK, hcapture.mono fun _ hn => hn t ⟨ht.1, htT⟩⟩ |
| 88 | have hpair (s : ℝ) (hs : s ∈ Ico (0 : ℝ) a) |
| 89 | (t : ℝ) (ht : t ∈ Ico (0 : ℝ) a) : |
| 90 | Tendsto (fun n => dist (arc n s) (arc n t)) atTop (𝓝 |s - t|) := by |
| 91 | apply tendsto_const_nhds.congr' |
| 92 | filter_upwards [(tendsto_order.mp hlength).1 s hs.2, |
| 93 | (tendsto_order.mp hlength).1 t ht.2] with n hsL htL |
| 94 | exact (hdist n s ⟨hs.1, hsL.le⟩ t ⟨ht.1, htL.le⟩).symm |
| 95 | obtain ⟨gamma, hgamma, hmetric⟩ := |
| 96 | exists_pointwise_metric_limit_of_eventually_compact |
| 97 | (Ico (0 : ℝ) a) arc (fun s t => |s - t|) hcompact hpair |
| 98 | have hsourceZero : Tendsto (fun n => arc n 0) atTop (𝓝 p) := by |
| 99 | apply tendsto_const_nhds.congr' |
| 100 | filter_upwards [hanchor] with n hn |
| 101 | exact hn.symm |
| 102 | refine ⟨gamma, ?_, ?_, hmetric, hgamma⟩ |
| 103 | · exact tendsto_nhds_unique (hgamma 0 ⟨le_rfl, ha⟩) |
| 104 | (hsourceZero.mono_left Nat.hyperfilter_le_atTop) |
| 105 | · apply Isometry.of_dist_eq |
| 106 | intro s t |
| 107 | change dist (gamma s.1) (gamma t.1) = dist s.1 t.1 |
| 108 | simpa only [Real.dist_eq] using hmetric s.1 s.2 t.1 t.2 |
| 109 | |
| 110 | /-- Completion-triangle bounds identify the ray's exact end radius. |
| 111 | The source inequalities remain explicit geometric inputs. |
| 112 | Source: Lemma 10.16; M28 derivation 130. -/ |
| 113 | theorem finite_ray_radius_eq_of_source_bounds |
| 114 | {X : Type*} [MetricSpace X] {a : ℝ} |
| 115 | {arc : ℕ → ℝ → X} {gamma : ℝ → X} {length defect : ℕ → ℝ} |
| 116 | {r : X → ℝ} (hr : Continuous r) |
| 117 | (hlength : Tendsto length atTop (𝓝 a)) |
| 118 | (hdefect : Tendsto defect atTop (𝓝 0)) |
| 119 | (hgamma : ∀ t ∈ Ico (0 : ℝ) a, Tendsto (fun n => arc n t) |
| 120 | (hyperfilter ℕ : Filter ℕ) (𝓝 (gamma t))) |
| 121 | (hbound : ∀ t ∈ Ico (0 : ℝ) a, ∀ᶠ n in atTop, |
| 122 | a - t ≤ r (arc n t) ∧ r (arc n t) ≤ length n - t + defect n) : |
| 123 | ∀ t ∈ Ico (0 : ℝ) a, r (gamma t) = a - t := by |
| 124 | intro t ht |
| 125 | have hupper : Tendsto (fun n => length n - t + defect n) |
| 126 | atTop (𝓝 (a - t)) := by |
| 127 | simpa only [add_zero] using (hlength.sub tendsto_const_nhds).add hdefect |
| 128 | have hradius : Tendsto (fun n => r (arc n t)) atTop (𝓝 (a - t)) := |
| 129 | tendsto_of_tendsto_of_tendsto_of_le_of_le' |
| 130 | tendsto_const_nhds hupper |
| 131 | ((hbound t ht).mono fun _ hn => hn.1) |
| 132 | ((hbound t ht).mono fun _ hn => hn.2) |
| 133 | exact tendsto_nhds_unique ((hr.tendsto (gamma t)).comp (hgamma t ht)) |
| 134 | (hradius.mono_left Nat.hyperfilter_le_atTop) |