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.Data.Nat.Pairing |
| 2 | import Mathlib.Order.Filter.AtTopBot.Basic |
| 3 | |
| 4 | /-! |
| 5 | # Natural labels for every actual finite-stage chart |
| 6 | |
| 7 | The explicit decoding retains index zero and has a right inverse at |
| 8 | each stage/index pair. No selected chart is dropped by countable indexing. |
| 9 | MT Proposition 5.14, pp. 90-91; terminal-source-countable-maps.md, C. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | namespace PoincareMT.M47 |
| 15 | |
| 16 | private def countableLabelOfPair (N : ℕ → ℕ) (z : ℕ × ℕ) : Σ j, Fin (N j + 1) := |
| 17 | ⟨z.1, ⟨z.2 % (N z.1 + 1), Nat.mod_lt _ (Nat.succ_pos _)⟩⟩ |
| 18 | |
| 19 | /-- Decode a natural label into its actual stage and fixed finite index. -/ |
| 20 | def terminalSourceCountableLabel (N : ℕ → ℕ) (n : ℕ) : Σ j, Fin (N j + 1) := |
| 21 | countableLabelOfPair N (Nat.unpair n) |
| 22 | |
| 23 | /-- The distinguished countable label is the actual stage-zero base chart. -/ |
| 24 | theorem terminalSourceCountableLabel_zero (N : ℕ → ℕ) : |
| 25 | terminalSourceCountableLabel N 0 = ⟨0, 0⟩ := by |
| 26 | rw [terminalSourceCountableLabel, Nat.unpair_zero] |
| 27 | apply congrArg (fun q : Fin (N 0 + 1) => (⟨0, q⟩ : Σ j, Fin (N j + 1))) |
| 28 | apply Fin.ext |
| 29 | exact Nat.zero_mod _ |
| 30 | |
| 31 | /-- Every original stage/index pair has its literal paired natural label. -/ |
| 32 | theorem terminalSourceCountableLabel_pair (N : ℕ → ℕ) (j : ℕ) (i : Fin (N j + 1)) : |
| 33 | terminalSourceCountableLabel N (Nat.pair j i.val) = ⟨j, i⟩ := by |
| 34 | rw [terminalSourceCountableLabel, Nat.unpair_pair] |
| 35 | apply congrArg (fun q : Fin (N j + 1) => (⟨j, q⟩ : Σ j, Fin (N j + 1))) |
| 36 | apply Fin.ext |
| 37 | exact Nat.mod_eq_of_lt i.isLt |
| 38 | |
| 39 | /-- Countable indexing includes every original finite-stage chart. -/ |
| 40 | theorem terminalSourceCountableLabel_surjective (N : ℕ → ℕ) : |
| 41 | Function.Surjective (terminalSourceCountableLabel N) := by |
| 42 | rintro ⟨j, i⟩ |
| 43 | exact ⟨Nat.pair j i.val, terminalSourceCountableLabel_pair N j i⟩ |
| 44 | |
| 45 | /-- A fixed countable label lies on the original good-stage tail. -/ |
| 46 | theorem terminalSourceCountableLabel_eventually_le (N : ℕ → ℕ) (n : ℕ) : |
| 47 | ∀ᶠ k in Filter.atTop, (terminalSourceCountableLabel N n).1 ≤ k := |
| 48 | Filter.eventually_ge_atTop _ |
| 49 | |
| 50 | end PoincareMT.M47 |