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.ReducedGeometry.LGeometry.Jacobi.OverlappingIntervals |
| 2 | |
| 3 | /-! Adapted from Mapher `PoincareMT/Proofs/M08/IntervalSolutionGluing.lean` at |
| 4 | `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. -/ |
| 5 | |
| 6 | |
| 7 | set_option autoImplicit false |
| 8 | |
| 9 | open Set Filter Topology |
| 10 | |
| 11 | namespace PoincareMT.LGeometry |
| 12 | |
| 13 | theorem lt_of_Icc_mem_nhdsWithin_Icc {a b l r s : ℝ} (hab : a < b) |
| 14 | (hs : s ∈ Icc a b) (hnear : Icc l r ∈ 𝓝[Icc a b] s) : l < r := by |
| 15 | obtain ⟨U, hU, hsU, hsub⟩ := mem_nhdsWithin.mp hnear |
| 16 | obtain ⟨u, v, ⟨hus, hsv⟩, huv⟩ := |
| 17 | mem_nhds_iff_exists_Ioo_subset.mp (hU.mem_nhds hsU) |
| 18 | let p := max a ((u + s) / 2) |
| 19 | let q := min b ((s + v) / 2) |
| 20 | have hups : u < (u + s) / 2 ∧ (u + s) / 2 < s := by constructor <;> linarith |
| 21 | have hsqv : s < (s + v) / 2 ∧ (s + v) / 2 < v := by constructor <;> linarith |
| 22 | have hpq : p < q := max_lt |
| 23 | (lt_min hab (hs.1.trans_lt hsqv.1)) |
| 24 | (lt_min (hups.2.trans_le hs.2) (hups.2.trans hsqv.1)) |
| 25 | have hps : p ≤ s := max_le hs.1 hups.2.le |
| 26 | have hsq : s ≤ q := le_min hs.2 hsqv.1.le |
| 27 | have hp : p ∈ Icc l r := hsub ⟨huv ⟨hups.1.trans_le (le_max_right _ _), |
| 28 | hps.trans_lt hsv⟩, ⟨le_max_left _ _, hps.trans hs.2⟩⟩ |
| 29 | have hq : q ∈ Icc l r := hsub ⟨huv ⟨hus.trans_le hsq, |
| 30 | (min_le_right _ _).trans_lt hsqv.2⟩, ⟨hs.1.trans hsq, min_le_left _ _⟩⟩ |
| 31 | exact (hp.1.trans_lt hpq).trans_le hq.2 |
| 32 | |
| 33 | structure IntervalSolutionLocality {X : Type*} |
| 34 | (Sol : ℝ → ℝ → (ℝ → X) → Prop) : Prop where |
| 35 | restrict : ∀ {a b c d : ℝ} {f : ℝ → X}, |
| 36 | a ≤ c → c < d → d ≤ b → Sol a b f → Sol c d f |
| 37 | paste : ∀ {a l c r : ℝ} {f g : ℝ → X}, |
| 38 | a ≤ l → l < c → c < r → Sol a c f → Sol l r g → EqOn f g (Icc l c) → |
| 39 | Sol a r (fun s ↦ if s ≤ c then f s else g s) |
| 40 | |
| 41 | set_option maxHeartbeats 1000000 in |
| 42 | theorem exists_interval_solution_of_overlapping_cover {X : Type*} |
| 43 | (Sol : ℝ → ℝ → (ℝ → X) → Prop) (hSol : IntervalSolutionLocality Sol) |
| 44 | {a b : ℝ} (hab : a < b) {m : ℕ} (hm : 0 < m) |
| 45 | (t : Fin (m + 1) → ℝ) (l r : Fin m → ℝ) |
| 46 | (ht : Monotone t) (hta : t 0 = a) (htb : t (Fin.last m) = b) |
| 47 | (hpieces : ∀ i, a ≤ l i ∧ l i < r i ∧ r i ≤ b ∧ l i ≤ t i.castSucc ∧ |
| 48 | t i.succ ≤ r i ∧ ∀ s ∈ Icc (t i.castSucc) (t i.succ), |
| 49 | Icc (l i) (r i) ∈ 𝓝[Icc a b] s) |
| 50 | (hlocal : ∀ i s, s ∈ Icc (l i) (r i) → ∀ z : X, |
| 51 | ∃ f : ℝ → X, Sol (l i) (r i) f ∧ f s = z) |
| 52 | (hunique : ∀ i {c d : ℝ}, l i ≤ c → c < d → d ≤ r i → |
| 53 | ∀ {f g : ℝ → X}, Sol c d f → Sol c d g → |
| 54 | ∀ s ∈ Icc c d, f s = g s → EqOn f g (Icc c d)) |
| 55 | (z₀ : X) : ∃ f : ℝ → X, Sol a b f ∧ f a = z₀ := by |
| 56 | classical |
| 57 | have hstep : ∀ k (hk : k < m), ∃ c : ℝ, ∃ f : ℝ → X, |
| 58 | a < c ∧ c ≤ b ∧ t ⟨k + 1, Nat.succ_lt_succ hk⟩ ≤ c ∧ |
| 59 | Icc a c ∈ 𝓝[Icc a b] (t ⟨k + 1, Nat.succ_lt_succ hk⟩) ∧ |
| 60 | Sol a c f ∧ f a = z₀ := by |
| 61 | intro k |
| 62 | induction k with |
| 63 | | zero => |
| 64 | intro hk |
| 65 | let i : Fin m := ⟨0, hk⟩ |
| 66 | obtain ⟨hal, hlr, hrb, hlt, htr, hnear⟩ := hpieces i |
| 67 | have hzero : t i.castSucc = a := hta |
| 68 | have hla : l i = a := le_antisymm (hzero ▸ hlt) hal |
| 69 | have ha : a ∈ Icc (l i) (r i) := ⟨hla.le, hla ▸ hlr.le⟩ |
| 70 | obtain ⟨f, hf, hf0⟩ := hlocal i a ha z₀ |
| 71 | have hnext := hnear (t i.succ) ⟨ht (show i.castSucc ≤ i.succ from Nat.le_succ i.val), le_rfl⟩ |
| 72 | refine ⟨r i, f, hla ▸ hlr, hrb, htr, ?_, ?_, hf0⟩ |
| 73 | · change Icc a (r i) ∈ 𝓝[Icc a b] (t i.succ) |
| 74 | simpa only [hla] using hnext |
| 75 | · simpa only [hla] using hf |
| 76 | | succ k ih => |
| 77 | intro hk |
| 78 | have hk' : k < m := (Nat.lt_succ_self k).trans hk |
| 79 | obtain ⟨c, f, hac, hcb, htc, hprefix, hf, hf0⟩ := ih hk' |
| 80 | let i : Fin m := ⟨k + 1, hk⟩ |
| 81 | obtain ⟨hal, hlr, hrb, hlt, htr, hnear⟩ := hpieces i |
| 82 | have hcore : t i.castSucc ≤ t i.succ := |
| 83 | ht (show i.castSucc ≤ i.succ from Nat.le_succ i.val) |
| 84 | have hstart : t i.castSucc ∈ Icc (l i) (r i) := ⟨hlt, hcore.trans htr⟩ |
| 85 | have hstartC : t i.castSucc ∈ Icc a b := |
| 86 | ⟨hal.trans hlt, (hcore.trans htr).trans hrb⟩ |
| 87 | have hprefix' : Icc a c ∈ 𝓝[Icc a b] (t i.castSucc) := hprefix |
| 88 | have hover : Icc (l i) (min c (r i)) ∈ 𝓝[Icc a b] (t i.castSucc) := by |
| 89 | apply mem_of_superset (inter_mem hprefix' (hnear _ ⟨le_rfl, hcore⟩)) |
| 90 | intro s hs |
| 91 | exact ⟨hs.2.1, le_min hs.1.2 hs.2.2⟩ |
| 92 | have hlmin := lt_of_Icc_mem_nhdsWithin_Icc hab hstartC hover |
| 93 | obtain ⟨g, hg, hgf⟩ := hlocal i (t i.castSucc) hstart (f (t i.castSucc)) |
| 94 | have heq : EqOn f g (Icc (l i) (min c (r i))) := by |
| 95 | apply hunique i le_rfl hlmin (min_le_right _ _) |
| 96 | (hSol.restrict hal hlmin (min_le_left _ _) hf) |
| 97 | (hSol.restrict le_rfl hlmin (min_le_right _ _) hg) (t i.castSucc) |
| 98 | ⟨hlt, le_min htc hstart.2⟩ hgf.symm |
| 99 | have hnext := hnear (t i.succ) ⟨hcore, le_rfl⟩ |
| 100 | by_cases hrc : r i ≤ c |
| 101 | · refine ⟨c, f, hac, hcb, htr.trans hrc, ?_, hf, hf0⟩ |
| 102 | exact mem_of_superset hnext (Icc_subset_Icc hal hrc) |
| 103 | · have hcr : c < r i := lt_of_not_ge hrc |
| 104 | have hlc : l i < c := hlmin.trans_le (min_le_left _ _) |
| 105 | have heq' : EqOn f g (Icc (l i) c) := by |
| 106 | simpa only [min_eq_left hcr.le] using heq |
| 107 | refine ⟨r i, (fun s ↦ if s ≤ c then f s else g s), |
| 108 | hac.trans hcr, hrb, htr, ?_, hSol.paste hal hlc hcr hf hg heq', ?_⟩ |
| 109 | · exact mem_of_superset hnext (Icc_subset_Icc hal le_rfl) |
| 110 | · simpa only [if_pos hac.le] using hf0 |
| 111 | have hk : m - 1 < m := by omega |
| 112 | obtain ⟨c, f, hac, hcb, htc, hnear, hf, hf0⟩ := hstep (m - 1) hk |
| 113 | have hlast : (⟨m - 1 + 1, Nat.succ_lt_succ hk⟩ : Fin (m + 1)) = Fin.last m := by |
| 114 | apply Fin.ext |
| 115 | simp only [Fin.val_last] |
| 116 | omega |
| 117 | have hbc : b ≤ c := by simpa only [hlast, htb] using htc |
| 118 | have hceq : c = b := le_antisymm hcb hbc |
| 119 | exact ⟨f, hceq ▸ hf, hf0⟩ |
| 120 | |
| 121 | end PoincareMT.LGeometry |