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.Manifold.RegularLevel.UniversalProperty |
| 2 | import Mathlib.Geometry.Manifold.Diffeomorph |
| 3 | import Mathlib.Geometry.Manifold.Algebra.Structures |
| 4 | |
| 5 | /-! |
| 6 | # Product coordinates from a flow transverse to a regular level |
| 7 | |
| 8 | A smooth global flow which increases a regular function at unit speed |
| 9 | identifies the manifold with the zero level times the real line. The inverse |
| 10 | returns along the same flow for the time given by the function value. |
| 11 | -/ |
| 12 | |
| 13 | noncomputable section |
| 14 | set_option autoImplicit false |
| 15 | set_option backward.isDefEq.respectTransparency false |
| 16 | |
| 17 | open Set TopologicalSpace |
| 18 | open scoped Manifold ContDiff Bundle Topology |
| 19 | |
| 20 | namespace Poincare.Geometry.Manifold.RegularLevel |
| 21 | |
| 22 | variable {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 23 | [ChartedSpace (EuclideanSpace ℝ (Fin (n + 1))) M] |
| 24 | [IsManifold (𝓡 (n + 1)) ∞ M] {f : M → ℝ} |
| 25 | |
| 26 | private def productEquivOfFlow (Φ : ℝ → M → M) |
| 27 | (h0 : ∀ x, Φ 0 x = x) (hadd : ∀ s t x, Φ (s + t) x = Φ s (Φ t x)) |
| 28 | (hscalar : ∀ t x, f (Φ t x) = f x + t) : |
| 29 | (openLevelSet f (⊤ : Opens M) 0 × ℝ) ≃ M where |
| 30 | toFun z := Φ z.2 (openLevelIncl f (⊤ : Opens M) 0 z.1) |
| 31 | invFun x := (⟨⟨Φ (-f x) x, mem_univ _⟩, by simp [hscalar]⟩, f x) |
| 32 | left_inv z := by |
| 33 | have hz : f (openLevelIncl f (⊤ : Opens M) 0 z.1) = 0 := z.1.2 |
| 34 | apply Prod.ext |
| 35 | · apply Subtype.ext |
| 36 | apply Subtype.ext |
| 37 | change Φ (-f (Φ z.2 (openLevelIncl f (⊤ : Opens M) 0 z.1))) |
| 38 | (Φ z.2 (openLevelIncl f (⊤ : Opens M) 0 z.1)) = |
| 39 | openLevelIncl f (⊤ : Opens M) 0 z.1 |
| 40 | rw [hscalar, hz, zero_add, ← hadd, neg_add_cancel, h0] |
| 41 | · change f (Φ z.2 (openLevelIncl f (⊤ : Opens M) 0 z.1)) = z.2 |
| 42 | rw [hscalar, hz, zero_add] |
| 43 | right_inv x := by |
| 44 | change Φ (f x) (Φ (-f x) x) = x |
| 45 | rw [← hadd, add_neg_cancel, h0] |
| 46 | |
| 47 | def productDiffeomorphOfFlow |
| 48 | (hf : ContMDiff (𝓡 (n + 1)) 𝓘(ℝ, ℝ) ∞ f) |
| 49 | (hreg : ∀ x, mfderiv (𝓡 (n + 1)) 𝓘(ℝ, ℝ) f x ≠ 0) |
| 50 | (Φ : ℝ → M → M) |
| 51 | (hs : ContMDiff (𝓘(ℝ, ℝ).prod (𝓡 (n + 1))) (𝓡 (n + 1)) ∞ |
| 52 | (fun z : ℝ × M => Φ z.1 z.2)) |
| 53 | (h0 : ∀ x, Φ 0 x = x) (hadd : ∀ s t x, Φ (s + t) x = Φ s (Φ t x)) |
| 54 | (hscalar : ∀ t x, f (Φ t x) = f x + t) : |
| 55 | letI : Fact (Module.finrank ℝ (EuclideanSpace ℝ (Fin (n + 1))) = n + 1) := |
| 56 | ⟨finrank_euclideanSpace_fin⟩ |
| 57 | letI := openLevelSetChartedSpace hf (⊤ : Opens M) (fun x _ => hreg x) n 0 |
| 58 | letI := isManifold_openLevelSet hf (⊤ : Opens M) (fun x _ => hreg x) n 0 |
| 59 | (openLevelSet f (⊤ : Opens M) 0 × ℝ) ≃ₘ⟮(𝓡 n).prod 𝓘(ℝ, ℝ), 𝓡 (n + 1)⟯ M := by |
| 60 | letI : Fact (Module.finrank ℝ (EuclideanSpace ℝ (Fin (n + 1))) = n + 1) := |
| 61 | ⟨finrank_euclideanSpace_fin⟩ |
| 62 | let hregular := fun x (_ : x ∈ (⊤ : Opens M)) => hreg x |
| 63 | letI := openLevelSetChartedSpace hf (⊤ : Opens M) hregular n 0 |
| 64 | letI := isManifold_openLevelSet hf (⊤ : Opens M) hregular n 0 |
| 65 | let e := productEquivOfFlow Φ h0 hadd hscalar |
| 66 | have he : ContMDiff ((𝓡 n).prod 𝓘(ℝ, ℝ)) (𝓡 (n + 1)) ∞ e := |
| 67 | hs.comp (contMDiff_snd.prodMk |
| 68 | ((contMDiff_openLevelIncl hf (⊤ : Opens M) hregular n 0).comp contMDiff_fst)) |
| 69 | have hr : ContMDiff (𝓡 (n + 1)) (𝓡 n) ∞ (fun x => (e.symm x).1) := by |
| 70 | intro x |
| 71 | apply (contMDiffAt_into_openLevelSet_iff hf n 0 (⊤ : Opens M) hregular |
| 72 | (fun x => (e.symm x).1) x).mpr |
| 73 | exact (hs.comp (hf.neg.prodMk contMDiff_id)) x |
| 74 | exact ⟨e, he, hr.prodMk hf⟩ |
| 75 | |
| 76 | end Poincare.Geometry.Manifold.RegularLevel |