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.ChartedSpace |
| 2 | import PoincareLib.Geometry.Manifold.RegularLevel.OpenInclusion |
| 3 | |
| 4 | /-! |
| 5 | # Regular levels inside an open subset |
| 6 | |
| 7 | The level is the subtype of the open submanifold, with its slice-chart atlas. |
| 8 | The inclusion has image exactly the level intersected with the prescribed open set. |
| 9 | The construction specializes LeeRiemannian's `RegularSetHypersurface.lean` |
| 10 | at revision `f47f76169b0f914d07661d052117fba97bd9852a` to any open regular domain. |
| 11 | -/ |
| 12 | |
| 13 | open Set Function TopologicalSpace |
| 14 | open scoped Manifold Topology ContDiff |
| 15 | |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | set_option linter.unusedSectionVars false |
| 18 | |
| 19 | noncomputable section |
| 20 | |
| 21 | namespace Poincare.Geometry.Manifold.RegularLevel |
| 22 | |
| 23 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 24 | [FiniteDimensional ℝ E] {H : Type*} [TopologicalSpace H] |
| 25 | {I : ModelWithCorners ℝ E H} {M : Type*} [TopologicalSpace M] |
| 26 | [ChartedSpace H M] [IsManifold I ∞ M] [I.Boundaryless] |
| 27 | |
| 28 | /-- A level inside an open submanifold. -/ |
| 29 | abbrev openLevelSet (f : M → ℝ) (U : Opens M) (c : ℝ) := |
| 30 | ((fun y : U => f (y : M)) ⁻¹' {c} : Set U) |
| 31 | |
| 32 | /-- The natural inclusion of the level into the original manifold. -/ |
| 33 | def openLevelIncl (f : M → ℝ) (U : Opens M) (c : ℝ) |
| 34 | (z : openLevelSet f U c) : M := ((z : U) : M) |
| 35 | |
| 36 | theorem range_openLevelIncl (f : M → ℝ) (U : Opens M) (c : ℝ) : |
| 37 | range (openLevelIncl f U c) = (U : Set M) ∩ f ⁻¹' {c} := by |
| 38 | ext x |
| 39 | constructor |
| 40 | · rintro ⟨z, rfl⟩ |
| 41 | exact ⟨(z : U).2, z.2⟩ |
| 42 | · rintro ⟨hxU, hxc⟩ |
| 43 | exact ⟨⟨⟨x, hxU⟩, hxc⟩, rfl⟩ |
| 44 | |
| 45 | theorem isEmbedding_openLevelIncl (f : M → ℝ) (U : Opens M) (c : ℝ) : |
| 46 | Topology.IsEmbedding (openLevelIncl f U c) := |
| 47 | Topology.IsEmbedding.subtypeVal.comp Topology.IsEmbedding.subtypeVal |
| 48 | |
| 49 | variable {f : M → ℝ} (hf : ContMDiff I 𝓘(ℝ, ℝ) ∞ f) (U : Opens M) |
| 50 | (hreg : ∀ x ∈ U, mfderiv I 𝓘(ℝ, ℝ) f x ≠ 0) |
| 51 | (n : ℕ) [Fact (Module.finrank ℝ E = n + 1)] (c : ℝ) |
| 52 | |
| 53 | include hf hreg in |
| 54 | theorem openLevelRestrict_regular (x : U) : |
| 55 | mfderiv I 𝓘(ℝ, ℝ) (fun y : U => f (y : M)) x ≠ 0 := by |
| 56 | rw [mfderiv_opens_restrict U f ((hf (x : M)).mdifferentiableAt (by simp))] |
| 57 | exact hreg (x : M) x.2 |
| 58 | |
| 59 | /-- The actual regular-level atlas obtained from the implicit function theorem. -/ |
| 60 | @[reducible] def openLevelSetChartedSpace : |
| 61 | ChartedSpace (EuclideanSpace ℝ (Fin n)) (openLevelSet f U c) := |
| 62 | levelSetChartedSpace (hf.comp contMDiff_subtype_val) n c |
| 63 | (fun x _ => openLevelRestrict_regular hf U hreg x) |
| 64 | |
| 65 | theorem isManifold_openLevelSet : |
| 66 | letI := openLevelSetChartedSpace hf U hreg n c |
| 67 | IsManifold (𝓡 n) ∞ (openLevelSet f U c) := |
| 68 | isManifold_levelSet (hf.comp contMDiff_subtype_val) n c |
| 69 | (fun x _ => openLevelRestrict_regular hf U hreg x) |
| 70 | |
| 71 | theorem contMDiff_openLevelIncl : |
| 72 | letI := openLevelSetChartedSpace hf U hreg n c |
| 73 | ContMDiff (𝓡 n) I ∞ (openLevelIncl f U c) := by |
| 74 | letI := openLevelSetChartedSpace hf U hreg n c |
| 75 | exact contMDiff_subtype_val.comp |
| 76 | (contMDiff_levelSet_val (hf.comp contMDiff_subtype_val) n c |
| 77 | (fun x _ => openLevelRestrict_regular hf U hreg x)) |
| 78 | |
| 79 | theorem mfderiv_openLevelIncl (z : openLevelSet f U c) : |
| 80 | letI := openLevelSetChartedSpace hf U hreg n c |
| 81 | mfderiv (𝓡 n) I (openLevelIncl f U c) z = |
| 82 | mfderiv (𝓡 n) I ((↑) : openLevelSet f U c → U) z := by |
| 83 | letI := openLevelSetChartedSpace hf U hreg n c |
| 84 | have hv : ContMDiff (𝓡 n) I ∞ ((↑) : openLevelSet f U c → U) := |
| 85 | contMDiff_levelSet_val (hf.comp contMDiff_subtype_val) n c |
| 86 | (fun x _ => openLevelRestrict_regular hf U hreg x) |
| 87 | have hval : MDifferentiableAt (𝓡 n) I |
| 88 | ((↑) : openLevelSet f U c → U) z := |
| 89 | (hv z).mdifferentiableAt (by simp) |
| 90 | have h := mfderiv_comp z |
| 91 | (hasMFDerivAt_opens_subtypeVal U (z : U)).mdifferentiableAt hval |
| 92 | change mfderiv (𝓡 n) I ((fun y : U => (y : M)) ∘ |
| 93 | ((↑) : openLevelSet f U c → U)) z = _ |
| 94 | rw [h, mfderiv_opens_subtypeVal] |
| 95 | ext v |
| 96 | rfl |
| 97 | |
| 98 | theorem injective_mfderiv_openLevelIncl (z : openLevelSet f U c) : |
| 99 | letI := openLevelSetChartedSpace hf U hreg n c |
| 100 | Injective (mfderiv (𝓡 n) I (openLevelIncl f U c) z) := by |
| 101 | letI := openLevelSetChartedSpace hf U hreg n c |
| 102 | rw [mfderiv_openLevelIncl hf U hreg n c] |
| 103 | exact mfderiv_levelSet_val_injective (hf.comp contMDiff_subtype_val) n c |
| 104 | (fun x _ => openLevelRestrict_regular hf U hreg x) z |
| 105 | |
| 106 | theorem range_mfderiv_openLevelIncl (z : openLevelSet f U c) : |
| 107 | letI := openLevelSetChartedSpace hf U hreg n c |
| 108 | (mfderiv (𝓡 n) I (openLevelIncl f U c) z : |
| 109 | EuclideanSpace ℝ (Fin n) →L[ℝ] E).range = |
| 110 | (mfderiv I 𝓘(ℝ, ℝ) f (openLevelIncl f U c z) : E →L[ℝ] ℝ).ker := by |
| 111 | letI := openLevelSetChartedSpace hf U hreg n c |
| 112 | have hr := range_mfderiv_levelSet_val (hf.comp contMDiff_subtype_val) n c |
| 113 | (fun x _ => openLevelRestrict_regular hf U hreg x) z |
| 114 | unfold levelHyperplane levelDifferential at hr |
| 115 | have hk := congrArg (fun A : E →L[ℝ] ℝ => A.ker) |
| 116 | (mfderiv_opens_restrict U f ((hf ((z : U) : M)).mdifferentiableAt (by simp))) |
| 117 | exact (congrArg (fun A : EuclideanSpace ℝ (Fin n) →L[ℝ] E => A.range) |
| 118 | (mfderiv_openLevelIncl hf U hreg n c z)).trans (hr.trans hk) |
| 119 | |
| 120 | end Poincare.Geometry.Manifold.RegularLevel |