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 Mathlib.Analysis.Calculus.InverseFunctionTheorem.ContDiff |
| 2 | import Mathlib.Analysis.Normed.Ring.Units |
| 3 | |
| 4 | /-! |
| 5 | # Regular-level Straightening |
| 6 | |
| 7 | Adapted from LeeRiemannian, `LeeLib/Foundations/LevelSetStraightening.lean`. |
| 8 | See `references/geometry/lee-riemannian/` for provenance. |
| 9 | Lee, Introduction to Riemannian Manifolds, Corollary A.26 and Proposition 2.37. |
| 10 | -/ |
| 11 | |
| 12 | open Set Filter Function |
| 13 | open scoped Topology ContDiff |
| 14 | |
| 15 | noncomputable section |
| 16 | |
| 17 | namespace Poincare.Geometry.Manifold.RegularLevel |
| 18 | |
| 19 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 20 | |
| 21 | /-- The straightening perturbation of the identity: `u` is moved along the |
| 22 | fixed direction `e` by the defect of `f` from its affine approximation at |
| 23 | `u₀`. -/ |
| 24 | private def straighteningMap (f : E → ℝ) (u₀ : E) (ℓ : E →L[ℝ] ℝ) (e : E) : |
| 25 | E → E := |
| 26 | fun u => u + (f u - f u₀ - ℓ (u - u₀)) • e |
| 27 | |
| 28 | private theorem straighteningMap_apply_self (f : E → ℝ) (u₀ : E) |
| 29 | (ℓ : E →L[ℝ] ℝ) (e : E) : straighteningMap f u₀ ℓ e u₀ = u₀ := by |
| 30 | simp [straighteningMap] |
| 31 | |
| 32 | /-- The affine defect `u ↦ f u - f u₀ - ℓ (u - u₀)` has vanishing derivative |
| 33 | at `u₀` when `df_{u₀} = ℓ`. -/ |
| 34 | private theorem hasFDerivAt_straighteningCoef {f : E → ℝ} {u₀ : E} |
| 35 | {ℓ : E →L[ℝ] ℝ} (hf' : HasFDerivAt f ℓ u₀) : |
| 36 | HasFDerivAt (fun u => f u - f u₀ - ℓ (u - u₀)) (0 : E →L[ℝ] ℝ) u₀ := by |
| 37 | have h1 : HasFDerivAt (fun u : E => ℓ (u - u₀)) ℓ u₀ := by |
| 38 | simpa [map_sub] using ℓ.hasFDerivAt.sub_const (ℓ u₀) |
| 39 | have h := (hf'.sub_const (f u₀)).sub h1 |
| 40 | have hfun : ((fun u => f u - f u₀) - fun u => ℓ (u - u₀)) = |
| 41 | fun u => f u - f u₀ - ℓ (u - u₀) := by |
| 42 | ext u |
| 43 | rfl |
| 44 | rw [hfun] at h |
| 45 | exact h.congr_fderiv (sub_self ℓ) |
| 46 | |
| 47 | /-- The straightening map has derivative the **identity** at `u₀`; this is what |
| 48 | makes the inverse function theorem apply. -/ |
| 49 | private theorem hasFDerivAt_straighteningMap {f : E → ℝ} {u₀ : E} |
| 50 | {ℓ : E →L[ℝ] ℝ} (hf' : HasFDerivAt f ℓ u₀) (e : E) : |
| 51 | HasFDerivAt (straighteningMap f u₀ ℓ e) |
| 52 | ((ContinuousLinearEquiv.refl ℝ E : E ≃L[ℝ] E) : E →L[ℝ] E) u₀ := by |
| 53 | have h := (hasFDerivAt_id u₀).add |
| 54 | ((hasFDerivAt_straighteningCoef hf').smul_const e) |
| 55 | have h0 : ContinuousLinearMap.id ℝ E + (0 : E →L[ℝ] ℝ).smulRight e |
| 56 | = ((ContinuousLinearEquiv.refl ℝ E : E ≃L[ℝ] E) : E →L[ℝ] E) := by |
| 57 | ext v; simp |
| 58 | rw [← h0] |
| 59 | exact h |
| 60 | |
| 61 | private theorem contDiffOn_straighteningMap {f : E → ℝ} {s : Set E} |
| 62 | (hf : ContDiffOn ℝ ∞ f s) (u₀ : E) (ℓ : E →L[ℝ] ℝ) (e : E) : |
| 63 | ContDiffOn ℝ ∞ (straighteningMap f u₀ ℓ e) s := by |
| 64 | unfold straighteningMap |
| 65 | exact contDiffOn_id.add (((hf.sub contDiffOn_const).sub |
| 66 | ((ℓ.contDiff.comp (contDiff_id.sub contDiff_const)).contDiffOn)).smul |
| 67 | contDiffOn_const) |
| 68 | |
| 69 | /-- **Straightening a scalar function into an affine coordinate** — the |
| 70 | normed-space layer of Lee's Corollary A.26 in codimension one. |
| 71 | |
| 72 | If `f : E → ℝ` is `C^∞` on an open set `s ∋ u₀` of a Banach space and |
| 73 | `df_{u₀} = ℓ ≠ 0`, there is a local `C^∞` diffeomorphism `G` of `E` with |
| 74 | `u₀ ∈ G.source ⊆ s`, `G u₀ = u₀`, both `G` and `G⁻¹` of class `C^∞`, in whose |
| 75 | coordinates `f` is **affine**: `f (G⁻¹ v) = f u₀ + ℓ (v - u₀)` for every `v` in |
| 76 | the target. In particular `f ⁻¹' {f u₀}` corresponds under `G` to the affine |
| 77 | hyperplane slice `{v | ℓ (v - u₀) = 0}`, which is Lee's slice condition for an |
| 78 | embedded hypersurface. |
| 79 | |
| 80 | The construction is `G u = u + (f u - f u₀ - ℓ (u - u₀)) • e` with `ℓ e = 1`, |
| 81 | whose derivative at `u₀` is the identity; the inverse function theorem makes it |
| 82 | a local diffeomorphism, and the source is restricted to the open locus where |
| 83 | `dG` is invertible so that the inverse is `C^∞` on the whole target. -/ |
| 84 | theorem exists_openPartialHomeomorph_comp_symm_eq_affine [CompleteSpace E] |
| 85 | {f : E → ℝ} {s : Set E} (hs : IsOpen s) (hf : ContDiffOn ℝ ∞ f s) |
| 86 | {u₀ : E} (hu₀ : u₀ ∈ s) {ℓ : E →L[ℝ] ℝ} (hf' : HasFDerivAt f ℓ u₀) |
| 87 | (hl : ℓ ≠ 0) : |
| 88 | ∃ G : OpenPartialHomeomorph E E, G.source ⊆ s ∧ u₀ ∈ G.source ∧ |
| 89 | G u₀ = u₀ ∧ ContDiffOn ℝ ∞ G G.source ∧ |
| 90 | ContDiffOn ℝ ∞ G.symm G.target ∧ |
| 91 | ∀ v ∈ G.target, f (G.symm v) = f u₀ + ℓ (v - u₀) := by |
| 92 | classical |
| 93 | -- a direction `e` on which `ℓ` is `1` |
| 94 | obtain ⟨w, hw⟩ : ∃ w, ℓ w ≠ 0 := by |
| 95 | by_contra h |
| 96 | push Not at h |
| 97 | exact hl (ContinuousLinearMap.ext fun v => by simpa using h v) |
| 98 | set e : E := (ℓ w)⁻¹ • w with he_def |
| 99 | have he : ℓ e = 1 := by |
| 100 | rw [he_def, map_smul, smul_eq_mul, inv_mul_cancel₀ hw] |
| 101 | -- the straightening map and its regularity |
| 102 | have hg_smooth : ContDiffOn ℝ ∞ (straighteningMap f u₀ ℓ e) s := |
| 103 | contDiffOn_straighteningMap hf u₀ ℓ e |
| 104 | have hgAt : ContDiffAt ℝ ∞ (straighteningMap f u₀ ℓ e) u₀ := |
| 105 | hg_smooth.contDiffAt (hs.mem_nhds hu₀) |
| 106 | have hg' := hasFDerivAt_straighteningMap hf' e |
| 107 | have hn : (∞ : WithTop ℕ∞) ≠ 0 := by simp |
| 108 | -- the inverse function theorem produces the local diffeomorphism |
| 109 | set G₀ : OpenPartialHomeomorph E E := |
| 110 | hgAt.toOpenPartialHomeomorph (straighteningMap f u₀ ℓ e) hg' hn with hG₀_def |
| 111 | have hG₀_coe : (G₀ : E → E) = straighteningMap f u₀ ℓ e := rfl |
| 112 | have hu₀_G₀ : u₀ ∈ G₀.source := |
| 113 | hgAt.mem_toOpenPartialHomeomorph_source hg' hn |
| 114 | -- the open locus where the derivative stays invertible |
| 115 | set t : Set E := (s ∩ G₀.source) ∩ |
| 116 | (fderiv ℝ (straighteningMap f u₀ ℓ e)) ⁻¹' {L : E →L[ℝ] E | IsUnit L} |
| 117 | with ht_def |
| 118 | have ht_open : IsOpen t := by |
| 119 | apply ContinuousOn.isOpen_inter_preimage |
| 120 | · exact (hg_smooth.continuousOn_fderiv_of_isOpen hs |
| 121 | (by exact_mod_cast le_top)).mono inter_subset_left |
| 122 | · exact hs.inter G₀.open_source |
| 123 | · exact Units.isOpen |
| 124 | have ht_sub_s : t ⊆ s := fun u hu => hu.1.1 |
| 125 | have ht_sub_G₀ : t ⊆ G₀.source := fun u hu => hu.1.2 |
| 126 | have hu₀_t : u₀ ∈ t := by |
| 127 | refine ⟨⟨hu₀, hu₀_G₀⟩, ?_⟩ |
| 128 | show IsUnit (fderiv ℝ (straighteningMap f u₀ ℓ e) u₀) |
| 129 | rw [hg'.fderiv, show ((ContinuousLinearEquiv.refl ℝ E : E ≃L[ℝ] E) : |
| 130 | E →L[ℝ] E) = 1 from ContinuousLinearMap.ext fun x => by |
| 131 | simp [ContinuousLinearMap.one_def]] |
| 132 | exact isUnit_one |
| 133 | -- restrict to that locus |
| 134 | refine ⟨G₀.restrOpen t ht_open, ?_, ?_, ?_, ?_, ?_, ?_⟩ |
| 135 | · rw [OpenPartialHomeomorph.restrOpen_source] |
| 136 | exact fun u hu => ht_sub_s hu.2 |
| 137 | · rw [OpenPartialHomeomorph.restrOpen_source] |
| 138 | exact ⟨hu₀_G₀, hu₀_t⟩ |
| 139 | · exact straighteningMap_apply_self f u₀ ℓ e |
| 140 | · rw [OpenPartialHomeomorph.restrOpen_source] |
| 141 | exact hg_smooth.mono fun u hu => ht_sub_s hu.2 |
| 142 | · -- the inverse is `C^∞` on the whole target |
| 143 | intro v hv |
| 144 | set G := G₀.restrOpen t ht_open |
| 145 | have hu_src : G.symm v ∈ G.source := G.map_target hv |
| 146 | have hu_t : G.symm v ∈ t := by |
| 147 | have := hu_src |
| 148 | rw [OpenPartialHomeomorph.restrOpen_source] at this |
| 149 | exact this.2 |
| 150 | have hu_s : G.symm v ∈ s := ht_sub_s hu_t |
| 151 | have hu_unit : IsUnit (fderiv ℝ (straighteningMap f u₀ ℓ e) (G.symm v)) := |
| 152 | hu_t.2 |
| 153 | have hDg : HasFDerivAt (straighteningMap f u₀ ℓ e) |
| 154 | (fderiv ℝ (straighteningMap f u₀ ℓ e) (G.symm v)) (G.symm v) := |
| 155 | ((hg_smooth.contDiffAt (hs.mem_nhds hu_s)).differentiableAt |
| 156 | hn).hasFDerivAt |
| 157 | have hDgEquiv : HasFDerivAt (straighteningMap f u₀ ℓ e) |
| 158 | ((ContinuousLinearEquiv.ofUnit hu_unit.unit : E ≃L[ℝ] E) : |
| 159 | E →L[ℝ] E) (G.symm v) := by |
| 160 | rwa [show ((ContinuousLinearEquiv.ofUnit hu_unit.unit : E ≃L[ℝ] E) : |
| 161 | E →L[ℝ] E) = fderiv ℝ (straighteningMap f u₀ ℓ e) (G.symm v) from |
| 162 | ContinuousLinearMap.ext fun x => by |
| 163 | simp [ContinuousLinearEquiv.ofUnit, IsUnit.unit_spec]] |
| 164 | exact (G.contDiffAt_symm hv hDgEquiv |
| 165 | (hg_smooth.contDiffAt (hs.mem_nhds hu_s))).contDiffWithinAt |
| 166 | · -- `f` is affine in the straightened coordinates |
| 167 | intro v hv |
| 168 | set G := G₀.restrOpen t ht_open |
| 169 | have hgv : straighteningMap f u₀ ℓ e (G.symm v) = v := G.right_inv hv |
| 170 | have h := congrArg ℓ hgv |
| 171 | simp only [straighteningMap, map_add, map_smul, smul_eq_mul, map_sub, |
| 172 | he, mul_one] at h |
| 173 | rw [map_sub] |
| 174 | linarith |
| 175 | |
| 176 | end Poincare.Geometry.Manifold.RegularLevel |
| 177 | |
| 178 | end |
| 179 |