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.Analysis.Calculus.InverseFunctionTheorem.ContDiff |
| 2 | import Mathlib.Analysis.Calculus.MeanValue |
| 3 | import Mathlib.Topology.Algebra.Support |
| 4 | |
| 5 | /-! |
| 6 | # Smooth perturbations of the identity |
| 7 | |
| 8 | A uniformly small derivative perturbation of the identity is a global smooth |
| 9 | diffeomorphism. This is the analytic correction used to patch nearby charts. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | open Set Filter |
| 14 | open scoped ContDiff Topology NNReal |
| 15 | |
| 16 | namespace Poincare.Analysis.Calculus |
| 17 | |
| 18 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 19 | |
| 20 | theorem exists_smooth_homeomorph_of_fderiv_close_id |
| 21 | {f : E → E} (hf : ContDiff ℝ ∞ f) {c : ℝ≥0} (hc : c < 1) |
| 22 | (hclose : ∀ x, ‖fderiv ℝ f x - ContinuousLinearMap.id ℝ E‖ ≤ c) : |
| 23 | ∃ e : E ≃ₜ E, (e : E → E) = f ∧ ContDiff ℝ ∞ e ∧ ContDiff ℝ ∞ e.symm := by |
| 24 | classical |
| 25 | have happ : ApproximatesLinearOn f |
| 26 | (ContinuousLinearEquiv.refl ℝ E : E →L[ℝ] E) univ c := by |
| 27 | intro x _ y _ |
| 28 | exact Convex.norm_image_sub_le_of_norm_fderiv_le' |
| 29 | (fun z _ => hf.differentiable (by simp) z) (fun z _ => hclose z) |
| 30 | convex_univ (mem_univ y) (mem_univ x) |
| 31 | have hsmall : Subsingleton E ∨ |
| 32 | c < ‖((ContinuousLinearEquiv.refl ℝ E).symm : E →L[ℝ] E)‖₊⁻¹ := by |
| 33 | rcases subsingleton_or_nontrivial E with h | h |
| 34 | · exact Or.inl h |
| 35 | · right |
| 36 | simpa using hc |
| 37 | let e := happ.toHomeomorph f hsmall |
| 38 | have he : (e : E → E) = f := rfl |
| 39 | have hinv (x : E) : ∃ A : E ≃L[ℝ] E, (A : E →L[ℝ] E) = fderiv ℝ f x := by |
| 40 | have hnorm : ‖(1 : E →L[ℝ] E) - fderiv ℝ f x‖ < 1 := by |
| 41 | rw [norm_sub_rev] |
| 42 | exact (hclose x).trans_lt hc |
| 43 | have hu : IsUnit (fderiv ℝ f x) := by |
| 44 | simpa only [sub_sub_cancel] using isUnit_one_sub_of_norm_lt_one hnorm |
| 45 | exact ⟨ContinuousLinearEquiv.ofUnit hu.unit, hu.unit_spec⟩ |
| 46 | choose A hA using hinv |
| 47 | refine ⟨e, he, he ▸ hf, e.contDiff_symm (f₀' := A) ?_ (he ▸ hf)⟩ |
| 48 | intro x |
| 49 | rw [hA x, he] |
| 50 | exact (hf.differentiable (by simp) x).hasFDerivAt |
| 51 | |
| 52 | omit [CompleteSpace E] in |
| 53 | private theorem cutoff_smul_eventually_zero {χ : E → ℝ} {f : E → E} {x : E} |
| 54 | (hx : x ∉ tsupport χ) : (fun y => χ y • f y) =ᶠ[𝓝 x] 0 := by |
| 55 | filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hx] with y hy |
| 56 | simp only [Pi.zero_apply] at hy ⊢ |
| 57 | rw [hy, zero_smul] |
| 58 | |
| 59 | omit [CompleteSpace E] in |
| 60 | theorem contDiff_cutoff_perturbation_of_contDiffAt |
| 61 | {χ : E → ℝ} (hχ : ContDiff ℝ ∞ χ) {f : E → E} |
| 62 | (hf : ∀ x ∈ tsupport χ, ContDiffAt ℝ ∞ f x) : |
| 63 | ContDiff ℝ ∞ (fun x => x + χ x • (f x - x)) := by |
| 64 | apply contDiff_iff_contDiffAt.mpr |
| 65 | intro x |
| 66 | by_cases hx : x ∈ tsupport χ |
| 67 | · exact contDiffAt_id.add (hχ.contDiffAt.smul ((hf x hx).sub contDiffAt_id)) |
| 68 | · apply contDiffAt_id.add |
| 69 | exact contDiffAt_const.congr_of_eventuallyEq (cutoff_smul_eventually_zero hx) |
| 70 | |
| 71 | omit [CompleteSpace E] in |
| 72 | theorem contDiff_cutoff_perturbation |
| 73 | {U : Set E} (hU : IsOpen U) {χ : E → ℝ} (hχ : ContDiff ℝ ∞ χ) |
| 74 | (hχU : tsupport χ ⊆ U) {f : E → E} (hf : ContDiffOn ℝ ∞ f U) : |
| 75 | ContDiff ℝ ∞ (fun x => x + χ x • (f x - x)) := by |
| 76 | exact contDiff_cutoff_perturbation_of_contDiffAt hχ |
| 77 | (fun _ hx => hf.contDiffAt (hU.mem_nhds (hχU hx))) |
| 78 | |
| 79 | omit [CompleteSpace E] in |
| 80 | theorem norm_fderiv_cutoff_perturbation_sub_id_le |
| 81 | {χ : E → ℝ} {f : E → E} {x : E} |
| 82 | (hχ : DifferentiableAt ℝ χ x) (hf : DifferentiableAt ℝ f x) : |
| 83 | ‖fderiv ℝ (fun y => y + χ y • (f y - y)) x - ContinuousLinearMap.id ℝ E‖ ≤ |
| 84 | ‖χ x‖ * ‖fderiv ℝ f x - ContinuousLinearMap.id ℝ E‖ + |
| 85 | ‖fderiv ℝ χ x‖ * ‖f x - x‖ := by |
| 86 | have hd := (hasFDerivAt_id x).add |
| 87 | (hχ.hasFDerivAt.smul (hf.hasFDerivAt.sub (hasFDerivAt_id x))) |
| 88 | change HasFDerivAt (fun y => y + χ y • (f y - y)) |
| 89 | (ContinuousLinearMap.id ℝ E + |
| 90 | (χ x • (fderiv ℝ f x - ContinuousLinearMap.id ℝ E) + |
| 91 | (fderiv ℝ χ x).smulRight (f x - x))) x at hd |
| 92 | rw [hd.fderiv, add_sub_cancel_left] |
| 93 | exact (norm_add_le _ _).trans_eq (by rw [norm_smul, ContinuousLinearMap.norm_smulRight_apply]) |
| 94 | |
| 95 | /-- A local coordinate perturbation tending to the identity in value and first |
| 96 | derivative extends, through a fixed cutoff, to global smooth diffeomorphisms. -/ |
| 97 | theorem eventually_exists_cutoff_diffeomorphism_of_contDiffAt |
| 98 | {χ : E → ℝ} (hχ : ContDiff ℝ ∞ χ) (hχcompact : HasCompactSupport χ) |
| 99 | {f : ℕ → E → E} (hf : ∀ᶠ k in atTop, ∀ x ∈ tsupport χ, ContDiffAt ℝ ∞ (f k) x) |
| 100 | (hzero : TendstoUniformlyOn f id atTop (tsupport χ)) |
| 101 | (hone : TendstoUniformlyOn (fun k => fderiv ℝ (f k)) |
| 102 | (fun _ => ContinuousLinearMap.id ℝ E) atTop (tsupport χ)) : |
| 103 | ∀ᶠ k in atTop, ∃ e : E ≃ₜ E, |
| 104 | (∀ x, e x = x + χ x • (f k x - x)) ∧ |
| 105 | ContDiff ℝ ∞ e ∧ ContDiff ℝ ∞ e.symm ∧ |
| 106 | (∀ x, χ x = 1 → e x = f k x) ∧ (∀ x, x ∉ tsupport χ → e x = x) := by |
| 107 | obtain ⟨B₀, hB₀⟩ := hχcompact.isCompact.exists_bound_of_continuousOn hχ.continuous.continuousOn |
| 108 | obtain ⟨B₁, hB₁⟩ := hχcompact.isCompact.exists_bound_of_continuousOn |
| 109 | (hχ.continuous_fderiv (by simp)).continuousOn |
| 110 | let B := max B₀ 0 + max B₁ 0 + 1 |
| 111 | have hB : 0 < B := by dsimp [B]; positivity |
| 112 | let ε := 1 / (4 * B) |
| 113 | have hε : 0 < ε := by dsimp [ε]; positivity |
| 114 | have hεB : B * ε = 1 / 4 := by dsimp [ε]; field_simp |
| 115 | filter_upwards [hf, Metric.tendstoUniformlyOn_iff.mp hzero ε hε, |
| 116 | Metric.tendstoUniformlyOn_iff.mp hone ε hε] with k hk hk₀ hk₁ |
| 117 | have hclose (x : E) : |
| 118 | ‖fderiv ℝ (fun y => y + χ y • (f k y - y)) x - ContinuousLinearMap.id ℝ E‖ ≤ |
| 119 | (1 / 2 : ℝ≥0) := by |
| 120 | by_cases hx : x ∈ tsupport χ |
| 121 | · have hfx := (hk x hx).differentiableAt (by simp) |
| 122 | have h₀ : ‖f k x - x‖ < ε := by simpa only [id_eq, dist_eq_norm, norm_sub_rev] using hk₀ x hx |
| 123 | have h₁ : ‖fderiv ℝ (f k) x - ContinuousLinearMap.id ℝ E‖ < ε := by |
| 124 | simpa only [dist_eq_norm, norm_sub_rev] using hk₁ x hx |
| 125 | have hbound := norm_fderiv_cutoff_perturbation_sub_id_le |
| 126 | (hχ.differentiable (by simp) x) hfx |
| 127 | have ha : ‖χ x‖ ≤ max B₀ 0 := (hB₀ x hx).trans (le_max_left _ _) |
| 128 | have hb : ‖fderiv ℝ χ x‖ ≤ max B₁ 0 := (hB₁ x hx).trans (le_max_left _ _) |
| 129 | have ha' := mul_le_mul ha h₁.le (norm_nonneg _) (le_max_right B₀ 0) |
| 130 | have hb' := mul_le_mul hb h₀.le (norm_nonneg _) (le_max_right B₁ 0) |
| 131 | have hsum : max B₀ 0 * ε + max B₁ 0 * ε ≤ B * ε := by |
| 132 | dsimp [B] |
| 133 | nlinarith |
| 134 | norm_num only [NNReal.coe_div, NNReal.coe_one, NNReal.coe_ofNat] at ⊢ |
| 135 | linarith |
| 136 | · have heq : (fun y => y + χ y • (f k y - y)) =ᶠ[𝓝 x] id := by |
| 137 | filter_upwards [cutoff_smul_eventually_zero (f := fun y => f k y - y) hx] with y hy |
| 138 | simp only [Pi.zero_apply] at hy |
| 139 | simp only [hy, add_zero, id_eq] |
| 140 | rw [heq.fderiv_eq, fderiv_id, sub_self, norm_zero] |
| 141 | positivity |
| 142 | obtain ⟨e, he, hes, hei⟩ := exists_smooth_homeomorph_of_fderiv_close_id |
| 143 | (contDiff_cutoff_perturbation_of_contDiffAt hχ hk) (by norm_num : (1 / 2 : ℝ≥0) < 1) hclose |
| 144 | refine ⟨e, fun x => congrFun he x, hes, hei, ?_, ?_⟩ |
| 145 | · intro x hx |
| 146 | simp only [he, hx, one_smul, add_sub_cancel] |
| 147 | · intro x hx |
| 148 | have hz := (cutoff_smul_eventually_zero (f := fun y => f k y - y) hx).self_of_nhds |
| 149 | simp only [he, hz, Pi.zero_apply, add_zero] |
| 150 | |
| 151 | theorem eventually_exists_cutoff_diffeomorphism |
| 152 | {U : Set E} (hU : IsOpen U) {χ : E → ℝ} (hχ : ContDiff ℝ ∞ χ) |
| 153 | (hχcompact : HasCompactSupport χ) (hχU : tsupport χ ⊆ U) |
| 154 | {f : ℕ → E → E} (hf : ∀ᶠ k in atTop, ContDiffOn ℝ ∞ (f k) U) |
| 155 | (hzero : TendstoUniformlyOn f id atTop (tsupport χ)) |
| 156 | (hone : TendstoUniformlyOn (fun k => fderiv ℝ (f k)) |
| 157 | (fun _ => ContinuousLinearMap.id ℝ E) atTop (tsupport χ)) : |
| 158 | ∀ᶠ k in atTop, ∃ e : E ≃ₜ E, |
| 159 | (∀ x, e x = x + χ x • (f k x - x)) ∧ |
| 160 | ContDiff ℝ ∞ e ∧ ContDiff ℝ ∞ e.symm ∧ |
| 161 | (∀ x, χ x = 1 → e x = f k x) ∧ (∀ x, x ∉ tsupport χ → e x = x) := |
| 162 | eventually_exists_cutoff_diffeomorphism_of_contDiffAt hχ hχcompact |
| 163 | (hf.mono fun _ hk _ hx => hk.contDiffAt (hU.mem_nhds (hχU hx))) hzero hone |
| 164 | |
| 165 | omit [CompleteSpace E] in |
| 166 | theorem eventually_contDiffAt_on_compact_of_locally_eventually_smooth |
| 167 | {Ω K : Set E} {f : ℕ → E → E} (hK : IsCompact K) (hKΩ : K ⊆ Ω) |
| 168 | (hlocal : ∀ x ∈ Ω, ∃ V : Set E, IsOpen V ∧ x ∈ V ∧ |
| 169 | ∀ᶠ k in atTop, ContDiffOn ℝ ∞ (f k) V) : |
| 170 | ∀ᶠ k in atTop, ∀ x ∈ K, ContDiffAt ℝ ∞ (f k) x := by |
| 171 | refine hK.induction_on (p := fun S => ∀ᶠ k in atTop, |
| 172 | ∀ x ∈ S, ContDiffAt ℝ ∞ (f k) x) ?_ ?_ ?_ ?_ |
| 173 | · exact Eventually.of_forall (by simp) |
| 174 | · intro S T hST hT |
| 175 | exact hT.mono fun _ hk x hx => hk x (hST hx) |
| 176 | · intro S T hS hT |
| 177 | filter_upwards [hS, hT] with k hkS hkT x hx |
| 178 | exact hx.elim (hkS x) (hkT x) |
| 179 | · intro x hx |
| 180 | obtain ⟨V, hV, hxV, hVsmooth⟩ := hlocal x (hKΩ hx) |
| 181 | exact ⟨V, mem_nhdsWithin_of_mem_nhds (hV.mem_nhds hxV), |
| 182 | hVsmooth.mono fun _ hk _ hy => hk.contDiffAt (hV.mem_nhds hy)⟩ |
| 183 | |
| 184 | /-- The inverse limiting transition turns a convergent family of local |
| 185 | transitions into a perturbation of the identity on the cutoff support. -/ |
| 186 | theorem eventually_exists_local_transition_correction |
| 187 | {U V : Set E} (hU : IsOpen U) (hV : IsOpen V) |
| 188 | {f g : E → E} (hf : ContDiffOn ℝ ∞ f U) (hg : ContDiffOn ℝ ∞ g V) |
| 189 | (hgU : MapsTo g V U) (hfg : EqOn (f ∘ g) id V) |
| 190 | {fseq : ℕ → E → E} |
| 191 | (hlocal : ∀ x ∈ U, ∃ W : Set E, IsOpen W ∧ x ∈ W ∧ |
| 192 | ∀ᶠ k in atTop, ContDiffOn ℝ ∞ (fseq k) W) |
| 193 | (hzero : ∀ K, IsCompact K → K ⊆ U → TendstoUniformlyOn fseq f atTop K) |
| 194 | (hone : ∀ K, IsCompact K → K ⊆ U → TendstoUniformlyOn |
| 195 | (fun k => fderiv ℝ (fseq k)) (fderiv ℝ f) atTop K) |
| 196 | {χ : E → ℝ} (hχ : ContDiff ℝ ∞ χ) (hχcompact : HasCompactSupport χ) |
| 197 | (hχV : tsupport χ ⊆ V) : |
| 198 | ∀ᶠ k in atTop, ∃ e : E ≃ₜ E, |
| 199 | (∀ x, e x = x + χ x • (fseq k (g x) - x)) ∧ |
| 200 | ContDiff ℝ ∞ e ∧ ContDiff ℝ ∞ e.symm ∧ |
| 201 | (∀ x, χ x = 1 → e x = fseq k (g x)) ∧ |
| 202 | (∀ x, x ∉ tsupport χ → e x = x) ∧ e '' V = V := by |
| 203 | have hK := hχcompact.isCompact.image_of_continuousOn (hg.continuousOn.mono hχV) |
| 204 | have hKU : g '' tsupport χ ⊆ U := image_subset_iff.mpr (fun _ hx => hgU (hχV hx)) |
| 205 | have hs := eventually_contDiffAt_on_compact_of_locally_eventually_smooth hK hKU hlocal |
| 206 | have hscomp : ∀ᶠ k in atTop, ∀ x ∈ tsupport χ, ContDiffAt ℝ ∞ (fseq k ∘ g) x := |
| 207 | hs.mono fun _ hk x hx => (hk _ (mem_image_of_mem g hx)).comp x |
| 208 | (hg.contDiffAt (hV.mem_nhds (hχV hx))) |
| 209 | have hz : TendstoUniformlyOn (fun k => fseq k ∘ g) id atTop (tsupport χ) := |
| 210 | (((hzero _ hK hKU).comp g).mono (subset_preimage_image g (tsupport χ))).congr_right |
| 211 | (hfg.mono hχV) |
| 212 | obtain ⟨B, hB⟩ := hχcompact.isCompact.exists_bound_of_continuousOn |
| 213 | ((hg.continuousOn_fderiv_of_isOpen hV (by simp)).mono hχV) |
| 214 | have ho : TendstoUniformlyOn (fun k => fderiv ℝ (fseq k ∘ g)) |
| 215 | (fun _ => ContinuousLinearMap.id ℝ E) atTop (tsupport χ) := by |
| 216 | apply Metric.tendstoUniformlyOn_iff.mpr |
| 217 | intro ε hε |
| 218 | have hden : 0 < max B 0 + 1 := by positivity |
| 219 | have hε' : 0 < ε / (max B 0 + 1) := div_pos hε hden |
| 220 | filter_upwards [hs, Metric.tendstoUniformlyOn_iff.mp (hone _ hK hKU) _ hε'] |
| 221 | with k hk hsmall x hx |
| 222 | have hgx := (hg.contDiffAt (hV.mem_nhds (hχV hx))).differentiableAt (by simp) |
| 223 | have hfx := (hf.contDiffAt (hU.mem_nhds (hgU (hχV hx)))).differentiableAt (by simp) |
| 224 | have heq : f ∘ g =ᶠ[𝓝 x] id := by |
| 225 | filter_upwards [hV.mem_nhds (hχV hx)] with y hy |
| 226 | exact hfg hy |
| 227 | have hder : (fderiv ℝ f (g x)).comp (fderiv ℝ g x) = ContinuousLinearMap.id ℝ E := by |
| 228 | rw [← fderiv_comp x hfx hgx, heq.fderiv_eq, fderiv_id] |
| 229 | rw [dist_eq_norm, norm_sub_rev, |
| 230 | fderiv_comp x ((hk _ (mem_image_of_mem g hx)).differentiableAt (by simp)) hgx, |
| 231 | ← hder, ← ContinuousLinearMap.sub_comp] |
| 232 | have hd : ‖fderiv ℝ (fseq k) (g x) - fderiv ℝ f (g x)‖ < ε / (max B 0 + 1) := by |
| 233 | simpa only [dist_eq_norm, norm_sub_rev] using hsmall _ (mem_image_of_mem g hx) |
| 234 | have hb : ‖fderiv ℝ g x‖ ≤ max B 0 := (hB x hx).trans (le_max_left _ _) |
| 235 | calc |
| 236 | _ ≤ ‖fderiv ℝ (fseq k) (g x) - fderiv ℝ f (g x)‖ * ‖fderiv ℝ g x‖ := |
| 237 | ContinuousLinearMap.opNorm_comp_le _ _ |
| 238 | _ ≤ ‖fderiv ℝ (fseq k) (g x) - fderiv ℝ f (g x)‖ * (max B 0 + 1) := by |
| 239 | gcongr |
| 240 | linarith |
| 241 | _ < ε := (lt_div_iff₀ hden).mp hd |
| 242 | filter_upwards [eventually_exists_cutoff_diffeomorphism_of_contDiffAt |
| 243 | hχ hχcompact hscomp hz ho] with k hk |
| 244 | obtain ⟨e, he, hes, hei, heone, hefix⟩ := hk |
| 245 | refine ⟨e, he, hes, hei, heone, hefix, ?_⟩ |
| 246 | ext y |
| 247 | constructor |
| 248 | · rintro ⟨x, hx, rfl⟩ |
| 249 | by_contra hy |
| 250 | have heey := hefix (e x) (fun h => hy (hχV h)) |
| 251 | have hxy := e.injective heey |
| 252 | exact hy (hxy.symm ▸ hx) |
| 253 | · intro hy |
| 254 | refine ⟨e.symm y, ?_, e.apply_symm_apply y⟩ |
| 255 | by_contra hx |
| 256 | have hey := hefix (e.symm y) (fun h => hx (hχV h)) |
| 257 | rw [e.apply_symm_apply] at hey |
| 258 | exact hx (hey ▸ hy) |
| 259 | |
| 260 | end Poincare.Analysis.Calculus |