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.Identity |
| 2 | |
| 3 | /-! |
| 4 | # Integral second variation along a surface Euler path |
| 5 | |
| 6 | Adapted from Mapher `Proofs/M08/SecondVariation.lean`, commit |
| 7 | `49331b7d7ecad38f53e4300c3b35d6a84b2cc648`. |
| 8 | The clock and Euler conditions are explicit formula hypotheses; the ancient |
| 9 | minimizer supplies both. Morgan--Tian, Proposition 6.33, pp. 120-121. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open Set Filter Topology MeasureTheory |
| 15 | open scoped Manifold ContDiff Bundle intervalIntegral |
| 16 | |
| 17 | universe u |
| 18 | |
| 19 | namespace PoincareMT.ReducedLengthMinimum.Variation.Geometry |
| 20 | |
| 21 | variable {M : Type u} [TopologicalSpace M] |
| 22 | [ChartedSpace (EuclideanSpace ℝ (Fin 2)) M] [IsManifold (𝓡 2) ∞ M] |
| 23 | |
| 24 | theorem secondVariationIndexDensity_intervalIntegrable {J : Set ℝ} {F : RicciFlow 2 M J} |
| 25 | {T τ₁ τ₂ : ℝ} |
| 26 | (hpotential : ContMDiff (𝓘(ℝ, ℝ).prod (𝓡 2)) 𝓘(ℝ, ℝ) ∞ |
| 27 | (fun z : ℝ × M => 2 * z.1 ^ 2 * |
| 28 | (F.connection (T - z.1 ^ 2)).scalarCurvature z.2)) |
| 29 | (hclock : ∀ s ∈ sqrtParameterInterval τ₁ τ₂, |
| 30 | s ∈ interior ((fun r : ℝ => T - r ^ 2) ⁻¹' J)) |
| 31 | (htime : ∀ r ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂), T - r ^ 2 ∈ interior J) |
| 32 | {p : BackwardTimePath F T τ₁ τ₂} (V : LVariation F T τ₁ τ₂ p) |
| 33 | (D : LVariationDerivativeData V) |
| 34 | (heuler : ∀ r ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂), |
| 35 | ∀ W : TangentSpace (𝓡 2) (V.baseSquareCurve r), |
| 36 | regularizedEulerResidual F T V.baseSquareCurve |
| 37 | (sqrtParameterInterval τ₁ τ₂) D.velocity_extension r W = 0) : |
| 38 | IntervalIntegrable (secondVariationIndexDensity V D) volume (Real.sqrt τ₁) (Real.sqrt τ₂) := by |
| 39 | let a := Real.sqrt τ₁ |
| 40 | let b := Real.sqrt τ₂ |
| 41 | let C := sqrtParameterInterval τ₁ τ₂ |
| 42 | let raw := fun s ↦ variationParameterDeriv C V.parameterDomain |
| 43 | (variationParameterDeriv C V.parameterDomain (variationActionDensity V)) (s, 0) |
| 44 | let B := variationAccelerationBoundaryPair V D |
| 45 | let dB := derivWithin B C |
| 46 | let idx := secondVariationIndexDensity V D |
| 47 | have hab : a < b := Real.sqrt_lt_sqrt p.nonnegative p.ordered |
| 48 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc hab |
| 49 | have hzero : (0 : ℝ) ∈ V.parameterDomain := ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 50 | have hraw : ContinuousOn raw C := |
| 51 | (variationParameterDeriv_contDiffOn hC isOpen_Ioo _ |
| 52 | (variationParameterDeriv_contDiffOn hC isOpen_Ioo _ |
| 53 | (variationActionDensity_contDiffOn hpotential V))).continuousOn.comp |
| 54 | (continuousOn_id.prodMk continuousOn_const) (fun s hs ↦ ⟨hs, hzero⟩) |
| 55 | have hB : ContDiffOn ℝ ∞ B C := variationAccelerationBoundaryPair_contDiffOn V D hclock |
| 56 | have hdB : ContinuousOn dB C := (hB.derivWithin hC (m := ∞) (by simp)).continuousOn |
| 57 | have hrawInt : IntervalIntegrable raw volume a b := hraw.intervalIntegrable_of_Icc hab.le |
| 58 | have hdBInt : IntervalIntegrable dB volume a b := hdB.intervalIntegrable_of_Icc hab.le |
| 59 | have hid (s : ℝ) (hs : s ∈ Ioo a b) : raw s = dB s + idx s := |
| 60 | secondVariation_density_identity hpotential htime V D heuler hs |
| 61 | apply (hrawInt.sub hdBInt).congr_uIoo |
| 62 | intro s hs |
| 63 | rw [uIoo_of_le hab.le] at hs |
| 64 | have h := hid s hs |
| 65 | linarith |
| 66 | |
| 67 | theorem hasDerivAt_secondVariation {J : Set ℝ} {F : RicciFlow 2 M J} |
| 68 | {T τ₁ τ₂ : ℝ} |
| 69 | (hpotential : ContMDiff (𝓘(ℝ, ℝ).prod (𝓡 2)) 𝓘(ℝ, ℝ) ∞ |
| 70 | (fun z : ℝ × M => 2 * z.1 ^ 2 * |
| 71 | (F.connection (T - z.1 ^ 2)).scalarCurvature z.2)) |
| 72 | (hclock : ∀ s ∈ sqrtParameterInterval τ₁ τ₂, |
| 73 | s ∈ interior ((fun r : ℝ => T - r ^ 2) ⁻¹' J)) |
| 74 | (htime : ∀ r ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂), T - r ^ 2 ∈ interior J) |
| 75 | {p : BackwardTimePath F T τ₁ τ₂} (V : LVariation F T τ₁ τ₂ p) |
| 76 | (D : LVariationDerivativeData V) |
| 77 | (heuler : ∀ r ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂), |
| 78 | ∀ W : TangentSpace (𝓡 2) (V.baseSquareCurve r), |
| 79 | regularizedEulerResidual F T V.baseSquareCurve |
| 80 | (sqrtParameterInterval τ₁ τ₂) D.velocity_extension r W = 0) : |
| 81 | HasDerivAt (fun u ↦ deriv (variationSquareAction V) u) |
| 82 | (secondVariationBoundaryTerm V D + secondVariationIndexForm V D) 0 := by |
| 83 | let a := Real.sqrt τ₁ |
| 84 | let b := Real.sqrt τ₂ |
| 85 | let C := sqrtParameterInterval τ₁ τ₂ |
| 86 | let raw := fun s ↦ variationParameterDeriv C V.parameterDomain |
| 87 | (variationParameterDeriv C V.parameterDomain (variationActionDensity V)) (s, 0) |
| 88 | let B := variationAccelerationBoundaryPair V D |
| 89 | let dB := derivWithin B C |
| 90 | let idx := secondVariationIndexDensity V D |
| 91 | have hab : a < b := Real.sqrt_lt_sqrt p.nonnegative p.ordered |
| 92 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc hab |
| 93 | have hzero : (0 : ℝ) ∈ V.parameterDomain := ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 94 | have hraw : ContinuousOn raw C := |
| 95 | (variationParameterDeriv_contDiffOn hC isOpen_Ioo _ |
| 96 | (variationParameterDeriv_contDiffOn hC isOpen_Ioo _ |
| 97 | (variationActionDensity_contDiffOn hpotential V))).continuousOn.comp |
| 98 | (continuousOn_id.prodMk continuousOn_const) (fun s hs ↦ ⟨hs, hzero⟩) |
| 99 | have hB : ContDiffOn ℝ ∞ B C := variationAccelerationBoundaryPair_contDiffOn V D hclock |
| 100 | have hdB : ContinuousOn dB C := (hB.derivWithin hC (m := ∞) (by simp)).continuousOn |
| 101 | have hrawInt : IntervalIntegrable raw volume a b := hraw.intervalIntegrable_of_Icc hab.le |
| 102 | have hdBInt : IntervalIntegrable dB volume a b := hdB.intervalIntegrable_of_Icc hab.le |
| 103 | have hid (s : ℝ) (hs : s ∈ Ioo a b) : raw s = dB s + idx s := |
| 104 | secondVariation_density_identity hpotential htime V D heuler hs |
| 105 | have hidxInt : IntervalIntegrable idx volume a b := by |
| 106 | apply (hrawInt.sub hdBInt).congr_uIoo |
| 107 | intro s hs |
| 108 | rw [uIoo_of_le hab.le] at hs |
| 109 | have h := hid s hs |
| 110 | linarith |
| 111 | have hFTC : (∫ s in a..b, dB s) = B b - B a := |
| 112 | intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le hab.le hB.continuousOn |
| 113 | (fun s hs ↦ (((hB s (Ioo_subset_Icc_self hs)).differentiableWithinAt |
| 114 | (by simp)).hasDerivWithinAt).hasDerivAt (Icc_mem_nhds hs.1 hs.2)) hdBInt |
| 115 | have hvalue : (∫ s in a..b, raw s) = |
| 116 | secondVariationBoundaryTerm V D + secondVariationIndexForm V D := by |
| 117 | calc |
| 118 | (∫ s in a..b, raw s) = ∫ s in a..b, dB s + idx s := |
| 119 | intervalIntegral.integral_congr_Ioo_of_le hab.le hid |
| 120 | _ = (∫ s in a..b, dB s) + ∫ s in a..b, idx s := |
| 121 | intervalIntegral.integral_add hdBInt hidxInt |
| 122 | _ = _ := by rw [hFTC, secondVariationBoundaryTerm_eq_accelerationPair]; rfl |
| 123 | have h := hasDerivAt_deriv_variationSquareAction_integral hpotential V hzero |
| 124 | change HasDerivAt (fun u ↦ deriv (variationSquareAction V) u) (∫ s in a..b, raw s) 0 at h |
| 125 | rwa [hvalue] at h |
| 126 | |
| 127 | |
| 128 | end PoincareMT.ReducedLengthMinimum.Variation.Geometry |