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.SpecialFunctions.SmoothTransition |
| 2 | import Mathlib.Topology.Compactness.Compact |
| 3 | import Mathlib.Topology.ContinuousOn |
| 4 | import Mathlib.Tactic |
| 5 | |
| 6 | /-! Adapted from Mapher06/Poincare-MorganTian, `PoincareMT/Proofs/M04/ExponentialBarrierProfile.lean`, |
| 7 | revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. See the curvature import record under |
| 8 | `references/ricci-flow/mapher/curvature/`. -/ |
| 9 | |
| 10 | set_option autoImplicit false |
| 11 | |
| 12 | open Set Topology Filter Polynomial |
| 13 | open scoped BigOperators |
| 14 | |
| 15 | universe u |
| 16 | |
| 17 | namespace PoincareMT.RicciFlowAnalysis |
| 18 | |
| 19 | theorem deriv_expNegInvGlue (s : ℝ) : |
| 20 | deriv expNegInvGlue s = s⁻¹ ^ 2 * expNegInvGlue s := by |
| 21 | have h := (expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul (1 : ℝ[X]) s).deriv |
| 22 | simpa using h |
| 23 | |
| 24 | theorem deriv_deriv_expNegInvGlue (s : ℝ) : |
| 25 | deriv (deriv expNegInvGlue) s = |
| 26 | (s⁻¹ ^ 4 - 2 * s⁻¹ ^ 3) * expNegInvGlue s := by |
| 27 | rw [show deriv expNegInvGlue = (fun x ↦ x⁻¹ ^ 2 * expNegInvGlue x) by |
| 28 | funext x; exact deriv_expNegInvGlue x] |
| 29 | have h := (expNegInvGlue.hasDerivAt_polynomial_eval_inv_mul (X ^ 2 : ℝ[X]) s).deriv |
| 30 | simp only [eval_X_pow, eval_mul, eval_sub, derivative_X_pow, eval_C] at h |
| 31 | convert h using 1 <;> ring |
| 32 | |
| 33 | set_option maxHeartbeats 1000000 in |
| 34 | -- The compact uniform bounds and exponential derivative estimates need extra elaboration. |
| 35 | theorem exists_exponential_barrier_decay |
| 36 | {X : Type u} [TopologicalSpace X] {K : Set X} (hK : IsCompact K) |
| 37 | {q L G : X → ℝ} (hq : ContinuousOn q K) (hL : ContinuousOn L K) |
| 38 | (hG : ContinuousOn G K) (hzero : ∀ x ∈ K, q x = 0 → 0 < G x) (b : ℝ) : |
| 39 | ∃ A : ℝ, 0 < A ∧ ∀ x ∈ K, |
| 40 | (b - L x) * deriv expNegInvGlue (q x) - |
| 41 | G x * deriv (deriv expNegInvGlue) (q x) ≤ |
| 42 | A * expNegInvGlue (q x) := by |
| 43 | let P : X → ℝ := fun x ↦ (b - L x) * q x ^ 2 - |
| 44 | (1 - 2 * q x) * G x |
| 45 | let U : ℝ → Set K := fun A ↦ {x | q x < 0 ∨ P x < A * q x ^ 4} |
| 46 | have hP : ContinuousOn P K := by |
| 47 | have hcoef : ContinuousOn (fun x : X ↦ (1 : ℝ) - 2 * q x) K := |
| 48 | continuousOn_const.sub (continuousOn_const.mul hq) |
| 49 | exact ((continuousOn_const.sub hL).mul (hq.pow 2)).sub |
| 50 | (hcoef.mul hG) |
| 51 | have hUo (A : ℝ) (hA : 0 < A) : IsOpen (U A) := by |
| 52 | change IsOpen ({x : K | q x < 0} ∪ {x : K | P x < A * q x ^ 4}) |
| 53 | exact (isOpen_lt hq.domRestrict continuous_const).union |
| 54 | (isOpen_lt hP.domRestrict ((continuousOn_const.mul (hq.pow 4)).domRestrict)) |
| 55 | have hcover : (Set.univ : Set K) ⊆ ⋃ A : {a : ℝ // 0 < a}, U A := by |
| 56 | intro x _ |
| 57 | by_cases hx : q x < 0 |
| 58 | · exact mem_iUnion.2 ⟨⟨1, zero_lt_one⟩, Or.inl hx⟩ |
| 59 | by_cases hq0 : q x = 0 |
| 60 | · have hneg : P x < 0 := by |
| 61 | simpa [P, hq0] using (neg_lt_zero.mpr (hzero x x.property hq0)) |
| 62 | exact mem_iUnion.2 ⟨⟨1, zero_lt_one⟩, Or.inr (by simpa [hq0] using hneg)⟩ |
| 63 | · have hqpos : 0 < q x := lt_of_le_of_ne (le_of_not_gt hx) (Ne.symm hq0) |
| 64 | let c : ℝ := max 1 (P x / q x ^ 4 + 1) |
| 65 | have hc : 0 < c := lt_of_lt_of_le zero_lt_one (le_max_left _ _) |
| 66 | have hratio : P x < c * q x ^ 4 := by |
| 67 | have hq4 : 0 < q x ^ 4 := pow_pos hqpos 4 |
| 68 | have hc' : P x / q x ^ 4 < c := lt_of_lt_of_le |
| 69 | (by nlinarith [show (0 : ℝ) < 1 from zero_lt_one]) |
| 70 | (le_max_right _ _) |
| 71 | exact (div_lt_iff₀ hq4).mp hc' |
| 72 | exact mem_iUnion.2 ⟨⟨c, hc⟩, Or.inr hratio⟩ |
| 73 | letI : CompactSpace K := isCompact_iff_compactSpace.mp hK |
| 74 | obtain ⟨A, hAK⟩ := (isCompact_univ : IsCompact (Set.univ : Set K)).elim_directed_cover |
| 75 | (fun a : {a : ℝ // 0 < a} ↦ U a) |
| 76 | (fun a ↦ hUo a a.property) |
| 77 | hcover |
| 78 | (by |
| 79 | intro a b |
| 80 | let c : {a : ℝ // 0 < a} := ⟨max (a : ℝ) (b : ℝ), |
| 81 | lt_of_lt_of_le a.property (le_max_left _ _)⟩ |
| 82 | refine ⟨c, ?_, ?_⟩ |
| 83 | · intro x hx |
| 84 | rcases hx with hxq | hxP |
| 85 | · exact Or.inl hxq |
| 86 | · exact Or.inr (hxP.trans_le (mul_le_mul_of_nonneg_right |
| 87 | (le_max_left _ _) (by positivity))) |
| 88 | · intro x hx |
| 89 | rcases hx with hxq | hxP |
| 90 | · exact Or.inl hxq |
| 91 | · exact Or.inr (hxP.trans_le (mul_le_mul_of_nonneg_right |
| 92 | (le_max_right _ _) (by positivity)))) |
| 93 | refine ⟨A, A.property, ?_⟩ |
| 94 | intro x hx |
| 95 | by_cases hqx : q x ≤ 0 |
| 96 | · have hz : expNegInvGlue (q x) = 0 := expNegInvGlue.zero_of_nonpos hqx |
| 97 | have hdz : deriv expNegInvGlue (q x) = 0 := by simp [deriv_expNegInvGlue, hz] |
| 98 | have hddz : deriv (deriv expNegInvGlue) (q x) = 0 := by |
| 99 | simp [deriv_deriv_expNegInvGlue, hz] |
| 100 | simp [hz, hdz, hddz] |
| 101 | · have hqx' : 0 < q x := lt_of_not_ge hqx |
| 102 | have hmem : (⟨x, hx⟩ : K) ∈ U A := hAK (Set.mem_univ _) |
| 103 | change q x < 0 ∨ P x < A * q x ^ 4 at hmem |
| 104 | have hPineq : P x < A * q x ^ 4 := |
| 105 | hmem.resolve_left (not_lt_of_ge (le_of_lt hqx')) |
| 106 | rw [deriv_expNegInvGlue, deriv_deriv_expNegInvGlue] |
| 107 | have hψ : 0 < expNegInvGlue (q x) := expNegInvGlue.pos_of_pos hqx' |
| 108 | have hq0 : q x ≠ 0 := ne_of_gt hqx' |
| 109 | have hcoeff : (b - L x) * (q x)⁻¹ ^ 2 - |
| 110 | G x * ((q x)⁻¹ ^ 4 - 2 * (q x)⁻¹ ^ 3) ≤ A := by |
| 111 | apply (le_of_mul_le_mul_right ?_ (pow_pos hqx' 4)) |
| 112 | calc |
| 113 | ((b - L x) * (q x)⁻¹ ^ 2 - |
| 114 | G x * ((q x)⁻¹ ^ 4 - 2 * (q x)⁻¹ ^ 3)) * q x ^ 4 = P x := by |
| 115 | field_simp [hq0] |
| 116 | ring |
| 117 | _ ≤ A * q x ^ 4 := hPineq.le |
| 118 | calc |
| 119 | _ = ((b - L x) * (q x)⁻¹ ^ 2 - |
| 120 | G x * ((q x)⁻¹ ^ 4 - 2 * (q x)⁻¹ ^ 3)) * expNegInvGlue (q x) := by |
| 121 | ring |
| 122 | _ ≤ A * expNegInvGlue (q x) := mul_le_mul_of_nonneg_right hcoeff hψ.le |
| 123 | |
| 124 | end PoincareMT.RicciFlowAnalysis |
| 125 |