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.AbsoluteValue |
| 2 | |
| 3 | /-! # A smooth concave regularized minimum |
| 4 | |
| 5 | This operation agrees exactly with minimum when its arguments are separated, |
| 6 | and its differential is a convex combination of the two coordinate maps. |
| 7 | Concavity supplies the nonpositive second-order correction needed for gluing |
| 8 | functions with a common upper Hessian bound. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open Set |
| 14 | open scoped ContDiff |
| 15 | |
| 16 | namespace Poincare |
| 17 | |
| 18 | /-- Smooth minimum with transition width `δ`, lying below the actual minimum. -/ |
| 19 | noncomputable def regularizedMin (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) : ℝ := |
| 20 | (x + y - regularizedAbs δ hδ (x - y)) / 2 |
| 21 | |
| 22 | theorem contDiff_regularizedMin (δ : ℝ) (hδ : 0 < δ) : |
| 23 | ContDiff ℝ ∞ (fun p : ℝ × ℝ => regularizedMin δ hδ p.1 p.2) := |
| 24 | ((contDiff_fst.add contDiff_snd).sub |
| 25 | ((contDiff_regularizedAbs δ hδ).comp (contDiff_fst.sub contDiff_snd))).div_const 2 |
| 26 | |
| 27 | theorem regularizedMin_comm (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) : |
| 28 | regularizedMin δ hδ x y = regularizedMin δ hδ y x := by |
| 29 | unfold regularizedMin |
| 30 | rw [show y - x = -(x - y) by ring, regularizedAbs_neg] |
| 31 | ring |
| 32 | |
| 33 | theorem regularizedMin_add (δ : ℝ) (hδ : 0 < δ) (x y t : ℝ) : |
| 34 | regularizedMin δ hδ (x + t) (y + t) = regularizedMin δ hδ x y + t := by |
| 35 | unfold regularizedMin |
| 36 | rw [show x + t - (y + t) = x - y by ring] |
| 37 | ring |
| 38 | |
| 39 | private theorem min_formula (x y : ℝ) : min x y = (x + y - |x - y|) / 2 := by |
| 40 | rcases le_total x y with h | h |
| 41 | · rw [min_eq_left h, abs_of_nonpos (sub_nonpos.mpr h)] |
| 42 | ring |
| 43 | · rw [min_eq_right h, abs_of_nonneg (sub_nonneg.mpr h)] |
| 44 | ring |
| 45 | |
| 46 | theorem regularizedMin_le_min (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) : |
| 47 | regularizedMin δ hδ x y ≤ min x y := by |
| 48 | rw [min_formula] |
| 49 | unfold regularizedMin |
| 50 | linarith [abs_le_regularizedAbs δ hδ (x - y)] |
| 51 | |
| 52 | theorem min_sub_le_regularizedMin (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) : |
| 53 | min x y - δ / 2 ≤ regularizedMin δ hδ x y := by |
| 54 | rw [min_formula] |
| 55 | unfold regularizedMin |
| 56 | linarith [regularizedAbs_le_abs_add δ hδ (x - y)] |
| 57 | |
| 58 | theorem regularizedMin_eq_min (δ : ℝ) (hδ : 0 < δ) {x y : ℝ} |
| 59 | (hxy : δ ≤ |x - y|) : regularizedMin δ hδ x y = min x y := by |
| 60 | rw [regularizedMin, regularizedAbs_eq_abs δ hδ hxy, min_formula] |
| 61 | |
| 62 | theorem hasDerivAt_regularizedMin_left (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) : |
| 63 | HasDerivAt (fun t => regularizedMin δ hδ t y) |
| 64 | ((1 - deriv (regularizedAbs δ hδ) (x - y)) / 2) x := by |
| 65 | have ha := ((contDiff_regularizedAbs δ hδ).differentiable (by simp) (x - y)).hasDerivAt |
| 66 | simpa +instances only [regularizedMin, Function.comp_def, Pi.sub_apply, id_eq, mul_one] using |
| 67 | (((hasDerivAt_id x).add_const y).sub |
| 68 | (ha.comp x ((hasDerivAt_id x).sub_const y))).div_const 2 |
| 69 | |
| 70 | theorem hasDerivAt_regularizedMin_right (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) : |
| 71 | HasDerivAt (regularizedMin δ hδ x) |
| 72 | ((1 + deriv (regularizedAbs δ hδ) (x - y)) / 2) y := by |
| 73 | have ha := ((contDiff_regularizedAbs δ hδ).differentiable (by simp) (x - y)).hasDerivAt |
| 74 | change HasDerivAt (fun t => (x + t - regularizedAbs δ hδ (x - t)) / 2) _ y |
| 75 | simpa +instances only [regularizedMin, Function.comp_def, Pi.sub_apply, id_eq, |
| 76 | mul_neg, mul_one, sub_neg_eq_add] using |
| 77 | (((hasDerivAt_id y).const_add x).sub |
| 78 | (ha.comp y ((hasDerivAt_id y).const_sub x))).div_const 2 |
| 79 | |
| 80 | theorem regularizedMin_partial_derivatives (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) : |
| 81 | 0 ≤ deriv (fun t => regularizedMin δ hδ t y) x ∧ |
| 82 | 0 ≤ deriv (regularizedMin δ hδ x) y ∧ |
| 83 | deriv (fun t => regularizedMin δ hδ t y) x + |
| 84 | deriv (regularizedMin δ hδ x) y = 1 := by |
| 85 | rw [(hasDerivAt_regularizedMin_left δ hδ x y).deriv, |
| 86 | (hasDerivAt_regularizedMin_right δ hδ x y).deriv] |
| 87 | have h := abs_le.mp (abs_deriv_regularizedAbs_le_one δ hδ (x - y)) |
| 88 | exact ⟨by linarith, by linarith, by ring⟩ |
| 89 | |
| 90 | theorem monotone_regularizedMin_left (δ : ℝ) (hδ : 0 < δ) (y : ℝ) : |
| 91 | Monotone (fun x => regularizedMin δ hδ x y) := |
| 92 | monotone_of_deriv_nonneg |
| 93 | (fun x => (hasDerivAt_regularizedMin_left δ hδ x y).differentiableAt) |
| 94 | (fun x => (regularizedMin_partial_derivatives δ hδ x y).1) |
| 95 | |
| 96 | theorem monotone_regularizedMin_right (δ : ℝ) (hδ : 0 < δ) (x : ℝ) : |
| 97 | Monotone (regularizedMin δ hδ x) := |
| 98 | monotone_of_deriv_nonneg |
| 99 | (fun y => (hasDerivAt_regularizedMin_right δ hδ x y).differentiableAt) |
| 100 | (fun y => (regularizedMin_partial_derivatives δ hδ x y).2.1) |
| 101 | |
| 102 | theorem concaveOn_regularizedMin (δ : ℝ) (hδ : 0 < δ) : |
| 103 | ConcaveOn ℝ univ (fun p : ℝ × ℝ => regularizedMin δ hδ p.1 p.2) := by |
| 104 | refine ⟨convex_univ, ?_⟩ |
| 105 | intro x hx y hy a b ha hb hab |
| 106 | have h := (convexOn_regularizedAbs δ hδ).2 |
| 107 | (mem_univ (x.1 - x.2)) (mem_univ (y.1 - y.2)) ha hb hab |
| 108 | simp only [Prod.smul_fst, Prod.smul_snd, Prod.fst_add, Prod.snd_add, |
| 109 | smul_eq_mul, regularizedMin] at h ⊢ |
| 110 | rw [show a * x.1 + b * y.1 - (a * x.2 + b * y.2) = |
| 111 | a * (x.1 - x.2) + b * (y.1 - y.2) by ring] |
| 112 | nlinarith |
| 113 | |
| 114 | end Poincare |