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.Topology.Connected.SublevelEndpoint |
| 2 | import PoincareLib.Topology.Manifold.CountableComplement |
| 3 | import PoincareLib.Geometry.Manifold.SmoothDomain.RegularChart |
| 4 | import PoincareLib.Geometry.Manifold.RegularLevel.OpenInclusion |
| 5 | import Mathlib.Topology.OpenPartialHomeomorph.IsImage |
| 6 | |
| 7 | /-! # Connected lower sides of manifold scalar levels |
| 8 | |
| 9 | Regular scalar coordinates give a connected half-ball on the strict lower |
| 10 | side, dense in the weak lower side. At a strict maximum, punctured chart balls |
| 11 | give the same property in dimension at least two. |
| 12 | -/ |
| 13 | |
| 14 | noncomputable section |
| 15 | set_option autoImplicit false |
| 16 | set_option backward.isDefEq.respectTransparency false |
| 17 | |
| 18 | open Set Filter Function Metric |
| 19 | open scoped Topology ContDiff Manifold |
| 20 | |
| 21 | namespace Poincare.Geometry.Manifold |
| 22 | |
| 23 | private theorem hasConnectedLowerSide_of_scalar_chart |
| 24 | {X F : Type*} [TopologicalSpace X] [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 25 | {f : X → ℝ} {O : Set X} (hO : IsOpen O) {x : X} (hx : x ∈ O) |
| 26 | (e : OpenPartialHomeomorph X (ℝ × F)) (hxe : x ∈ e.source) |
| 27 | (hef : ∀ y ∈ e.source, (e y).1 = f y) : |
| 28 | Poincare.Topology.HasConnectedLowerSide f O (f x) x := by |
| 29 | have htarget : e.target ∩ e.symm ⁻¹' O ∈ 𝓝 (e x) := |
| 30 | (e.symm.isOpen_inter_preimage hO).mem_nhds |
| 31 | ⟨e.map_source hxe, by simpa only [mem_preimage, e.left_inv hxe] using hx⟩ |
| 32 | obtain ⟨r, hr, hball⟩ := Metric.mem_nhds_iff.mp htarget |
| 33 | have hBT : ball (e x) r ⊆ e.target := hball.trans inter_subset_left |
| 34 | let V := e.symm '' ball (e x) r |
| 35 | have hV : IsOpen V := e.isOpen_image_symm_of_subset_target isOpen_ball hBT |
| 36 | have hxV : x ∈ V := ⟨e x, mem_ball_self hr, e.left_inv hxe⟩ |
| 37 | have hVO : V ⊆ O := by rintro y ⟨z, hz, rfl⟩; exact (hball hz).2 |
| 38 | have hVe : V ⊆ e.source := by |
| 39 | rintro y ⟨z, hz, rfl⟩ |
| 40 | exact e.map_target (hBT hz) |
| 41 | let A : Set (ℝ × F) := ball (e x) r ∩ {z | z.1 < f x} |
| 42 | have hA : IsPreconnected A := |
| 43 | ((convex_ball (e x) r).inter |
| 44 | (convex_halfSpace_lt (show IsLinearMap ℝ (Prod.fst : ℝ × F → ℝ) from |
| 45 | ⟨fun _ _ => rfl, fun _ _ => rfl⟩) (f x))).isPreconnected |
| 46 | have himage : e.symm '' A = V ∩ f ⁻¹' Iio (f x) := by |
| 47 | ext y |
| 48 | constructor |
| 49 | · rintro ⟨z, hz, rfl⟩ |
| 50 | refine ⟨⟨z, hz.1, rfl⟩, ?_⟩ |
| 51 | have hval := hef (e.symm z) (e.map_target (hBT hz.1)) |
| 52 | rw [e.right_inv (hBT hz.1)] at hval |
| 53 | change f (e.symm z) < f x |
| 54 | rw [← hval] |
| 55 | exact hz.2 |
| 56 | · rintro ⟨⟨z, hz, rfl⟩, hzy⟩ |
| 57 | refine ⟨z, ⟨hz, ?_⟩, rfl⟩ |
| 58 | have hval := hef (e.symm z) (e.map_target (hBT hz)) |
| 59 | rw [e.right_inv (hBT hz)] at hval |
| 60 | change z.1 < f x |
| 61 | rw [hval] |
| 62 | exact hzy |
| 63 | have hisimage : e.IsImage (V ∩ f ⁻¹' Iio (f x)) A := by |
| 64 | intro y hy |
| 65 | constructor |
| 66 | · intro hye |
| 67 | rw [← himage] |
| 68 | exact ⟨e y, hye, e.left_inv hy⟩ |
| 69 | · intro hyv |
| 70 | rw [← himage] at hyv |
| 71 | rcases hyv with ⟨z, hz, rfl⟩ |
| 72 | rwa [e.right_inv (hBT hz.1)] |
| 73 | refine ⟨V, hV, hxV, hVO, ?_, ?_⟩ |
| 74 | · rw [← himage] |
| 75 | exact hA.image e.symm (e.symm.continuousOn.mono (inter_subset_left.trans hBT)) |
| 76 | · intro y hy |
| 77 | have hye := hVe hy.1 |
| 78 | apply (hisimage.closure.apply_mem_iff hye).mp |
| 79 | have hyball : e y ∈ ball (e x) r := by |
| 80 | rcases hy.1 with ⟨z, hz, rfl⟩ |
| 81 | simpa only [e.right_inv (hBT hz)] using hz |
| 82 | have hyhalf : e y ∈ closure ({z : ℝ × F | z.1 < f x}) := by |
| 83 | have heq : {z : ℝ × F | z.1 < f x} = Iio (f x) ×ˢ (univ : Set F) := by ext z; simp |
| 84 | rw [heq, closure_prod_eq, closure_Iio, closure_univ] |
| 85 | exact ⟨by change (e y).1 ≤ f x; rw [hef y hye]; exact hy.2, mem_univ _⟩ |
| 86 | exact isOpen_ball.inter_closure ⟨hyball, hyhalf⟩ |
| 87 | |
| 88 | /-- A regular smooth scalar has a connected local lower side inside every open |
| 89 | neighborhood of the regular point. -/ |
| 90 | theorem hasConnectedLowerSide_of_regular |
| 91 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 92 | {M : Type*} [TopologicalSpace M] [ChartedSpace E M] [IsManifold 𝓘(ℝ, E) ∞ M] |
| 93 | {f : M → ℝ} (hf : ContMDiff 𝓘(ℝ, E) 𝓘(ℝ, ℝ) ∞ f) |
| 94 | {O : Set M} (hO : IsOpen O) {x : M} (hx : x ∈ O) |
| 95 | (hreg : mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f x ≠ 0) : |
| 96 | Poincare.Topology.HasConnectedLowerSide f O (f x) x := by |
| 97 | let L : E →L[ℝ] ℝ := mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f x |
| 98 | have hsurj : Surjective (mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f x) := |
| 99 | (LinearMap.surjective_iff_ne_zero (f := L.toLinearMap)).mpr (by |
| 100 | intro heq |
| 101 | apply hreg |
| 102 | ext v |
| 103 | exact congrArg (fun A : E →ₗ[ℝ] ℝ => A v) heq) |
| 104 | obtain ⟨e, hxe, _, _, _, hef, _⟩ := |
| 105 | Poincare.Manifold.exists_manifold_superlevel_chart hf x hsurj |
| 106 | exact hasConnectedLowerSide_of_scalar_chart hO hx e hxe hef |
| 107 | |
| 108 | /-- The regular-point lower-side construction only needs smoothness on the |
| 109 | given open domain. -/ |
| 110 | theorem hasConnectedLowerSide_of_regular_on |
| 111 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [FiniteDimensional ℝ E] |
| 112 | {M : Type*} [TopologicalSpace M] [ChartedSpace E M] [IsManifold 𝓘(ℝ, E) ∞ M] |
| 113 | {f : M → ℝ} {O : Set M} (hO : IsOpen O) |
| 114 | (hf : ContMDiffOn 𝓘(ℝ, E) 𝓘(ℝ, ℝ) ∞ f O) |
| 115 | {x : M} (hx : x ∈ O) (hreg : mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) f x ≠ 0) : |
| 116 | Poincare.Topology.HasConnectedLowerSide f O (f x) x := by |
| 117 | let U : TopologicalSpace.Opens M := ⟨O, hO⟩ |
| 118 | let xU : U := ⟨x, hx⟩ |
| 119 | have hfU : ContMDiff 𝓘(ℝ, E) 𝓘(ℝ, ℝ) ∞ (fun y : U => f y) := |
| 120 | fun y => (hf.contMDiffAt (hO.mem_nhds y.2)).comp y (contMDiff_subtype_val y) |
| 121 | have hregU : mfderiv 𝓘(ℝ, E) 𝓘(ℝ, ℝ) (fun y : U => f y) xU ≠ 0 := by |
| 122 | rw [RegularLevel.mfderiv_opens_restrict U f |
| 123 | ((hf.contMDiffAt (hO.mem_nhds hx)).mdifferentiableAt (by simp))] |
| 124 | exact hreg |
| 125 | obtain ⟨V, hV, hxV, _, hconn, hdense⟩ := |
| 126 | hasConnectedLowerSide_of_regular hfU isOpen_univ (mem_univ xU) hregU |
| 127 | let W : Set M := Subtype.val '' V |
| 128 | have himage (s : Set ℝ) : |
| 129 | Subtype.val '' (V ∩ (fun y : U => f y) ⁻¹' s) = W ∩ f ⁻¹' s := by |
| 130 | ext y |
| 131 | constructor |
| 132 | · rintro ⟨z, ⟨hz, hzf⟩, rfl⟩ |
| 133 | exact ⟨⟨z, hz, rfl⟩, hzf⟩ |
| 134 | · rintro ⟨⟨z, hz, rfl⟩, hzf⟩ |
| 135 | exact ⟨z, ⟨hz, hzf⟩, rfl⟩ |
| 136 | refine ⟨W, hO.isOpenEmbedding_subtypeVal.isOpenMap V hV, ⟨xU, hxV, rfl⟩, |
| 137 | ?_, ?_, ?_⟩ |
| 138 | · rintro y ⟨z, _, rfl⟩ |
| 139 | exact z.2 |
| 140 | · rw [← himage] |
| 141 | exact hconn.image Subtype.val continuous_subtype_val.continuousOn |
| 142 | · intro y hy |
| 143 | rw [← himage (Iic (f x))] at hy |
| 144 | rcases hy with ⟨z, hz, rfl⟩ |
| 145 | rw [← himage (Iio (f x))] |
| 146 | exact image_closure_subset_closure_image continuous_subtype_val ⟨z, hdense hz, rfl⟩ |
| 147 | |
| 148 | /-- In dimension at least two, a strict maximum has a connected lower side: |
| 149 | it is a punctured chart ball, dense in the whole chart ball. -/ |
| 150 | theorem hasConnectedLowerSide_of_strict_maximum |
| 151 | {n : ℕ} {M : Type*} [TopologicalSpace M] |
| 152 | [ChartedSpace (EuclideanSpace ℝ (Fin (n + 2))) M] |
| 153 | {f : M → ℝ} {O : Set M} (hO : IsOpen O) {x : M} (hx : x ∈ O) |
| 154 | (hmax : ∀ᶠ y in 𝓝 x, y ≠ x → f y < f x) : |
| 155 | Poincare.Topology.HasConnectedLowerSide f O (f x) x := by |
| 156 | obtain ⟨W, hWsub, hW, hxW⟩ := mem_nhds_iff.mp (inter_mem (hO.mem_nhds hx) hmax) |
| 157 | let e := chartAt (EuclideanSpace ℝ (Fin (n + 2))) x |
| 158 | have hxe : x ∈ e.source := mem_chart_source _ x |
| 159 | obtain ⟨r, hr, hball⟩ := Metric.mem_nhds_iff.mp |
| 160 | ((e.symm.isOpen_inter_preimage hW).mem_nhds |
| 161 | ⟨e.map_source hxe, by simpa only [mem_preimage, e.left_inv hxe] using hxW⟩) |
| 162 | have hBT : ball (e x) r ⊆ e.target := hball.trans inter_subset_left |
| 163 | let V := e.symm '' ball (e x) r |
| 164 | have hV : IsOpen V := e.isOpen_image_symm_of_subset_target isOpen_ball hBT |
| 165 | have hVW : V ⊆ W := by rintro y ⟨z, hz, rfl⟩; exact (hball hz).2 |
| 166 | have heq : V ∩ f ⁻¹' Iio (f x) = V \ {x} := by |
| 167 | ext y |
| 168 | constructor |
| 169 | · rintro ⟨hyV, hyf⟩ |
| 170 | exact ⟨hyV, fun hyx => (lt_irrefl (f x)) (mem_singleton_iff.mp hyx ▸ hyf)⟩ |
| 171 | · rintro ⟨hyV, hyx⟩ |
| 172 | exact ⟨hyV, (hWsub (hVW hyV)).2 (by simpa only [mem_singleton_iff] using hyx)⟩ |
| 173 | refine ⟨V, hV, ⟨e x, mem_ball_self hr, e.left_inv hxe⟩, |
| 174 | fun y hy => (hWsub (hVW hy)).1, ?_, ?_⟩ |
| 175 | · rw [heq] |
| 176 | exact (Poincare.Topology.Manifold.isPathConnected_chart_ball_sdiff_countable |
| 177 | x hr hBT (countable_singleton x)).isConnected.isPreconnected |
| 178 | · intro y hy |
| 179 | rw [heq] |
| 180 | exact (Poincare.Topology.Manifold.dense_compl_countable (n := n) |
| 181 | (countable_singleton x)).open_subset_closure_inter hV hy.1 |
| 182 | |
| 183 | end Poincare.Geometry.Manifold |