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.AdaptedChart |
| 2 | import PoincareLib.Analysis.Calculus.ImplicitFunction.RegularScalar |
| 3 | import PoincareLib.Analysis.InnerProductSpace.Coordinates.FinSucc |
| 4 | import Mathlib.LinearAlgebra.Dual.Lemmas |
| 5 | import Mathlib.Geometry.Manifold.Instances.Real |
| 6 | |
| 7 | /-! |
| 8 | # Euclidean coordinates for a regular scalar function |
| 9 | |
| 10 | The scalar implicit function theorem gives coordinates with the defining |
| 11 | function as the first coordinate, inside any prescribed open neighborhood. |
| 12 | -/ |
| 13 | |
| 14 | open Set Function TopologicalSpace Poincare.EuclideanSpace |
| 15 | open scoped Manifold ContDiff Topology |
| 16 | |
| 17 | set_option backward.isDefEq.respectTransparency false |
| 18 | |
| 19 | namespace Poincare.Geometry.Manifold.RegularLevel |
| 20 | |
| 21 | theorem exists_regular_coordinates |
| 22 | {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 23 | [ChartedSpace (EuclideanSpace ℝ (Fin (n + 1))) M] |
| 24 | [IsManifold (𝓡 (n + 1)) ∞ M] |
| 25 | {f : M → ℝ} (hf : ContMDiff (𝓡 (n + 1)) 𝓘(ℝ, ℝ) ∞ f) |
| 26 | (U : Opens M) {p : M} (hp : p ∈ U) |
| 27 | (hreg : mfderiv (𝓡 (n + 1)) 𝓘(ℝ, ℝ) f p ≠ 0) : |
| 28 | ∃ e : OpenPartialHomeomorph (EuclideanSpace ℝ (Fin (n + 1))) M, |
| 29 | p ∈ e.target ∧ e.target ⊆ U ∧ |
| 30 | ContMDiffOn (𝓡 (n + 1)) (𝓡 (n + 1)) ∞ e e.source ∧ |
| 31 | ContMDiffOn (𝓡 (n + 1)) (𝓡 (n + 1)) ∞ e.symm e.target ∧ |
| 32 | ∀ y ∈ e.source, f (e y) = y 0 := by |
| 33 | let E := EuclideanSpace ℝ (Fin (n + 1)) |
| 34 | let κ : OpenPartialHomeomorph M E := chartAt E p |
| 35 | let F : E → ℝ := f ∘ κ.symm |
| 36 | let a : E := κ p |
| 37 | let V : Set E := κ.target ∩ κ.symm ⁻¹' U |
| 38 | have hV : IsOpen V := |
| 39 | κ.continuousOn_symm.isOpen_inter_preimage κ.open_target U.isOpen |
| 40 | have ha : a ∈ V := ⟨κ.map_source (mem_chart_source E p), by |
| 41 | change κ.symm (κ p) ∈ U |
| 42 | rwa [κ.left_inv (mem_chart_source E p)]⟩ |
| 43 | have hF : ContDiffOn ℝ ∞ F V := |
| 44 | (contDiffOn_comp_extChartAt_symm hf p).mono (by |
| 45 | intro x hx |
| 46 | simpa [extChartAt, κ] using hx.1) |
| 47 | have hder : HasFDerivAt F (mfderiv (𝓡 (n + 1)) 𝓘(ℝ, ℝ) f p) a := |
| 48 | hasFDerivAt_comp_extChartAt_symm hf p |
| 49 | let L := fderiv ℝ F a |
| 50 | have hL : (L : E →ₗ[ℝ] ℝ) ≠ 0 := by |
| 51 | intro hzero |
| 52 | apply hreg |
| 53 | rw [← hder.fderiv] |
| 54 | exact ContinuousLinearMap.ext fun v => DFunLike.congr_fun hzero v |
| 55 | obtain ⟨q, haq, hqV, hqa, hq, hqi, hqf, _⟩ := |
| 56 | Poincare.Analysis.exists_smooth_superlevel_chart hV hF ha (LinearMap.surjective hL) |
| 57 | have hdim : Module.finrank ℝ L.ker = n := by |
| 58 | have h := Module.Dual.finrank_ker_add_one_of_ne_zero hL |
| 59 | have hd : Module.finrank ℝ E = n + 1 := finrank_euclideanSpace_fin |
| 60 | rw [hd] at h |
| 61 | omega |
| 62 | let K : L.ker ≃L[ℝ] EuclideanSpace ℝ (Fin n) := |
| 63 | ContinuousLinearEquiv.ofFinrankEq (by rw [hdim, finrank_euclideanSpace_fin]) |
| 64 | let A : (ℝ × L.ker) ≃L[ℝ] E := |
| 65 | ((ContinuousLinearEquiv.refl ℝ ℝ).prodCongr K).trans (euclideanConsCLE n) |
| 66 | let C := κ.trans (q.trans A.toHomeomorph.toOpenPartialHomeomorph) |
| 67 | refine ⟨C.symm, ?_, ?_, ?_, ?_, ?_⟩ |
| 68 | · exact ⟨mem_chart_source E p, haq, Set.mem_univ _⟩ |
| 69 | · intro x hx |
| 70 | have hxV := (hqV hx.2.1).2 |
| 71 | change κ.symm (κ x) ∈ U at hxV |
| 72 | rwa [κ.left_inv hx.1] at hxV |
| 73 | · intro y hy |
| 74 | have hyq : A.symm y ∈ q.target := hy.1.2 |
| 75 | have hyκ : q.symm (A.symm y) ∈ κ.target := hy.2 |
| 76 | have hA : ContMDiffAt (𝓡 (n + 1)) 𝓘(ℝ, ℝ × L.ker) ∞ A.symm y := |
| 77 | A.symm.contDiff.contDiffAt.contMDiffAt |
| 78 | have hqinv := ((hqi _ hyq).contDiffAt (q.open_target.mem_nhds hyq)).contMDiffAt.comp y hA |
| 79 | have hκinv : ContMDiffAt (𝓡 (n + 1)) (𝓡 (n + 1)) ∞ κ.symm |
| 80 | (q.symm (A.symm y)) := |
| 81 | (contMDiffOn_extChartAt_symm (I := 𝓡 (n + 1)) (n := ∞) p).contMDiffAt |
| 82 | (by simpa [extChartAt, κ] using κ.open_target.mem_nhds hyκ) |
| 83 | exact (hκinv.comp y hqinv).contMDiffWithinAt |
| 84 | · intro x hx |
| 85 | have hκ : ContMDiffAt (𝓡 (n + 1)) (𝓡 (n + 1)) ∞ κ x := |
| 86 | contMDiffAt_extChartAt' hx.1 |
| 87 | have hqAt := ((hq _ hx.2.1).contDiffAt (q.open_source.mem_nhds hx.2.1)).contMDiffAt |
| 88 | exact (A.contDiff.contDiffAt.contMDiffAt.comp x (hqAt.comp x hκ)).contMDiffWithinAt |
| 89 | · intro y hy |
| 90 | have hx := C.symm.map_source hy |
| 91 | have hfq := hqf (κ (C.symm y)) hx.2.1 |
| 92 | change (q (κ (C.symm y))).1 = f (κ.symm (κ (C.symm y))) at hfq |
| 93 | rw [κ.left_inv hx.1] at hfq |
| 94 | have hround : A (q (κ (C.symm y))) = y := C.right_inv hy |
| 95 | have hfirst := congrArg (fun v : E => v 0) hround |
| 96 | change (q (κ (C.symm y))).1 = y 0 at hfirst |
| 97 | exact hfq.symm.trans hfirst |
| 98 | |
| 99 | end Poincare.Geometry.Manifold.RegularLevel |