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.ContDiff.Deriv |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 3 | import Mathlib.Analysis.Calculus.TangentCone.Real |
| 4 | import Mathlib.Analysis.ODE.Gronwall |
| 5 | |
| 6 | /-! |
| 7 | # Closed-time propagation of coordinate bounds |
| 8 | |
| 9 | An affine derivative estimate on the open time interior controls both |
| 10 | the norm and time variation through the endpoints. This is the analytic |
| 11 | step in Morgan--Tian, Lemma 16.8 and Corollary 16.9, pp. 372-373. |
| 12 | See M44 derivation 34. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Set |
| 18 | open scoped ContDiff Topology |
| 19 | |
| 20 | namespace PoincareMT.M44 |
| 21 | |
| 22 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | |
| 24 | /-- A continuous derivative bound on the interior extends to the |
| 25 | one-sided endpoint derivatives. Source: Corollary 16.9, p. 373; |
| 26 | M44 derivation 34. -/ |
| 27 | theorem norm_derivWithin_le_of_interior {f : ℝ → E} {a b : ℝ} (hab : a < b) |
| 28 | (hf : ContDiffOn ℝ 1 f (Icc a b)) {B : ℝ → ℝ} (hB : ContinuousOn B (Icc a b)) |
| 29 | (hbound : ∀ t ∈ Ioo a b, ‖deriv f t‖ ≤ B t) : |
| 30 | ∀ t ∈ Icc a b, ‖derivWithin f (Icc a b) t‖ ≤ B t := by |
| 31 | have hc := (hf.continuousOn_derivWithin (uniqueDiffOn_Icc hab) le_rfl).norm |
| 32 | have hi : ∀ t ∈ Ioo a b, ‖derivWithin f (Icc a b) t‖ ≤ B t := by |
| 33 | intro t ht |
| 34 | rw [derivWithin_of_mem_nhds (Icc_mem_nhds ht.1 ht.2)] |
| 35 | exact hbound t ht |
| 36 | simpa only [closure_Ioo hab.ne] using |
| 37 | le_on_closure hi (by simpa only [closure_Ioo hab.ne] using hc) |
| 38 | (by simpa only [closure_Ioo hab.ne] using hB) |
| 39 | |
| 40 | /-- A within-interval affine differential inequality has the same |
| 41 | exponential bound at the endpoints. Source: the coordinate estimate in |
| 42 | Lemma 16.8, pp. 372-373; M44 derivation 34. -/ |
| 43 | theorem norm_le_exp_of_affine_derivWithin_bound {f : ℝ → E} {a b : ℝ} |
| 44 | (hf : DifferentiableOn ℝ f (Icc a b)) {C D : ℝ} (hC : 0 ≤ C) (hD : 1 ≤ D) |
| 45 | (hinit : ‖f a‖ ≤ D) |
| 46 | (hbound : ∀ t ∈ Icc a b, ‖derivWithin f (Icc a b) t‖ ≤ C * (1 + ‖f t‖)) : |
| 47 | ∀ t ∈ Icc a b, ‖f t‖ ≤ D * Real.exp ((2 * C) * (t - a)) := by |
| 48 | let q : ℝ → E × ℝ := fun t => (f t, 1) |
| 49 | let d : ℝ → E × ℝ := fun t => (derivWithin f (Icc a b) t, 0) |
| 50 | have hd (t : ℝ) (ht : t ∈ Ico a b) : HasDerivWithinAt q (d t) (Ici t) t := by |
| 51 | have hq : HasDerivWithinAt q (d t) (Icc a b) t := |
| 52 | (hf t (Ico_subset_Icc_self ht)).hasDerivWithinAt.prodMk |
| 53 | (hasDerivWithinAt_const t (Icc a b) (1 : ℝ)) |
| 54 | exact hq.mono_of_mem_nhdsWithin (Icc_mem_nhdsGE_of_mem ht) |
| 55 | have hrate (t : ℝ) (ht : t ∈ Ico a b) : ‖d t‖ ≤ (2 * C) * ‖q t‖ + 0 := by |
| 56 | have hmax0 : ‖f t‖ ≤ max ‖f t‖ 1 := le_max_left _ _ |
| 57 | have hmax1 : 1 ≤ max ‖f t‖ 1 := le_max_right _ _ |
| 58 | have hh := hbound t (Ico_subset_Icc_self ht) |
| 59 | simp only [q, d, Prod.norm_def, norm_zero, max_eq_left (norm_nonneg _), norm_one] |
| 60 | nlinarith [mul_nonneg hC (sub_nonneg.mpr hmax0), |
| 61 | mul_nonneg hC (sub_nonneg.mpr hmax1)] |
| 62 | have hq : ContinuousOn q (Icc a b) := hf.continuousOn.prodMk continuousOn_const |
| 63 | have hqa : ‖q a‖ ≤ D := by |
| 64 | simpa only [q, Prod.norm_def, norm_one] using max_le hinit hD |
| 65 | intro t ht |
| 66 | have h := norm_le_gronwallBound_of_norm_deriv_right_le hq hd hqa hrate t ht |
| 67 | rw [gronwallBound_ε0] at h |
| 68 | exact (norm_fst_le (q t)).trans h |
| 69 | |
| 70 | /-- An interior affine derivative estimate yields a uniform norm bound |
| 71 | on the entire closed interval. Source: Lemma 16.8, pp. 372-373; |
| 72 | M44 derivation 34. -/ |
| 73 | theorem norm_le_exp_of_interior_affine_bound {f : ℝ → E} {a b : ℝ} (hab : a < b) |
| 74 | (hf : ContDiffOn ℝ 1 f (Icc a b)) {C D : ℝ} (hC : 0 ≤ C) (hD : 1 ≤ D) |
| 75 | (hinit : ‖f a‖ ≤ D) |
| 76 | (hbound : ∀ t ∈ Ioo a b, ‖deriv f t‖ ≤ C * (1 + ‖f t‖)) : |
| 77 | ∀ t ∈ Icc a b, ‖f t‖ ≤ D * Real.exp ((2 * C) * (b - a)) := by |
| 78 | have hclosed := norm_derivWithin_le_of_interior hab hf |
| 79 | (continuousOn_const.mul (continuousOn_const.add hf.continuousOn.norm)) hbound |
| 80 | intro t ht |
| 81 | apply (norm_le_exp_of_affine_derivWithin_bound (hf.differentiableOn (by norm_num)) |
| 82 | hC hD hinit hclosed t ht).trans |
| 83 | apply mul_le_mul_of_nonneg_left _ (by linarith : 0 ≤ D) |
| 84 | exact Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left (sub_le_sub_right ht.2 a) |
| 85 | (by positivity)) |
| 86 | |
| 87 | /-- A uniform derivative bound gives the time modulus on the closed |
| 88 | interval. Source: the terminal uniformity in Corollary 16.9, p. 373; |
| 89 | M44 derivation 34. -/ |
| 90 | theorem norm_sub_le_of_interior_deriv_bound {f : ℝ → E} {a b : ℝ} (hab : a < b) |
| 91 | (hf : ContDiffOn ℝ 1 f (Icc a b)) {C : ℝ} |
| 92 | (hbound : ∀ t ∈ Ioo a b, ‖deriv f t‖ ≤ C) : |
| 93 | ∀ s ∈ Icc a b, ∀ t ∈ Icc a b, ‖f t - f s‖ ≤ C * |t - s| := by |
| 94 | have hclosed := norm_derivWithin_le_of_interior hab hf continuousOn_const hbound |
| 95 | intro s hs t ht |
| 96 | simpa only [Real.norm_eq_abs] using (convex_Icc a b).norm_image_sub_le_of_norm_derivWithin_le |
| 97 | (hf.differentiableOn (by norm_num)) hclosed hs ht |
| 98 | |
| 99 | end PoincareMT.M44 |