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.Weights |
| 2 | |
| 3 | /-! # Inactive coordinates of the finite smooth minimum |
| 4 | |
| 5 | A coordinate more than `2 * n * δ` above the true minimum has zero differential |
| 6 | weight. More strongly, changing that coordinate within the inactive region |
| 7 | leaves the selector exactly unchanged, including on a neighborhood of each |
| 8 | strictly inactive input. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open Set Filter |
| 14 | open scoped ContDiff Topology |
| 15 | |
| 16 | namespace Poincare |
| 17 | |
| 18 | private theorem left_factor_eq_zero (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) |
| 19 | (hx : regularizedMin δ hδ x y + 2 * δ < x) : |
| 20 | (1 - deriv (regularizedAbs δ hδ) (x - y)) / 2 = 0 := by |
| 21 | have hlow := min_sub_le_regularizedMin δ hδ x y |
| 22 | have hgap : y + δ < x := by |
| 23 | rcases le_total x y with h | h |
| 24 | · rw [min_eq_left h] at hlow |
| 25 | linarith |
| 26 | · rw [min_eq_right h] at hlow |
| 27 | linarith |
| 28 | have hd : HasDerivAt (fun t => regularizedMin δ hδ t y) 0 x := by |
| 29 | apply (hasDerivAt_const x y).congr_of_eventuallyEq |
| 30 | filter_upwards [continuousAt_const.eventually_lt continuousAt_id hgap] with t ht |
| 31 | dsimp only [id_eq] at ht |
| 32 | rw [regularizedMin_eq_min δ hδ (by |
| 33 | rw [abs_of_nonneg (by linarith : 0 ≤ t - y)] |
| 34 | linarith), min_eq_right (by linarith)] |
| 35 | exact (hasDerivAt_regularizedMin_left δ hδ x y).unique hd |
| 36 | |
| 37 | private theorem right_factor_eq_zero (δ : ℝ) (hδ : 0 < δ) (x y : ℝ) |
| 38 | (hy : regularizedMin δ hδ x y + 2 * δ < y) : |
| 39 | (1 + deriv (regularizedAbs δ hδ) (x - y)) / 2 = 0 := by |
| 40 | have hlow := min_sub_le_regularizedMin δ hδ x y |
| 41 | have hgap : x + δ < y := by |
| 42 | rcases le_total x y with h | h |
| 43 | · rw [min_eq_left h] at hlow |
| 44 | linarith |
| 45 | · rw [min_eq_right h] at hlow |
| 46 | linarith |
| 47 | have hd : HasDerivAt (regularizedMin δ hδ x) 0 y := by |
| 48 | apply (hasDerivAt_const y x).congr_of_eventuallyEq |
| 49 | filter_upwards [continuousAt_const.eventually_lt continuousAt_id hgap] with t ht |
| 50 | dsimp only [id_eq] at ht |
| 51 | rw [regularizedMin_comm, regularizedMin_eq_min δ hδ (by |
| 52 | rw [abs_of_nonneg (by linarith : 0 ≤ t - x)] |
| 53 | linarith), min_eq_right (by linarith)] |
| 54 | exact (hasDerivAt_regularizedMin_right δ hδ x y).unique hd |
| 55 | |
| 56 | theorem finiteRegularizedMinWeight_eq_zero_of_value_gap |
| 57 | (δ : ℝ) (hδ : 0 < δ) (n : ℕ) (f : Fin (n + 1) → ℝ) (i : Fin (n + 1)) |
| 58 | (hi : finiteRegularizedMin δ hδ n f + 2 * n * δ < f i) : |
| 59 | finiteRegularizedMinWeight δ hδ n f i = 0 := by |
| 60 | induction n with |
| 61 | | zero => |
| 62 | simp only [finiteRegularizedMin, Nat.cast_zero, mul_zero, zero_mul, add_zero, |
| 63 | Fin.fin_one_eq_zero i, lt_self_iff_false] at hi |
| 64 | | succ n ih => |
| 65 | refine Fin.cases (fun hi => ?_) (fun i hi => ?_) i hi |
| 66 | · apply left_factor_eq_zero |
| 67 | have hn : 0 ≤ (n : ℝ) * δ := by positivity |
| 68 | change regularizedMin δ hδ (f 0) (finiteRegularizedMin δ hδ n (Fin.tail f)) + |
| 69 | 2 * (n + 1 : ℕ) * δ < f 0 at hi |
| 70 | push_cast at hi |
| 71 | linarith |
| 72 | · change ((1 + deriv (regularizedAbs δ hδ) |
| 73 | (f 0 - finiteRegularizedMin δ hδ n (Fin.tail f))) / 2) * |
| 74 | finiteRegularizedMinWeight δ hδ n (Fin.tail f) i = 0 |
| 75 | by_cases ht : finiteRegularizedMin δ hδ (n + 1) f + 2 * δ < |
| 76 | finiteRegularizedMin δ hδ n (Fin.tail f) |
| 77 | · rw [right_factor_eq_zero δ hδ _ _ ht, zero_mul] |
| 78 | · rw [ih (Fin.tail f) i (by |
| 79 | push_cast at hi |
| 80 | dsimp only [Fin.tail] |
| 81 | linarith), mul_zero] |
| 82 | |
| 83 | theorem finiteRegularizedMinWeight_eq_zero_of_iInf_gap |
| 84 | (δ : ℝ) (hδ : 0 < δ) (n : ℕ) (f : Fin (n + 1) → ℝ) (i : Fin (n + 1)) |
| 85 | (hi : (⨅ j, f j) + 2 * n * δ < f i) : |
| 86 | finiteRegularizedMinWeight δ hδ n f i = 0 := by |
| 87 | apply finiteRegularizedMinWeight_eq_zero_of_value_gap |
| 88 | have h := finiteRegularizedMin_le_iInf δ hδ n f |
| 89 | linarith |
| 90 | |
| 91 | theorem hasDerivAt_finiteRegularizedMin_update |
| 92 | (δ : ℝ) (hδ : 0 < δ) (n : ℕ) (f : Fin (n + 1) → ℝ) (i : Fin (n + 1)) (t : ℝ) : |
| 93 | HasDerivAt (fun s => finiteRegularizedMin δ hδ n (Function.update f i s)) |
| 94 | (finiteRegularizedMinWeight δ hδ n (Function.update f i t) i) t := by |
| 95 | rw [finiteRegularizedMinWeight_eq_fderiv] |
| 96 | exact ((contDiff_finiteRegularizedMin δ hδ n).differentiable (by simp) _).hasFDerivAt.comp_hasDerivAt |
| 97 | t (hasDerivAt_update f i t) |
| 98 | |
| 99 | /-- Replacing a high coordinate by another high value leaves the selector unchanged. -/ |
| 100 | theorem finiteRegularizedMin_update_eq |
| 101 | (δ : ℝ) (hδ : 0 < δ) (n : ℕ) (f : Fin (n + 1) → ℝ) (i j : Fin (n + 1)) |
| 102 | (hji : j ≠ i) (t : ℝ) |
| 103 | (hi : f j + 2 * n * δ < f i) (ht : f j + 2 * n * δ < t) : |
| 104 | finiteRegularizedMin δ hδ n (Function.update f i t) = finiteRegularizedMin δ hδ n f := by |
| 105 | have hconst := (isOpen_Ioi : IsOpen (Ioi (f j + 2 * n * δ))).is_const_of_deriv_eq_zero |
| 106 | isPreconnected_Ioi |
| 107 | (fun s _ => (hasDerivAt_finiteRegularizedMin_update δ hδ n f i s).differentiableAt.differentiableWithinAt) |
| 108 | (fun s hs => ?_) ht hi |
| 109 | · simpa only [Function.update_eq_self] using hconst |
| 110 | · rw [(hasDerivAt_finiteRegularizedMin_update δ hδ n f i s).deriv] |
| 111 | apply finiteRegularizedMinWeight_eq_zero_of_value_gap |
| 112 | have hle := finiteRegularizedMin_le δ hδ n (Function.update f i s) j |
| 113 | simp only [Function.update_of_ne hji] at hle |
| 114 | simp only [Function.update_self] |
| 115 | change f j + 2 * n * δ < s at hs |
| 116 | linarith |
| 117 | |
| 118 | /-- Near a strictly inactive input, freezing that coordinate gives the same function. -/ |
| 119 | theorem finiteRegularizedMin_update_eventuallyEq |
| 120 | (δ : ℝ) (hδ : 0 < δ) (n : ℕ) (f : Fin (n + 1) → ℝ) (i : Fin (n + 1)) |
| 121 | (hi : (⨅ j, f j) + 2 * n * δ < f i) : |
| 122 | (fun g => finiteRegularizedMin δ hδ n (Function.update g i (f i))) =ᶠ[𝓝 f] |
| 123 | finiteRegularizedMin δ hδ n := by |
| 124 | obtain ⟨j, hj⟩ := exists_eq_ciInf_of_finite (f := f) |
| 125 | have hgap : f j + 2 * n * δ < f i := by simpa only [hj] using hi |
| 126 | have hji : j ≠ i := by |
| 127 | intro h |
| 128 | subst j |
| 129 | have hn : 0 ≤ 2 * (n : ℝ) * δ := by positivity |
| 130 | linarith |
| 131 | have hc : Continuous (fun g : Fin (n + 1) → ℝ => g j + 2 * n * δ) := by fun_prop |
| 132 | have hci : Continuous (fun g : Fin (n + 1) → ℝ => g i) := continuous_apply i |
| 133 | have hfirst : ∀ᶠ g : Fin (n + 1) → ℝ in 𝓝 f, g j + 2 * n * δ < g i := |
| 134 | hc.continuousAt.eventually_lt hci.continuousAt hgap |
| 135 | have hsecond : ∀ᶠ g : Fin (n + 1) → ℝ in 𝓝 f, g j + 2 * n * δ < f i := |
| 136 | hc.continuousAt.eventually_lt continuousAt_const hgap |
| 137 | filter_upwards [hfirst, hsecond] with g hgi hgt |
| 138 | exact finiteRegularizedMin_update_eq δ hδ n g i j hji (f i) hgi hgt |
| 139 | |
| 140 | end Poincare |