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.RicciFlow.Generalized.BoundedDistance.GeometryImports |
| 2 | import PoincareLib.Geometry.RicciFlow.Generalized.BoundedDistance.Predecessors.Analysis.Geometry.FiberwiseDiffeomorph |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Comp |
| 4 | import Mathlib.Topology.Order.IntermediateValue |
| 5 | import Mathlib.Topology.OpenPartialHomeomorph.Composition |
| 6 | |
| 7 | /-! |
| 8 | # Relative extensions of positively oriented fibre maps |
| 9 | |
| 10 | A scalar clamp extends a smooth positive transition on an open strip to |
| 11 | an actual global diffeomorphism with exact agreement on a closed retained |
| 12 | band and affine tails. The scalar fibre inverse theorem supplies the |
| 13 | jointly smooth inverse. This is the gluing engine for Morgan--Tian A.13, |
| 14 | p. 505, and A.19, p. 507; see section 5 of the reviewed derivation |
| 15 | `tasks/M25/case-local/relative-fiberwise-extension-plan.md`. |
| 16 | -/ |
| 17 | |
| 18 | set_option autoImplicit false |
| 19 | |
| 20 | open Set Filter Function |
| 21 | open scoped Manifold ContDiff Topology |
| 22 | |
| 23 | universe u v w |
| 24 | |
| 25 | namespace Diffeomorph |
| 26 | |
| 27 | variable {E : Type u} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 28 | [CompleteSpace E] |
| 29 | {H : Type v} [TopologicalSpace H] |
| 30 | {I : ModelWithCorners ℝ E H} [I.Boundaryless] |
| 31 | {K : Type w} [TopologicalSpace K] [ChartedSpace H K] |
| 32 | [IsManifold I ∞ K] |
| 33 | |
| 34 | /-- A positive real-fibre transition on an open strip extends to an |
| 35 | actual global diffeomorphism, retaining the closed inner band and both |
| 36 | literal affine tails. MT A.13/A.19, pp. 505/507; section 5 of the reviewed |
| 37 | relative-fibrewise-extension derivation. -/ |
| 38 | theorem exists_relative_fiberwise_extension |
| 39 | (A : Diffeomorph I I K K ∞) (h : K × ℝ → ℝ) |
| 40 | {a₀ a b b₀ : ℝ} (hleft : a₀ < a) (hab : a < b) (hright : b < b₀) |
| 41 | (hh : ContMDiffOn (I.prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ h |
| 42 | (univ ×ˢ Ioo a₀ b₀)) |
| 43 | (hhpos : ∀ q : K, ∀ s ∈ Ioo a₀ b₀, |
| 44 | 0 < deriv (fun r : ℝ => h (q, r)) s) |
| 45 | (rho : ℝ → ℝ) (hrho : ContDiff ℝ ∞ rho) |
| 46 | (hrange : ∀ s : ℝ, rho s ∈ Ioo a₀ b₀) |
| 47 | (hagree : EqOn rho id (Icc a b)) |
| 48 | (hrhoderiv : ∀ s : ℝ, deriv rho s ∈ Icc 0 1) |
| 49 | (hrholeft : ∀ s : ℝ, s ≤ a₀ → rho s = rho a₀) |
| 50 | (hrhoright : ∀ s : ℝ, b₀ ≤ s → rho s = rho b₀) : |
| 51 | let F : K × ℝ → ℝ := fun z => h (z.1, rho z.2) + z.2 - rho z.2 |
| 52 | let cminus : K → ℝ := fun q => h (q, rho a₀) - rho a₀ |
| 53 | let cplus : K → ℝ := fun q => h (q, rho b₀) - rho b₀ |
| 54 | let V : Set (K × ℝ) := {z | |
| 55 | h (A.symm z.1, a) < z.2 ∧ z.2 < h (A.symm z.1, b)} |
| 56 | ∃ D : Diffeomorph (I.prod 𝓘(ℝ, ℝ)) (I.prod 𝓘(ℝ, ℝ)) |
| 57 | (K × ℝ) (K × ℝ) ∞, |
| 58 | (∀ z : K × ℝ, D z = (A z.1, F z)) ∧ |
| 59 | (∀ z : K × ℝ, |
| 60 | (D.symm z).1 = A.symm z.1 ∧ F (D.symm z) = z.2) ∧ |
| 61 | (∀ q : K, ∀ s : ℝ, 0 < deriv (fun r : ℝ => F (q, r)) s) ∧ |
| 62 | (∀ z : K × ℝ, z.2 ∈ Icc a b → |
| 63 | D z = (A z.1, h z) ∧ D.symm (A z.1, h z) = z) ∧ |
| 64 | (∀ q : K, ∀ s : ℝ, s ≤ a₀ → D (q, s) = (A q, s + cminus q)) ∧ |
| 65 | (∀ q : K, ∀ s : ℝ, b₀ ≤ s → D (q, s) = (A q, s + cplus q)) ∧ |
| 66 | (∀ z : K × ℝ, z.2 ≤ a₀ + cminus (A.symm z.1) → |
| 67 | D.symm z = (A.symm z.1, z.2 - cminus (A.symm z.1))) ∧ |
| 68 | (∀ z : K × ℝ, b₀ + cplus (A.symm z.1) ≤ z.2 → |
| 69 | D.symm z = (A.symm z.1, z.2 - cplus (A.symm z.1))) ∧ |
| 70 | D '' (univ ×ˢ Ioo a b) = V ∧ |
| 71 | (∀ z ∈ V, (D.symm z).2 ∈ Ioo a b ∧ h (D.symm z) = z.2) ∧ |
| 72 | let T := D.toHomeomorph.toOpenPartialHomeomorph.restr (univ ×ˢ Ioo a b) |
| 73 | T.source = univ ×ˢ Ioo a b ∧ T.target = V := by |
| 74 | classical |
| 75 | dsimp only |
| 76 | let F : K × ℝ → ℝ := fun z => h (z.1, rho z.2) + z.2 - rho z.2 |
| 77 | let cminus : K → ℝ := fun q => h (q, rho a₀) - rho a₀ |
| 78 | let cplus : K → ℝ := fun q => h (q, rho b₀) - rho b₀ |
| 79 | let V : Set (K × ℝ) := {z | |
| 80 | h (A.symm z.1, a) < z.2 ∧ z.2 < h (A.symm z.1, b)} |
| 81 | have hrhosmooth : ContMDiff (I.prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ |
| 82 | (fun z : K × ℝ => rho z.2) := |
| 83 | hrho.comp_contMDiff contMDiff_snd |
| 84 | have hclamp : ContMDiff (I.prod 𝓘(ℝ, ℝ)) (I.prod 𝓘(ℝ, ℝ)) ∞ |
| 85 | (fun z : K × ℝ => (z.1, rho z.2)) := |
| 86 | contMDiff_fst.prodMk hrhosmooth |
| 87 | have hhclamp : ContMDiff (I.prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ |
| 88 | (fun z : K × ℝ => h (z.1, rho z.2)) := |
| 89 | hh.comp_contMDiff hclamp (fun z => ⟨mem_univ _, hrange z.2⟩) |
| 90 | have hcombine : ContDiff ℝ ∞ |
| 91 | (fun x : ℝ × (ℝ × ℝ) => x.1 + x.2.1 - x.2.2) := |
| 92 | (contDiff_fst.add (contDiff_fst.comp contDiff_snd)).sub |
| 93 | (contDiff_snd.comp contDiff_snd) |
| 94 | have hF : ContMDiff (I.prod 𝓘(ℝ, ℝ)) 𝓘(ℝ, ℝ) ∞ F := |
| 95 | hcombine.comp_contMDiff |
| 96 | (hhclamp.prodMk_space (contMDiff_snd.prodMk_space hrhosmooth)) |
| 97 | have hderiv (q : K) (s : ℝ) : |
| 98 | deriv (fun r : ℝ => F (q, r)) s = |
| 99 | deriv (fun r : ℝ => h (q, r)) (rho s) * deriv rho s + 1 - deriv rho s := by |
| 100 | have hhqd : DifferentiableAt ℝ (fun r : ℝ => h (q, r)) (rho s) := |
| 101 | differentiableAt_of_deriv_ne_zero (ne_of_gt (hhpos q (rho s) (hrange s))) |
| 102 | have hrhod := (hrho.differentiable (by simp) s).hasDerivAt |
| 103 | have hfder := ((hhqd.hasDerivAt.comp s hrhod).fun_add |
| 104 | (hasDerivAt_id s)).fun_sub hrhod |
| 105 | simpa only [F, Function.comp_def, id_eq] using hfder.deriv |
| 106 | have hpos (q : K) (s : ℝ) : 0 < deriv (fun r : ℝ => F (q, r)) s := by |
| 107 | rw [hderiv] |
| 108 | have hd := hhpos q (rho s) (hrange s) |
| 109 | rcases lt_or_eq_of_le (hrhoderiv s).2 with hwlt | hweq |
| 110 | · have hmul := mul_nonneg hd.le (hrhoderiv s).1 |
| 111 | linarith |
| 112 | · rw [hweq] |
| 113 | simpa using hd |
| 114 | have hFleft (q : K) (s : ℝ) (hs : s ≤ a₀) : F (q, s) = s + cminus q := by |
| 115 | dsimp only [F, cminus] |
| 116 | rw [hrholeft s hs] |
| 117 | ring |
| 118 | have hFright (q : K) (s : ℝ) (hs : b₀ ≤ s) : F (q, s) = s + cplus q := by |
| 119 | dsimp only [F, cplus] |
| 120 | rw [hrhoright s hs] |
| 121 | ring |
| 122 | have hsurj (q : K) : Function.Surjective (fun s : ℝ => F (q, s)) := by |
| 123 | intro y |
| 124 | let sm : ℝ := min a₀ (y - cminus q) - 1 |
| 125 | let sp : ℝ := max b₀ (y - cplus q) + 1 |
| 126 | have hsm : sm ≤ a₀ := by |
| 127 | dsimp only [sm] |
| 128 | linarith [min_le_left a₀ (y - cminus q)] |
| 129 | have hsp : b₀ ≤ sp := by |
| 130 | dsimp only [sp] |
| 131 | linarith [le_max_left b₀ (y - cplus q)] |
| 132 | have hsmp : sm ≤ sp := |
| 133 | hsm.trans ((hleft.trans (hab.trans hright)).le.trans hsp) |
| 134 | have hlo : F (q, sm) < y := by |
| 135 | rw [hFleft q sm hsm] |
| 136 | dsimp only [sm] |
| 137 | linarith [min_le_right a₀ (y - cminus q)] |
| 138 | have hhi : y < F (q, sp) := by |
| 139 | rw [hFright q sp hsp] |
| 140 | dsimp only [sp] |
| 141 | linarith [le_max_right b₀ (y - cplus q)] |
| 142 | have hc : Continuous (fun s : ℝ => F (q, s)) := |
| 143 | hF.continuous.comp (continuous_const.prodMk continuous_id) |
| 144 | obtain ⟨s, _hs, heq⟩ := intermediate_value_Icc hsmp hc.continuousOn ⟨hlo.le, hhi.le⟩ |
| 145 | exact ⟨s, heq⟩ |
| 146 | obtain ⟨D, hD, hDi⟩ := exists_fiberwise_of_deriv_pos A F hF hpos hsurj |
| 147 | have hmono (q : K) : StrictMono (fun s : ℝ => F (q, s)) := |
| 148 | strictMono_of_deriv_pos (hpos q) |
| 149 | have hFagree (q : K) (s : ℝ) (hs : s ∈ Icc a b) : F (q, s) = h (q, s) := by |
| 150 | dsimp only [F] |
| 151 | rw [hagree hs] |
| 152 | simp |
| 153 | have hDagree (z : K × ℝ) (hz : z.2 ∈ Icc a b) : |
| 154 | D z = (A z.1, h z) := by |
| 155 | rw [hD z] |
| 156 | exact Prod.ext rfl (hFagree z.1 z.2 hz) |
| 157 | have hDleft (q : K) (s : ℝ) (hs : s ≤ a₀) : |
| 158 | D (q, s) = (A q, s + cminus q) := by |
| 159 | rw [hD (q, s), hFleft q s hs] |
| 160 | have hDright (q : K) (s : ℝ) (hs : b₀ ≤ s) : |
| 161 | D (q, s) = (A q, s + cplus q) := by |
| 162 | rw [hD (q, s), hFright q s hs] |
| 163 | have hDileft (z : K × ℝ) (hz : z.2 ≤ a₀ + cminus (A.symm z.1)) : |
| 164 | D.symm z = (A.symm z.1, z.2 - cminus (A.symm z.1)) := by |
| 165 | apply D.injective |
| 166 | change D (D.symm z) = D (A.symm z.1, z.2 - cminus (A.symm z.1)) |
| 167 | rw [D.apply_symm_apply, hDleft (A.symm z.1) |
| 168 | (z.2 - cminus (A.symm z.1)) (by linarith)] |
| 169 | simp |
| 170 | have hDiright (z : K × ℝ) (hz : b₀ + cplus (A.symm z.1) ≤ z.2) : |
| 171 | D.symm z = (A.symm z.1, z.2 - cplus (A.symm z.1)) := by |
| 172 | apply D.injective |
| 173 | change D (D.symm z) = D (A.symm z.1, z.2 - cplus (A.symm z.1)) |
| 174 | rw [D.apply_symm_apply, hDright (A.symm z.1) |
| 175 | (z.2 - cplus (A.symm z.1)) (by linarith)] |
| 176 | simp |
| 177 | have ha : a ∈ Icc a b := ⟨le_rfl, hab.le⟩ |
| 178 | have hb : b ∈ Icc a b := ⟨hab.le, le_rfl⟩ |
| 179 | have hinverse (z : K × ℝ) (hz : z ∈ V) : |
| 180 | (D.symm z).2 ∈ Ioo a b ∧ h (D.symm z) = z.2 := by |
| 181 | change h (A.symm z.1, a) < z.2 ∧ z.2 < h (A.symm z.1, b) at hz |
| 182 | have hbase := (hDi z).1 |
| 183 | have hheight : F (A.symm z.1, (D.symm z).2) = z.2 := by |
| 184 | rw [← hbase] |
| 185 | exact (hDi z).2 |
| 186 | have hlo : a < (D.symm z).2 := by |
| 187 | by_contra hnot |
| 188 | have hle := (hmono (A.symm z.1)).monotone (le_of_not_gt hnot) |
| 189 | rw [hheight, hFagree (A.symm z.1) a ha] at hle |
| 190 | exact (not_le_of_gt hz.1) hle |
| 191 | have hhi : (D.symm z).2 < b := by |
| 192 | by_contra hnot |
| 193 | have hle := (hmono (A.symm z.1)).monotone (le_of_not_gt hnot) |
| 194 | rw [hheight, hFagree (A.symm z.1) b hb] at hle |
| 195 | exact (not_le_of_gt hz.2) hle |
| 196 | refine ⟨⟨hlo, hhi⟩, ?_⟩ |
| 197 | exact (hFagree (D.symm z).1 (D.symm z).2 ⟨hlo.le, hhi.le⟩).symm.trans (hDi z).2 |
| 198 | have himage : D '' (univ ×ˢ Ioo a b) = V := by |
| 199 | ext z |
| 200 | constructor |
| 201 | · rintro ⟨x, hx, rfl⟩ |
| 202 | change h (A.symm (D x).1, a) < (D x).2 ∧ |
| 203 | (D x).2 < h (A.symm (D x).1, b) |
| 204 | rw [hD x] |
| 205 | simp only [A.symm_apply_apply] |
| 206 | rw [← hFagree x.1 a ha, ← hFagree x.1 b hb] |
| 207 | exact ⟨hmono x.1 hx.2.1, hmono x.1 hx.2.2⟩ |
| 208 | · intro hz |
| 209 | exact ⟨D.symm z, ⟨mem_univ _, (hinverse z hz).1⟩, D.apply_symm_apply z⟩ |
| 210 | let T := D.toHomeomorph.toOpenPartialHomeomorph.restr (univ ×ˢ Ioo a b) |
| 211 | have hTsource : T.source = univ ×ˢ Ioo a b := by |
| 212 | dsimp only [T] |
| 213 | rw [D.toHomeomorph.toOpenPartialHomeomorph.restr_source' _ |
| 214 | (isOpen_univ.prod isOpen_Ioo)] |
| 215 | simp |
| 216 | have hTtarget : T.target = V := by |
| 217 | calc |
| 218 | T.target = T '' T.source := T.image_source_eq_target.symm |
| 219 | _ = D '' (univ ×ˢ Ioo a b) := by rw [hTsource]; rfl |
| 220 | _ = V := himage |
| 221 | refine ⟨D, hD, hDi, hpos, ?_, hDleft, hDright, hDileft, hDiright, |
| 222 | himage, hinverse, hTsource, hTtarget⟩ |
| 223 | intro z hz |
| 224 | refine ⟨hDagree z hz, ?_⟩ |
| 225 | rw [← hDagree z hz, D.symm_apply_apply] |
| 226 | |
| 227 | end Diffeomorph |