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.ReducedGeometry.ReducedLength.Minimum.Variation.Second.Density |
| 2 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Minimum.Variation.Second.Commutation |
| 3 | |
| 4 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Minimum.Variation.Geometry.MetricPair |
| 5 | |
| 6 | /-! |
| 7 | # Second variation on a parameter surface |
| 8 | |
| 9 | Adapted from Mapher `Proofs/M08/SecondVariationSurface.lean`, commit |
| 10 | `49331b7d7ecad38f53e4300c3b35d6a84b2cc648`. |
| 11 | These are Euclidean calculus identities used in the intrinsic second variation; |
| 12 | see Morgan--Tian, Proposition 6.43 and Claim 6.44, pp. 127-129. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | noncomputable section |
| 19 | |
| 20 | open Set Filter Topology |
| 21 | open scoped ContDiff |
| 22 | |
| 23 | namespace PoincareMT.ReducedLengthMinimum.Variation.Geometry |
| 24 | |
| 25 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 26 | |
| 27 | local instance secondVariationSurfaceDualGroup : NormedAddCommGroup (E →L[ℝ] ℝ) := |
| 28 | ContinuousLinearMap.toNormedAddCommGroup |
| 29 | local instance secondVariationSurfaceDualSpace : NormedSpace ℝ (E →L[ℝ] ℝ) := |
| 30 | ContinuousLinearMap.toNormedSpace |
| 31 | local instance secondVariationSurfaceBilinGroup : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := |
| 32 | ContinuousLinearMap.toNormedAddCommGroup |
| 33 | local instance secondVariationSurfaceBilinSpace : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := |
| 34 | ContinuousLinearMap.toNormedSpace |
| 35 | local instance secondVariationSurfaceEndGroup : NormedAddCommGroup (E →L[ℝ] E) := |
| 36 | ContinuousLinearMap.toNormedAddCommGroup |
| 37 | local instance secondVariationSurfaceEndSpace : NormedSpace ℝ (E →L[ℝ] E) := |
| 38 | ContinuousLinearMap.toNormedSpace |
| 39 | local instance secondVariationSurfaceConnectionGroup : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] E) := |
| 40 | ContinuousLinearMap.toNormedAddCommGroup |
| 41 | local instance secondVariationSurfaceConnectionSpace : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] E) := |
| 42 | ContinuousLinearMap.toNormedSpace |
| 43 | |
| 44 | theorem curveCoordinateCovariantDerivative_congr (Γ : E → E →L[ℝ] E →L[ℝ] E) |
| 45 | (q : ℝ → E) {W Z : ℝ → E} {u : ℝ} (h : W =ᶠ[𝓝 u] Z) : |
| 46 | curveCoordinateCovariantDerivative Γ q W u = |
| 47 | curveCoordinateCovariantDerivative Γ q Z u := by |
| 48 | simp only [curveCoordinateCovariantDerivative, h.deriv_eq, h.eq_of_nhds] |
| 49 | |
| 50 | theorem curveCoordinateCovariantDerivative_sliceU |
| 51 | (Γ : ℝ × E → E →L[ℝ] E →L[ℝ] E) (q W : ℝ × ℝ → E) |
| 52 | {p : ℝ × ℝ} (hq : DifferentiableAt ℝ q p) (hW : DifferentiableAt ℝ W p) : |
| 53 | curveCoordinateCovariantDerivative (fun x ↦ Γ (p.1, x)) |
| 54 | (fun u ↦ q (p.1, u)) (fun u ↦ W (p.1, u)) p.2 = |
| 55 | coordinateCovariantU Γ q W p := by |
| 56 | simp only [curveCoordinateCovariantDerivative, |
| 57 | (coordinateSlice_snd_hasDerivAt q hq).deriv, |
| 58 | (coordinateSlice_snd_hasDerivAt W hW).deriv, Prod.mk.eta, |
| 59 | coordinateCovariantU, coordinatePartialU] |
| 60 | |
| 61 | theorem curveCoordinateCovariantDerivative_sliceU_twice |
| 62 | {Ω : Set (ℝ × ℝ)} {O : Set (ℝ × E)} (hΩ : IsOpen Ω) |
| 63 | (Γ : ℝ × E → E →L[ℝ] E →L[ℝ] E) (q W : ℝ × ℝ → E) |
| 64 | (hΓ : ContDiffOn ℝ ∞ Γ O) (hq : ContDiffOn ℝ ∞ q Ω) |
| 65 | (hW : ContDiffOn ℝ ∞ W Ω) (hmap : MapsTo (fun p ↦ (p.1, q p)) Ω O) |
| 66 | {p : ℝ × ℝ} (hp : p ∈ Ω) : |
| 67 | curveCoordinateCovariantDerivative (fun x ↦ Γ (p.1, x)) (fun u ↦ q (p.1, u)) |
| 68 | (curveCoordinateCovariantDerivative (fun x ↦ Γ (p.1, x)) |
| 69 | (fun u ↦ q (p.1, u)) (fun u ↦ W (p.1, u))) p.2 = |
| 70 | coordinateCovariantU Γ q (coordinateCovariantU Γ q W) p := by |
| 71 | have heq : curveCoordinateCovariantDerivative (fun x ↦ Γ (p.1, x)) |
| 72 | (fun u ↦ q (p.1, u)) (fun u ↦ W (p.1, u)) =ᶠ[𝓝 p.2] |
| 73 | (fun u ↦ coordinateCovariantU Γ q W (p.1, u)) := by |
| 74 | have hnear := (continuous_const.prodMk continuous_id).continuousAt.preimage_mem_nhds |
| 75 | (hΩ.mem_nhds hp) |
| 76 | filter_upwards [hnear] with u hu |
| 77 | exact curveCoordinateCovariantDerivative_sliceU Γ q W |
| 78 | (((hq (p.1, u) hu).contDiffAt (hΩ.mem_nhds hu)).differentiableAt (by simp)) |
| 79 | (((hW (p.1, u) hu).contDiffAt (hΩ.mem_nhds hu)).differentiableAt (by simp)) |
| 80 | rw [curveCoordinateCovariantDerivative_congr _ _ heq] |
| 81 | exact curveCoordinateCovariantDerivative_sliceU Γ q _ |
| 82 | (((hq p hp).contDiffAt (hΩ.mem_nhds hp)).differentiableAt (by simp)) |
| 83 | ((((coordinateCovariantU_contDiffOn hΩ Γ q W hΓ hq hW hmap) p hp).contDiffAt |
| 84 | (hΩ.mem_nhds hp)).differentiableAt (by simp)) |
| 85 | |
| 86 | def coordinateCurvature (Γ : ℝ × E → E →L[ℝ] E →L[ℝ] E) |
| 87 | (z : ℝ × E) (u v w : E) : E := |
| 88 | fderiv ℝ Γ z (0, u) v w - fderiv ℝ Γ z (0, v) u w + |
| 89 | Γ z u (Γ z v w) - Γ z v (Γ z u w) |
| 90 | |
| 91 | def surfaceActionDensity (G : ℝ × E → E →L[ℝ] E →L[ℝ] ℝ) |
| 92 | (P : ℝ × E → ℝ) (q : ℝ × ℝ → E) (p : ℝ × ℝ) : ℝ := |
| 93 | G (p.1, q p) (coordinatePartialS q p) (coordinatePartialS q p) / 2 + P (p.1, q p) |
| 94 | |
| 95 | set_option maxHeartbeats 2200000 in |
| 96 | theorem surfaceActionDensity_second_hasDerivAt |
| 97 | {Ω : Set (ℝ × ℝ)} {O : Set (ℝ × E)} (hΩ : IsOpen Ω) (hO : IsOpen O) |
| 98 | (G : ℝ × E → E →L[ℝ] E →L[ℝ] ℝ) (P : ℝ × E → ℝ) |
| 99 | (Γ : ℝ × E → E →L[ℝ] E →L[ℝ] E) (q : ℝ × ℝ → E) |
| 100 | (hG : ContDiffOn ℝ ∞ G O) (hP : ContDiffOn ℝ ∞ P O) |
| 101 | (hΓ : ContDiffOn ℝ ∞ Γ O) (hq : ContDiffOn ℝ ∞ q Ω) |
| 102 | (hmap : MapsTo (fun p ↦ (p.1, q p)) Ω O) |
| 103 | (hsym : ∀ z ∈ O, ∀ v w : E, G z v w = G z w v) |
| 104 | (hcompat : ∀ z ∈ O, ∀ y v w : E, |
| 105 | fderiv ℝ (fun x ↦ G (z.1, x)) z.2 y v w = |
| 106 | G z (Γ z y v) w + G z v (Γ z y w)) |
| 107 | (htor : ∀ z ∈ O, ∀ v w : E, Γ z v w = Γ z w v) |
| 108 | {p : ℝ × ℝ} (hp : p ∈ Ω) : |
| 109 | let z := (p.1, q p) |
| 110 | let A := coordinatePartialS q p |
| 111 | let Y := coordinatePartialU q p |
| 112 | let Z := coordinateCovariantU Γ q (coordinatePartialU q) p |
| 113 | let DY := coordinateCovariantS Γ q (coordinatePartialU q) p |
| 114 | let DZ := coordinateCovariantS Γ q (coordinateCovariantU Γ q (coordinatePartialU q)) p |
| 115 | let P₀ := fun x ↦ P (p.1, x) |
| 116 | HasDerivAt (fun u ↦ deriv (fun v ↦ surfaceActionDensity G P q (p.1, v)) u) |
| 117 | (G z DZ A + G z (coordinateCurvature Γ z Y A Y) A - |
| 118 | G z (fderiv ℝ Γ z (1, 0) Y Y) A + G z DY DY + |
| 119 | (fderiv ℝ (fderiv ℝ P₀) (q p) Y Y - fderiv ℝ P₀ (q p) (Γ z Y Y)) + |
| 120 | fderiv ℝ P₀ (q p) Z) p.2 := by |
| 121 | let I := (fun u : ℝ ↦ (p.1, u)) ⁻¹' Ω |
| 122 | let U := (fun x : E ↦ (p.1, x)) ⁻¹' O |
| 123 | let A := coordinatePartialS q |
| 124 | let Y := coordinatePartialU q |
| 125 | have hI : IsOpen I := hΩ.preimage (continuous_const.prodMk continuous_id) |
| 126 | have hU : IsOpen U := hO.preimage (continuous_const.prodMk continuous_id) |
| 127 | have hpI : p.2 ∈ I := by simpa only [I, mem_preimage, Prod.mk.eta] using hp |
| 128 | have hA : ContDiffOn ℝ ∞ A Ω := coordinatePartialS_contDiffOn hΩ q hq |
| 129 | have hY : ContDiffOn ℝ ∞ Y Ω := coordinatePartialU_contDiffOn hΩ q hq |
| 130 | have hslice : MapsTo (fun u : ℝ ↦ (p.1, u)) I Ω := fun _ h ↦ h |
| 131 | have htarget : MapsTo (fun x : E ↦ (p.1, x)) U O := fun _ h ↦ h |
| 132 | have hqs : ContDiffOn ℝ ∞ (fun u ↦ q (p.1, u)) I := |
| 133 | hq.comp (contDiffOn_const.prodMk contDiffOn_id) hslice |
| 134 | have hAs : ContDiffOn ℝ ∞ (fun u ↦ A (p.1, u)) I := |
| 135 | hA.comp (contDiffOn_const.prodMk contDiffOn_id) hslice |
| 136 | have hqsmap : MapsTo (fun u ↦ q (p.1, u)) I U := fun u hu ↦ hmap hu |
| 137 | have hfixed := chart_density_second_covariant_hasDerivAt hI hU |
| 138 | (fun x ↦ G (p.1, x)) (fun x ↦ P (p.1, x)) (fun x ↦ Γ (p.1, x)) |
| 139 | (fun u ↦ q (p.1, u)) (fun u ↦ A (p.1, u)) |
| 140 | (hG.comp (contDiffOn_const.prodMk contDiffOn_id) htarget) |
| 141 | (hP.comp (contDiffOn_const.prodMk contDiffOn_id) htarget) |
| 142 | (hΓ.comp (contDiffOn_const.prodMk contDiffOn_id) htarget) hqs hAs hqsmap |
| 143 | (fun x hx ↦ hsym (p.1, x) hx) (fun x hx ↦ hcompat (p.1, x) hx) hpI |
| 144 | have hqp := ((hq p hp).contDiffAt (hΩ.mem_nhds hp)).differentiableAt (by simp) |
| 145 | have hAp := ((hA p hp).contDiffAt (hΩ.mem_nhds hp)).differentiableAt (by simp) |
| 146 | have hYp := ((hY p hp).contDiffAt (hΩ.mem_nhds hp)).differentiableAt (by simp) |
| 147 | have hfirst := curveCoordinateCovariantDerivative_sliceU Γ q A hqp hAp |
| 148 | have hsecond := curveCoordinateCovariantDerivative_sliceU_twice hΩ Γ q A hΓ hq hA hmap hp |
| 149 | have hy : deriv (fun u ↦ q (p.1, u)) =ᶠ[𝓝 p.2] (fun u ↦ Y (p.1, u)) := by |
| 150 | have hnear := (continuous_const.prodMk continuous_id).continuousAt.preimage_mem_nhds |
| 151 | (hΩ.mem_nhds hp) |
| 152 | filter_upwards [hnear] with u hu |
| 153 | exact (coordinateSlice_snd_hasDerivAt q |
| 154 | (((hq (p.1, u) hu).contDiffAt (hΩ.mem_nhds hu)).differentiableAt (by simp))).deriv |
| 155 | have hZ := (curveCoordinateCovariantDerivative_congr (fun x ↦ Γ (p.1, x)) |
| 156 | (fun u ↦ q (p.1, u)) hy).trans (curveCoordinateCovariantDerivative_sliceU Γ q Y hqp hYp) |
| 157 | rw [hfirst, hsecond, hZ, hy.eq_of_nhds] at hfixed |
| 158 | have htorp := coordinateCovariant_torsion Γ q ((hq p hp).contDiffAt (hΩ.mem_nhds hp)) |
| 159 | (htor _ (hmap hp)) |
| 160 | have hcomm := coordinateCovariant_velocity_second hΩ Γ q hq |
| 161 | (fun r hr ↦ htor _ (hmap hr)) hp |
| 162 | (((hΓ _ (hmap hp)).contDiffAt (hO.mem_nhds (hmap hp))).differentiableAt (by simp)) |
| 163 | dsimp only [A] at hfixed |
| 164 | rw [htorp, hcomm] at hfixed |
| 165 | convert hfixed using 1 <;> try rfl |
| 166 | simp only [map_add, map_sub, add_apply, sub_apply, coordinateCurvature, Prod.mk.eta] |
| 167 | ring |
| 168 | |
| 169 | end PoincareMT.ReducedLengthMinimum.Variation.Geometry |