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.Volume.Surgery.Analysis.FiniteJumps |
| 2 | import Mathlib.Topology.Algebra.Monoid |
| 3 | import Mathlib.Algebra.Order.BigOperators.Group.Finset |
| 4 | |
| 5 | /-! |
| 6 | Adapted from Mapher `PoincareMT/Proofs/M49/Mathlib/FiniteJumpBalance.lean` |
| 7 | at revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. |
| 8 | |
| 9 | # Additive balance across finitely many left-limit jumps |
| 10 | |
| 11 | Morgan-Tian Lemma 17.12, pp. 410-411, uses both weighted-volume |
| 12 | loss and component gains/losses. The same finite induction tracks |
| 13 | the sum of losses and gains in any ordered additive commutative |
| 14 | monoid with continuous addition, including Nat and ENNReal. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open Set Filter |
| 20 | open scoped Topology BigOperators |
| 21 | |
| 22 | /-- Ordinary nonincrease and left-limit jump balances control the sum of |
| 23 | all finite losses and gains (MT Lemma 17.12, pp. 410-411; M49 derivation 28). -/ |
| 24 | theorem add_sum_le_add_sum_of_finite_left_jumps {β : Type*} |
| 25 | [AddCommMonoid β] [Preorder β] [IsOrderedAddMonoid β] |
| 26 | [TopologicalSpace β] [OrderClosedTopology β] [ContinuousAdd β] |
| 27 | {f loss gain : ℝ → β} {a b : ℝ} (S : Finset ℝ) |
| 28 | (hab : a ≤ b) (hS : (S : Set ℝ) ⊆ Ioc a b) |
| 29 | (hregular : ∀ x ∈ Icc a b, ∀ y ∈ Icc a b, x ≤ y → |
| 30 | Disjoint (S : Set ℝ) (Ioc x y) → f y ≤ f x) |
| 31 | (hjump : ∀ T ∈ S, ∃ L, Tendsto f (𝓝[<] T) (𝓝 L) ∧ |
| 32 | f T + loss T ≤ L + gain T) : |
| 33 | f b + ∑ T ∈ S, loss T ≤ f a + ∑ T ∈ S, gain T := by |
| 34 | classical |
| 35 | induction S using Finset.induction_on_max generalizing a b with |
| 36 | | empty => |
| 37 | simpa only [Finset.sum_empty, add_zero] using |
| 38 | hregular a ⟨le_rfl, hab⟩ b ⟨hab, le_rfl⟩ hab (by simp) |
| 39 | | insert T S hST ih => |
| 40 | have hT : T ∈ Ioc a b := hS (Finset.mem_insert_self T S) |
| 41 | let c := (insert a S).max' (Finset.insert_nonempty a S) |
| 42 | have hac : a ≤ c := (insert a S).le_max' a (Finset.mem_insert_self a S) |
| 43 | have hzc (z : ℝ) (hz : z ∈ S) : z ≤ c := |
| 44 | (insert a S).le_max' z (Finset.mem_insert_of_mem hz) |
| 45 | have hcT : c < T := ((insert a S).max'_lt_iff _).mpr (by |
| 46 | intro z hz |
| 47 | rcases Finset.mem_insert.mp hz with rfl | hz |
| 48 | · exact hT.1 |
| 49 | · exact hST z hz) |
| 50 | obtain ⟨L, hlim, hdrop⟩ := hjump T (Finset.mem_insert_self T S) |
| 51 | have hL : L + ∑ z ∈ S, loss z ≤ f a + ∑ z ∈ S, gain z := by |
| 52 | apply le_of_tendsto (hlim.add_const (∑ z ∈ S, loss z)) |
| 53 | filter_upwards [Ioo_mem_nhdsLT hcT] with t ht |
| 54 | apply ih (hac.trans ht.1.le) |
| 55 | · intro z hz |
| 56 | exact ⟨(hS (Finset.mem_insert_of_mem hz)).1, (hzc z hz).trans ht.1.le⟩ |
| 57 | · intro x hx y hy hxy hdisjoint |
| 58 | apply hregular x ⟨hx.1, hx.2.trans (ht.2.le.trans hT.2)⟩ |
| 59 | y ⟨hy.1, hy.2.trans (ht.2.le.trans hT.2)⟩ hxy |
| 60 | apply disjoint_left.mpr |
| 61 | intro z hz hzxy |
| 62 | rcases Finset.mem_insert.mp hz with rfl | hz |
| 63 | · exact (not_le_of_gt (hy.2.trans_lt ht.2)) hzxy.2 |
| 64 | · exact disjoint_left.mp hdisjoint hz hzxy |
| 65 | · intro z hz |
| 66 | exact hjump z (Finset.mem_insert_of_mem hz) |
| 67 | have hlast : f b ≤ f T := by |
| 68 | apply hregular T ⟨hT.1.le, hT.2⟩ b ⟨hab, le_rfl⟩ hT.2 |
| 69 | apply disjoint_left.mpr |
| 70 | intro z hz hTz |
| 71 | rcases Finset.mem_insert.mp hz with rfl | hz |
| 72 | · exact (lt_irrefl _) hTz.1 |
| 73 | · exact (not_lt_of_gt (hST z hz)) hTz.1 |
| 74 | have hnot : T ∉ S := fun h => (lt_irrefl T) (hST T h) |
| 75 | rw [Finset.sum_insert hnot, Finset.sum_insert hnot] |
| 76 | calc |
| 77 | f b + (loss T + ∑ z ∈ S, loss z) = |
| 78 | (f b + loss T) + ∑ z ∈ S, loss z := (add_assoc _ _ _).symm |
| 79 | _ ≤ (L + gain T) + ∑ z ∈ S, loss z := |
| 80 | add_le_add ((add_le_add hlast le_rfl).trans hdrop) le_rfl |
| 81 | _ = (L + ∑ z ∈ S, loss z) + gain T := by ac_rfl |
| 82 | _ ≤ (f a + ∑ z ∈ S, gain z) + gain T := add_le_add hL le_rfl |
| 83 | _ = f a + (gain T + ∑ z ∈ S, gain z) := by ac_rfl |