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.Geometry.RicciFlow.Surgery.StandardCap.Existence.Analysis.Basic.FirstExitLevel |
| 2 | import Mathlib.Analysis.Calculus.Deriv.MeanValue |
| 3 | import Mathlib.Tactic.Linarith |
| 4 | import Mathlib.Tactic.Positivity |
| 5 | import Mathlib.Tactic.Ring |
| 6 | |
| 7 | /-! |
| 8 | # Short-time control from a guarded quadratic derivative bound |
| 9 | |
| 10 | Only derivatives above the lower threshold are controlled. Between |
| 11 | the last lower crossing and the first upper crossing, the derivative |
| 12 | has a constant upper bound, so the mean-value theorem prevents escape. |
| 13 | Source: Morgan-Tian Theorem 12.29, pp. 324-325; |
| 14 | exterior-scalar-and-second-blowup.md, section 3. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Set |
| 20 | |
| 21 | /-- A continuous function with guarded quadratic upper derivative bound |
| 22 | cannot double its positive initial bound on this short interval. |
| 23 | No sign of the function and no endpoint differentiability are assumed. -/ |
| 24 | theorem ContinuousOn.lt_two_mul_of_guarded_quadratic_deriv |
| 25 | {f : ℝ → ℝ} {a b A B R : ℝ} |
| 26 | (hf : ContinuousOn f (Icc a b)) (hd : DifferentiableOn ℝ f (Ioo a b)) |
| 27 | (hA : 0 ≤ A) (hB : 0 < B) (hRB : R ≤ B) (hinit : f a ≤ B) |
| 28 | (hderiv : ∀ t ∈ Ioo a b, R ≤ f t → deriv f t ≤ A * (f t) ^ 2) |
| 29 | (htime : 4 * A * B * (b - a) < 1) : |
| 30 | ∀ t ∈ Icc a b, f t < 2 * B := by |
| 31 | intro t ht |
| 32 | by_contra hlarge |
| 33 | obtain ⟨sigma, hsigma, hfsigma, hbefore⟩ := |
| 34 | (hf.mono (Icc_subset_Icc_right ht.2)).exists_first_eq_of_le ht.1 |
| 35 | (hinit.trans (by linarith : B ≤ 2 * B)) (le_of_not_gt hlarge) |
| 36 | have hfsmall : ContinuousOn f (Icc a sigma) := |
| 37 | hf.mono (Icc_subset_Icc_right (hsigma.2.trans ht.2)) |
| 38 | have hlevel : (Icc a sigma ∩ f ⁻¹' {B}).Nonempty := by |
| 39 | obtain ⟨s, hs, hfs⟩ := intermediate_value_Icc hsigma.1 hfsmall |
| 40 | ⟨hinit, by rw [hfsigma]; linarith⟩ |
| 41 | exact ⟨s, hs, hfs⟩ |
| 42 | have hcompact : IsCompact (Icc a sigma ∩ f ⁻¹' {B}) := |
| 43 | isCompact_Icc.of_isClosed_subset |
| 44 | (hfsmall.preimage_isClosed_of_isClosed isClosed_Icc isClosed_singleton) inter_subset_left |
| 45 | obtain ⟨alpha, halpha⟩ := hcompact.exists_isGreatest hlevel |
| 46 | have haalpha : a ≤ alpha := halpha.1.1.1 |
| 47 | have halphasigma : alpha ≤ sigma := halpha.1.1.2 |
| 48 | have hfalpha : f alpha = B := halpha.1.2 |
| 49 | have hsigmab : sigma ≤ b := hsigma.2.trans ht.2 |
| 50 | have hinterior : interior (Icc alpha sigma) ⊆ Ioo a b := by |
| 51 | rw [interior_Icc] |
| 52 | intro s hs |
| 53 | exact ⟨haalpha.trans_lt hs.1, hs.2.trans_le hsigmab⟩ |
| 54 | have hbound : ∀ s ∈ interior (Icc alpha sigma), deriv f s ≤ 4 * A * B ^ 2 := by |
| 55 | intro s hs |
| 56 | have hs' : s ∈ Ioo alpha sigma := by simpa only [interior_Icc] using hs |
| 57 | have hlo : B < f s := by |
| 58 | by_contra hlow |
| 59 | obtain ⟨r, hr, hfr⟩ := intermediate_value_Icc hs'.2.le |
| 60 | (hfsmall.mono (Icc_subset_Icc_left (haalpha.trans hs'.1.le))) |
| 61 | ⟨le_of_not_gt hlow, by rw [hfsigma]; linarith⟩ |
| 62 | have hra : r ≤ alpha := halpha.2 |
| 63 | ⟨⟨haalpha.trans (hs'.1.le.trans hr.1), hr.2⟩, hfr⟩ |
| 64 | exact (not_le_of_gt (hs'.1.trans_le hr.1)) hra |
| 65 | have hup : f s < 2 * B := hbefore s ⟨haalpha.trans hs'.1.le, hs'.2⟩ |
| 66 | calc |
| 67 | deriv f s ≤ A * (f s) ^ 2 := hderiv s (hinterior hs) (hRB.trans hlo.le) |
| 68 | _ ≤ A * (2 * B) ^ 2 := mul_le_mul_of_nonneg_left (by |
| 69 | simpa only [pow_two] using mul_self_le_mul_self (hB.le.trans hlo.le) hup.le) hA |
| 70 | _ = 4 * A * B ^ 2 := by ring |
| 71 | have hgrowth := (convex_Icc alpha sigma).image_sub_le_mul_sub_of_deriv_le |
| 72 | (hf.mono (Icc_subset_Icc haalpha hsigmab)) (hd.mono hinterior) hbound |
| 73 | alpha ⟨le_rfl, halphasigma⟩ sigma ⟨halphasigma, le_rfl⟩ halphasigma |
| 74 | have hlength : 4 * A * B ^ 2 * (sigma - alpha) ≤ 4 * A * B ^ 2 * (b - a) := |
| 75 | mul_le_mul_of_nonneg_left (by linarith) (by positivity) |
| 76 | have hsmall := mul_lt_mul_of_pos_right htime hB |
| 77 | rw [hfsigma, hfalpha] at hgrowth |
| 78 | nlinarith [hgrowth.trans hlength] |