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.LGeometry.Variation.Second.SecondVariationIdentity |
| 2 | |
| 3 | /-! Adapted from Mapher `PoincareMT/Proofs/M08/SecondVariation.lean` at |
| 4 | `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. -/ |
| 5 | |
| 6 | |
| 7 | set_option autoImplicit false |
| 8 | |
| 9 | open Set Filter Topology MeasureTheory |
| 10 | open scoped Manifold ContDiff Bundle intervalIntegral |
| 11 | |
| 12 | universe u |
| 13 | |
| 14 | namespace PoincareMT.LGeometry |
| 15 | |
| 16 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 17 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 18 | |
| 19 | theorem hasDerivAt_secondVariation {J : Set ℝ} {F : RicciFlow n M J} |
| 20 | {T τ₁ τ₂ : ℝ} (hM04 : RicciFlowCurvatureTheory.{u}) |
| 21 | {p : BackwardTimePath F T τ₁ τ₂} (V : LVariation F T τ₁ τ₂ p) |
| 22 | (D : LVariationDerivativeData V) (R : RegularizedLGeodesicData p) : |
| 23 | HasDerivAt (fun u ↦ deriv (variationLLength V) u) |
| 24 | (secondVariationBoundaryTerm V D + secondVariationIndexForm V D) 0 := by |
| 25 | let a := Real.sqrt τ₁ |
| 26 | let b := Real.sqrt τ₂ |
| 27 | let C := sqrtParameterInterval τ₁ τ₂ |
| 28 | let raw := fun s ↦ variationParameterDeriv C V.parameterDomain |
| 29 | (variationParameterDeriv C V.parameterDomain (variationActionDensity V)) (s, 0) |
| 30 | let B := variationAccelerationBoundaryPair V D |
| 31 | let dB := derivWithin B C |
| 32 | let idx := secondVariationIndexDensity V D |
| 33 | have hab : a < b := Real.sqrt_lt_sqrt p.nonnegative p.ordered |
| 34 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc hab |
| 35 | have hzero : (0 : ℝ) ∈ V.parameterDomain := ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 36 | have hraw : ContinuousOn raw C := |
| 37 | (variationParameterDeriv_contDiffOn hC isOpen_Ioo _ |
| 38 | (variationParameterDeriv_contDiffOn hC isOpen_Ioo _ |
| 39 | (variationActionDensity_contDiffOn hM04 V))).continuousOn.comp |
| 40 | (continuousOn_id.prodMk continuousOn_const) (fun s hs ↦ ⟨hs, hzero⟩) |
| 41 | have hB : ContDiffOn ℝ ∞ B C := variationAccelerationBoundaryPair_contDiffOn V D |
| 42 | have hdB : ContinuousOn dB C := (hB.derivWithin hC (m := ∞) (by simp)).continuousOn |
| 43 | have hrawInt : IntervalIntegrable raw volume a b := hraw.intervalIntegrable_of_Icc hab.le |
| 44 | have hdBInt : IntervalIntegrable dB volume a b := hdB.intervalIntegrable_of_Icc hab.le |
| 45 | have hid (s : ℝ) (hs : s ∈ Ioo a b) : raw s = dB s + idx s := |
| 46 | secondVariation_density_identity hM04 V D R hs |
| 47 | have hidxInt : IntervalIntegrable idx volume a b := by |
| 48 | apply (hrawInt.sub hdBInt).congr_uIoo |
| 49 | intro s hs |
| 50 | rw [uIoo_of_le hab.le] at hs |
| 51 | have h := hid s hs |
| 52 | linarith |
| 53 | have hFTC : (∫ s in a..b, dB s) = B b - B a := |
| 54 | intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le hab.le hB.continuousOn |
| 55 | (fun s hs ↦ (((hB s (Ioo_subset_Icc_self hs)).differentiableWithinAt |
| 56 | (by simp)).hasDerivWithinAt).hasDerivAt (Icc_mem_nhds hs.1 hs.2)) hdBInt |
| 57 | have hvalue : (∫ s in a..b, raw s) = |
| 58 | secondVariationBoundaryTerm V D + secondVariationIndexForm V D := by |
| 59 | calc |
| 60 | (∫ s in a..b, raw s) = ∫ s in a..b, dB s + idx s := |
| 61 | intervalIntegral.integral_congr_Ioo_of_le hab.le hid |
| 62 | _ = (∫ s in a..b, dB s) + ∫ s in a..b, idx s := |
| 63 | intervalIntegral.integral_add hdBInt hidxInt |
| 64 | _ = _ := by rw [hFTC, secondVariationBoundaryTerm_eq_accelerationPair]; rfl |
| 65 | have h := hasDerivAt_deriv_variationLLength_integral hM04 V hzero |
| 66 | change HasDerivAt (fun u ↦ deriv (variationLLength V) u) (∫ s in a..b, raw s) 0 at h |
| 67 | rwa [hvalue] at h |
| 68 | |
| 69 | theorem exists_secondVariation {J : Set ℝ} {F : RicciFlow n M J} |
| 70 | {T τ₁ τ₂ : ℝ} (hM04 : RicciFlowCurvatureTheory.{u}) |
| 71 | {p : BackwardTimePath F T τ₁ τ₂} (V : LVariation F T τ₁ τ₂ p) |
| 72 | (R : RegularizedLGeodesicData p) : |
| 73 | ∃ D : LVariationDerivativeData V, ∃ q : ℝ, |
| 74 | HasDerivAt (fun u ↦ deriv (variationLLength V) u) q 0 ∧ |
| 75 | q = secondVariationBoundaryTerm V D + secondVariationIndexForm V D := by |
| 76 | obtain ⟨D⟩ := exists_variationDerivativeData V |
| 77 | exact ⟨D, _, hasDerivAt_secondVariation hM04 V D R, rfl⟩ |
| 78 | |
| 79 | end PoincareMT.LGeometry |