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.Elliptic.Regularity.EnergyEstimate.ComparisonTest |
| 2 | import Mathlib.Analysis.SpecialFunctions.ExpDeriv |
| 3 | |
| 4 | /-! # Exponentially weighted compact Lipschitz tests -/ |
| 5 | |
| 6 | noncomputable section |
| 7 | |
| 8 | open Set Filter |
| 9 | open scoped Topology NNReal |
| 10 | |
| 11 | namespace Poincare.Analysis.Elliptic |
| 12 | |
| 13 | variable {d : ℕ} |
| 14 | local notation "E" => EuclideanSpace ℝ (Fin d) |
| 15 | |
| 16 | theorem compact_lipschitz_product |
| 17 | {O : Set E} {u φ : E → ℝ} {A B : ℝ≥0} |
| 18 | (hu : LipschitzOnWith A u O) (huB : ∀ x ∈ O, |u x| ≤ B) |
| 19 | (hφ : ContDiff ℝ (⊤ : ℕ∞) φ) (hφc : HasCompactSupport φ) |
| 20 | (hφO : tsupport φ ⊆ O) : |
| 21 | ∃ C : ℝ≥0, LipschitzWith C (fun x => φ x * u x) := by |
| 22 | obtain ⟨w, hw, heq⟩ := hu.extend_real |
| 23 | let z : E → ℝ := fun x => max (-(B : ℝ)) (min (B : ℝ) (w x)) |
| 24 | have hz : LipschitzWith A z := (hw.const_min _).const_max _ |
| 25 | have hzB (x) : |z x| ≤ B := abs_le.mpr |
| 26 | ⟨le_max_left _ _, max_le (neg_le_self B.coe_nonneg) (min_le_left _ _)⟩ |
| 27 | have hprod : (fun x => φ x * z x) = (fun x => φ x * u x) := by |
| 28 | funext x |
| 29 | by_cases hx : φ x = 0 |
| 30 | · simp only [hx, zero_mul] |
| 31 | · have hxO := hφO (subset_tsupport _ hx) |
| 32 | have hb := abs_le.mp (huB x hxO) |
| 33 | simp only [z, ← heq hxO, min_eq_right hb.2, max_eq_right hb.1] |
| 34 | rw [← hprod] |
| 35 | obtain ⟨C, hC⟩ := ContDiff.lipschitzWith_of_hasCompactSupport hφc hφ (by simp) |
| 36 | obtain ⟨D, hD⟩ := hφc.exists_bound_of_continuous hφ.continuous |
| 37 | let D' : ℝ≥0 := ⟨max D 0, le_max_right _ _⟩ |
| 38 | have hD' (x) : |φ x| ≤ D' := (hD x).trans (le_max_left _ _) |
| 39 | refine ⟨D' * A + B * C, LipschitzWith.of_dist_le_mul fun x y => ?_⟩ |
| 40 | have hp := hC.dist_le_mul x y |
| 41 | have hq := hz.dist_le_mul x y |
| 42 | simp only [Real.dist_eq] at hp hq ⊢ |
| 43 | calc |
| 44 | |φ x * z x - φ y * z y| = |φ x * (z x - z y) + z y * (φ x - φ y)| := by ring_nf |
| 45 | _ ≤ |φ x * (z x - z y)| + |z y * (φ x - φ y)| := abs_add_le _ _ |
| 46 | _ = |φ x| * |z x - z y| + |z y| * |φ x - φ y| := by rw [abs_mul, abs_mul] |
| 47 | _ ≤ D' * (A * dist x y) + B * (C * dist x y) := |
| 48 | add_le_add (mul_le_mul (hD' x) hq (abs_nonneg _) D'.coe_nonneg) |
| 49 | (mul_le_mul (hzB y) hp (abs_nonneg _) B.coe_nonneg) |
| 50 | _ = ((D' * A + B * C : ℝ≥0) : ℝ) * dist x y := by push_cast; ring |
| 51 | |
| 52 | theorem compact_lipschitz_exp_test |
| 53 | {O : Set E} (hOc : IsCompact (closure O)) {u φ : E → ℝ} {A : ℝ≥0} |
| 54 | (hu : LipschitzOnWith A u (closure O)) |
| 55 | (hφ : ContDiff ℝ (⊤ : ℕ∞) φ) (hφc : HasCompactSupport φ) |
| 56 | (hφO : tsupport φ ⊆ O) : |
| 57 | ∃ C : ℝ≥0, LipschitzWith C (fun x => φ x * Real.exp (-u x)) := by |
| 58 | have hn := hu.neg |
| 59 | have hcompact : IsCompact ((fun x => -u x) '' closure O) := |
| 60 | hOc.image_of_continuousOn hn.continuousOn |
| 61 | obtain ⟨B, hB⟩ := hcompact.exists_bound_of_continuousOn Real.continuous_exp.continuousOn |
| 62 | obtain ⟨L, hL⟩ := LocallyLipschitzOn.exists_lipschitzOnWith_of_compact hcompact |
| 63 | Real.contDiff_exp.locallyLipschitz.locallyLipschitzOn |
| 64 | apply compact_lipschitz_product ((hL.comp hn (mapsTo_image _ _)).mono subset_closure) |
| 65 | (B := ⟨max B 0, le_max_right _ _⟩) ?_ hφ hφc hφO |
| 66 | intro x hx |
| 67 | exact (hB _ (mem_image_of_mem _ (subset_closure hx))).trans (le_max_left _ _) |
| 68 | |
| 69 | end Poincare.Analysis.Elliptic |