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.Surface.VariationSurfaceTerms |
| 3 | |
| 4 | /-! |
| 5 | # Pointwise second variation of the actual generalized density |
| 6 | |
| 7 | Morgan-Tian Proposition 6.33, pp. 120-121. The generic M08 surface |
| 8 | identity is applied inside an actual compatible gauge rectangle. |
| 9 | All density, boundary, index and Euler terms are the frozen M14 |
| 10 | quantities, for arbitrary supplied variation derivative data. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | -- The ordinary open-subset coefficients and actual horizontal fibers share their models. |
| 15 | set_option backward.isDefEq.respectTransparency false |
| 16 | |
| 17 | open Set Filter |
| 18 | open scoped Manifold ContDiff Topology |
| 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 actual second density variation is the boundary-pair |
| 30 | derivative plus the index density minus the square Euler residual, |
| 31 | Proposition 6.33, pp. 120-121. -/ |
| 32 | theorem secondVariation_density_identity_with_residual |
| 33 | (hM04 : RicciFlowCurvatureTheory.{0}) (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 | (M08.variationParameterDeriv (M14SqrtParameterInterval τ₁ τ₂) V.parameterDomain |
| 38 | (variationActionDensity V)) (s, 0) = |
| 39 | derivWithin (variationAccelerationBoundaryPair V D) (M14SqrtParameterInterval τ₁ τ₂) s + |
| 40 | M14SecondVariationIndexDensity V D s - |
| 41 | M14SquareRootEulerResidual G R D.base_extension s (variationAccelerationField V D s) := by |
| 42 | have hCoordinates := hM12.coordinate_gauges X time I G.spacetime G.slices |
| 43 | G.timeIntervals G.gaugeCover G.leafwise |
| 44 | have hscalar := ((hM12.leafwise_calculus X time I G.spacetime G.slices |
| 45 | G.timeIntervals G.gaugeCover).2 G.leafwise).scalar_smooth |
| 46 | have hsC : s ∈ M14SqrtParameterInterval τ₁ τ₂ := Ioo_subset_Icc_self hs |
| 47 | obtain ⟨b, N, P, β, hN, hsN, hP, hzero, hPsub, hβ, hrec, hclock⟩ := |
| 48 | exists_variation_gauge_rectangle V hsC |
| 49 | obtain ⟨W⟩ := ordinaryGaugeWitness_nonempty b hCoordinates |
| 50 | let C := M14SqrtParameterInterval τ₁ τ₂ |
| 51 | let S := C ∩ N |
| 52 | let J := Ioo (Real.sqrt τ₁) (Real.sqrt τ₂) ∩ N |
| 53 | let x₀ := (β (s, 0)).2 |
| 54 | let e := extChartAt (𝓡 n) x₀ |
| 55 | let U := e.target |
| 56 | let O := J ×ˢ U |
| 57 | let Ω := J ×ˢ P |
| 58 | let q := fun z : ℝ × ℝ => (β z).2.val |
| 59 | let m := M08.chartActionMetric W.flow T x₀ |
| 60 | let P₀ := M08.chartActionPotential W.flow T x₀ |
| 61 | let Γ := M08.closedChartConnection W.flow T x₀ S |
| 62 | have hC : UniqueDiffOn ℝ C := uniqueDiffOn_Icc (Real.sqrt_lt_sqrt p.tau_nonneg p.tau_lt) |
| 63 | have hS : UniqueDiffOn ℝ S := hC.inter hN |
| 64 | have hJ : IsOpen J := isOpen_Ioo.inter hN |
| 65 | have hU : IsOpen U := isOpen_extChartAt_target (I := 𝓡 n) x₀ |
| 66 | have hO : IsOpen O := hJ.prod hU |
| 67 | have hΩ : IsOpen Ω := hJ.prod hP |
| 68 | have hp : (s, (0 : ℝ)) ∈ Ω := ⟨⟨hs, hsN⟩, hzero⟩ |
| 69 | have htime (r : ℝ) (hr : r ∈ S) : T - r ^ 2 ∈ (G.gaugeCover.interval b).domain := by |
| 70 | rw [← hclock r hr 0 hzero] |
| 71 | exact (β (r, 0)).1.property |
| 72 | have hsub : O ⊆ S ×ˢ U := fun _ hz => ⟨⟨Ioo_subset_Icc_self hz.1.1, hz.1.2⟩, hz.2⟩ |
| 73 | have hm : ContDiffOn ℝ ∞ m O := |
| 74 | (M08.chartActionMetric_closed_contDiffOn W.flow T x₀ htime).mono hsub |
| 75 | have hP₀ : ContDiffOn ℝ ∞ P₀ O := |
| 76 | (M08.chartActionPotential_closed_contDiffOn W.flow hM04 T x₀ htime).mono hsub |
| 77 | have hΓ : ContDiffOn ℝ ∞ Γ O := |
| 78 | (M08.closedChartConnection_contDiffOn W.flow T x₀ hS htime).mono hsub |
| 79 | have hq : ContDiffOn ℝ ∞ q Ω := (variationGauge_spatial_contDiffOn b hβ).mono |
| 80 | (fun _ hz => ⟨⟨Ioo_subset_Icc_self hz.1.1, hz.1.2⟩, hz.2⟩) |
| 81 | have hmap : MapsTo (fun z => (z.1, q z)) Ω O := by |
| 82 | intro z hz |
| 83 | refine ⟨hz.1, ?_⟩ |
| 84 | have hsrc : (β z).2 ∈ e.source := by |
| 85 | rw [extChartAt_source, (G.gaugeCover.spatial b).chartAt_source_eq_univ] |
| 86 | exact mem_univ _ |
| 87 | have heq : e (β z).2 = q z := by |
| 88 | rw [extChartAt_coe] |
| 89 | rfl |
| 90 | change q z ∈ e.target |
| 91 | rw [← heq] |
| 92 | exact e.map_source hsrc |
| 93 | have hsym (z : ℝ × EuclideanSpace ℝ (Fin n)) (hz : z ∈ O) |
| 94 | (v w : EuclideanSpace ℝ (Fin n)) : m z v w = m z w v := by |
| 95 | obtain ⟨r, a⟩ := z |
| 96 | have hy : e.symm a ∈ (chartAt (EuclideanSpace ℝ (Fin n)) x₀).source := by |
| 97 | simpa only [e, extChartAt_source] using e.map_target hz.2 |
| 98 | have heq : extChartAt (𝓡 n) x₀ (e.symm a) = a := e.right_inv hz.2 |
| 99 | simpa only [heq] using M08.chartActionMetric_symm_at W.flow T hy r v w |
| 100 | have hcompat (z : ℝ × EuclideanSpace ℝ (Fin n)) (hz : z ∈ O) |
| 101 | (a v w : EuclideanSpace ℝ (Fin n)) : |
| 102 | fderiv ℝ (fun y => m (z.1, y)) z.2 a v w = |
| 103 | m z (Γ z a v) w + m z v (Γ z a w) := by |
| 104 | obtain ⟨r, y⟩ := z |
| 105 | have hy : e.symm y ∈ (chartAt (EuclideanSpace ℝ (Fin n)) x₀).source := by |
| 106 | simpa only [e, extChartAt_source] using e.map_target hz.2 |
| 107 | have heq : extChartAt (𝓡 n) x₀ (e.symm y) = y := e.right_inv hz.2 |
| 108 | simpa only [heq] using M08.closedChartConnection_spatial_compatibility W.flow T htime hy |
| 109 | ⟨Ioo_subset_Icc_self hz.1.1, hz.1.2⟩ a v w |
| 110 | have htor (z : ℝ × EuclideanSpace ℝ (Fin n)) (hz : z ∈ O) |
| 111 | (v w : EuclideanSpace ℝ (Fin n)) : Γ z v w = Γ z w v := by |
| 112 | obtain ⟨r, y⟩ := z |
| 113 | have hy : e.symm y ∈ (chartAt (EuclideanSpace ℝ (Fin n)) x₀).source := by |
| 114 | simpa only [e, extChartAt_source] using e.map_target hz.2 |
| 115 | have heq : extChartAt (𝓡 n) x₀ (e.symm y) = y := e.right_inv hz.2 |
| 116 | change M08.closedChartChristoffel W.flow T x₀ S (r, y) v w = |
| 117 | M08.closedChartChristoffel W.flow T x₀ S (r, y) w v |
| 118 | simpa only [heq] using M08.closedChartChristoffel_symm W.flow T htime hy |
| 119 | ⟨Ioo_subset_Icc_self hz.1.1, hz.1.2⟩ v w |
| 120 | have hid := M08.surfaceActionDensity_second_boundary hΩ hO m P₀ Γ q hm hP₀ hΓ hq hmap |
| 121 | hsym hcompat htor hp |
| 122 | dsimp only at hid |
| 123 | rw [surfaceIndex_gauge V D b hCoordinates hscalar hM04 W x₀ hN hP hzero hβ hrec hclock hs hsN, |
| 124 | surfaceEuler_gauge V D b hCoordinates hscalar hM04 W x₀ hN hP hzero hβ hrec hclock |
| 125 | hPsub hs hsN] at hid |
| 126 | have hLnear : (fun u => variationActionDensity V (s, u)) =ᶠ[𝓝 (0 : ℝ)] |
| 127 | (fun u => M08.surfaceActionDensity m P₀ q (s, u)) := by |
| 128 | filter_upwards [hP.mem_nhds hzero] with u hu |
| 129 | exact (surfaceActionDensity_gauge V b hCoordinates W x₀ hN hP hβ hrec hclock hs hsN hu).symm |
| 130 | have hPV : IsOpen V.parameterDomain := V.parameterDomain_eq ▸ isOpen_Ioo |
| 131 | have hzeroV : (0 : ℝ) ∈ V.parameterDomain := hPsub hzero |
| 132 | have hL := variationActionDensity_contDiffOn hM12 V |
| 133 | have hL' := M08.variationParameterDeriv_contDiffOn hC hPV _ hL |
| 134 | have hfirst : (fun u => M08.variationParameterDeriv C V.parameterDomain |
| 135 | (variationActionDensity V) (s, u)) =ᶠ[𝓝 (0 : ℝ)] |
| 136 | (fun u => deriv (fun v => variationActionDensity V (s, v)) u) := by |
| 137 | filter_upwards [hPV.mem_nhds hzeroV] with u hu |
| 138 | exact (M08.hasDerivAt_variationParameter hPV _ hL hsC hu).deriv.symm |
| 139 | have hraw := (M08.hasDerivAt_variationParameter hPV _ hL' hsC hzeroV).deriv.symm |
| 140 | have hraw' := (hraw.trans hfirst.deriv_eq).trans hLnear.deriv.deriv_eq |
| 141 | have hBnear : (fun r => M08.surfaceAccelerationBoundaryPair m Γ q (r, 0)) =ᶠ[𝓝 s] |
| 142 | variationAccelerationBoundaryPair V D := by |
| 143 | filter_upwards [hJ.mem_nhds ⟨hs, hsN⟩] with r hr |
| 144 | exact surfaceAccelerationBoundaryPair_gauge V b hCoordinates W x₀ hN hP hβ hrec hclock |
| 145 | D hzero hPsub hr.1 hr.2 |
| 146 | rw [hBnear.deriv_eq, ← derivWithin_of_mem_nhds (Icc_mem_nhds hs.1 hs.2)] at hid |
| 147 | exact hraw'.trans hid |
| 148 | |
| 149 | end PoincareMT.M14 |