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.StandardCap.Persistence.Analysis.Compactness.UniformCompactComposition |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Operations |
| 3 | import Mathlib.Analysis.Normed.Module.FiniteDimension |
| 4 | |
| 5 | /-! |
| 6 | # Compact convergence under the differentiated chain rule |
| 7 | |
| 8 | Compact C1 convergence is preserved by a smooth outer map on a |
| 9 | neighborhood of the limiting image. This is used for the geodesic |
| 10 | and variational operators in Morgan--Tian, Claim 16.6, pp. 371-372; |
| 11 | see `derivations/17-first-variational-convergence.md`. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set Filter Metric |
| 17 | open scoped ContDiff Topology |
| 18 | |
| 19 | /-- Pairing two uniformly convergent families with the same index |
| 20 | filter preserves uniform convergence. -/ |
| 21 | theorem TendstoUniformlyOn.prodMk_same |
| 22 | {P E F ι : Type*} [UniformSpace E] [UniformSpace F] {l : Filter ι} |
| 23 | {fseq : ι → P → E} {f : P → E} {gseq : ι → P → F} {g : P → F} {K : Set P} |
| 24 | (hf : TendstoUniformlyOn fseq f l K) (hg : TendstoUniformlyOn gseq g l K) : |
| 25 | TendstoUniformlyOn (fun i x => (fseq i x, gseq i x)) (fun x => (f x, g x)) l K := by |
| 26 | intro u hu |
| 27 | exact (tendsto_id.prodMk tendsto_id).eventually ((hf.prodMk hg) u hu) |
| 28 | |
| 29 | /-- Currying a convergent first multilinear derivative gives convergence |
| 30 | of the ordinary continuous linear derivative. -/ |
| 31 | theorem tendstoUniformlyOn_fderiv_of_iteratedFDeriv_one |
| 32 | {E F ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 33 | [NormedAddCommGroup F] [NormedSpace ℝ F] {l : Filter ι} |
| 34 | {fseq : ι → E → F} {f : E → F} {K : Set E} |
| 35 | (h : TendstoUniformlyOn (fun i => iteratedFDeriv ℝ 1 (fseq i)) |
| 36 | (iteratedFDeriv ℝ 1 f) l K) : |
| 37 | TendstoUniformlyOn (fun i => fderiv ℝ (fseq i)) (fderiv ℝ f) l K := by |
| 38 | have he (B : E → F) : |
| 39 | (fun x => continuousMultilinearCurryFin1 ℝ E F (iteratedFDeriv ℝ 1 B x)) = |
| 40 | fderiv ℝ B := by |
| 41 | funext x |
| 42 | apply ContinuousLinearMap.ext |
| 43 | intro v |
| 44 | simp [continuousMultilinearCurryFin1_apply, iteratedFDeriv_one_apply] |
| 45 | simpa only [Function.comp_def, he] using |
| 46 | (continuousMultilinearCurryFin1 ℝ E F).isometry.uniformContinuous.comp_tendstoUniformlyOn h |
| 47 | |
| 48 | /-- The right currying isometry converts convergence of order j+1 |
| 49 | into order j convergence of the derivative, without smoothness assumptions |
| 50 | on totalized derivatives outside the set in question. -/ |
| 51 | theorem tendstoUniformlyOn_iteratedFDeriv_fderiv |
| 52 | {E F ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 53 | [NormedAddCommGroup F] [NormedSpace ℝ F] {l : Filter ι} |
| 54 | {fseq : ι → E → F} {f : E → F} {K : Set E} {j : ℕ} |
| 55 | (h : TendstoUniformlyOn (fun i => iteratedFDeriv ℝ (j + 1) (fseq i)) |
| 56 | (iteratedFDeriv ℝ (j + 1) f) l K) : |
| 57 | TendstoUniformlyOn (fun i => iteratedFDeriv ℝ j (fderiv ℝ (fseq i))) |
| 58 | (iteratedFDeriv ℝ j (fderiv ℝ f)) l K := by |
| 59 | have he (B : E → F) (x : E) : |
| 60 | continuousMultilinearCurryRightEquiv' ℝ j E F (iteratedFDeriv ℝ (j + 1) B x) = |
| 61 | iteratedFDeriv ℝ j (fderiv ℝ B) x := by |
| 62 | rw [iteratedFDeriv_succ_eq_comp_right, Function.comp_apply, |
| 63 | LinearIsometryEquiv.apply_symm_apply] |
| 64 | have hc := (continuousMultilinearCurryRightEquiv' ℝ j E F).isometry.uniformContinuous |
| 65 | simpa only [Function.comp_def, he] using hc.comp_tendstoUniformlyOn h |
| 66 | |
| 67 | /-- Uniform convergence into a compact limiting image eventually puts |
| 68 | all approximate images in any open neighborhood of that image. -/ |
| 69 | theorem TendstoUniformlyOn.eventually_mapsTo_of_compact_image |
| 70 | {P E ι : Type*} [MetricSpace E] {l : Filter ι} |
| 71 | {fseq : ι → P → E} {f : P → E} {K : Set P} {U : Set E} |
| 72 | (hconv : TendstoUniformlyOn fseq f l K) |
| 73 | (hf : IsCompact (f '' K)) (hU : IsOpen U) (hfU : MapsTo f K U) : |
| 74 | ∀ᶠ i in l, MapsTo (fseq i) K U := by |
| 75 | obtain ⟨delta, hdelta, hthick⟩ := |
| 76 | hf.exists_cthickening_subset_open hU (image_subset_iff.mpr hfU) |
| 77 | filter_upwards [Metric.tendstoUniformlyOn_iff.mp hconv delta hdelta] with i hi |
| 78 | intro x hx |
| 79 | exact hthick (mem_cthickening_of_dist_le (fseq i x) (f x) delta (f '' K) |
| 80 | (mem_image_of_mem f hx) (by simpa only [dist_comm] using (hi x hx).le)) |
| 81 | |
| 82 | /-- The chain rule preserves compact uniform convergence of first |
| 83 | derivatives when the fixed outer map is C1 near the limiting image. -/ |
| 84 | theorem tendstoUniformlyOn_fderiv_comp_of_compact |
| 85 | {E F G ι : Type*} |
| 86 | [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 87 | [NormedAddCommGroup F] [NormedSpace ℝ F] [FiniteDimensional ℝ F] |
| 88 | [NormedAddCommGroup G] [NormedSpace ℝ G] |
| 89 | {l : Filter ι} {fseq : ι → E → F} {f : E → F} {g : F → G} |
| 90 | {K : Set E} {U : Set F} (hK : IsCompact K) (hU : IsOpen U) |
| 91 | (hf : ∀ x ∈ K, ContDiffAt ℝ 1 f x) (hg : ContDiffOn ℝ 1 g U) |
| 92 | (hfU : MapsTo f K U) |
| 93 | (hfseq : ∀ᶠ i in l, ∀ x ∈ K, DifferentiableAt ℝ (fseq i) x) |
| 94 | (hzero : TendstoUniformlyOn fseq f l K) |
| 95 | (hone : TendstoUniformlyOn (fun i => fderiv ℝ (fseq i)) (fderiv ℝ f) l K) : |
| 96 | TendstoUniformlyOn (fun i => fderiv ℝ (g ∘ fseq i)) (fderiv ℝ (g ∘ f)) l K := by |
| 97 | let J (x : E) := (f x, fderiv ℝ f x) |
| 98 | let Jseq (i : ι) (x : E) := (fseq i x, fderiv ℝ (fseq i) x) |
| 99 | have hfcont : ContinuousOn f K := fun x hx => (hf x hx).continuousAt.continuousWithinAt |
| 100 | have hdcont : ContinuousOn (fderiv ℝ f) K := fun x hx => |
| 101 | ((hf x hx).fderiv_right (m := 0) (by simp)).continuousAt.continuousWithinAt |
| 102 | have hJ : TendstoUniformlyOn Jseq J l K := by |
| 103 | intro u hu |
| 104 | exact (tendsto_id.prodMk tendsto_id).eventually ((hzero.prodMk hone) u hu) |
| 105 | let H (z : F × (E →L[ℝ] F)) : E →L[ℝ] G := (fderiv ℝ g z.1).comp z.2 |
| 106 | have hH : ContinuousOn H (U ×ˢ univ) := |
| 107 | ((hg.continuousOn_fderiv_of_isOpen hU le_rfl).comp continuousOn_fst |
| 108 | (fun _ hz => hz.1)).clm_comp continuousOn_snd |
| 109 | have hlim := hH.comp_tendstoUniformlyOn_of_compact_image (hU.prod isOpen_univ) |
| 110 | (hK.image_of_continuousOn (hfcont.prodMk hdcont)) |
| 111 | (fun x hx => ⟨hfU hx, mem_univ _⟩) hJ |
| 112 | have hfit := hzero.eventually_mapsTo_of_compact_image |
| 113 | (hK.image_of_continuousOn hfcont) hU hfU |
| 114 | have heq : ∀ᶠ i in l, ∀ x ∈ K, fderiv ℝ (g ∘ fseq i) x = H (Jseq i x) := by |
| 115 | filter_upwards [hfseq, hfit] with i hi him |
| 116 | intro x hx |
| 117 | exact fderiv_comp x ((hg.contDiffAt (hU.mem_nhds (him hx))).differentiableAt one_ne_zero) |
| 118 | (hi x hx) |
| 119 | have heqmodel : ∀ x ∈ K, fderiv ℝ (g ∘ f) x = H (J x) := by |
| 120 | intro x hx |
| 121 | exact fderiv_comp x ((hg.contDiffAt (hU.mem_nhds (hfU hx))).differentiableAt one_ne_zero) |
| 122 | ((hf x hx).differentiableAt one_ne_zero) |
| 123 | rw [Metric.tendstoUniformlyOn_iff] at hlim ⊢ |
| 124 | intro epsilon hepsilon |
| 125 | filter_upwards [heq, hlim epsilon hepsilon] with i hi hdist |
| 126 | intro x hx |
| 127 | rw [hi x hx, heqmodel x hx] |
| 128 | exact hdist x hx |