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.Analysis.ODE.LocalFlow.Smooth |
| 2 | import Mathlib.Analysis.Calculus.InverseFunctionTheorem.ContDiff |
| 3 | import Mathlib.Analysis.InnerProductSpace.PiL2 |
| 4 | |
| 5 | /-! |
| 6 | # Smooth planar flow boxes |
| 7 | |
| 8 | A nonzero smooth vector field admits local coordinates in which the second |
| 9 | coordinate is flow time. These local transverse sections support the planar |
| 10 | nontrapping argument used in Smale, Diffeomorphisms of the 2-sphere (1959), |
| 11 | Lemma 2, printed p. 622. |
| 12 | -/ |
| 13 | |
| 14 | noncomputable section |
| 15 | |
| 16 | namespace Poincare.ODE.LocalFlow |
| 17 | |
| 18 | open Set Filter |
| 19 | open scoped ContDiff Topology |
| 20 | |
| 21 | private theorem exists_flowBox_of_transverse_equiv |
| 22 | {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | [FiniteDimensional ℝ E] [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 24 | [FiniteDimensional ℝ F] |
| 25 | {U : Set E} (hU : IsOpen U) {V : E → E} (hV : ContDiffOn ℝ ∞ V U) |
| 26 | {p : E} (hp : p ∈ U) (A : (F × ℝ) ≃L[ℝ] E) (hA : A (0, 1) = V p) : |
| 27 | ∃ e : OpenPartialHomeomorph (F × ℝ) E, |
| 28 | (0, 0) ∈ e.source ∧ e (0, 0) = p ∧ e.target ⊆ U ∧ |
| 29 | ContDiffOn ℝ ∞ e e.source ∧ ContDiffOn ℝ ∞ e.symm e.target ∧ |
| 30 | (∀ s, (s, 0) ∈ e.source → e (s, 0) = p + A (s, 0)) ∧ |
| 31 | ∀ s t, (s, t) ∈ e.source → |
| 32 | HasDerivAt (fun r => e (s, r)) (V (e (s, t))) t := by |
| 33 | obtain ⟨W, δ, Φ, hW, hpW, _, hδ, hΦ, hinit, hmaps, hderiv⟩ := |
| 34 | exists_smooth_localFlow hU hV hp |
| 35 | let B : F × ℝ → E × ℝ := fun z => (p + A (z.1, 0), z.2) |
| 36 | let f : F × ℝ → E := fun z => Φ (B z) |
| 37 | let D : Set (F × ℝ) := B ⁻¹' (W ×ˢ Ioo (-δ) δ) |
| 38 | have hB : ContDiff ℝ ∞ B := |
| 39 | (contDiff_const.add (A.contDiff.comp (contDiff_fst.prodMk contDiff_const))).prodMk |
| 40 | contDiff_snd |
| 41 | have hD : IsOpen D := (hW.prod isOpen_Ioo).preimage hB.continuous |
| 42 | have hA0 : A (0, 0) = 0 := map_zero A |
| 43 | have h0D : (0, 0) ∈ D := by |
| 44 | change (p + A (0, 0), (0 : ℝ)) ∈ W ×ˢ Ioo (-δ) δ |
| 45 | rw [hA0, add_zero] |
| 46 | exact ⟨hpW, by linarith, hδ⟩ |
| 47 | have hf : ContDiffOn ℝ ∞ f D := hΦ.comp hB.contDiffOn (fun _ h => h) |
| 48 | have hf0 : ContDiffAt ℝ ∞ f (0, 0) := hf.contDiffAt (hD.mem_nhds h0D) |
| 49 | have hfzero : f (0, 0) = p := by |
| 50 | simpa [f, B, hA0] using hinit p hpW |
| 51 | have hleft : (fun s : F => f (s, 0)) =ᶠ[𝓝 0] (fun s => p + A (s, 0)) := by |
| 52 | have ht : Tendsto (fun s : F => (s, (0 : ℝ))) (𝓝 0) (𝓝 (0, 0)) := by |
| 53 | exact (continuous_id.prodMk continuous_const).continuousAt |
| 54 | filter_upwards [ht.eventually (hD.mem_nhds h0D)] with s hs |
| 55 | exact hinit _ hs.1 |
| 56 | have hdleft : HasFDerivAt (fun s : F => f (s, 0)) |
| 57 | (A.toContinuousLinearMap.comp (ContinuousLinearMap.inl ℝ F ℝ)) 0 := |
| 58 | ((A.toContinuousLinearMap.comp (ContinuousLinearMap.inl ℝ F ℝ)).hasFDerivAt.const_add p) |
| 59 | |>.congr_of_eventuallyEq hleft |
| 60 | have hdright : HasDerivAt (fun t : ℝ => f (0, t)) (V p) 0 := by |
| 61 | simpa [f, B, hA0, hinit p hpW] using hderiv p hpW 0 h0D.2 |
| 62 | have hd : HasFDerivAt f A.toContinuousLinearMap (0, 0) := by |
| 63 | have hdf := (hf0.differentiableAt (by simp)).hasFDerivAt |
| 64 | have heq : fderiv ℝ f (0, 0) = A.toContinuousLinearMap := by |
| 65 | apply ContinuousLinearMap.prod_ext |
| 66 | · have hc : HasFDerivAt (fun s : F => f (s, 0)) |
| 67 | ((fderiv ℝ f (0, 0)).comp (ContinuousLinearMap.inl ℝ F ℝ)) 0 := |
| 68 | hdf.comp (f := fun s : F => (s, (0 : ℝ))) (0 : F) |
| 69 | (hasFDerivAt_prodMk_left (0 : F) (0 : ℝ)) |
| 70 | exact hc.unique hdleft |
| 71 | · have he := (hdf.comp (0 : ℝ) (hasFDerivAt_prodMk_right (0 : F) (0 : ℝ))).unique |
| 72 | hdright.hasFDerivAt |
| 73 | rw [he] |
| 74 | apply ContinuousLinearMap.ext |
| 75 | intro t |
| 76 | change t • V p = A (0, t) |
| 77 | rw [← hA, ← map_smul] |
| 78 | simp |
| 79 | rwa [heq] at hdf |
| 80 | let Q := hf0.toOpenPartialHomeomorph f hd (by simp) |
| 81 | let N : Set (F × ℝ) := D ∩ (fderiv ℝ f) ⁻¹' |
| 82 | range ((↑) : ((F × ℝ) ≃L[ℝ] E) → (F × ℝ) →L[ℝ] E) |
| 83 | have hN : IsOpen N := |
| 84 | (hf.continuousOn_fderiv_of_isOpen hD (by simp)).isOpen_inter_preimage hD |
| 85 | ContinuousLinearEquiv.isOpen |
| 86 | have h0N : (0, 0) ∈ N := ⟨h0D, A, hd.fderiv.symm⟩ |
| 87 | let e := Q.restrOpen N hN |
| 88 | have hsource : e.source ⊆ D := fun _ h => h.2.1 |
| 89 | have hecoe : (e : F × ℝ → E) = f := rfl |
| 90 | refine ⟨e, ⟨hf0.mem_toOpenPartialHomeomorph_source hd (by simp), h0N⟩, |
| 91 | hfzero, ?_, hf.mono hsource, ?_, ?_, ?_⟩ |
| 92 | · intro y hy |
| 93 | have hx := hsource (e.map_target hy) |
| 94 | have hm := hmaps _ hx.1 _ hx.2 |
| 95 | change f (e.symm y) ∈ U at hm |
| 96 | simpa only [← hecoe, e.right_inv hy] using hm |
| 97 | · intro y hy |
| 98 | have hx := e.map_target hy |
| 99 | obtain ⟨C, hC⟩ := hx.2.2 |
| 100 | have hfat := hf.contDiffAt (hD.mem_nhds (hsource hx)) |
| 101 | apply (e.contDiffAt_symm hy (f₀' := C) ?_ hfat).contDiffWithinAt |
| 102 | rw [hecoe, hC] |
| 103 | exact (hfat.differentiableAt (by simp)).hasFDerivAt |
| 104 | · intro s hs |
| 105 | exact hinit _ (hsource hs).1 |
| 106 | · intro s t hst |
| 107 | exact hderiv _ (hsource hst).1 _ (hsource hst).2 |
| 108 | |
| 109 | private theorem exists_planar_transverse_equiv |
| 110 | (v : EuclideanSpace ℝ (Fin 2)) (hv : v ≠ 0) : |
| 111 | ∃ A : (ℝ × ℝ) ≃L[ℝ] EuclideanSpace ℝ (Fin 2), A (0, 1) = v := by |
| 112 | let w : EuclideanSpace ℝ (Fin 2) := !₂[-v 1, v 0] |
| 113 | let L : (ℝ × ℝ) →ₗ[ℝ] EuclideanSpace ℝ (Fin 2) := { |
| 114 | toFun := fun z => z.1 • w + z.2 • v |
| 115 | map_add' := by intro a b; simp only [Prod.fst_add, Prod.snd_add, add_smul]; abel |
| 116 | map_smul' := by intro c a; simp [smul_add, mul_smul] } |
| 117 | have hn : v 0 ^ 2 + v 1 ^ 2 ≠ 0 := by |
| 118 | intro h |
| 119 | apply hv |
| 120 | ext i |
| 121 | fin_cases i |
| 122 | · change v 0 = 0 |
| 123 | exact sq_eq_zero_iff.mp (by nlinarith [sq_nonneg (v 1)]) |
| 124 | · change v 1 = 0 |
| 125 | exact sq_eq_zero_iff.mp (by nlinarith [sq_nonneg (v 0)]) |
| 126 | have hker : ∀ z, L z = 0 → z = 0 := by |
| 127 | rintro ⟨s, t⟩ hz |
| 128 | have h0 := congrArg (fun x : EuclideanSpace ℝ (Fin 2) => x 0) hz |
| 129 | have h1 := congrArg (fun x : EuclideanSpace ℝ (Fin 2) => x 1) hz |
| 130 | change s * (-v 1) + t * v 0 = 0 at h0 |
| 131 | change s * v 0 + t * v 1 = 0 at h1 |
| 132 | have hs : s * (v 0 ^ 2 + v 1 ^ 2) = 0 := by |
| 133 | linear_combination v 0 * h1 - v 1 * h0 |
| 134 | have ht : t * (v 0 ^ 2 + v 1 ^ 2) = 0 := by |
| 135 | linear_combination v 0 * h0 + v 1 * h1 |
| 136 | exact Prod.ext ((mul_eq_zero.mp hs).resolve_right hn) ((mul_eq_zero.mp ht).resolve_right hn) |
| 137 | have hi : Function.Injective L := by |
| 138 | intro x y hxy |
| 139 | apply sub_eq_zero.mp |
| 140 | apply hker |
| 141 | rw [map_sub, hxy, sub_self] |
| 142 | let A := (LinearEquiv.ofInjectiveOfFinrankEq L hi (by simp [Module.finrank_prod])).toContinuousLinearEquiv |
| 143 | refine ⟨A, ?_⟩ |
| 144 | change L (0, 1) = v |
| 145 | simp [L] |
| 146 | |
| 147 | /-- Near a point where a smooth planar vector field is nonzero, there are |
| 148 | smooth coordinates whose second-coordinate curves solve the vector field. |
| 149 | The chart and its inverse are smooth throughout their open domains. -/ |
| 150 | theorem exists_smooth_planar_flowBox |
| 151 | {U : Set (EuclideanSpace ℝ (Fin 2))} (hU : IsOpen U) |
| 152 | {V : EuclideanSpace ℝ (Fin 2) → EuclideanSpace ℝ (Fin 2)} |
| 153 | (hV : ContDiffOn ℝ ∞ V U) {p : EuclideanSpace ℝ (Fin 2)} |
| 154 | (hp : p ∈ U) (hne : V p ≠ 0) : |
| 155 | ∃ e : OpenPartialHomeomorph (ℝ × ℝ) (EuclideanSpace ℝ (Fin 2)), |
| 156 | (0, 0) ∈ e.source ∧ e (0, 0) = p ∧ e.target ⊆ U ∧ |
| 157 | ContDiffOn ℝ ∞ e e.source ∧ ContDiffOn ℝ ∞ e.symm e.target ∧ |
| 158 | ∀ s t, (s, t) ∈ e.source → |
| 159 | HasDerivAt (fun r => e (s, r)) (V (e (s, t))) t := by |
| 160 | obtain ⟨A, hA⟩ := exists_planar_transverse_equiv (V p) hne |
| 161 | obtain ⟨e, h0, he0, htarget, he, hi, _, ht⟩ := |
| 162 | exists_flowBox_of_transverse_equiv hU hV hp A hA |
| 163 | exact ⟨e, h0, he0, htarget, he, hi, ht⟩ |
| 164 | |
| 165 | end Poincare.ODE.LocalFlow |