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 Mathlib.Analysis.Calculus.ParametricIntervalIntegral |
| 2 | import Mathlib.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus |
| 3 | |
| 4 | /-! |
| 5 | # Interval differentiation with continuous parameter derivatives |
| 6 | |
| 7 | The analytic step in Morgan-Tian Lemma 6.4, pp. 107-108, needs no |
| 8 | time derivative of the path velocity. This adapts M08 VariationIntegral's |
| 9 | compact rectangle bound to a supplied continuous parameter derivative. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open Set Filter MeasureTheory |
| 15 | open scoped Topology intervalIntegral |
| 16 | |
| 17 | namespace intervalIntegral |
| 18 | |
| 19 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 20 | {μ : Measure ℝ} [IsLocallyFiniteMeasure μ] |
| 21 | |
| 22 | /-- Continuous densities with continuous actual parameter derivatives |
| 23 | can be differentiated under a compact interval integral, the analytic |
| 24 | step in Lemma 6.4, pp. 107-108. -/ |
| 25 | theorem hasDerivAt_integral_of_continuousOn_parameter {a b : ℝ} (hab : a ≤ b) |
| 26 | {P : Set ℝ} (hP : IsOpen P) (L L' : ℝ × ℝ → E) |
| 27 | (hL : ContinuousOn L (Icc a b ×ˢ P)) (hL' : ContinuousOn L' (Icc a b ×ˢ P)) |
| 28 | (hd : ∀ s ∈ Icc a b, ∀ v ∈ P, HasDerivAt (fun w => L (s, w)) (L' (s, v)) v) |
| 29 | {v : ℝ} (hv : v ∈ P) : |
| 30 | IntervalIntegrable (fun s => L' (s, v)) μ a b ∧ |
| 31 | HasDerivAt (fun w => ∫ s in a..b, L (s, w) ∂μ) |
| 32 | (∫ s in a..b, L' (s, v) ∂μ) v := by |
| 33 | have hslice (w : ℝ) (hw : w ∈ P) : ContinuousOn (fun s => L (s, w)) (Icc a b) := |
| 34 | hL.comp (continuousOn_id.prodMk continuousOn_const) (fun _ hs => ⟨hs, hw⟩) |
| 35 | have hslice' (w : ℝ) (hw : w ∈ P) : ContinuousOn (fun s => L' (s, w)) (Icc a b) := |
| 36 | hL'.comp (continuousOn_id.prodMk continuousOn_const) (fun _ hs => ⟨hs, hw⟩) |
| 37 | obtain ⟨l, r, _, hnear, hsub⟩ := exists_Icc_mem_subset_of_mem_nhds (hP.mem_nhds hv) |
| 38 | have hcompact : IsCompact (Icc a b ×ˢ Icc l r) := isCompact_Icc.prod isCompact_Icc |
| 39 | obtain ⟨K, hK⟩ := hcompact.exists_bound_of_continuousOn |
| 40 | (hL'.mono (prod_mono Subset.rfl hsub)) |
| 41 | apply hasDerivAt_integral_of_dominated_loc_of_deriv_le |
| 42 | (F := fun w s => L (s, w)) (F' := fun w s => L' (s, w)) |
| 43 | (bound := fun _ => K) hnear ?_ ?_ ?_ ?_ intervalIntegrable_const ?_ |
| 44 | · filter_upwards [hP.mem_nhds hv] with w hw |
| 45 | exact ((hslice w hw).intervalIntegrable_of_Icc hab).aestronglyMeasurable_restrict_uIoc |
| 46 | · exact (hslice v hv).intervalIntegrable_of_Icc hab |
| 47 | · exact ((hslice' v hv).intervalIntegrable_of_Icc hab).aestronglyMeasurable_restrict_uIoc |
| 48 | · exact Eventually.of_forall (fun s hs w hw => hK (s, w) |
| 49 | ⟨Ioc_subset_Icc_self (by simpa only [uIoc_of_le hab] using hs), hw⟩) |
| 50 | · exact Eventually.of_forall (fun s hs w hw => hd s |
| 51 | (Ioc_subset_Icc_self (by simpa only [uIoc_of_le hab] using hs)) w (hsub hw)) |
| 52 | |
| 53 | end intervalIntegral |