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.VariationAction |
| 2 | import PoincareLib.Geometry.RicciFlow.ReducedGeometry.LGeometry.Variation.VariationMetricPair |
| 3 | |
| 4 | /-! Adapted from Mapher `PoincareMT/Proofs/M08/FirstVariationIdentity.lean` at |
| 5 | `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. -/ |
| 6 | |
| 7 | |
| 8 | set_option autoImplicit false |
| 9 | set_option backward.isDefEq.respectTransparency false |
| 10 | |
| 11 | noncomputable section |
| 12 | |
| 13 | open Set Filter Topology |
| 14 | open scoped Manifold ContDiff Bundle |
| 15 | |
| 16 | universe u |
| 17 | |
| 18 | namespace PoincareMT.LGeometry |
| 19 | |
| 20 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 21 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 22 | |
| 23 | theorem curveVelocityWithin_eq_of_open_subset {I C : Set ℝ} (hI : IsOpen I) |
| 24 | (hIC : I ⊆ C) (α : ℝ → M) {s : ℝ} (hs : s ∈ I) : |
| 25 | curveVelocityWithin (n := n) α I s = curveVelocityWithin (n := n) α C s := by |
| 26 | unfold curveVelocityWithin |
| 27 | rw [mfderivWithin_of_mem_nhds (hI.mem_nhds hs), |
| 28 | mfderivWithin_of_mem_nhds (mem_of_superset (hI.mem_nhds hs) hIC)] |
| 29 | |
| 30 | def restrictInteriorVelocityExtension {I C : Set ℝ} (hI : IsOpen I) |
| 31 | (hIC : I ⊆ C) (α : ℝ → M) |
| 32 | (E : ParametricAlongCurveExtensionOn C α (curveVelocityWithin (n := n) α C)) : |
| 33 | ParametricAlongCurveExtensionOn I α (curveVelocityWithin (n := n) α I) where |
| 34 | extension := E.extension |
| 35 | domain := E.domain |
| 36 | open_domain := E.open_domain |
| 37 | graph_mem s hs := E.graph_mem s (hIC hs) |
| 38 | smooth := E.smooth |
| 39 | agrees s hs := (E.agrees s (hIC hs)).trans |
| 40 | (curveVelocityWithin_eq_of_open_subset hI hIC α hs).symm |
| 41 | |
| 42 | theorem chartActionPotential_apply {J : Set ℝ} (F : RicciFlow n M J) (T : ℝ) |
| 43 | {x y : M} (hy : y ∈ (chartAt (EuclideanSpace ℝ (Fin n)) x).source) (s : ℝ) : |
| 44 | chartActionPotential F T x (s, extChartAt (𝓡 n) x y) = |
| 45 | 2 * s ^ 2 * (F.connection (T - s ^ 2)).scalarCurvature y := by |
| 46 | have hy' : y ∈ (extChartAt (𝓡 n) x).source := by simpa only [extChartAt_source] using hy |
| 47 | simp only [chartActionPotential, (extChartAt (𝓡 n) x).left_inv hy'] |
| 48 | |
| 49 | theorem regularizedLIntegrand_eq_chart {J : Set ℝ} (F : RicciFlow n M J) (T : ℝ) |
| 50 | {α : ℝ → M} {x : M} {s : ℝ} |
| 51 | (hx : α s ∈ (chartAt (EuclideanSpace ℝ (Fin n)) x).source) |
| 52 | (hα : MDifferentiableAt (𝓘(ℝ, ℝ)) (𝓡 n) α s) : |
| 53 | regularizedLIntegrand F T α s = |
| 54 | chartActionMetric F T x (s, extChartAt (𝓡 n) x (α s)) |
| 55 | (deriv ((extChartAt (𝓡 n) x) ∘ α) s) |
| 56 | (deriv ((extChartAt (𝓡 n) x) ∘ α) s) / 2 + |
| 57 | chartActionPotential F T x (s, extChartAt (𝓡 n) x (α s)) := by |
| 58 | rw [chartActionMetric_apply F T hx, chartActionPotential_apply F T hx, |
| 59 | chartFrame_curveVelocity hx hα] |
| 60 | unfold regularizedLIntegrand |
| 61 | ring |
| 62 | |
| 63 | set_option maxHeartbeats 2000000 in |
| 64 | theorem firstVariation_density_identity {J : Set ℝ} {F : RicciFlow n M J} |
| 65 | {T τmax τ₁ τ₂ : ℝ} (hM04 : RicciFlowCurvatureTheory.{u}) |
| 66 | (hwindow : Icc (T - τmax) T ⊆ J) (hτ₂ : τ₂ ≤ τmax) |
| 67 | {p : BackwardTimePath F T τ₁ τ₂} (V : LVariation F T τ₁ τ₂ p) |
| 68 | (D : LVariationDerivativeData V) {s : ℝ} |
| 69 | (hs : s ∈ Ioo (Real.sqrt τ₁) (Real.sqrt τ₂)) : |
| 70 | variationParameterDeriv (sqrtParameterInterval τ₁ τ₂) V.parameterDomain |
| 71 | (variationActionDensity V) (s, 0) = |
| 72 | derivWithin (variationBoundaryPair V) (sqrtParameterInterval τ₁ τ₂) s - |
| 73 | regularizedEulerResidual F T V.baseSquareCurve (sqrtParameterInterval τ₁ τ₂) |
| 74 | D.velocity_extension s (squareVariationField V s) := by |
| 75 | let C := sqrtParameterInterval τ₁ τ₂ |
| 76 | let I := Ioo (Real.sqrt τ₁) (Real.sqrt τ₂) |
| 77 | let α := V.baseSquareCurve |
| 78 | let H := fun z : ℝ × ℝ ↦ V.squareFamily z.1 z.2 |
| 79 | let x := α s |
| 80 | let e := extChartAt (𝓡 n) x |
| 81 | let z := fun a : ℝ × ℝ ↦ e (H a) |
| 82 | let Ω := V.squareDomain ∩ H ⁻¹' (chartAt (EuclideanSpace ℝ (Fin n)) x).source |
| 83 | let q := fun r ↦ deriv (fun t ↦ z (t, 0)) r |
| 84 | let w := fun r ↦ deriv (fun u ↦ z (r, u)) 0 |
| 85 | let qv := fun u ↦ deriv (fun r ↦ z (r, u)) s |
| 86 | have hzero : (0 : ℝ) ∈ V.parameterDomain := ⟨neg_neg_of_pos V.radius_pos, V.radius_pos⟩ |
| 87 | have hsC : s ∈ C := Ioo_subset_Icc_self hs |
| 88 | have hΩ : IsOpen Ω := V.square_smooth.continuousOn.isOpen_inter_preimage |
| 89 | V.square_open (chartAt (EuclideanSpace ℝ (Fin n)) x).open_source |
| 90 | have hsΩ : (s, (0 : ℝ)) ∈ Ω := |
| 91 | ⟨V.square_contains ⟨hsC, hzero⟩, mem_chart_source _ _⟩ |
| 92 | have hH (a : ℝ × ℝ) (ha : a ∈ Ω) : |
| 93 | MDifferentiableAt ((𝓘(ℝ, ℝ)).prod (𝓘(ℝ, ℝ))) (𝓡 n) H a := |
| 94 | ((V.square_smooth a ha.1).contMDiffAt (V.square_open.mem_nhds ha.1)).mdifferentiableAt |
| 95 | (by simp) |
| 96 | have hz : ContDiffOn ℝ ∞ z Ω := by |
| 97 | have h := (contMDiffOn_extChartAt (I := 𝓡 n) (x := x)).comp |
| 98 | (V.square_smooth.mono inter_subset_left) (fun a ha ↦ by |
| 99 | simpa only [extChartAt_source] using ha.2) |
| 100 | apply ContMDiffOn.contDiffOn |
| 101 | rw [modelWithCornersSelf_prod, ← chartedSpaceSelf_prod] |
| 102 | exact h |
| 103 | obtain ⟨k, hqv, hw⟩ := coordinate_mixed_hasDerivAt hΩ z hz hsΩ |
| 104 | have hzd : DifferentiableAt ℝ z (s, 0) := |
| 105 | ((hz (s, 0) hsΩ).contDiffAt (hΩ.mem_nhds hsΩ)).differentiableAt (by simp) |
| 106 | have hzv : HasDerivAt (fun u ↦ z (s, u)) (w s) 0 := |
| 107 | ((coordinateSlice_snd_hasDerivAt z hzd).differentiableAt).hasDerivAt |
| 108 | have hα : MDifferentiableAt (𝓘(ℝ, ℝ)) (𝓡 n) α s := |
| 109 | (hH (s, 0) hsΩ).comp s (mdifferentiableAt_id.prodMk mdifferentiableAt_const) |
| 110 | have hx : α s ∈ (chartAt (EuclideanSpace ℝ (Fin n)) x).source := mem_chart_source _ _ |
| 111 | have ht := backwardSquareTime_mem_interior hwindow p.nonnegative p.ordered hτ₂ hs |
| 112 | have hdom : (s, e (α s)) ∈ chartActionDomain F T x := by |
| 113 | refine ⟨ht, e.map_source ?_⟩ |
| 114 | simpa only [e, extChartAt_source] using hx |
| 115 | have hG := hasFDerivAt_spatial (chartActionDomain_open F T x) _ |
| 116 | (chartActionMetric_contDiffOn F T x) hdom |
| 117 | have hV := hasFDerivAt_spatial (chartActionDomain_open F T x) _ |
| 118 | (chartActionPotential_contDiffOn F hM04 T x) hdom |
| 119 | have hsym (v v' : EuclideanSpace ℝ (Fin n)) : |
| 120 | chartActionMetric F T x (s, z (s, 0)) v v' = |
| 121 | chartActionMetric F T x (s, z (s, 0)) v' v := by |
| 122 | change chartActionMetric F T x (s, extChartAt (𝓡 n) x (α s)) v v' = |
| 123 | chartActionMetric F T x (s, extChartAt (𝓡 n) x (α s)) v' v |
| 124 | rw [chartActionMetric_apply F T hx, chartActionMetric_apply F T hx] |
| 125 | exact (F.metric (T - s ^ 2)).symm _ _ _ |
| 126 | have hraw := chart_density_hasDerivAt (fun y ↦ chartActionMetric F T x (s, y)) |
| 127 | (fun y ↦ chartActionPotential F T x (s, y)) _ _ hG hV hzv hqv hsym |
| 128 | have hnearU : ∀ᶠ u in 𝓝 (0 : ℝ), (s, u) ∈ Ω := |
| 129 | (continuous_const.prodMk continuous_id).continuousAt.preimage_mem_nhds (hΩ.mem_nhds hsΩ) |
| 130 | have hraw' := hraw.congr_of_eventuallyEq (show |
| 131 | (fun u ↦ variationActionDensity V (s, u)) =ᶠ[𝓝 (0 : ℝ)] _ from by |
| 132 | filter_upwards [hnearU] with u hu |
| 133 | exact regularizedLIntegrand_eq_chart F T hu.2 |
| 134 | ((hH (s, u) hu).comp s (mdifferentiableAt_id.prodMk mdifferentiableAt_const))) |
| 135 | have hrawActual := hasDerivAt_variationParameter isOpen_Ioo (variationActionDensity V) |
| 136 | (variationActionDensity_contDiffOn hM04 V) hsC hzero |
| 137 | have hrawEq := hrawActual.unique hraw' |
| 138 | change variationParameterDeriv C V.parameterDomain (variationActionDensity V) (s, 0) = _ |
| 139 | at hrawEq |
| 140 | let E := restrictInteriorVelocityExtension isOpen_Ioo Ioo_subset_Icc_self α D.velocity_extension |
| 141 | have hB := parametricExtension_metric_pair_moving_graph F T isOpen_Ioo E hs hx hα ht hw |
| 142 | have hwfield (r : ℝ) (hr : (r, (0 : ℝ)) ∈ Ω) : |
| 143 | chartFrame x (w r) (α r) = squareVariationField V r := |
| 144 | chartFrame_curveVelocity hr.2 |
| 145 | ((hH (r, 0) hr).comp 0 (mdifferentiableAt_const.prodMk mdifferentiableAt_id)) |
| 146 | have hnearS : ∀ᶠ r in 𝓝 s, (r, (0 : ℝ)) ∈ Ω := |
| 147 | (continuous_id.prodMk continuous_const).continuousAt.preimage_mem_nhds (hΩ.mem_nhds hsΩ) |
| 148 | have hB' := hB.congr_of_eventuallyEq (show variationBoundaryPair V =ᶠ[𝓝 s] _ from by |
| 149 | filter_upwards [hnearS, isOpen_Ioo.mem_nhds hs] with r hr hrI |
| 150 | rw [E.agrees r hrI, hwfield r hr, |
| 151 | curveVelocityWithin_eq_of_open_subset isOpen_Ioo Ioo_subset_Icc_self α hrI] |
| 152 | rfl) |
| 153 | have hBDeriv := hB'.hasDerivWithinAt.derivWithin |
| 154 | (uniqueDiffOn_Icc (Real.sqrt_lt_sqrt p.nonnegative p.ordered) s hsC) |
| 155 | have hR (W : TangentSpace (𝓡 n) (α s)) : |
| 156 | regularizedEulerResidual F T α I E s W = |
| 157 | regularizedEulerResidual F T α C D.velocity_extension s W := by |
| 158 | unfold regularizedEulerResidual pullbackCovariantDerivative E restrictInteriorVelocityExtension |
| 159 | rw [curveVelocityWithin_eq_of_open_subset isOpen_Ioo Ioo_subset_Icc_self α hs] |
| 160 | rfl |
| 161 | have hpot := chartActionPotential_spatial_apply F hM04 T hx ht (w s) |
| 162 | change variationParameterDeriv C V.parameterDomain (variationActionDensity V) (s, 0) = |
| 163 | derivWithin (variationBoundaryPair V) C s - |
| 164 | regularizedEulerResidual F T α C D.velocity_extension s (squareVariationField V s) |
| 165 | change derivWithin (variationBoundaryPair V) C s = _ at hBDeriv |
| 166 | rw [hrawEq, hBDeriv, ← hR] |
| 167 | unfold regularizedEulerResidual scalarCurvatureDifferential |
| 168 | rw [← hwfield s hsΩ, ← hpot] |
| 169 | dsimp only [q, w, qv, α, z, H, e, I, LVariation.baseSquareCurve, Function.comp_def] |
| 170 | ring |
| 171 | |
| 172 | end PoincareMT.LGeometry |