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.Topology.Piecewise |
| 2 | import Mathlib.Topology.Order.DenselyOrdered |
| 3 | import Mathlib.Analysis.Convex.Combination |
| 4 | import Mathlib.Topology.Instances.Real.Lemmas |
| 5 | |
| 6 | /-! |
| 7 | # Monotone replacement on a real interval |
| 8 | |
| 9 | Replacing a continuous monotone function by another monotone function |
| 10 | with matching endpoint values preserves continuity and monotonicity. |
| 11 | This is the elementary boundary-label step in M64's derivation |
| 12 | `2026-09-26-free-boundary-replacement.md` (Lemaire 1982, p. 102). |
| 13 | |
| 14 | Morgan--Tian context: Lemma 19.15, printed pp. 447-449. This project analytic helper |
| 15 | supports the actual annular minimizer and boundary regularity construction. |
| 16 | -/ |
| 17 | |
| 18 | set_option autoImplicit false |
| 19 | set_option warningAsError true |
| 20 | |
| 21 | noncomputable section |
| 22 | |
| 23 | open Set |
| 24 | |
| 25 | namespace PoincareMT |
| 26 | |
| 27 | /-- Matching endpoint values allow continuous monotone interpolation on a closed interval, |
| 28 | including collapsed image intervals. Source: M64 free-boundary-replacement derivation, label |
| 29 | construction. Source/construction: |
| 30 | proof-work/tasks/M64/derivations/2026-09-26-free-boundary-replacement.md, Producing the |
| 31 | changed labels. -/ |
| 32 | theorem m64Monotone_interval_replacement |
| 33 | {f g : ℝ → ℝ} {a b : ℝ} (hab : a ≤ b) |
| 34 | (hf : Continuous f) (hg : Continuous g) (hmf : Monotone f) (hmg : Monotone g) |
| 35 | (ha : g a = f a) (hb : g b = f b) [DecidablePred (· ∈ Icc a b)] : |
| 36 | Continuous ((Icc a b).piecewise g f) ∧ Monotone ((Icc a b).piecewise g f) := by |
| 37 | constructor |
| 38 | · apply hg.piecewise _ hf |
| 39 | intro x hx |
| 40 | rw [frontier_Icc hab] at hx |
| 41 | rcases hx with (rfl | rfl) <;> assumption |
| 42 | · intro x y hxy |
| 43 | by_cases hx : x ∈ Icc a b |
| 44 | · rw [piecewise_eq_of_mem _ _ _ hx] |
| 45 | by_cases hy : y ∈ Icc a b |
| 46 | · rw [piecewise_eq_of_mem _ _ _ hy] |
| 47 | exact hmg hxy |
| 48 | · rw [piecewise_eq_of_notMem _ _ _ hy] |
| 49 | have hby : b ≤ y := by |
| 50 | by_contra h |
| 51 | exact hy ⟨hx.1.trans hxy, (lt_of_not_ge h).le⟩ |
| 52 | exact (hmg hx.2).trans (hb ▸ hmf hby) |
| 53 | · rw [piecewise_eq_of_notMem _ _ _ hx] |
| 54 | by_cases hy : y ∈ Icc a b |
| 55 | · rw [piecewise_eq_of_mem _ _ _ hy] |
| 56 | have hxa : x ≤ a := by |
| 57 | by_contra h |
| 58 | exact hx ⟨(lt_of_not_ge h).le, hxy.trans hy.2⟩ |
| 59 | exact (hmf hxa).trans (ha ▸ hmg hy.1) |
| 60 | · rw [piecewise_eq_of_notMem _ _ _ hy] |
| 61 | exact hmf hxy |
| 62 | |
| 63 | end PoincareMT |