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.Analysis.Calculus.ImplicitFunction.RegularScalar |
| 2 | import Mathlib.Geometry.Manifold.ContMDiff.Atlas |
| 3 | import Mathlib.Geometry.Manifold.ContMDiff.NormedSpace |
| 4 | import Mathlib.Geometry.Manifold.MFDeriv.Basic |
| 5 | |
| 6 | set_option backward.isDefEq.respectTransparency false |
| 7 | |
| 8 | open Poincare.Analysis Set Function |
| 9 | open scoped Topology ContDiff Manifold |
| 10 | |
| 11 | /-! Adapted from AxelWorkspace, `MorganTianLib/Foundations/ManifoldSuperlevelCharts.lean`, |
| 12 | revision `f1cdb30cabdc8781d2d3dec86d3d99ab1820f30e`. |
| 13 | See `references/analysis/axel-workspace/regular-domain-reuse.md`. -/ |
| 14 | |
| 15 | namespace Poincare.Manifold |
| 16 | |
| 17 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 18 | [FiniteDimensional ℝ E] {M : Type*} [TopologicalSpace M] [ChartedSpace E M] |
| 19 | [IsManifold 𝓘(ℝ, E) ∞ M] |
| 20 | |
| 21 | /-- Smooth local coordinates adapted to a scalar function at a regular point. -/ |
| 22 | theorem exists_manifold_superlevel_chart {f : M → ℝ} |
| 23 | (hf : ContMDiff 𝓘(ℝ, E) 𝓘(ℝ, ℝ) ∞ f) (a : M) |
| 24 | (hreg : Surjective (mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f a)) : |
| 25 | let L : E →L[ℝ] ℝ := mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f a |
| 26 | ∃ e : OpenPartialHomeomorph M (ℝ × L.ker), |
| 27 | a ∈ e.source ∧ e a = (f a, 0) ∧ |
| 28 | ContMDiffOn 𝓘(ℝ, E) 𝓘(ℝ, ℝ × L.ker) ∞ e e.source ∧ |
| 29 | ContMDiffOn 𝓘(ℝ, ℝ × L.ker) 𝓘(ℝ, E) ∞ e.symm e.target ∧ |
| 30 | (∀ x ∈ e.source, (e x).1 = f x) ∧ |
| 31 | ∀ c : ℝ, e '' (e.source ∩ {x | c ≤ f x}) = e.target ∩ {y | c ≤ y.1} := by |
| 32 | dsimp only |
| 33 | let φ := chartAt E a |
| 34 | let g : E → ℝ := f ∘ φ.symm |
| 35 | have hg : ContDiffOn ℝ ∞ g φ.target := |
| 36 | (hf.comp_contMDiffOn (contMDiffOn_chart_symm (I := 𝓘(ℝ, E)))).contDiffOn |
| 37 | have hder : mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f a = fderiv ℝ g (φ a) := by |
| 38 | rw [(hf.mdifferentiable (by simp) a).mfderiv] |
| 39 | simp [writtenInExtChartAt, extChartAt, g, φ, fderivWithin_univ, chartAt_self_eq] |
| 40 | rw [hder] at hreg ⊢ |
| 41 | obtain ⟨e0, ha0, heV, he0a, he0, he0inv, he0f, he0level⟩ := |
| 42 | exists_smooth_superlevel_chart φ.open_target hg |
| 43 | (φ.map_source (mem_chart_source E a)) hreg |
| 44 | let e := φ.trans e0 |
| 45 | have hea : a ∈ e.source := ⟨mem_chart_source E a, ha0⟩ |
| 46 | have hefirst : ∀ x ∈ e.source, (e x).1 = f x := by |
| 47 | intro x hx |
| 48 | change (e0 (φ x)).1 = f x |
| 49 | rw [he0f (φ x) (show φ x ∈ e0.source from hx.2)] |
| 50 | change f (φ.symm (φ x)) = f x |
| 51 | rw [φ.left_inv hx.1] |
| 52 | refine ⟨e, hea, ?_, ?_, ?_, hefirst, ?_⟩ |
| 53 | · change e0 (φ a) = (f a, 0) |
| 54 | simpa [g, φ] using he0a |
| 55 | · exact he0.contMDiffOn.comp |
| 56 | ((contMDiffOn_chart (I := 𝓘(ℝ, E))).mono (fun x hx => hx.1)) |
| 57 | (fun x hx => hx.2) |
| 58 | · exact (contMDiffOn_chart_symm (I := 𝓘(ℝ, E))).comp |
| 59 | (he0inv.contMDiffOn.mono (fun y hy => hy.1)) (fun y hy => hy.2) |
| 60 | · intro c |
| 61 | ext y |
| 62 | constructor |
| 63 | · rintro ⟨x, ⟨hx, hcx⟩, rfl⟩ |
| 64 | exact ⟨e.map_source hx, by simpa [hefirst x hx] using hcx⟩ |
| 65 | · rintro ⟨hy, hcy⟩ |
| 66 | refine ⟨e.symm y, ⟨e.map_target hy, ?_⟩, e.right_inv hy⟩ |
| 67 | change c ≤ f (e.symm y) |
| 68 | rw [← hefirst _ (e.map_target hy), e.right_inv hy] |
| 69 | exact hcy |
| 70 | |
| 71 | |
| 72 | /-- The frontier of a regular superlevel is precisely its defining level set. -/ |
| 73 | theorem frontier_superlevel_eq_regular_level {f : M → ℝ} |
| 74 | (hf : ContMDiff 𝓘(ℝ, E) 𝓘(ℝ, ℝ) ∞ f) (c : ℝ) |
| 75 | (hc : ∀ x, f x = c → Surjective (mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f x)) : |
| 76 | frontier {x | c ≤ f x} = {x | f x = c} := by |
| 77 | apply Subset.antisymm |
| 78 | · intro x hx |
| 79 | exact (frontier_le_subset_eq continuous_const hf.continuous hx).symm |
| 80 | · intro x hx |
| 81 | obtain ⟨e, hxe, hea, he, hei, hef, helevel⟩ := |
| 82 | exists_manifold_superlevel_chart hf x (hc x hx) |
| 83 | have himg := OpenPartialHomeomorph.IsImage.of_image_eq (helevel c) |
| 84 | apply (himg.frontier.apply_mem_iff hxe).mp |
| 85 | let L : E →L[ℝ] ℝ := mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f x |
| 86 | have hhalf : {y : ℝ × L.ker | c ≤ y.1} = Ici c ×ˢ univ := by |
| 87 | ext y |
| 88 | simp |
| 89 | rw [hhalf, frontier_prod_univ_eq, frontier_Ici] |
| 90 | exact ⟨by simpa [hea] using hx, mem_univ _⟩ |
| 91 | |
| 92 | |
| 93 | end Poincare.Manifold |