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.BoundedDistance.GeometryImports |
| 2 | import PoincareLib.Geometry.Riemannian.Comparison.Volume.Conjugate.Variation.Energy |
| 3 | import Mathlib.Analysis.Calculus.ContDiff.Deriv |
| 4 | import Mathlib.Topology.Order.ProjIcc |
| 5 | import Mathlib.MeasureTheory.Integral.Bochner.Set |
| 6 | |
| 7 | /-! |
| 8 | # Local C2 parameter integrals |
| 9 | |
| 10 | Continuous densities on a compact integration interval yield continuous |
| 11 | parameter integrals. Two local differentiations then give C2 regularity |
| 12 | from an open-rectangle hypothesis. |
| 13 | Source: Morgan--Tian Theorem 2.4, p. 23, and the incomplete comparison |
| 14 | argument in Chapter 10, pp. 258-260; M28 derivation 139. |
| 15 | -/ |
| 16 | |
| 17 | open Set MeasureTheory |
| 18 | open scoped Topology ContDiff |
| 19 | |
| 20 | noncomputable section |
| 21 | set_option autoImplicit false |
| 22 | |
| 23 | namespace PoincareMT.ConjugateVariation |
| 24 | |
| 25 | /-- A continuous density on an open parameter set and a compact integration |
| 26 | interval has a continuous parameter integral on that open set. |
| 27 | Source: M28 derivation 139, local regularity of the constructed energy. -/ |
| 28 | theorem continuousOn_intervalIntegral_of_continuousOn_prod |
| 29 | {F : ℝ → ℝ → ℝ} {I : Set ℝ} {a b : ℝ} |
| 30 | (hI : IsOpen I) (hab : a ≤ b) |
| 31 | (hF : ContinuousOn (Function.uncurry F) (I ×ˢ Icc a b)) : |
| 32 | ContinuousOn (fun s => ∫ t in a..b, F s t) I := by |
| 33 | let : LocallyCompactSpace I := hI.locallyCompactSpace |
| 34 | let f : I → ℝ → ℝ := fun s t => F s (projIcc a b hab t) |
| 35 | have hf : Continuous (Function.uncurry f) := by |
| 36 | apply hF.comp_continuous |
| 37 | ((continuous_subtype_val.comp continuous_fst).prodMk |
| 38 | (continuous_subtype_val.comp ((continuous_projIcc (h := hab)).comp continuous_snd))) |
| 39 | intro p |
| 40 | exact ⟨p.1.property, (projIcc a b hab p.2).property⟩ |
| 41 | have hc : Continuous (fun s : I => ∫ t in Icc a b, f s t) := |
| 42 | continuous_parametric_integral_of_continuous hf isCompact_Icc |
| 43 | apply continuousOn_iff_continuous_domRestrict.mpr |
| 44 | have heq : (fun s : I => ∫ t in a..b, F s t) = |
| 45 | (fun s : I => ∫ t in Icc a b, f s t) := by |
| 46 | funext s |
| 47 | rw [intervalIntegral.integral_of_le hab, ← integral_Icc_eq_integral_Ioc] |
| 48 | apply setIntegral_congr_fun measurableSet_Icc |
| 49 | intro t ht |
| 50 | simp [f, projIcc_of_mem hab ht] |
| 51 | change Continuous (fun s : I => ∫ t in a..b, F s t) |
| 52 | rw [heq] |
| 53 | exact hc |
| 54 | |
| 55 | /-- A C2 density on an open rectangle gives a C2 parameter integral on |
| 56 | the parameter interval, with no global regularity hypothesis. |
| 57 | Source: M28 derivation 139, local regularity of the constructed energy. -/ |
| 58 | theorem contDiffOn_two_intervalIntegral_of_contDiffOn_box |
| 59 | {F : ℝ → ℝ → ℝ} {a b s₀ r : ℝ} (hab : a ≤ b) (hr : 0 < r) |
| 60 | (hF : ContDiffOn ℝ 2 (Function.uncurry F) |
| 61 | (Ioo (s₀ - r) (s₀ + r) ×ˢ Ioo (a - r) (b + r))) : |
| 62 | ContDiffOn ℝ 2 (fun s => ∫ t in a..b, F s t) (Ioo (s₀ - r) (s₀ + r)) := by |
| 63 | let I := Ioo (s₀ - r) (s₀ + r) |
| 64 | let J := Ioo (a - r) (b + r) |
| 65 | have hU : IsOpen (I ×ˢ J) := isOpen_Ioo.prod isOpen_Ioo |
| 66 | have hIccJ : Icc a b ⊆ J := fun t ht => |
| 67 | ⟨by linarith [ht.1], by linarith [ht.2]⟩ |
| 68 | let G : ℝ → ℝ → ℝ := fun s t => deriv (fun σ => F σ t) s |
| 69 | let K : ℝ → ℝ → ℝ := fun s t => deriv (fun σ => G σ t) s |
| 70 | have hF1 : ContDiffOn ℝ 1 (Function.uncurry F) (I ×ˢ J) := |
| 71 | hF.of_le (by norm_num) |
| 72 | have hG1 : ContDiffOn ℝ 1 (Function.uncurry G) (I ×ˢ J) := by |
| 73 | have hfd : ContDiffOn ℝ 1 (fun p => fderiv ℝ (Function.uncurry F) p) |
| 74 | (I ×ˢ J) := hF.fderiv_of_isOpen hU (by norm_num) |
| 75 | refine (hfd.clm_apply (contDiffOn_const (c := ((1 : ℝ), (0 : ℝ))))).congr ?_ |
| 76 | rintro ⟨s, t⟩ ⟨hs, ht⟩ |
| 77 | exact (hasDerivAt_partial_of_contDiffOn_box hF1 hs ht).deriv |
| 78 | have hK : ContinuousOn (Function.uncurry K) (I ×ˢ J) := by |
| 79 | have hfd := hG1.continuousOn_fderiv_of_isOpen hU le_rfl |
| 80 | refine (hfd.clm_apply (continuousOn_const (c := ((1 : ℝ), (0 : ℝ))))).congr ?_ |
| 81 | rintro ⟨s, t⟩ ⟨hs, ht⟩ |
| 82 | exact (hasDerivAt_partial_of_contDiffOn_box hG1 hs ht).deriv |
| 83 | have hcK : ContinuousOn (fun s => ∫ t in a..b, K s t) I := |
| 84 | continuousOn_intervalIntegral_of_continuousOn_prod isOpen_Ioo hab |
| 85 | (hK.mono (prod_mono subset_rfl hIccJ)) |
| 86 | have hDF (s : ℝ) (hs : s ∈ I) : |
| 87 | HasDerivAt (fun σ => ∫ t in a..b, F σ t) (∫ t in a..b, G s t) s := |
| 88 | hasDerivAt_intervalIntegral_of_contDiffOn_box hab hr hF1 hs |
| 89 | have hDG (s : ℝ) (hs : s ∈ I) : |
| 90 | HasDerivAt (fun σ => ∫ t in a..b, G σ t) (∫ t in a..b, K s t) s := |
| 91 | hasDerivAt_intervalIntegral_of_contDiffOn_box hab hr hG1 hs |
| 92 | have hEG : ContDiffOn ℝ 1 (fun s => ∫ t in a..b, G s t) I := by |
| 93 | rw [show (1 : ℕ∞ω) = 0 + 1 from rfl, |
| 94 | contDiffOn_succ_iff_deriv_of_isOpen isOpen_Ioo] |
| 95 | refine ⟨fun s hs => (hDG s hs).differentiableAt.differentiableWithinAt, |
| 96 | by simp, ?_⟩ |
| 97 | rw [contDiffOn_zero] |
| 98 | exact hcK.congr fun s hs => (hDG s hs).deriv |
| 99 | rw [show (2 : ℕ∞ω) = 1 + 1 from rfl, |
| 100 | contDiffOn_succ_iff_deriv_of_isOpen isOpen_Ioo] |
| 101 | refine ⟨fun s hs => (hDF s hs).differentiableAt.differentiableWithinAt, |
| 102 | by simp, ?_⟩ |
| 103 | exact hEG.congr fun s hs => (hDF s hs).deriv |
| 104 | |
| 105 | end PoincareMT.ConjugateVariation |
| 106 | end |