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.MeasureTheory.Integral.IntervalIntegral.FundThmCalculus |
| 2 | |
| 3 | /-! |
| 4 | # Actual time derivatives from an integral primitive |
| 5 | |
| 6 | An integrable primitive whose integrand has a continuous representative |
| 7 | has a genuine derivative at every interior time. This is the FTC input |
| 8 | for MT2007 Claim 19.1, p. 437; |
| 9 | `2026-09-22-classical-regularity-from-primitive.md`, statement 1. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open Set Filter MeasureTheory |
| 15 | open scoped Topology |
| 16 | |
| 17 | /-- A literal primitive with an AE continuous integrand has its actual |
| 18 | interior derivative. No prior differentiability of the primitive is |
| 19 | assumed. MT2007 Claim 19.1, p. 437; classical regularity from primitive, |
| 20 | statement 1. Integrability and the restricted AE measure are explicit. -/ |
| 21 | theorem hasDerivAt_of_ae_continuous_primitive |
| 22 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 23 | {a b : ℝ} (hab : a ≤ b) {f R Q : ℝ → E} |
| 24 | (hf : IntervalIntegrable f volume a b) (hR : ContinuousOn R (Icc a b)) |
| 25 | (heq : f =ᵐ[volume.restrict (Ioc a b)] R) |
| 26 | (hprimitive : ∀ s ∈ Icc a b, Q s = Q a + ∫ r in a..s, f r) |
| 27 | {t : ℝ} (ht : t ∈ Ioo a b) : HasDerivAt Q (R t) t := by |
| 28 | have heq' (s : ℝ) (hs : s ∈ Icc a b) : f =ᵐ[volume.restrict (uIoc a s)] R := by |
| 29 | rw [uIoc_of_le hs.1] |
| 30 | exact ae_restrict_of_ae_restrict_of_subset (Ioc_subset_Ioc le_rfl hs.2) heq |
| 31 | have hft : IntervalIntegrable f volume a t := hf.mono_set (by |
| 32 | simpa only [uIcc_of_le ht.1.le, uIcc_of_le hab] using |
| 33 | (Icc_subset_Icc le_rfl ht.2.le)) |
| 34 | have hRt : IntervalIntegrable R volume a t := hft.congr_ae (heq' t (Ioo_subset_Icc_self ht)) |
| 35 | have hRopen : ContinuousOn R (Ioo a b) := hR.mono Ioo_subset_Icc_self |
| 36 | have hFTC := intervalIntegral.integral_hasDerivAt_right hRt |
| 37 | (hRopen.stronglyMeasurableAtFilter isOpen_Ioo t ht) |
| 38 | (hRopen.continuousAt (isOpen_Ioo.mem_nhds ht)) |
| 39 | have hderiv : HasDerivAt (fun s => Q a + ∫ r in a..s, R r) (R t) t := by |
| 40 | exact hFTC.const_add (Q a) |
| 41 | apply hderiv.congr_of_eventuallyEq |
| 42 | filter_upwards [isOpen_Ioo.mem_nhds ht] with s hs |
| 43 | rw [hprimitive s (Ioo_subset_Icc_self hs), |
| 44 | intervalIntegral.integral_congr_ae_restrict (heq' s (Ioo_subset_Icc_self hs))] |