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.CurveShortening.Ramp.Analysis.Classical.Primitive |
| 2 | import Mathlib.Analysis.Calculus.IteratedDeriv.Defs |
| 3 | import Mathlib.Analysis.Calculus.ParametricIntervalIntegral |
| 4 | import Mathlib.Analysis.Normed.Group.Bounded |
| 5 | |
| 6 | /-! |
| 7 | # Actual spatial derivatives of a time primitive |
| 8 | |
| 9 | Compact bounds for the next spatial jet justify differentiation under |
| 10 | the actual interval integral. The resulting primitives give genuine |
| 11 | interior time derivatives. MT2007 Claim 19.1, p. 437; |
| 12 | `2026-09-22-interior-parabolic-smooth-upgrade.md`, statement 2. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set Filter MeasureTheory |
| 18 | open scoped ContDiff Topology |
| 19 | |
| 20 | /-- Every spatial jet of a literal time primitive has its own literal |
| 21 | primitive and witnessed interior time derivative. No mixed derivative |
| 22 | or time derivative of the jets is assumed. MT2007 Claim 19.1, p. 437; |
| 23 | interior parabolic smooth upgrade derivation, statement 2. -/ |
| 24 | theorem iteratedDeriv_primitive_and_hasDerivAt |
| 25 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 26 | {a b : ℝ} (hab : a ≤ b) {q R : ℝ → ℝ → E} |
| 27 | (hq : ∀ t ∈ Icc a b, ContDiff ℝ ∞ (q t)) |
| 28 | (hR : ∀ t ∈ Icc a b, ContDiff ℝ ∞ (R t)) |
| 29 | (hjets : ∀ k : ℕ, ContinuousOn |
| 30 | (fun z : ℝ × ℝ => iteratedDeriv k (R z.1) z.2) (Icc a b ×ˢ univ)) |
| 31 | (hprimitive : ∀ t ∈ Icc a b, ∀ x, |
| 32 | q t x = q a x + ∫ r in a..t, R r x) : |
| 33 | ∀ k : ℕ, |
| 34 | (∀ t ∈ Icc a b, ∀ x, iteratedDeriv k (q t) x = |
| 35 | iteratedDeriv k (q a) x + ∫ r in a..t, iteratedDeriv k (R r) x) ∧ |
| 36 | ∀ t ∈ Ioo a b, ∀ x, HasDerivAt (fun r => iteratedDeriv k (q r) x) |
| 37 | (iteratedDeriv k (R t) x) t := by |
| 38 | have hqd (k : ℕ) (t : ℝ) (ht : t ∈ Icc a b) (x : ℝ) : |
| 39 | HasDerivAt (iteratedDeriv k (q t)) (iteratedDeriv (k + 1) (q t) x) x := by |
| 40 | simpa only [iteratedDeriv_succ] using |
| 41 | ((hq t ht).differentiable_iteratedDeriv k |
| 42 | (ENat.natCast_lt_of_coe_top_le_withTop le_rfl k) x).hasDerivAt |
| 43 | have hRd (k : ℕ) (t : ℝ) (ht : t ∈ Icc a b) (x : ℝ) : |
| 44 | HasDerivAt (iteratedDeriv k (R t)) (iteratedDeriv (k + 1) (R t) x) x := by |
| 45 | simpa only [iteratedDeriv_succ] using |
| 46 | ((hR t ht).differentiable_iteratedDeriv k |
| 47 | (ENat.natCast_lt_of_coe_top_le_withTop le_rfl k) x).hasDerivAt |
| 48 | have hcont (k : ℕ) (x : ℝ) : |
| 49 | ContinuousOn (fun r => iteratedDeriv k (R r) x) (Icc a b) := |
| 50 | (hjets k).comp (continuous_id.prodMk continuous_const).continuousOn |
| 51 | (fun _ hr => ⟨hr, mem_univ _⟩) |
| 52 | have hint (k : ℕ) (t : ℝ) (ht : t ∈ Icc a b) (x : ℝ) : |
| 53 | IntervalIntegrable (fun r => iteratedDeriv k (R r) x) volume a t := |
| 54 | ContinuousOn.intervalIntegrable_of_Icc ht.1 |
| 55 | ((hcont k x).mono (Icc_subset_Icc_right ht.2)) |
| 56 | have hprim : ∀ k : ℕ, ∀ t ∈ Icc a b, ∀ x, iteratedDeriv k (q t) x = |
| 57 | iteratedDeriv k (q a) x + ∫ r in a..t, iteratedDeriv k (R r) x := by |
| 58 | intro k |
| 59 | induction k with |
| 60 | | zero => simpa only [iteratedDeriv_zero] using hprimitive |
| 61 | | succ k ih => |
| 62 | intro t ht x |
| 63 | obtain ⟨C, hC⟩ := (isCompact_Icc.prod |
| 64 | (isCompact_Icc : IsCompact (Icc (x - 1) (x + 1)))).exists_bound_of_continuousOn |
| 65 | ((hjets (k + 1)).mono (prod_mono_right (subset_univ _))) |
| 66 | have hdint := intervalIntegral.hasDerivAt_integral_of_dominated_loc_of_deriv_le |
| 67 | (F := fun y r => iteratedDeriv k (R r) y) |
| 68 | (F' := fun y r => iteratedDeriv (k + 1) (R r) y) |
| 69 | (x₀ := x) (s := Ioo (x - 1) (x + 1)) (bound := fun _ => C) |
| 70 | (a := a) (b := t) (Ioo_mem_nhds (by linarith) (by linarith)) |
| 71 | (Eventually.of_forall fun y => (hint k t ht y).def'.aestronglyMeasurable) |
| 72 | (hint k t ht x) (hint (k + 1) t ht x).def'.aestronglyMeasurable |
| 73 | (Eventually.of_forall fun r hr y hy => by |
| 74 | rw [uIoc_of_le ht.1] at hr |
| 75 | exact hC (r, y) ⟨⟨hr.1.le, hr.2.trans ht.2⟩, hy.1.le, hy.2.le⟩) |
| 76 | intervalIntegrable_const |
| 77 | (Eventually.of_forall fun r hr y _ => by |
| 78 | rw [uIoc_of_le ht.1] at hr |
| 79 | exact hRd k r ⟨hr.1.le, hr.2.trans ht.2⟩ y) |
| 80 | have heq : iteratedDeriv k (q t) = fun y => |
| 81 | iteratedDeriv k (q a) y + ∫ r in a..t, iteratedDeriv k (R r) y := |
| 82 | funext (ih t ht) |
| 83 | have hsum : HasDerivAt (iteratedDeriv k (q t)) |
| 84 | (iteratedDeriv (k + 1) (q a) x + |
| 85 | ∫ r in a..t, iteratedDeriv (k + 1) (R r) x) x := by |
| 86 | rw [heq] |
| 87 | exact (hqd k a ⟨le_rfl, hab⟩ x).add hdint.2 |
| 88 | exact (hqd k t ht x).unique hsum |
| 89 | intro k |
| 90 | refine ⟨hprim k, ?_⟩ |
| 91 | intro t ht x |
| 92 | exact hasDerivAt_of_ae_continuous_primitive hab |
| 93 | (hint k b ⟨hab, le_rfl⟩ x) (hcont k x) Filter.EventuallyEq.rfl |
| 94 | (fun s hs => hprim k s hs x) ht |