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 PoincareLib.Geometry.Manifold.InverseFunction.LocalDiffeomorph |
| 3 | import Mathlib.Topology.Connected.Clopen |
| 4 | |
| 5 | /-! |
| 6 | # Compact graphs are full level components |
| 7 | |
| 8 | An immersed compact connected hypersurface in a regular level is open in that |
| 9 | level by the inverse function theorem and closed by compactness. Thus its image |
| 10 | is the full connected component through any of its points. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | set_option backward.isDefEq.respectTransparency false |
| 15 | |
| 16 | open Set Function TopologicalSpace |
| 17 | open scoped Manifold ContDiff Topology |
| 18 | open Poincare.Geometry.Manifold.RegularLevel |
| 19 | |
| 20 | namespace Poincare.Manifold |
| 21 | |
| 22 | variable {n : ℕ} {M N : Type*} [TopologicalSpace M] [TopologicalSpace N] |
| 23 | [ChartedSpace (EuclideanSpace ℝ (Fin (n + 1))) M] |
| 24 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) N] |
| 25 | [IsManifold (𝓡 (n + 1)) ∞ M] [IsManifold (𝓡 n) ∞ N] |
| 26 | {f : M → ℝ} (hf : ContMDiff (𝓡 (n + 1)) 𝓘(ℝ, ℝ) ∞ f) |
| 27 | (U : Opens M) (hreg : ∀ x ∈ U, mfderiv (𝓡 (n + 1)) 𝓘(ℝ, ℝ) f x ≠ 0) |
| 28 | (c : ℝ) |
| 29 | |
| 30 | local instance : Fact (Module.finrank ℝ (EuclideanSpace ℝ (Fin (n + 1))) = n + 1) := |
| 31 | ⟨finrank_euclideanSpace_fin⟩ |
| 32 | |
| 33 | /-- A smooth map into a regular level with injective ambient differential |
| 34 | is a local diffeomorphism onto the level. -/ |
| 35 | theorem isLocalDiffeomorph_into_level_of_ambient_immersion |
| 36 | (F : N → openLevelSet f U c) |
| 37 | (hF : ContMDiff (𝓡 n) (𝓡 (n + 1)) ∞ (openLevelIncl f U c ∘ F)) |
| 38 | (hinj : ∀ x, Injective |
| 39 | (mfderiv (𝓡 n) (𝓡 (n + 1)) (openLevelIncl f U c ∘ F) x)) : |
| 40 | letI := openLevelSetChartedSpace hf U hreg n c |
| 41 | IsLocalDiffeomorph (𝓡 n) (𝓡 n) ∞ F := by |
| 42 | let := openLevelSetChartedSpace hf U hreg n c |
| 43 | let := isManifold_openLevelSet hf U hreg n c |
| 44 | have hFs : ContMDiff (𝓡 n) (𝓡 n) ∞ F := fun x => |
| 45 | (contMDiffAt_into_openLevelSet_iff hf n c U hreg F x).mpr (hF x) |
| 46 | apply Poincare.isLocalDiffeomorph_of_contMDiff_bijective_mfderiv hFs |
| 47 | intro x |
| 48 | have hcomp := mfderiv_comp x |
| 49 | ((contMDiff_openLevelIncl hf U hreg n c (F x)).mdifferentiableAt (by simp)) |
| 50 | ((hFs x).mdifferentiableAt (by simp)) |
| 51 | have hFi : Injective (mfderiv (𝓡 n) (𝓡 n) F x) := by |
| 52 | apply Function.Injective.of_comp |
| 53 | (f := mfderiv (𝓡 n) (𝓡 (n + 1)) (openLevelIncl f U c) (F x)) |
| 54 | change Injective ((mfderiv (𝓡 n) (𝓡 (n + 1)) (openLevelIncl f U c) (F x)).comp |
| 55 | (mfderiv (𝓡 n) (𝓡 n) F x)) |
| 56 | rw [← hcomp] |
| 57 | exact hinj x |
| 58 | let A : EuclideanSpace ℝ (Fin n) →L[ℝ] EuclideanSpace ℝ (Fin n) := |
| 59 | mfderiv (𝓡 n) (𝓡 n) F x |
| 60 | exact ⟨hFi, (LinearMap.injective_iff_surjective (f := A.toLinearMap)).mp hFi⟩ |
| 61 | |
| 62 | include hf hreg in |
| 63 | /-- A compact connected immersed graph fills the entire connected component |
| 64 | of its regular level, even if that level has other components. -/ |
| 65 | theorem range_eq_level_component_of_compact_immersion |
| 66 | [T2Space M] [CompactSpace N] [ConnectedSpace N] |
| 67 | (F : N → openLevelSet f U c) |
| 68 | (hF : ContMDiff (𝓡 n) (𝓡 (n + 1)) ∞ (openLevelIncl f U c ∘ F)) |
| 69 | (hinj : ∀ x, Injective |
| 70 | (mfderiv (𝓡 n) (𝓡 (n + 1)) (openLevelIncl f U c ∘ F) x)) (x : N) : |
| 71 | range F = connectedComponent (F x) := by |
| 72 | let := openLevelSetChartedSpace hf U hreg n c |
| 73 | let := isManifold_openLevelSet hf U hreg n c |
| 74 | have hlocal := isLocalDiffeomorph_into_level_of_ambient_immersion hf U hreg c F hF hinj |
| 75 | have hcont : Continuous F := hlocal.contMDiff.continuous |
| 76 | have hclosed : IsClosed (range F) := (isCompact_range hcont).isClosed |
| 77 | have hclopen : IsClopen (range F) := ⟨hclosed, hlocal.isOpen_range⟩ |
| 78 | exact (isPreconnected_range hcont).subset_connectedComponent (mem_range_self x) |
| 79 | |>.antisymm (hclopen.connectedComponent_subset (mem_range_self x)) |
| 80 | |
| 81 | end Poincare.Manifold |