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.MeanValue |
| 2 | |
| 3 | /-! |
| 4 | # Nonnegativity from a derivative condition on negative values |
| 5 | -/ |
| 6 | |
| 7 | open Set Filter |
| 8 | open scoped Topology |
| 9 | |
| 10 | namespace Poincare |
| 11 | |
| 12 | /-- A continuous function initially nonnegative stays nonnegative if its |
| 13 | derivative is positive at every negative interior point. No endpoint |
| 14 | derivatives are required. -/ |
| 15 | theorem nonneg_of_deriv_pos_on_neg |
| 16 | {a b : ℝ} (hab : a ≤ b) {f : ℝ → ℝ} |
| 17 | (hf : ContinuousOn f (Icc a b)) (ha : 0 ≤ f a) |
| 18 | (hd : ∀ t ∈ Ioo a b, f t < 0 → ∃ d, HasDerivAt f d t ∧ 0 < d) : |
| 19 | ∀ t ∈ Icc a b, 0 ≤ f t := by |
| 20 | have hhalf : ∀ t ∈ Ico a b, 0 ≤ f t := by |
| 21 | intro t ht |
| 22 | by_contra hneg |
| 23 | have hft : f t < 0 := lt_of_not_ge hneg |
| 24 | obtain ⟨c, hc, hmin⟩ := isCompact_Icc.exists_isMinOn |
| 25 | (nonempty_Icc.mpr ht.1) (hf.mono (Icc_subset_Icc le_rfl ht.2.le)) |
| 26 | have hcneg : f c < 0 := (hmin ⟨ht.1, le_rfl⟩).trans_lt hft |
| 27 | have hac : a < c := lt_of_le_of_ne hc.1 (by |
| 28 | intro heq |
| 29 | subst c |
| 30 | exact (not_lt_of_ge ha) hcneg) |
| 31 | obtain ⟨d, hcd, hdpos⟩ := hd c ⟨hac, hc.2.trans_lt ht.2⟩ hcneg |
| 32 | have hslope : ∀ᶠ y in 𝓝[<] c, 0 < slope f c y := |
| 33 | (hasDerivAt_iff_tendsto_slope_left_right.mp hcd).1 (Ioi_mem_nhds hdpos) |
| 34 | obtain ⟨y, hypos, hy⟩ := (hslope.and (Ioo_mem_nhdsLT hac)).exists |
| 35 | have hmy : f c ≤ f y := hmin ⟨hy.1.le, hy.2.le.trans hc.2⟩ |
| 36 | have hslopenonpos : slope f c y ≤ 0 := by |
| 37 | rw [slope_def_field] |
| 38 | exact div_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hmy) |
| 39 | (sub_nonpos.mpr hy.2.le) |
| 40 | exact (not_lt_of_ge hslopenonpos) hypos |
| 41 | rcases hab.lt_or_eq with hab | rfl |
| 42 | · intro t ht |
| 43 | exact ContinuousWithinAt.closure_le |
| 44 | (by simpa [closure_Ico hab.ne] using ht) |
| 45 | continuousWithinAt_const ((hf t ht).mono Ico_subset_Icc_self) hhalf |
| 46 | · simpa only [Icc_self, mem_singleton_iff, forall_eq] using ha |
| 47 | |
| 48 | end Poincare |