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.Coordinates |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 3 | |
| 4 | /-! |
| 5 | # Second derivative of the coordinate action density |
| 6 | |
| 7 | Adapted from Mapher `Proofs/M08/SecondVariationDensity.lean`, commit |
| 8 | `49331b7d7ecad38f53e4300c3b35d6a84b2cc648`. |
| 9 | These are Euclidean calculus identities used in the intrinsic second variation; |
| 10 | see Morgan--Tian, Proposition 6.43 and Claim 6.44, pp. 127-129. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | noncomputable section |
| 17 | |
| 18 | open Set Filter Topology |
| 19 | open scoped ContDiff |
| 20 | |
| 21 | namespace PoincareMT.ReducedLengthMinimum.Variation.Geometry |
| 22 | |
| 23 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 24 | |
| 25 | local instance secondVariationDensityDualGroup : NormedAddCommGroup (E →L[ℝ] ℝ) := |
| 26 | ContinuousLinearMap.toNormedAddCommGroup |
| 27 | local instance secondVariationDensityDualSpace : NormedSpace ℝ (E →L[ℝ] ℝ) := |
| 28 | ContinuousLinearMap.toNormedSpace |
| 29 | local instance secondVariationDensityBilinGroup : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] ℝ) := |
| 30 | ContinuousLinearMap.toNormedAddCommGroup |
| 31 | local instance secondVariationDensityBilinSpace : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] ℝ) := |
| 32 | ContinuousLinearMap.toNormedSpace |
| 33 | local instance secondVariationDensityEndGroup : NormedAddCommGroup (E →L[ℝ] E) := |
| 34 | ContinuousLinearMap.toNormedAddCommGroup |
| 35 | local instance secondVariationDensityEndSpace : NormedSpace ℝ (E →L[ℝ] E) := |
| 36 | ContinuousLinearMap.toNormedSpace |
| 37 | local instance secondVariationDensityConnectionGroup : NormedAddCommGroup (E →L[ℝ] E →L[ℝ] E) := |
| 38 | ContinuousLinearMap.toNormedAddCommGroup |
| 39 | local instance secondVariationDensityConnectionSpace : NormedSpace ℝ (E →L[ℝ] E →L[ℝ] E) := |
| 40 | ContinuousLinearMap.toNormedSpace |
| 41 | |
| 42 | def curveCoordinateCovariantDerivative (Γ : E → E →L[ℝ] E →L[ℝ] E) |
| 43 | (q W : ℝ → E) (r : ℝ) : E := deriv W r + Γ (q r) (deriv q r) (W r) |
| 44 | |
| 45 | theorem curveCoordinateCovariantDerivative_contDiffOn {I : Set ℝ} {U : Set E} |
| 46 | (hI : IsOpen I) (Γ : E → E →L[ℝ] E →L[ℝ] E) (q W : ℝ → E) |
| 47 | (hΓ : ContDiffOn ℝ ∞ Γ U) (hq : ContDiffOn ℝ ∞ q I) |
| 48 | (hW : ContDiffOn ℝ ∞ W I) (hmap : MapsTo q I U) : |
| 49 | ContDiffOn ℝ ∞ (curveCoordinateCovariantDerivative Γ q W) I := |
| 50 | (hW.deriv_of_isOpen hI (m := ∞) (by simp)).add |
| 51 | (((hΓ.comp hq hmap).clm_apply (hq.deriv_of_isOpen hI (m := ∞) (by simp))).clm_apply hW) |
| 52 | |
| 53 | theorem chart_density_first_covariant_hasDerivAt |
| 54 | (G : E → E →L[ℝ] E →L[ℝ] ℝ) (P : E → ℝ) |
| 55 | (Γ : E →L[ℝ] E →L[ℝ] E) |
| 56 | (DG : E →L[ℝ] E →L[ℝ] E →L[ℝ] ℝ) (DP : E →L[ℝ] ℝ) |
| 57 | {q A : ℝ → E} {u : ℝ} {y a : E} |
| 58 | (hG : HasFDerivAt G DG (q u)) (hP : HasFDerivAt P DP (q u)) |
| 59 | (hq : HasDerivAt q y u) (hA : HasDerivAt A a u) |
| 60 | (hsym : ∀ v w : E, G (q u) v w = G (q u) w v) |
| 61 | (hcompat : DG y (A u) (A u) = |
| 62 | G (q u) (Γ y (A u)) (A u) + G (q u) (A u) (Γ y (A u))) : |
| 63 | HasDerivAt (fun r ↦ G (q r) (A r) (A r) / 2 + P (q r)) |
| 64 | (G (q u) (a + Γ y (A u)) (A u) + DP y) u := by |
| 65 | have h := chart_density_hasDerivAt G P DG DP hG hP hq hA hsym |
| 66 | have hc := hcompat |
| 67 | rw [hsym (A u) (Γ y (A u))] at hc |
| 68 | convert h using 1 <;> try rfl |
| 69 | simp only [map_add, add_apply] |
| 70 | rw [hsym (A u) a] |
| 71 | linarith |
| 72 | |
| 73 | set_option maxHeartbeats 1600000 in |
| 74 | theorem chart_density_second_covariant_hasDerivAt {I : Set ℝ} {U : Set E} |
| 75 | (hI : IsOpen I) (hU : IsOpen U) |
| 76 | (G : E → E →L[ℝ] E →L[ℝ] ℝ) (P : E → ℝ) |
| 77 | (Γ : E → E →L[ℝ] E →L[ℝ] E) (q A : ℝ → E) |
| 78 | (hG : ContDiffOn ℝ ∞ G U) (hP : ContDiffOn ℝ ∞ P U) |
| 79 | (hΓ : ContDiffOn ℝ ∞ Γ U) (hq : ContDiffOn ℝ ∞ q I) |
| 80 | (hA : ContDiffOn ℝ ∞ A I) (hmap : MapsTo q I U) |
| 81 | (hsym : ∀ x ∈ U, ∀ v w : E, G x v w = G x w v) |
| 82 | (hcompat : ∀ x ∈ U, ∀ y v w : E, |
| 83 | fderiv ℝ G x y v w = G x (Γ x y v) w + G x v (Γ x y w)) |
| 84 | {u : ℝ} (hu : u ∈ I) : |
| 85 | HasDerivAt (fun r ↦ deriv (fun v ↦ G (q v) (A v) (A v) / 2 + P (q v)) r) |
| 86 | (G (q u) (curveCoordinateCovariantDerivative Γ q |
| 87 | (curveCoordinateCovariantDerivative Γ q A) u) (A u) + |
| 88 | G (q u) (curveCoordinateCovariantDerivative Γ q A u) |
| 89 | (curveCoordinateCovariantDerivative Γ q A u) + |
| 90 | fderiv ℝ (fderiv ℝ P) (q u) (deriv q u) (deriv q u) - |
| 91 | fderiv ℝ P (q u) (Γ (q u) (deriv q u) (deriv q u)) + |
| 92 | fderiv ℝ P (q u) (curveCoordinateCovariantDerivative Γ q (deriv q) u)) u := by |
| 93 | let L := fun r ↦ G (q r) (A r) (A r) / 2 + P (q r) |
| 94 | let B := curveCoordinateCovariantDerivative Γ q A |
| 95 | let Y := deriv q |
| 96 | have hB : ContDiffOn ℝ ∞ B I := |
| 97 | curveCoordinateCovariantDerivative_contDiffOn hI Γ q A hΓ hq hA hmap |
| 98 | have hY : ContDiffOn ℝ ∞ Y I := hq.deriv_of_isOpen hI (m := ∞) (by simp) |
| 99 | have hfirst (r : ℝ) (hr : r ∈ I) : |
| 100 | deriv L r = G (q r) (B r) (A r) + fderiv ℝ P (q r) (Y r) := by |
| 101 | have hGr := ((hG (q r) (hmap hr)).contDiffAt (hU.mem_nhds (hmap hr))).differentiableAt |
| 102 | (by simp) |
| 103 | have hPr := ((hP (q r) (hmap hr)).contDiffAt (hU.mem_nhds (hmap hr))).differentiableAt |
| 104 | (by simp) |
| 105 | have hqr := ((hq r hr).contDiffAt (hI.mem_nhds hr)).differentiableAt (by simp) |
| 106 | have hAr := ((hA r hr).contDiffAt (hI.mem_nhds hr)).differentiableAt (by simp) |
| 107 | exact (chart_density_first_covariant_hasDerivAt G P (Γ (q r)) _ _ |
| 108 | hGr.hasFDerivAt hPr.hasFDerivAt hqr.hasDerivAt hAr.hasDerivAt |
| 109 | (hsym (q r) (hmap hr)) (hcompat (q r) (hmap hr) _ _ _)).deriv |
| 110 | have hqu := ((hq u hu).contDiffAt (hI.mem_nhds hu)).differentiableAt (by simp) |
| 111 | have hAu := ((hA u hu).contDiffAt (hI.mem_nhds hu)).differentiableAt (by simp) |
| 112 | have hBu := ((hB u hu).contDiffAt (hI.mem_nhds hu)).differentiableAt (by simp) |
| 113 | have hYu := ((hY u hu).contDiffAt (hI.mem_nhds hu)).differentiableAt (by simp) |
| 114 | have hGu := ((hG (q u) (hmap hu)).contDiffAt (hU.mem_nhds (hmap hu))).differentiableAt |
| 115 | (by simp) |
| 116 | have hPu := (hP (q u) (hmap hu)).contDiffAt (hU.mem_nhds (hmap hu)) |
| 117 | have hpair := chart_pair_covariant_hasDerivAt G (Γ (q u)) _ hGu.hasFDerivAt |
| 118 | hqu.hasDerivAt hBu.hasDerivAt hAu.hasDerivAt (hcompat (q u) (hmap hu) _ _ _) |
| 119 | change HasDerivAt (fun r ↦ G (q r) (B r) (A r)) |
| 120 | (G (q u) (curveCoordinateCovariantDerivative Γ q B u) (A u) + G (q u) (B u) (B u)) u |
| 121 | at hpair |
| 122 | have hP₂ := ((hPu.fderiv_right (m := ∞) (by simp)).differentiableAt (by simp)).hasFDerivAt |
| 123 | have hpot := (hP₂.comp_hasDerivAt u hqu.hasDerivAt).clm_apply hYu.hasDerivAt |
| 124 | have hsum := hpair.add hpot |
| 125 | have hactual := hsum.congr_of_eventuallyEq (show |
| 126 | (fun r ↦ deriv L r) =ᶠ[𝓝 u] |
| 127 | (fun r ↦ G (q r) (B r) (A r) + fderiv ℝ P (q r) (Y r)) from by |
| 128 | filter_upwards [hI.mem_nhds hu] with r hr |
| 129 | exact hfirst r hr) |
| 130 | convert hactual using 1 <;> try rfl |
| 131 | dsimp only [curveCoordinateCovariantDerivative, B, Y, Function.comp_def] |
| 132 | simp only [map_add, add_apply] |
| 133 | ring |
| 134 | |
| 135 | end PoincareMT.ReducedLengthMinimum.Variation.Geometry |