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.Calculus.LocalExtr.Basic |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Inv |
| 3 | import Mathlib.Topology.Order.Compact |
| 4 | import Mathlib.Tactic |
| 5 | |
| 6 | /-! Adapted from Mapher06/Poincare-MorganTian, `PoincareMT/Proofs/Ch02/ScalarComparison.lean`, |
| 7 | revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. See the curvature import record under |
| 8 | `references/ricci-flow/mapher/curvature/`. -/ |
| 9 | |
| 10 | /-! |
| 11 | # Compact comparison with a negative scalar barrier |
| 12 | |
| 13 | A direct compact-minimum argument gives the corrected negative branch of |
| 14 | Morgan-Tian, Proposition 4.1, printed pp. 64-65. It requires neither a |
| 15 | derivative of the spatial minimum nor continuity of the prescribed velocity. |
| 16 | -/ |
| 17 | |
| 18 | set_option autoImplicit false |
| 19 | |
| 20 | open Set |
| 21 | |
| 22 | universe u |
| 23 | |
| 24 | namespace PoincareMT |
| 25 | |
| 26 | /-- A compact scalar family with the minimum reaction inequality stays above its negative barrier. |
| 27 | -/ |
| 28 | theorem compact_min_velocity_lower_bound |
| 29 | {M : Type u} [TopologicalSpace M] [CompactSpace M] |
| 30 | {a b r0 : ℝ} {n : ℕ} |
| 31 | (_hab : a < b) (hn : 0 < n) (hr0 : r0 < 0) |
| 32 | (f v : ℝ → M → ℝ) |
| 33 | (hf : ContinuousOn (Function.uncurry f) (Ico a b ×ˢ (univ : Set M))) |
| 34 | (hderiv : ∀ t ∈ Ico a b, ∀ x : M, |
| 35 | HasDerivWithinAt (fun s : ℝ ↦ f s x) (v t x) (Ico a b) t) |
| 36 | (hmin : ∀ t ∈ Ico a b, ∀ x : M, |
| 37 | (∀ y : M, f t x ≤ f t y) → (2 / (n : ℝ)) * (f t x) ^ 2 ≤ v t x) |
| 38 | (hinit : ∀ x : M, r0 ≤ f a x) : |
| 39 | ∀ t ∈ Ico a b, ∀ x : M, |
| 40 | r0 / (1 - 2 * r0 * (t - a) / (n : ℝ)) ≤ f t x := by |
| 41 | have hnR : 0 < (n : ℝ) := Nat.cast_pos.mpr hn |
| 42 | let r : ℝ → ℝ := fun s ↦ r0 / (1 - 2 * r0 * (s - a) / (n : ℝ)) |
| 43 | have hden (s : ℝ) (hs : a ≤ s) : 0 < 1 - 2 * r0 * (s - a) / (n : ℝ) := by |
| 44 | have hprod : 2 * r0 * (s - a) / (n : ℝ) ≤ 0 := |
| 45 | div_nonpos_of_nonpos_of_nonneg |
| 46 | (mul_nonpos_of_nonpos_of_nonneg (by linarith) (sub_nonneg.mpr hs)) hnR.le |
| 47 | linarith |
| 48 | have hr (s : ℝ) (hs : a ≤ s) : r s < 0 := div_neg_of_neg_of_pos hr0 (hden s hs) |
| 49 | have hra : r a = r0 := by simp [r] |
| 50 | have hrderiv (s : ℝ) (hs : a ≤ s) : |
| 51 | HasDerivAt r ((2 / (n : ℝ)) * (r s) ^ 2) s := by |
| 52 | have hd := (hasDerivAt_const s (1 : ℝ)).sub |
| 53 | ((((hasDerivAt_id s).sub_const a).const_mul (2 * r0)).div_const (n : ℝ)) |
| 54 | convert! (hasDerivAt_const s r0).div hd (ne_of_gt (hden s hs)) using 1 |
| 55 | dsimp [r] |
| 56 | field_simp |
| 57 | ring |
| 58 | intro t ht x |
| 59 | by_contra hbad |
| 60 | have hbad' : f t x < r t := lt_of_not_ge hbad |
| 61 | let K : Set (ℝ × M) := Icc a t ×ˢ univ |
| 62 | have hsub : K ⊆ Ico a b ×ˢ (univ : Set M) := |
| 63 | fun p hp ↦ ⟨⟨hp.1.1, hp.1.2.trans_lt ht.2⟩, hp.2⟩ |
| 64 | have hrc : ContinuousOn (fun p : ℝ × M ↦ r p.1) K := |
| 65 | (show ContinuousOn r (Icc a t) from |
| 66 | fun s hs ↦ (hrderiv s hs.1).continuousAt.continuousWithinAt).comp |
| 67 | continuous_fst.continuousOn (fun _ hp ↦ hp.1) |
| 68 | have hwc : ContinuousOn (fun p : ℝ × M ↦ f p.1 p.2 - r p.1) K := |
| 69 | (hf.mono hsub).sub hrc |
| 70 | obtain ⟨⟨s, y⟩, hsy, hminw⟩ := (isCompact_Icc.prod isCompact_univ).exists_isMinOn |
| 71 | (show K.Nonempty from ⟨(a, x), ⟨⟨le_rfl, ht.1⟩, mem_univ x⟩⟩) hwc |
| 72 | change (s ∈ Icc a t) ∧ y ∈ (univ : Set M) at hsy |
| 73 | have hwy : f s y - r s < 0 := |
| 74 | (hminw (show (t, x) ∈ K from ⟨⟨ht.1, le_rfl⟩, mem_univ x⟩)).trans_lt |
| 75 | (sub_neg.mpr hbad') |
| 76 | have hsa : a < s := by |
| 77 | rcases lt_or_eq_of_le hsy.1.1 with hsa | hsa |
| 78 | · exact hsa |
| 79 | · rw [← hsa, hra] at hwy |
| 80 | exact False.elim ((not_lt_of_ge (sub_nonneg.mpr (hinit y))) hwy) |
| 81 | have hsJ : s ∈ Ico a b := ⟨hsa.le, hsy.1.2.trans_lt ht.2⟩ |
| 82 | have hspace : ∀ z : M, f s y ≤ f s z := by |
| 83 | intro z |
| 84 | have h := hminw (show (s, z) ∈ K from ⟨hsy.1, mem_univ z⟩) |
| 85 | change f s y - r s ≤ f s z - r s at h |
| 86 | linarith |
| 87 | have hpos : 0 < v s y - (2 / (n : ℝ)) * (r s) ^ 2 := by |
| 88 | have hsq : (r s) ^ 2 < (f s y) ^ 2 := by |
| 89 | have := hr s hsa.le |
| 90 | nlinarith |
| 91 | have hmul := mul_lt_mul_of_pos_left hsq (div_pos (by norm_num : (0 : ℝ) < 2) hnR) |
| 92 | have := hmin s hsJ y hspace |
| 93 | linarith |
| 94 | have htime : IsMinOn (fun q : ℝ ↦ f q y - r q) (Icc a s) s := by |
| 95 | intro q hq |
| 96 | exact hminw (show (q, y) ∈ K from ⟨⟨hq.1, hq.2.trans hsy.1.2⟩, mem_univ y⟩) |
| 97 | have hdw : HasDerivWithinAt (fun q : ℝ ↦ f q y - r q) |
| 98 | (v s y - (2 / (n : ℝ)) * (r s) ^ 2) (Icc a s) s := |
| 99 | ((hderiv s hsJ y).mono fun q hq ↦ ⟨hq.1, hq.2.trans_lt hsJ.2⟩).sub |
| 100 | (hrderiv s hsa.le).hasDerivWithinAt |
| 101 | have hcone : a - s ∈ posTangentConeAt (Icc a s) s := |
| 102 | sub_mem_posTangentConeAt_of_segment_subset (by rw [segment_symm, segment_eq_Icc hsa.le]) |
| 103 | have hsign : 0 ≤ (a - s) * (v s y - (2 / (n : ℝ)) * (r s) ^ 2) := by |
| 104 | simpa only [ContinuousLinearMap.toSpanSingleton_apply, smul_eq_mul] |
| 105 | using htime.localize.hasFDerivWithinAt_nonneg hdw hcone |
| 106 | exact (not_le_of_gt (mul_neg_of_neg_of_pos (sub_neg.mpr hsa) hpos)) hsign |
| 107 | |
| 108 | end PoincareMT |