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.Generalized.ReducedGeometry.SourceNames.LGeometry |
| 2 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Variation.Action.SecondVariationDensity |
| 3 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Variation.Euler.EulerEquation |
| 4 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Paths.SquareRoot.Equation.SquareEuler |
| 5 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Variation.IndexForm.IndexPositivity |
| 6 | |
| 7 | /-! |
| 8 | # The exact generalized second-variation and index statements |
| 9 | |
| 10 | Morgan-Tian Proposition 6.33, pp. 120-121. Integrating the actual |
| 11 | density identity gives the frozen acceleration boundary contribution |
| 12 | and index form. Original Euler paths and supplied square Euler paths |
| 13 | are both covered. Actual minimality gives the fixed-endpoint index |
| 14 | inequality for every supplied derivative record. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Set Filter Topology MeasureTheory |
| 20 | open scoped Manifold ContDiff intervalIntegral |
| 21 | |
| 22 | universe u |
| 23 | |
| 24 | namespace PoincareMT.M14 |
| 25 | |
| 26 | variable {n : ℕ} {X : Type u} [TopologicalSpace X] {time : X → ℝ} |
| 27 | {I : SpacetimeInterval} {G : GeneralizedLGeometryTransport n X time I} |
| 28 | {T τ₁ τ₂ : ℝ} {x y : G.Point} {p : M14BackwardPath G T τ₁ τ₂ x y} |
| 29 | {R : M14SquareRootPath G p} |
| 30 | |
| 31 | /-- A vanishing actual square Euler residual gives the exact frozen |
| 32 | second-variation identity, retaining both endpoint accelerations, |
| 33 | Proposition 6.33, pp. 120-121. -/ |
| 34 | theorem secondVariationIdentity_of_squareEuler |
| 35 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 36 | (hM04 : RicciFlowCurvatureTheory.{0}) (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 37 | (V : M14LVariationData G p R) (D : M14VariationDerivativeData V) |
| 38 | (heuler : ∀ s ∈ M14SqrtParameterInterval τ₁ τ₂, ∀ Z : G.Horizontal (R.curve s), |
| 39 | M14SquareRootEulerResidual G R D.base_extension s Z = 0) : |
| 40 | M14SecondVariationIdentity V D := by |
| 41 | refine ⟨⟨_, firstVariationIdentity hCoordinates hM12 V D, rfl⟩, ?_⟩ |
| 42 | let a := Real.sqrt τ₁ |
| 43 | let b := Real.sqrt τ₂ |
| 44 | let C := M14SqrtParameterInterval τ₁ τ₂ |
| 45 | let raw := fun s => M08.variationParameterDeriv C V.parameterDomain |
| 46 | (M08.variationParameterDeriv C V.parameterDomain (variationActionDensity V)) (s, 0) |
| 47 | let B := variationAccelerationBoundaryPair V D |
| 48 | let dB := derivWithin B C |
| 49 | let Idx := M14SecondVariationIndexDensity V D |
| 50 | have hab : a < b := Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt |
| 51 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc hab |
| 52 | have hP : IsOpen V.parameterDomain := V.parameterDomain_eq ▸ isOpen_Ioo |
| 53 | have hzero : (0 : ℝ) ∈ V.parameterDomain := by |
| 54 | rw [V.parameterDomain_eq] |
| 55 | exact ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 56 | have hraw : ContinuousOn raw C := |
| 57 | (M08.variationParameterDeriv_contDiffOn hC hP _ |
| 58 | (M08.variationParameterDeriv_contDiffOn hC hP _ |
| 59 | (variationActionDensity_contDiffOn hM12 V))).continuousOn.comp |
| 60 | (continuousOn_id.prodMk continuousOn_const) (fun _ hs => ⟨hs, hzero⟩) |
| 61 | have hB : ContDiffOn ℝ ∞ B C := variationAccelerationBoundaryPair_contDiffOn V D |
| 62 | (hM12.coordinate_gauges X time I G.spacetime G.slices G.timeIntervals G.gaugeCover G.leafwise) |
| 63 | have hdB : ContinuousOn dB C := (hB.derivWithin hC (m := ∞) (by simp)).continuousOn |
| 64 | have hrawInt : IntervalIntegrable raw volume a b := hraw.intervalIntegrable_of_Icc hab.le |
| 65 | have hdBInt : IntervalIntegrable dB volume a b := hdB.intervalIntegrable_of_Icc hab.le |
| 66 | have hid (s : ℝ) (hs : s ∈ Ioo a b) : raw s = dB s + Idx s := by |
| 67 | have h := secondVariation_density_identity_with_residual hM04 hM12 V D hs |
| 68 | rw [heuler s (Ioo_subset_Icc_self hs), sub_zero] at h |
| 69 | exact h |
| 70 | have hIdxInt : IntervalIntegrable Idx volume a b := by |
| 71 | apply (hrawInt.sub hdBInt).congr_uIoo |
| 72 | intro s hs |
| 73 | rw [uIoo_of_le hab.le] at hs |
| 74 | have h := hid s hs |
| 75 | linarith |
| 76 | have hFTC : (∫ s in a..b, dB s) = B b - B a := |
| 77 | intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le hab.le hB.continuousOn |
| 78 | (fun s hs => (((hB s (Ioo_subset_Icc_self hs)).differentiableWithinAt |
| 79 | (by simp)).hasDerivWithinAt).hasDerivAt (Icc_mem_nhds hs.1 hs.2)) hdBInt |
| 80 | have hvalue : (∫ s in a..b, raw s) = |
| 81 | M14SecondVariationBoundaryTerm V D + M14SecondVariationIndexForm V D := by |
| 82 | calc |
| 83 | (∫ s in a..b, raw s) = ∫ s in a..b, dB s + Idx s := |
| 84 | intervalIntegral.integral_congr_Ioo_of_le hab.le hid |
| 85 | _ = (∫ s in a..b, dB s) + ∫ s in a..b, Idx s := |
| 86 | intervalIntegral.integral_add hdBInt hIdxInt |
| 87 | _ = _ := by |
| 88 | rw [hFTC, secondVariationBoundaryTerm_eq_accelerationPair V D] |
| 89 | rfl |
| 90 | refine ⟨_, ?_, rfl⟩ |
| 91 | have h := hasDerivAt_deriv_variationAction_integral hM12 V hzero |
| 92 | change HasDerivAt (fun u => deriv (M14VariationAction V) u) (∫ s in a..b, raw s) 0 at h |
| 93 | rwa [hvalue] at h |
| 94 | |
| 95 | /-- Every actual original-time Euler path has the frozen second |
| 96 | variation for each supplied square representative and derivative |
| 97 | record, without minimality, Proposition 6.33, pp. 120-121. -/ |
| 98 | theorem secondVariationIdentity |
| 99 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 100 | (hM04 : RicciFlowCurvatureTheory.{0}) (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 101 | (V : M14LVariationData G p R) (D : M14VariationDerivativeData V) |
| 102 | (E₀ : M14PullbackExtension G p.curve (Ioo τ₁ τ₂) p.horizontal_velocity) |
| 103 | (heuler : M14EulerEquation G p E₀) : M14SecondVariationIdentity V D := |
| 104 | secondVariationIdentity_of_squareEuler hCoordinates hM04 hM12 V D |
| 105 | (fun _ hs Z => squareRootEulerResidual_eq_zero_of_euler p hCoordinates hM12 E₀ heuler R |
| 106 | D.base_extension hs Z) |
| 107 | |
| 108 | /-- The exact frozen generalized second-variation statement, |
| 109 | including zero initial time and arbitrary endpoint variations, |
| 110 | Proposition 6.33, pp. 120-121. -/ |
| 111 | theorem secondVariationStatement |
| 112 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 113 | (hM04 : RicciFlowCurvatureTheory.{0}) (hM12 : GeneralizedRicciGaugeTheory.{u} n) : |
| 114 | M14SecondVariationStatement G := by |
| 115 | intro T τ₁ τ₂ x y p R V E₀ heuler |
| 116 | obtain ⟨D⟩ := exists_variationDerivativeData V |
| 117 | exact ⟨D, secondVariationIdentity hCoordinates hM04 hM12 V D E₀ heuler⟩ |
| 118 | |
| 119 | /-- The actual fixed-endpoint index form is nonnegative at a |
| 120 | minimizing path, for every supplied derivative record, Proposition 6.33, |
| 121 | pp. 120-121. -/ |
| 122 | theorem secondVariationIndexForm_nonneg |
| 123 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 124 | (hM04 : RicciFlowCurvatureTheory.{0}) (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 125 | (V : M14LVariationData G p R) (D : M14VariationDerivativeData V) |
| 126 | (hmin : M14IsMinimizing p) (hfix : M14BothEndpointsFixed V) : |
| 127 | 0 ≤ M14SecondVariationIndexForm V D := |
| 128 | secondVariationIndexForm_nonneg_of_identity V D hmin hfix |
| 129 | (secondVariationIdentity_of_squareEuler hCoordinates hM04 hM12 V D |
| 130 | (fun _ hs Z => squareRootEulerResidual_eq_zero_of_minimizing hCoordinates hM12 hmin |
| 131 | D.base_extension hs Z)) |
| 132 | |
| 133 | /-- The exact frozen fixed-endpoint index statement, with the |
| 134 | closed square Euler equation for its same derivative record, |
| 135 | Proposition 6.33, pp. 120-121. -/ |
| 136 | theorem fixedEndpointIndexStatement |
| 137 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 138 | (hM04 : RicciFlowCurvatureTheory.{0}) (hM12 : GeneralizedRicciGaugeTheory.{u} n) : |
| 139 | M14FixedEndpointIndexStatement G := by |
| 140 | intro T τ₁ τ₂ x y p R V hmin hfix |
| 141 | obtain ⟨D⟩ := exists_variationDerivativeData V |
| 142 | refine ⟨D, fun _ hs Z => squareRootEulerResidual_eq_zero_of_minimizing |
| 143 | hCoordinates hM12 hmin D.base_extension hs Z, ?_⟩ |
| 144 | exact secondVariationIndexForm_nonneg hCoordinates hM04 hM12 V D hmin hfix |
| 145 | |
| 146 | end PoincareMT.M14 |