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.VariationDensity |
| 3 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Variation.Action.VariationBoundary |
| 4 | import PoincareLib.Geometry.RicciFlow.Generalized.ReducedGeometry.Variation.Theory |
| 5 | |
| 6 | /-! |
| 7 | # First variation of the generalized L-action |
| 8 | |
| 9 | Morgan-Tian Lemma 6.4, pp. 107-108, with the square-root substitution |
| 10 | of equation (6.2), p. 106. The actual density partial is the derivative |
| 11 | of the boundary pair minus the frozen Euler residual. The interval |
| 12 | argument follows M08 FirstVariation and applies at a zero initial time. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set Filter Topology MeasureTheory |
| 18 | open scoped Manifold ContDiff Bundle intervalIntegral |
| 19 | |
| 20 | universe u |
| 21 | |
| 22 | namespace PoincareMT.M14 |
| 23 | |
| 24 | variable {n : ℕ} {X : Type u} [TopologicalSpace X] {time : X → ℝ} |
| 25 | {I : SpacetimeInterval} {G : GeneralizedLGeometryTransport n X time I} |
| 26 | {T τ₁ τ₂ : ℝ} {x y : G.Point} {p : M14BackwardPath G T τ₁ τ₂ x y} |
| 27 | {R : M14SquareRootPath G p} |
| 28 | |
| 29 | /-- The first density variation equals the boundary-pair derivative |
| 30 | minus the actual paired Euler residual, Lemma 6.4, pp. 107-108. -/ |
| 31 | theorem firstVariation_density_identity |
| 32 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 33 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 34 | (V : M14LVariationData G p R) (D : M14VariationDerivativeData V) |
| 35 | {s : ℝ} (hs : s ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂)) : |
| 36 | M08.variationParameterDeriv (M14SqrtParameterInterval τ₁ τ₂) V.parameterDomain |
| 37 | (variationActionDensity V) (s, 0) = |
| 38 | derivWithin (variationBoundaryPair V) (M14SqrtParameterInterval τ₁ τ₂) s - |
| 39 | M14SquareRootEulerResidual G R D.base_extension s (M14VariationField V s) := by |
| 40 | have hP : IsOpen V.parameterDomain := V.parameterDomain_eq ▸ isOpen_Ioo |
| 41 | have hsC : s ∈ M14SqrtParameterInterval τ₁ τ₂ := Ioo_subset_Icc_self hs |
| 42 | have hzero : (0 : ℝ) ∈ V.parameterDomain := by |
| 43 | rw [V.parameterDomain_eq] |
| 44 | exact ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 45 | have hraw := M08.hasDerivAt_variationParameter hP (variationActionDensity V) |
| 46 | (variationActionDensity_contDiffOn hM12 V) hsC hzero |
| 47 | have hvalue := hraw.unique (hasDerivAt_variationActionDensity_zero hCoordinates hM12 V D hs) |
| 48 | have hB := (hasDerivWithinAt_variationBoundaryPair V D hsC).derivWithin |
| 49 | (uniqueDiffOn_Icc (Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt) s hsC) |
| 50 | rw [hvalue, hB] |
| 51 | unfold M14SquareRootEulerResidual M14SquareRootVelocity |
| 52 | ring |
| 53 | |
| 54 | /-- The frozen first-variation identity holds for every supplied actual |
| 55 | derivative record, including paths starting at zero, Lemma 6.4, pp. 107-108. -/ |
| 56 | theorem firstVariationIdentity |
| 57 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 58 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) |
| 59 | (V : M14LVariationData G p R) (D : M14VariationDerivativeData V) : |
| 60 | M14FirstVariationIdentity V D := by |
| 61 | let a := Real.sqrt τ₁ |
| 62 | let b := Real.sqrt τ₂ |
| 63 | let C := M14SqrtParameterInterval τ₁ τ₂ |
| 64 | let raw := fun s => M08.variationParameterDeriv C V.parameterDomain |
| 65 | (variationActionDensity V) (s, 0) |
| 66 | let B := variationBoundaryPair V |
| 67 | let dB := derivWithin B C |
| 68 | let Res := fun s => M14SquareRootEulerResidual G R D.base_extension s (M14VariationField V s) |
| 69 | have hab : a < b := Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt |
| 70 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc hab |
| 71 | have hP : IsOpen V.parameterDomain := V.parameterDomain_eq ▸ isOpen_Ioo |
| 72 | have hzero : (0 : ℝ) ∈ V.parameterDomain := by |
| 73 | rw [V.parameterDomain_eq] |
| 74 | exact ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 75 | have hraw : ContinuousOn raw C := |
| 76 | (M08.variationParameterDeriv_contDiffOn hC hP (variationActionDensity V) |
| 77 | (variationActionDensity_contDiffOn hM12 V)).continuousOn.comp |
| 78 | (continuousOn_id.prodMk continuousOn_const) (fun _ hs => ⟨hs, hzero⟩) |
| 79 | have hB : ContDiffOn ℝ ∞ B C := variationBoundaryPair_contDiffOn V |
| 80 | have hdB : ContinuousOn dB C := (hB.derivWithin hC (m := ∞) (by simp)).continuousOn |
| 81 | have hrawInt : IntervalIntegrable raw volume a b := hraw.intervalIntegrable_of_Icc hab.le |
| 82 | have hdBInt : IntervalIntegrable dB volume a b := hdB.intervalIntegrable_of_Icc hab.le |
| 83 | have hid (s : ℝ) (hs : s ∈ Ioo a b) : raw s = dB s - Res s := |
| 84 | firstVariation_density_identity hCoordinates hM12 V D hs |
| 85 | have hResInt : IntervalIntegrable Res volume a b := by |
| 86 | apply (hdBInt.sub hrawInt).congr_uIoo |
| 87 | intro s hs |
| 88 | rw [uIoo_of_le hab.le] at hs |
| 89 | have h := hid s hs |
| 90 | linarith |
| 91 | have hFTC : (∫ s in a..b, dB s) = B b - B a := |
| 92 | intervalIntegral.integral_eq_sub_of_hasDerivAt_of_le hab.le hB.continuousOn |
| 93 | (fun s hs => (((hB s (Ioo_subset_Icc_self hs)).differentiableWithinAt |
| 94 | (by simp)).hasDerivWithinAt).hasDerivAt (Icc_mem_nhds hs.1 hs.2)) hdBInt |
| 95 | have hvalue : (∫ s in a..b, raw s) = |
| 96 | M14FirstVariationBoundaryTerm V + M14FirstVariationResidualIntegral V D := by |
| 97 | calc |
| 98 | (∫ s in a..b, raw s) = ∫ s in a..b, dB s + -Res s := |
| 99 | intervalIntegral.integral_congr_Ioo_of_le hab.le (fun s hs => by |
| 100 | simpa only [sub_eq_add_neg] using hid s hs) |
| 101 | _ = (∫ s in a..b, dB s) + ∫ s in a..b, -Res s := |
| 102 | intervalIntegral.integral_add hdBInt hResInt.neg |
| 103 | _ = _ := by rw [hFTC]; rfl |
| 104 | have h := hasDerivAt_variationAction_integral hM12 V hzero |
| 105 | change HasDerivAt (M14VariationAction V) (∫ s in a..b, raw s) 0 at h |
| 106 | rwa [hvalue] at h |
| 107 | |
| 108 | /-- The exact frozen generalized first-variation statement, |
| 109 | with its actual extension witnesses, Lemma 6.4, pp. 107-108. -/ |
| 110 | theorem firstVariationStatement |
| 111 | (hCoordinates : M12MetricPredecessors.{0} n) |
| 112 | (hM12 : GeneralizedRicciGaugeTheory.{u} n) : M14FirstVariationStatement G := by |
| 113 | intro T τ₁ τ₂ x y p R V |
| 114 | obtain ⟨D⟩ := exists_variationDerivativeData V |
| 115 | exact ⟨D, firstVariationIdentity hCoordinates hM12 V D⟩ |
| 116 | |
| 117 | end PoincareMT.M14 |