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.Analysis.Approximation.RegularizedMinimum.Finite.Basic |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Pi |
| 3 | |
| 4 | /-! # Differential weights of the finite smooth minimum -/ |
| 5 | |
| 6 | set_option autoImplicit false |
| 7 | |
| 8 | open Set |
| 9 | open scoped ContDiff |
| 10 | |
| 11 | namespace Poincare |
| 12 | |
| 13 | /-- Explicit weights obtained by differentiating the fixed binary recursion. -/ |
| 14 | noncomputable def finiteRegularizedMinWeight (δ : ℝ) (hδ : 0 < δ) : |
| 15 | (n : ℕ) → (Fin (n + 1) → ℝ) → Fin (n + 1) → ℝ |
| 16 | | 0, _ => fun _ => 1 |
| 17 | | n + 1, f => |
| 18 | let d := deriv (regularizedAbs δ hδ) (f 0 - finiteRegularizedMin δ hδ n (Fin.tail f)) |
| 19 | Fin.cases ((1 - d) / 2) |
| 20 | (fun i => ((1 + d) / 2) * finiteRegularizedMinWeight δ hδ n (Fin.tail f) i) |
| 21 | |
| 22 | theorem finiteRegularizedMinWeight_nonneg (δ : ℝ) (hδ : 0 < δ) (n : ℕ) |
| 23 | (f : Fin (n + 1) → ℝ) (i : Fin (n + 1)) : 0 ≤ finiteRegularizedMinWeight δ hδ n f i := by |
| 24 | induction n with |
| 25 | | zero => exact zero_le_one |
| 26 | | succ n ih => |
| 27 | have hd := abs_le.mp (abs_deriv_regularizedAbs_le_one δ hδ |
| 28 | (f 0 - finiteRegularizedMin δ hδ n (Fin.tail f))) |
| 29 | refine Fin.cases (by dsimp [finiteRegularizedMinWeight]; linarith) (fun i => ?_) i |
| 30 | exact mul_nonneg (by linarith) (ih (Fin.tail f) i) |
| 31 | |
| 32 | theorem sum_finiteRegularizedMinWeight (δ : ℝ) (hδ : 0 < δ) (n : ℕ) |
| 33 | (f : Fin (n + 1) → ℝ) : ∑ i, finiteRegularizedMinWeight δ hδ n f i = 1 := by |
| 34 | induction n with |
| 35 | | zero => simp [finiteRegularizedMinWeight] |
| 36 | | succ n ih => |
| 37 | rw [Fin.sum_univ_succ] |
| 38 | simp only [finiteRegularizedMinWeight, Fin.cases_zero, Fin.cases_succ] |
| 39 | rw [← Finset.mul_sum, ih] |
| 40 | ring |
| 41 | |
| 42 | theorem hasDerivAt_finiteRegularizedMin (δ : ℝ) (hδ : 0 < δ) (n : ℕ) |
| 43 | (u : Fin (n + 1) → ℝ → ℝ) (v : Fin (n + 1) → ℝ) (x : ℝ) |
| 44 | (hu : ∀ i, HasDerivAt (u i) (v i) x) : |
| 45 | HasDerivAt (fun t => finiteRegularizedMin δ hδ n (fun i => u i t)) |
| 46 | (∑ i, finiteRegularizedMinWeight δ hδ n (fun i => u i x) i * v i) x := by |
| 47 | induction n with |
| 48 | | zero => simpa [finiteRegularizedMin, finiteRegularizedMinWeight] using hu 0 |
| 49 | | succ n ih => |
| 50 | have ht := ih (fun i => u i.succ) (fun i => v i.succ) (fun i => hu i.succ) |
| 51 | let d := deriv (regularizedAbs δ hδ) |
| 52 | (u 0 x - finiteRegularizedMin δ hδ n (fun i => u i.succ x)) |
| 53 | have ha : HasDerivAt (regularizedAbs δ hδ) d |
| 54 | (u 0 x - finiteRegularizedMin δ hδ n (fun i => u i.succ x)) := |
| 55 | ((contDiff_regularizedAbs δ hδ).differentiable (by simp) _).hasDerivAt |
| 56 | have heq : (∑ i, finiteRegularizedMinWeight δ hδ (n + 1) (fun i => u i x) i * v i) = |
| 57 | (v 0 + (∑ i, finiteRegularizedMinWeight δ hδ n (fun i => u i.succ x) i * v i.succ) - |
| 58 | d * (v 0 - (∑ i, finiteRegularizedMinWeight δ hδ n (fun i => u i.succ x) i * v i.succ))) / 2 := by |
| 59 | rw [Fin.sum_univ_succ] |
| 60 | simp only [finiteRegularizedMinWeight, Fin.cases_zero, Fin.cases_succ, Fin.tail_def] |
| 61 | simp_rw [mul_assoc] |
| 62 | rw [← Finset.mul_sum] |
| 63 | dsimp only [d] |
| 64 | ring |
| 65 | rw [heq] |
| 66 | simpa +instances only [finiteRegularizedMin, regularizedMin, Fin.tail_def, |
| 67 | Function.comp_def, Pi.add_apply, Pi.sub_apply] using |
| 68 | (((hu 0).add ht).sub (ha.comp x ((hu 0).sub ht))).div_const 2 |
| 69 | |
| 70 | theorem fderiv_finiteRegularizedMin_apply (δ : ℝ) (hδ : 0 < δ) (n : ℕ) |
| 71 | (f v : Fin (n + 1) → ℝ) : |
| 72 | fderiv ℝ (finiteRegularizedMin δ hδ n) f v = |
| 73 | ∑ i, finiteRegularizedMinWeight δ hδ n f i * v i := by |
| 74 | have hline : HasDerivAt (fun t : ℝ => f + t • v) v 0 := by |
| 75 | simpa +instances only [one_smul, id_eq] using |
| 76 | ((hasDerivAt_id (0 : ℝ)).smul_const v).const_add f |
| 77 | have hd := ((contDiff_finiteRegularizedMin δ hδ n).differentiable (by simp) f).hasFDerivAt |
| 78 | have hd' : HasFDerivAt (finiteRegularizedMin δ hδ n) |
| 79 | (fderiv ℝ (finiteRegularizedMin δ hδ n) f) (f + (0 : ℝ) • v) := by |
| 80 | simpa only [zero_smul, add_zero] using hd |
| 81 | have hcomp := hd'.comp_hasDerivAt 0 hline |
| 82 | have hcomp' : HasDerivAt (fun t => finiteRegularizedMin δ hδ n (fun i => f i + t * v i)) |
| 83 | (fderiv ℝ (finiteRegularizedMin δ hδ n) f v) 0 := by |
| 84 | simpa +instances only [zero_smul, add_zero, Function.comp_def, Pi.add_def, Pi.smul_def, |
| 85 | smul_eq_mul] using hcomp |
| 86 | have h := hasDerivAt_finiteRegularizedMin δ hδ n |
| 87 | (fun i t => f i + t * v i) v 0 (fun i => by |
| 88 | simpa +instances only [one_mul, id_eq] using |
| 89 | ((hasDerivAt_id (0 : ℝ)).mul_const (v i)).const_add (f i)) |
| 90 | simpa only [zero_mul, add_zero] using hcomp'.unique h |
| 91 | |
| 92 | theorem finiteRegularizedMinWeight_eq_fderiv (δ : ℝ) (hδ : 0 < δ) (n : ℕ) |
| 93 | (f : Fin (n + 1) → ℝ) (i : Fin (n + 1)) : |
| 94 | finiteRegularizedMinWeight δ hδ n f i = |
| 95 | fderiv ℝ (finiteRegularizedMin δ hδ n) f (Pi.single i 1) := by |
| 96 | rw [fderiv_finiteRegularizedMin_apply] |
| 97 | simp [Pi.single_apply] |
| 98 | |
| 99 | /-- The actual second differential has a nonpositive quadratic form. -/ |
| 100 | theorem fderiv2_finiteRegularizedMin_nonpos (δ : ℝ) (hδ : 0 < δ) (n : ℕ) |
| 101 | (f v : Fin (n + 1) → ℝ) : |
| 102 | fderiv ℝ (fderiv ℝ (finiteRegularizedMin δ hδ n)) f v v ≤ 0 := by |
| 103 | let A : ℝ → (Fin (n + 1) → ℝ) := fun t => f + t • v |
| 104 | let q : ℝ → ℝ := fun t => finiteRegularizedMin δ hδ n (A t) |
| 105 | have hA (t : ℝ) : HasDerivAt A v t := by |
| 106 | simpa +instances only [A, one_smul, id_eq] using |
| 107 | ((hasDerivAt_id t).smul_const v).const_add f |
| 108 | have hq : ConcaveOn ℝ univ q := by |
| 109 | simpa [A, q, Function.comp_def, AffineMap.coe_lineMap, add_comm] using |
| 110 | (concaveOn_finiteRegularizedMin δ hδ n).comp_affineMap (AffineMap.lineMap f (f + v)) |
| 111 | have hd (t : ℝ) : HasDerivAt q |
| 112 | (fderiv ℝ (finiteRegularizedMin δ hδ n) (A t) v) t := |
| 113 | ((contDiff_finiteRegularizedMin δ hδ n).differentiable (by simp) (A t)).hasFDerivAt.comp_hasDerivAt |
| 114 | t (hA t) |
| 115 | have hant := hq.antitoneOn_deriv (fun t _ => (hd t).differentiableAt) |
| 116 | have hn : deriv (deriv q) 0 ≤ 0 := |
| 117 | (show Antitone (deriv q) from fun x y hxy => hant (mem_univ x) (mem_univ y) hxy).deriv_nonpos |
| 118 | have hdf : HasFDerivAt (fderiv ℝ (finiteRegularizedMin δ hδ n)) |
| 119 | (fderiv ℝ (fderiv ℝ (finiteRegularizedMin δ hδ n)) f) (A 0) := by |
| 120 | simpa [A] using |
| 121 | (((contDiff_finiteRegularizedMin δ hδ n).fderiv_right (m := ∞) (by simp)).differentiable |
| 122 | (by simp) f).hasFDerivAt |
| 123 | have hsecond := (hdf.comp_hasDerivAt 0 (hA 0)).clm_apply (hasDerivAt_const 0 v) |
| 124 | simp only [Function.comp_def, map_zero, add_zero] at hsecond |
| 125 | have heq : deriv q = fun t => fderiv ℝ (finiteRegularizedMin δ hδ n) (A t) v := |
| 126 | funext fun t => (hd t).deriv |
| 127 | rw [heq, hsecond.deriv] at hn |
| 128 | simpa using hn |
| 129 | |
| 130 | end Poincare |