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.Jets.UniformCompactJets |
| 2 | import PoincareLib.Analysis.Calculus.SmoothCompactness.LinearPrecompose |
| 3 | |
| 4 | /-! |
| 5 | # Smooth convergence on compact subsets of an open domain |
| 6 | |
| 7 | This records actual local smoothness and convergence of every finite |
| 8 | jet. Product, differentiation and coordinate operations preserve these |
| 9 | properties. It organizes the repeated variational equations in |
| 10 | Morgan--Tian, Claim 16.6, pp. 371-372; see derivation 22. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | open Set Filter |
| 17 | open scoped ContDiff Topology |
| 18 | |
| 19 | universe u |
| 20 | |
| 21 | /-- Smooth convergence on an open domain includes eventual actual |
| 22 | smoothness near every point of each compact subset, as well as every |
| 23 | uniform finite-jet limit. -/ |
| 24 | structure CompactSmoothConvergenceOn |
| 25 | {E F ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 26 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 27 | (fseq : ι → E → F) (f : E → F) (l : Filter ι) (U : Set E) : Prop where |
| 28 | isOpen : IsOpen U |
| 29 | smooth : ContDiffOn ℝ ∞ f U |
| 30 | eventually_smooth : ∀ K : Set E, IsCompact K → K ⊆ U → |
| 31 | ∀ᶠ i in l, ∀ x ∈ K, ContDiffAt ℝ ∞ (fseq i) x |
| 32 | jets : ∀ (j : ℕ) (K : Set E), IsCompact K → K ⊆ U → |
| 33 | TendstoUniformlyOn (fun i => iteratedFDeriv ℝ j (fseq i)) (iteratedFDeriv ℝ j f) l K |
| 34 | |
| 35 | namespace CompactSmoothConvergenceOn |
| 36 | |
| 37 | variable {E F G ι : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 38 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 39 | [NormedAddCommGroup G] [NormedSpace ℝ G] |
| 40 | {l : Filter ι} {U : Set E} {fseq : ι → E → F} {f : E → F} |
| 41 | |
| 42 | /-- The zeroth jet gives ordinary compact uniform convergence. -/ |
| 43 | theorem uniformlyOn (h : CompactSmoothConvergenceOn fseq f l U) |
| 44 | {K : Set E} (hK : IsCompact K) (hKU : K ⊆ U) : TendstoUniformlyOn fseq f l K := |
| 45 | tendstoUniformlyOn_of_iteratedFDeriv_zero (h.jets 0 K hK hKU) |
| 46 | |
| 47 | /-- Smooth compact convergence restricts to any smaller open domain. -/ |
| 48 | theorem mono (h : CompactSmoothConvergenceOn fseq f l U) |
| 49 | {V : Set E} (hV : IsOpen V) (hVU : V ⊆ U) : |
| 50 | CompactSmoothConvergenceOn fseq f l V where |
| 51 | isOpen := hV |
| 52 | smooth := h.smooth.mono hVU |
| 53 | eventually_smooth K hK hKV := h.eventually_smooth K hK (hKV.trans hVU) |
| 54 | jets j K hK hKV := h.jets j K hK (hKV.trans hVU) |
| 55 | |
| 56 | /-- Equality on the open comparison domain preserves actual smoothness |
| 57 | and every compact jet limit, by equality of germs at its points. -/ |
| 58 | theorem congr (h : CompactSmoothConvergenceOn fseq f l U) |
| 59 | {gseq : ι → E → F} {g : E → F} |
| 60 | (hseq : ∀ i, EqOn (gseq i) (fseq i) U) (hmodel : EqOn g f U) : |
| 61 | CompactSmoothConvergenceOn gseq g l U where |
| 62 | isOpen := h.isOpen |
| 63 | smooth := h.smooth.congr hmodel |
| 64 | eventually_smooth K hK hKU := by |
| 65 | filter_upwards [h.eventually_smooth K hK hKU] with i hi |
| 66 | intro x hx |
| 67 | exact (hi x hx).congr_of_eventuallyEq |
| 68 | (Filter.eventuallyEq_of_mem (h.isOpen.mem_nhds (hKU hx)) (hseq i)) |
| 69 | jets j K hK hKU := by |
| 70 | apply ((h.jets j K hK hKU).congr ?_).congr_right ?_ |
| 71 | · refine Eventually.of_forall fun i x hx => ?_ |
| 72 | have heq := Filter.eventuallyEq_of_mem (h.isOpen.mem_nhds (hKU hx)) (hseq i) |
| 73 | exact (heq.iteratedFDeriv ℝ j).self_of_nhds.symm |
| 74 | · intro x hx |
| 75 | have heq := Filter.eventuallyEq_of_mem (h.isOpen.mem_nhds (hKU hx)) hmodel |
| 76 | exact (heq.iteratedFDeriv ℝ j).self_of_nhds.symm |
| 77 | |
| 78 | /-- Differentiating the actual family preserves compact smooth |
| 79 | convergence by the right currying isometry. -/ |
| 80 | theorem fderiv (h : CompactSmoothConvergenceOn fseq f l U) : |
| 81 | CompactSmoothConvergenceOn (fun i => _root_.fderiv ℝ (fseq i)) (_root_.fderiv ℝ f) l U where |
| 82 | isOpen := h.isOpen |
| 83 | smooth := h.smooth.fderiv_of_isOpen h.isOpen (by simp) |
| 84 | eventually_smooth K hK hKU := (h.eventually_smooth K hK hKU).mono |
| 85 | fun i hi x hx => (hi x hx).fderiv_right (m := ∞) (by simp) |
| 86 | jets j K hK hKU := tendstoUniformlyOn_iteratedFDeriv_fderiv (h.jets (j + 1) K hK hKU) |
| 87 | |
| 88 | /-- Pairing two families on the same domain preserves every compact |
| 89 | finite-jet limit and actual local smoothness. -/ |
| 90 | theorem prodMk (hf : CompactSmoothConvergenceOn fseq f l U) |
| 91 | {gseq : ι → E → G} {g : E → G} (hg : CompactSmoothConvergenceOn gseq g l U) : |
| 92 | CompactSmoothConvergenceOn (fun i x => (fseq i x, gseq i x)) (fun x => (f x, g x)) l U where |
| 93 | isOpen := hf.isOpen |
| 94 | smooth := hf.smooth.prodMk hg.smooth |
| 95 | eventually_smooth K hK hKU := by |
| 96 | filter_upwards [hf.eventually_smooth K hK hKU, hg.eventually_smooth K hK hKU] with i hi hgi |
| 97 | exact fun x hx => (hi x hx).prodMk (hgi x hx) |
| 98 | jets j K hK hKU := tendstoUniformlyOn_iteratedFDeriv_prodMk j |
| 99 | (fun x hx => hf.smooth.contDiffAt (hf.isOpen.mem_nhds (hKU hx))) |
| 100 | (fun x hx => hg.smooth.contDiffAt (hg.isOpen.mem_nhds (hKU hx))) |
| 101 | (hf.eventually_smooth K hK hKU) (hg.eventually_smooth K hK hKU) |
| 102 | (hf.jets j K hK hKU) (hg.jets j K hK hKU) |
| 103 | |
| 104 | /-- A fixed smooth function is its own compact smooth limit. -/ |
| 105 | theorem constant (hU : IsOpen U) (hf : ContDiffOn ℝ ∞ f U) : |
| 106 | CompactSmoothConvergenceOn (fun _ : ι => f) f l U where |
| 107 | isOpen := hU |
| 108 | smooth := hf |
| 109 | eventually_smooth K _ hKU := Eventually.of_forall |
| 110 | (fun _ x hx => hf.contDiffAt (hU.mem_nhds (hKU hx))) |
| 111 | jets _ _ _ _ := by |
| 112 | rw [Metric.tendstoUniformlyOn_iff] |
| 113 | intro epsilon hepsilon |
| 114 | exact Eventually.of_forall fun _ _ _ => by simpa only [dist_self] using hepsilon |
| 115 | |
| 116 | /-- Converging constant values give a compact smooth family: every |
| 117 | positive-order derivative is identically zero. -/ |
| 118 | theorem of_tendsto_const {a : ι → F} {b : F} (hab : Tendsto a l (𝓝 b)) (hU : IsOpen U) : |
| 119 | CompactSmoothConvergenceOn (fun i => fun _ : E => a i) (fun _ => b) l U where |
| 120 | isOpen := hU |
| 121 | smooth := contDiffOn_const |
| 122 | eventually_smooth _ _ _ := Eventually.of_forall fun _ _ _ => contDiffAt_const |
| 123 | jets j K _ _ := by |
| 124 | cases j with |
| 125 | | zero => |
| 126 | have hc := (continuousMultilinearCurryFin0 ℝ E F).symm.isometry.uniformContinuous |
| 127 | simpa only [iteratedFDeriv_zero_eq_comp, Function.comp_def] using |
| 128 | hc.comp_tendstoUniformlyOn (hab.tendstoUniformlyOn_const K) |
| 129 | | succ j => |
| 130 | simp only [iteratedFDeriv_succ_const] |
| 131 | exact tendsto_const_nhds.tendstoUniformlyOn_const K |
| 132 | |
| 133 | /-- Fixed linear precomposition preserves compact smooth convergence, |
| 134 | including noninvertible projections used in variational fields. -/ |
| 135 | theorem comp_continuousLinearMap (h : CompactSmoothConvergenceOn fseq f l U) |
| 136 | (L : G →L[ℝ] E) : |
| 137 | CompactSmoothConvergenceOn (fun i => fseq i ∘ L) (f ∘ L) l (L ⁻¹' U) where |
| 138 | isOpen := h.isOpen.preimage L.continuous |
| 139 | smooth := h.smooth.comp_continuousLinearMap L |
| 140 | eventually_smooth K hK hKU := by |
| 141 | filter_upwards [h.eventually_smooth (L '' K) (hK.image L.continuous) |
| 142 | (image_subset_iff.mpr hKU)] with i hi |
| 143 | exact fun x hx => (hi (L x) (mem_image_of_mem L hx)).comp x L.contDiff.contDiffAt |
| 144 | jets j K hK hKU := by |
| 145 | have hconv := ((h.jets j (L '' K) (hK.image L.continuous) |
| 146 | (image_subset_iff.mpr hKU)).comp L).mono (subset_preimage_image L K) |
| 147 | have hread := (ContinuousMultilinearMap.compContinuousLinearMapL |
| 148 | (F := F) (fun _ : Fin j => L)).uniformContinuous.comp_tendstoUniformlyOn hconv |
| 149 | apply (hread.congr ?_).congr_right ?_ |
| 150 | · filter_upwards [h.eventually_smooth (L '' K) (hK.image L.continuous) |
| 151 | (image_subset_iff.mpr hKU)] with i hi |
| 152 | intro x hx |
| 153 | exact (Poincare.Analysis.Calculus.iteratedFDeriv_comp_continuousLinearMap_of_contDiffAt L |
| 154 | (hi (L x) (mem_image_of_mem L hx)) j).symm |
| 155 | · intro x hx |
| 156 | exact (Poincare.Analysis.Calculus.iteratedFDeriv_comp_continuousLinearMap_of_contDiffAt L |
| 157 | (h.smooth.contDiffAt (h.isOpen.mem_nhds (hKU hx))) j).symm |
| 158 | |
| 159 | end CompactSmoothConvergenceOn |
| 160 | |
| 161 | /-- A fixed smooth outer map preserves compact smooth convergence |
| 162 | when the limiting image stays inside its open domain. -/ |
| 163 | theorem CompactSmoothConvergenceOn.comp_smooth |
| 164 | {E F G : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 165 | [NormedAddCommGroup F] [NormedSpace ℝ F] [FiniteDimensional ℝ F] |
| 166 | [NormedAddCommGroup G] [NormedSpace ℝ G] |
| 167 | {ι : Type*} {l : Filter ι} {U : Set E} {V : Set F} |
| 168 | {fseq : ι → E → F} {f : E → F} {g : F → G} |
| 169 | (h : CompactSmoothConvergenceOn fseq f l U) |
| 170 | (hV : IsOpen V) (hg : ContDiffOn ℝ ∞ g V) (hfV : MapsTo f U V) : |
| 171 | CompactSmoothConvergenceOn (fun i => g ∘ fseq i) (g ∘ f) l U where |
| 172 | isOpen := h.isOpen |
| 173 | smooth := hg.comp h.smooth hfV |
| 174 | eventually_smooth K hK hKU := by |
| 175 | have hfit := (h.uniformlyOn hK hKU).eventually_mapsTo_of_compact_image |
| 176 | (hK.image_of_continuousOn (h.smooth.continuousOn.mono hKU)) hV (fun x hx => hfV (hKU hx)) |
| 177 | filter_upwards [h.eventually_smooth K hK hKU, hfit] with i hi him |
| 178 | exact fun x hx => (hg.contDiffAt (hV.mem_nhds (him hx))).comp x (hi x hx) |
| 179 | jets j K hK hKU := tendstoUniformlyOn_iteratedFDeriv_comp_of_compact j hK hV |
| 180 | (fun x hx => h.smooth.contDiffAt (h.isOpen.mem_nhds (hKU hx))) hg |
| 181 | (fun x hx => hfV (hKU hx)) (h.eventually_smooth K hK hKU) |
| 182 | (fun m _ => h.jets m K hK hKU) |
| 183 | |
| 184 | /-- Converging continuous linear maps converge smoothly on compact |
| 185 | sets when evaluated on their spatial argument. -/ |
| 186 | theorem Filter.Tendsto.compactSmoothConvergenceOn_clm_apply |
| 187 | {E F : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 188 | [NormedAddCommGroup F] [NormedSpace ℝ F] [FiniteDimensional ℝ F] |
| 189 | {ι : Type*} {l : Filter ι} {Lseq : ι → E →L[ℝ] F} {L : E →L[ℝ] F} |
| 190 | (h : Tendsto Lseq l (𝓝 L)) : |
| 191 | CompactSmoothConvergenceOn (fun i x => Lseq i x) (fun x => L x) l univ := by |
| 192 | have hc : CompactSmoothConvergenceOn (fun i => fun _ : E => Lseq i) |
| 193 | (fun _ => L) l univ := |
| 194 | CompactSmoothConvergenceOn.of_tendsto_const h isOpen_univ |
| 195 | have hi : CompactSmoothConvergenceOn (fun _ : ι => (id : E → E)) id l univ := |
| 196 | CompactSmoothConvergenceOn.constant isOpen_univ contDiff_id.contDiffOn |
| 197 | have heval : ContDiff ℝ ∞ (fun z : (E →L[ℝ] F) × E => z.1 z.2) := |
| 198 | contDiff_fst.clm_apply contDiff_snd |
| 199 | exact (hc.prodMk hi).comp_smooth isOpen_univ heval.contDiffOn (fun _ _ => mem_univ _) |