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.Finset.Max |
| 2 | import Mathlib.Order.WellFoundedSet |
| 3 | |
| 4 | set_option autoImplicit false |
| 5 | |
| 6 | open Set |
| 7 | |
| 8 | universe u v |
| 9 | |
| 10 | namespace PoincareMT |
| 11 | |
| 12 | def M67OrdinaryBetween {J : Type u} [LinearOrder J] (events : Finset J) |
| 13 | (a b : J) : Prop := a ≤ b ∧ Disjoint (↑events : Set J) (Ioc a b) |
| 14 | |
| 15 | theorem M67OrdinaryBetween.refl {J : Type u} [LinearOrder J] |
| 16 | (events : Finset J) (a : J) : M67OrdinaryBetween events a a := by |
| 17 | simp [M67OrdinaryBetween] |
| 18 | |
| 19 | theorem M67OrdinaryBetween.trans {J : Type u} [LinearOrder J] |
| 20 | {events : Finset J} {a b c : J} |
| 21 | (hab : M67OrdinaryBetween events a b) (hbc : M67OrdinaryBetween events b c) : |
| 22 | M67OrdinaryBetween events a c := by |
| 23 | refine ⟨hab.1.trans hbc.1, Set.disjoint_left.mpr ?_⟩ |
| 24 | intro t ht htc |
| 25 | by_cases htb : t ≤ b |
| 26 | · exact Set.disjoint_left.mp hab.2 ht ⟨htc.1, htb⟩ |
| 27 | · exact Set.disjoint_left.mp hbc.2 ht ⟨lt_of_not_ge htb, htc.2⟩ |
| 28 | |
| 29 | /-- Assemble a section from an initial value, coherent ordinary transports, |
| 30 | and one earlier-time transition at each event. The construction recursively |
| 31 | chooses only the finite collection of event seeds. -/ |
| 32 | theorem m67_finite_transport_section |
| 33 | {J : Type u} [LinearOrder J] (zero : J) (hzero : ∀ t : J, zero ≤ t) |
| 34 | (events : Finset J) (hzero_event : zero ∉ events) |
| 35 | (before : ∀ s : J, s ∈ events → J) |
| 36 | (before_lt : ∀ s hs, before s hs < s) |
| 37 | (U : J → Type v) (initial : U zero) |
| 38 | (regular : ∀ a b, M67OrdinaryBetween events a b → U a → U b) |
| 39 | (regular_refl : ∀ a h x, regular a a h x = x) |
| 40 | (regular_trans : ∀ a b c hab hbc x, |
| 41 | regular b c hbc (regular a b hab x) = |
| 42 | regular a c (hab.trans hbc) x) |
| 43 | (event : ∀ s hs, U (before s hs) → U s) : |
| 44 | ∃ sol : ∀ t, U t, |
| 45 | sol zero = initial ∧ |
| 46 | (∀ a b h, regular a b h (sol a) = sol b) ∧ |
| 47 | (∀ s hs, sol s = event s hs (sol (before s hs))) := by |
| 48 | classical |
| 49 | let stages : Finset J := insert zero events |
| 50 | let Stage := {t : J // t ∈ stages} |
| 51 | let lastSet (t : J) : Finset J := stages.filter (· ≤ t) |
| 52 | have hlastNonempty (t : J) : (lastSet t).Nonempty := |
| 53 | ⟨zero, Finset.mem_filter.mpr ⟨Finset.mem_insert_self _ _, hzero t⟩⟩ |
| 54 | let last (t : J) : Stage := |
| 55 | ⟨(lastSet t).max' (hlastNonempty t), |
| 56 | (Finset.mem_filter.mp ((lastSet t).max'_mem (hlastNonempty t))).1⟩ |
| 57 | have last_le (t : J) : (last t).val ≤ t := |
| 58 | (Finset.mem_filter.mp ((lastSet t).max'_mem (hlastNonempty t))).2 |
| 59 | have le_last (s : Stage) (t : J) (hst : s.val ≤ t) : s.val ≤ (last t).val := |
| 60 | Finset.le_max' _ _ (Finset.mem_filter.mpr ⟨s.property, hst⟩) |
| 61 | have last_stage (s : Stage) : last s.val = s := by |
| 62 | apply Subtype.ext |
| 63 | exact le_antisymm (last_le _) (le_last s s.val le_rfl) |
| 64 | have last_regular (t : J) : M67OrdinaryBetween events (last t).val t := by |
| 65 | refine ⟨last_le t, Set.disjoint_left.mpr ?_⟩ |
| 66 | intro s hs hst |
| 67 | have hstage : s ∈ stages := Finset.mem_insert_of_mem hs |
| 68 | exact (not_lt_of_ge (le_last ⟨s, hstage⟩ t hst.2)) hst.1 |
| 69 | have stage_event (s : Stage) (hs : s.val ≠ zero) : s.val ∈ events := |
| 70 | (Finset.mem_insert.mp s.property).resolve_left hs |
| 71 | have hwf : WellFounded ((· < ·) : Stage → Stage → Prop) := |
| 72 | Finite.wellFounded_of_trans_of_irrefl _ |
| 73 | let seed : ∀ s : Stage, U s.val := hwf.fix fun s rec => |
| 74 | if hs : s.val = zero then hs.symm ▸ initial |
| 75 | else event s.val (stage_event s hs) |
| 76 | (regular (last (before s.val (stage_event s hs))).val |
| 77 | (before s.val (stage_event s hs)) (last_regular _) |
| 78 | (rec (last (before s.val (stage_event s hs))) |
| 79 | ((last_le _).trans_lt (before_lt s.val (stage_event s hs))))) |
| 80 | have seed_zero (s : Stage) (hs : s.val = zero) : seed s = hs.symm ▸ initial := by |
| 81 | rw [show seed s = _ from hwf.fix_eq _ s] |
| 82 | rw [dif_pos hs] |
| 83 | have seed_event (s : Stage) (hs : s.val ∈ events) : |
| 84 | seed s = event s.val hs |
| 85 | (regular (last (before s.val hs)).val (before s.val hs) (last_regular _) |
| 86 | (seed (last (before s.val hs)))) := by |
| 87 | have hne : s.val ≠ zero := fun h => hzero_event (h ▸ hs) |
| 88 | rw [show seed s = _ from hwf.fix_eq _ s] |
| 89 | rw [dif_neg hne] |
| 90 | let sol (t : J) : U t := regular (last t).val t (last_regular t) (seed (last t)) |
| 91 | have regular_seed_congr (a b : Stage) (h : a = b) (t : J) |
| 92 | (ha : M67OrdinaryBetween events a.val t) |
| 93 | (hb : M67OrdinaryBetween events b.val t) : |
| 94 | regular a.val t ha (seed a) = regular b.val t hb (seed b) := by |
| 95 | subst b |
| 96 | rfl |
| 97 | have section_stage (s : Stage) : sol s.val = seed s := by |
| 98 | exact (regular_seed_congr (last s.val) s (last_stage s) s.val |
| 99 | (last_regular s.val) (M67OrdinaryBetween.refl events s.val)).trans |
| 100 | (regular_refl _ _ _) |
| 101 | refine ⟨sol, ?_, ?_, ?_⟩ |
| 102 | · have h := section_stage ⟨zero, Finset.mem_insert_self _ _⟩ |
| 103 | exact h.trans (seed_zero _ rfl) |
| 104 | · intro a b hab |
| 105 | have hl : last a = last b := by |
| 106 | apply Subtype.ext |
| 107 | apply le_antisymm |
| 108 | · exact le_last (last a) b ((last_le a).trans hab.1) |
| 109 | · apply le_last (last b) a |
| 110 | by_contra hn |
| 111 | have hn' : a < (last b).val := lt_of_not_ge hn |
| 112 | have hne : (last b).val ≠ zero := by |
| 113 | intro h |
| 114 | exact (not_lt_of_ge (hzero a)) (h ▸ hn') |
| 115 | exact Set.disjoint_left.mp hab.2 (stage_event (last b) hne) |
| 116 | ⟨hn', last_le b⟩ |
| 117 | dsimp only [sol] |
| 118 | exact (regular_trans _ _ _ _ _ _).trans |
| 119 | (regular_seed_congr (last a) (last b) hl b |
| 120 | ((last_regular a).trans hab) (last_regular b)) |
| 121 | · intro s hs |
| 122 | exact (section_stage ⟨s, Finset.mem_insert_of_mem hs⟩).trans |
| 123 | (seed_event ⟨s, Finset.mem_insert_of_mem hs⟩ hs) |
| 124 | |
| 125 | end PoincareMT |