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.CurveShortening.Comparison.PolygonApproximation.Interpolator.LocalLipschitz |
| 2 | |
| 3 | /-! |
| 4 | Actual vertical derivative and speed bounds for the geodesic interpolation between a curve and |
| 5 | its polygonal approximation. |
| 6 | |
| 7 | Morgan--Tian context: Section 19.4, Definition 19.18 and Claims 19.19-19.22, printed pp. |
| 8 | 450-453. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | set_option backward.isDefEq.respectTransparency false |
| 13 | |
| 14 | open Set Filter MeasureTheory Bundle |
| 15 | open scoped Manifold ContDiff Topology Bundle ENNReal NNReal |
| 16 | |
| 17 | universe u |
| 18 | |
| 19 | namespace PoincareMT |
| 20 | |
| 21 | variable {M : Type u} [TopologicalSpace M] [T2Space M] |
| 22 | [ChartedSpace (EuclideanSpace ℝ (Fin 3)) M] |
| 23 | [IsManifold (𝓡 3) ∞ M] |
| 24 | |
| 25 | /-- The first coordinate derivative vanishes on the vertical basis vector. Source: Auxiliary |
| 26 | step for MT Definition 19.18 and Claims 19.19/19.22, pp. 450-453; project construction in |
| 27 | `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 28 | theorem m64_loopPlane_vertical_basis_zero (x : LoopPlane) : |
| 29 | mfderiv (𝓡 2) 𝓘(ℝ, ℝ) (fun p : LoopPlane => p 0) x |
| 30 | (EuclideanSpace.basisFun (Fin 2) ℝ 1) = 0 := by |
| 31 | rw [mfderiv_eq_fderiv] |
| 32 | have hderiv : fderiv ℝ (fun y : LoopPlane => y 0) x = |
| 33 | (EuclideanSpace.proj 0 : LoopPlane →L[ℝ] ℝ) := |
| 34 | (show LoopPlane →L[ℝ] ℝ from EuclideanSpace.proj 0).fderiv |
| 35 | rw [hderiv] |
| 36 | change (EuclideanSpace.basisFun (Fin 2) ℝ 1) 0 = 0 |
| 37 | simp [EuclideanSpace.basisFun_apply] |
| 38 | |
| 39 | /-- The second coordinate derivative equals one on the vertical basis vector. Source: |
| 40 | Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. 450-453; project |
| 41 | construction in `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 42 | theorem m64_loopPlane_horizontal_basis_one (x : LoopPlane) : |
| 43 | mfderiv (𝓡 2) 𝓘(ℝ, ℝ) (fun p : LoopPlane => p 1) x |
| 44 | (EuclideanSpace.basisFun (Fin 2) ℝ 1) = 1 := by |
| 45 | rw [mfderiv_eq_fderiv] |
| 46 | have hderiv : fderiv ℝ (fun y : LoopPlane => y 1) x = |
| 47 | (EuclideanSpace.proj 1 : LoopPlane →L[ℝ] ℝ) := |
| 48 | (show LoopPlane →L[ℝ] ℝ from EuclideanSpace.proj 1).fderiv |
| 49 | rw [hderiv] |
| 50 | change (EuclideanSpace.basisFun (Fin 2) ℝ 1) 1 = 1 |
| 51 | simp [EuclideanSpace.basisFun_apply] |
| 52 | |
| 53 | omit [T2Space M] in |
| 54 | /-- The vertical rectangle derivative is the actual constant-speed interpolation derivative. |
| 55 | Source: Auxiliary step for MT Definition 19.18 and Claims 19.19/19.22, pp. 450-453; project |
| 56 | construction in `proof-work/tasks/M64/reports/2026-09-23-static-polygon.md`. -/ |
| 57 | theorem m64_interpolator_vertical_column_of_speed |
| 58 | {g : RiemannianMetric 3 M} {D : LeviCivitaData g} |
| 59 | {N : ℕ} (polygon : M63GeodesicPolygon g D N) |
| 60 | {gamma : ℝ → M} {U : Set (M × M)} {H : ℝ × (M × M) → M} |
| 61 | (hU : IsOpen U) |
| 62 | (hH : ContMDiffOn |
| 63 | ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) (𝓡 3) ∞ H |
| 64 | (Ioo (-1 : ℝ) 2 ×ˢ U)) |
| 65 | (hgamma : ContMDiffOn 𝓘(ℝ, ℝ) (𝓡 3) 1 gamma Set.univ) |
| 66 | (hpair : ∀ j : Fin N, ∀ p ∈ m64PolygonCellSet j, |
| 67 | (gamma (p 0), (polygon.side j).map |
| 68 | (p 0 - m63CellLeft N j)) ∈ U) |
| 69 | (j : Fin N) {x : LoopPlane} (hx : x ∈ m64PolygonCellSet j) |
| 70 | {r : ℝ} |
| 71 | (hpq : g.edist (gamma (x 0)) ((polygon.side j).map |
| 72 | (x 0 - m63CellLeft N j)) < ENNReal.ofReal r) |
| 73 | (hgeom : g.edist (gamma (x 0)) ((polygon.side j).map |
| 74 | (x 0 - m63CellLeft N j)) < ENNReal.ofReal r → |
| 75 | H (0, gamma (x 0), (polygon.side j).map (x 0 - m63CellLeft N j)) = |
| 76 | gamma (x 0) ∧ |
| 77 | H (1, gamma (x 0), (polygon.side j).map (x 0 - m63CellLeft N j)) = |
| 78 | (polygon.side j).map (x 0 - m63CellLeft N j) ∧ |
| 79 | g.IsGeodesicOn |
| 80 | (fun t => H (t, gamma (x 0), |
| 81 | (polygon.side j).map (x 0 - m63CellLeft N j))) |
| 82 | (Ioo (-1 : ℝ) 2) ∧ |
| 83 | (∀ t ∈ Ioo (-1 : ℝ) 2, |
| 84 | g.tangentNorm |
| 85 | (H (t, gamma (x 0), (polygon.side j).map |
| 86 | (x 0 - m63CellLeft N j))) |
| 87 | (mfderiv 𝓘(ℝ, ℝ) (𝓡 3) |
| 88 | (fun s => H (s, gamma (x 0), |
| 89 | (polygon.side j).map (x 0 - m63CellLeft N j))) t 1) = |
| 90 | (g.edist (gamma (x 0)) |
| 91 | ((polygon.side j).map (x 0 - m63CellLeft N j))).toReal) ∧ |
| 92 | g.pathELength |
| 93 | (fun t => H (t, gamma (x 0), |
| 94 | (polygon.side j).map (x 0 - m63CellLeft N j))) 0 1 = |
| 95 | g.edist (gamma (x 0)) ((polygon.side j).map |
| 96 | (x 0 - m63CellLeft N j))) : |
| 97 | g.tangentNorm |
| 98 | (H (x 1, gamma (x 0), (polygon.side j).map |
| 99 | (x 0 - m63CellLeft N j))) |
| 100 | (mfderiv (𝓡 2) (𝓡 3) |
| 101 | (fun p : LoopPlane => H (p 1, gamma (p 0), |
| 102 | (polygon.side j).map (p 0 - m63CellLeft N j))) x |
| 103 | (EuclideanSpace.basisFun (Fin 2) ℝ 1)) = |
| 104 | (g.edist (gamma (x 0)) ((polygon.side j).map |
| 105 | (x 0 - m63CellLeft N j))).toReal := by |
| 106 | change m63CellLeft N j ≤ x 0 ∧ |
| 107 | x 0 ≤ m63CellLeft N j + m63CellLength N ∧ |
| 108 | 0 ≤ x 1 ∧ x 1 ≤ 1 at hx |
| 109 | have htime : x 1 ∈ Ioo (-1 : ℝ) 2 := by |
| 110 | constructor <;> linarith [hx.2.2.1, hx.2.2.2] |
| 111 | have hleft : x 0 - m63CellLeft N j ∈ (polygon.side j).domain := by |
| 112 | apply (polygon.side j).interval_subset |
| 113 | constructor <;> linarith [hx.1, hx.2.1] |
| 114 | have hpairx : (gamma (x 0), (polygon.side j).map |
| 115 | (x 0 - m63CellLeft N j)) ∈ U := hpair j x ⟨hx.1, hx.2.1, hx.2.2.1, hx.2.2.2⟩ |
| 116 | have hp0 : MDifferentiableAt (𝓡 2) 𝓘(ℝ, ℝ) |
| 117 | (fun p : LoopPlane => p 0) x := |
| 118 | (PiLp.proj (𝕜 := ℝ) 2 (fun _ : Fin 2 => ℝ) 0).contDiff |
| 119 | (n := ∞) |>.of_le (m := 1) (by norm_num) |>.contMDiff.contMDiffAt |
| 120 | |>.mdifferentiableAt (by simp) |
| 121 | have hp1 : MDifferentiableAt (𝓡 2) 𝓘(ℝ, ℝ) |
| 122 | (fun p : LoopPlane => p 1) x := |
| 123 | (PiLp.proj (𝕜 := ℝ) 2 (fun _ : Fin 2 => ℝ) 1).contDiff |
| 124 | (n := ∞) |>.of_le (m := 1) (by norm_num) |>.contMDiff.contMDiffAt |
| 125 | |>.mdifferentiableAt (by simp) |
| 126 | let phi : LoopPlane → ℝ := fun p => p 0 - m63CellLeft N j |
| 127 | have hphi : MDifferentiableAt (𝓡 2) 𝓘(ℝ, ℝ) phi x := by |
| 128 | have hp0top : ContMDiffAt (𝓡 2) 𝓘(ℝ, ℝ) ∞ |
| 129 | (fun p : LoopPlane => p 0) x := by |
| 130 | exact (PiLp.proj (𝕜 := ℝ) 2 (fun _ : Fin 2 => ℝ) 0).contDiff |
| 131 | (n := ∞) |>.contMDiff.contMDiffAt |
| 132 | have hc := hp0top.add (contMDiffAt_const (x := x) |
| 133 | (c := -(m63CellLeft N j))) |
| 134 | have hc1 := hc.of_le (m := 1) (by norm_num) |
| 135 | have hcmd : ContMDiffAt (𝓡 2) 𝓘(ℝ, ℝ) 1 |
| 136 | (fun p : LoopPlane => p 0 + -(m63CellLeft N j)) x := by |
| 137 | convert hc1 using 1 |
| 138 | rfl |
| 139 | simpa only [phi, sub_eq_add_neg] using hcmd.mdifferentiableAt (by simp) |
| 140 | have hgammaAt : MDifferentiableAt 𝓘(ℝ, ℝ) (𝓡 3) gamma (x 0) := |
| 141 | (hgamma.contMDiffAt (isOpen_univ.mem_nhds (mem_univ _))).mdifferentiableAt |
| 142 | (by simp) |
| 143 | have hsideAt : MDifferentiableAt 𝓘(ℝ, ℝ) (𝓡 3) |
| 144 | (polygon.side j).map (x 0 - m63CellLeft N j) := |
| 145 | (polygon.side j).smooth.contMDiffAt |
| 146 | ((polygon.side j).domain_open.mem_nhds hleft) |>.mdifferentiableAt |
| 147 | (by simp) |
| 148 | let input : LoopPlane → ℝ × (M × M) := fun p => |
| 149 | (p 1, (gamma (p 0), (polygon.side j).map (phi p))) |
| 150 | have hinput : MDifferentiableAt (𝓡 2) |
| 151 | ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) input x := by |
| 152 | exact hp1.prodMk ((hgammaAt.comp x hp0).prodMk |
| 153 | (hsideAt.comp x hphi)) |
| 154 | have hpoint : (x 1, (gamma (x 0), (polygon.side j).map |
| 155 | (x 0 - m63CellLeft N j))) ∈ Ioo (-1 : ℝ) 2 ×ˢ U := |
| 156 | ⟨htime, hpairx⟩ |
| 157 | have hHat : MDifferentiableAt |
| 158 | ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) (𝓡 3) H |
| 159 | (x 1, (gamma (x 0), (polygon.side j).map |
| 160 | (x 0 - m63CellLeft N j))) := |
| 161 | (hH.contMDiffAt ((isOpen_Ioo.prod hU).mem_nhds hpoint)).mdifferentiableAt |
| 162 | (by simp) |
| 163 | let b : TangentSpace (𝓡 2) x := EuclideanSpace.basisFun (Fin 2) ℝ 1 |
| 164 | have hchain := mfderiv_comp_apply x hHat hinput b |
| 165 | have hb0 : mfderiv (𝓡 2) 𝓘(ℝ, ℝ) |
| 166 | (fun p : LoopPlane => p 0) x b = 0 := by |
| 167 | exact m64_loopPlane_vertical_basis_zero x |
| 168 | have hb1 : mfderiv (𝓡 2) 𝓘(ℝ, ℝ) |
| 169 | (fun p : LoopPlane => p 1) x b = 1 := by |
| 170 | exact m64_loopPlane_horizontal_basis_one x |
| 171 | have hgamma_b : mfderiv (𝓡 2) (𝓡 3) |
| 172 | (fun p : LoopPlane => gamma (p 0)) x b = 0 := by |
| 173 | have hc := mfderiv_comp_apply x hgammaAt hp0 b |
| 174 | rw [hb0] at hc |
| 175 | simpa only [Function.comp_def, map_zero] using hc |
| 176 | have hside_b : mfderiv (𝓡 2) (𝓡 3) |
| 177 | (fun p : LoopPlane => (polygon.side j).map (phi p)) x b = 0 := by |
| 178 | have hc := mfderiv_comp_apply x hsideAt hphi b |
| 179 | rw [show mfderiv (𝓡 2) 𝓘(ℝ, ℝ) phi x b = 0 by |
| 180 | dsimp only [phi] |
| 181 | rw [mfderiv_eq_fderiv, fderiv_sub_const] |
| 182 | have hproj : fderiv ℝ (fun p : LoopPlane => p 0) x = |
| 183 | (EuclideanSpace.proj 0 : LoopPlane →L[ℝ] ℝ) := |
| 184 | (show LoopPlane →L[ℝ] ℝ from EuclideanSpace.proj 0).fderiv |
| 185 | rw [hproj] |
| 186 | change (EuclideanSpace.basisFun (Fin 2) ℝ 1) 0 = 0 |
| 187 | simp [EuclideanSpace.basisFun_apply]] at hc |
| 188 | simpa only [Function.comp_def, map_zero] using hc |
| 189 | have hbinput : mfderiv (𝓡 2) |
| 190 | ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) |
| 191 | (fun p : LoopPlane => (p 1, (gamma (p 0), |
| 192 | (polygon.side j).map (phi p)))) x b = (1, (0, 0)) := by |
| 193 | have hprod := mfderiv_prodMk hp1 |
| 194 | ((hgammaAt.comp x hp0).prodMk (hsideAt.comp x hphi)) |
| 195 | have hev := congrArg (fun L => L b) hprod |
| 196 | erw [mfderiv_prodMk (hgammaAt.comp x hp0) (hsideAt.comp x hphi)] at hev |
| 197 | change _ = ((mfderiv (𝓡 2) 𝓘(ℝ, ℝ) (fun p : LoopPlane => p 1) x) b, |
| 198 | ((mfderiv (𝓡 2) (𝓡 3) (fun p : LoopPlane => gamma (p 0)) x) b, |
| 199 | (mfderiv (𝓡 2) (𝓡 3) |
| 200 | (fun p : LoopPlane => (polygon.side j).map (phi p)) x) b)) at hev |
| 201 | simpa only [Function.comp_def, hb1, hgamma_b, hside_b] using hev |
| 202 | let v : TangentSpace ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) |
| 203 | (x 1, (gamma (x 0), (polygon.side j).map |
| 204 | (x 0 - m63CellLeft N j))) := (1, (0, 0)) |
| 205 | have hchain' : mfderiv (𝓡 2) (𝓡 3) |
| 206 | (fun p : LoopPlane => H (p 1, gamma (p 0), |
| 207 | (polygon.side j).map (p 0 - m63CellLeft N j))) x b = |
| 208 | mfderiv ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) (𝓡 3) H |
| 209 | (x 1, (gamma (x 0), (polygon.side j).map |
| 210 | (x 0 - m63CellLeft N j))) v := by |
| 211 | have hbeq : mfderiv (𝓡 2) |
| 212 | ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) input x b = v := by |
| 213 | simpa only [input] using hbinput |
| 214 | have hceq := hchain.trans (congrArg |
| 215 | (fun w => mfderiv ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) |
| 216 | (𝓡 3) H (input x) w) hbeq) |
| 217 | simpa only [Function.comp_def, input] using hceq |
| 218 | let time : ℝ → ℝ × (M × M) := fun t => |
| 219 | (t, (gamma (x 0), (polygon.side j).map (x 0 - m63CellLeft N j))) |
| 220 | have htimeInput : MDifferentiableAt 𝓘(ℝ, ℝ) |
| 221 | ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) time (x 1) := by |
| 222 | exact mdifferentiableAt_id.prodMk |
| 223 | (mdifferentiableAt_const.prodMk mdifferentiableAt_const) |
| 224 | have htimeChain := mfderiv_comp_apply (x 1) hHat htimeInput (1 : ℝ) |
| 225 | erw [mfderiv_prodMk mdifferentiableAt_id |
| 226 | (mdifferentiableAt_const.prodMk mdifferentiableAt_const), |
| 227 | mfderiv_prodMk mdifferentiableAt_const mdifferentiableAt_const] at htimeChain |
| 228 | simp only [mfderiv_const, mfderiv_id] at htimeChain |
| 229 | erw [ContinuousLinearMap.prod_apply, ContinuousLinearMap.prod_apply] at htimeChain |
| 230 | have htimeChain' : mfderiv 𝓘(ℝ, ℝ) (𝓡 3) |
| 231 | (fun t : ℝ => H (t, gamma (x 0), (polygon.side j).map |
| 232 | (x 0 - m63CellLeft N j))) (x 1) 1 = |
| 233 | mfderiv ((𝓘(ℝ, ℝ)).prod ((𝓡 3).prod (𝓡 3))) (𝓡 3) H |
| 234 | (x 1, (gamma (x 0), (polygon.side j).map |
| 235 | (x 0 - m63CellLeft N j))) v := by |
| 236 | simpa [Function.comp_def, time, v] using htimeChain |
| 237 | change g.tangentNorm |
| 238 | (H (x 1, gamma (x 0), (polygon.side j).map |
| 239 | (x 0 - m63CellLeft N j))) |
| 240 | (mfderiv (𝓡 2) (𝓡 3) |
| 241 | (fun p : LoopPlane => H (p 1, gamma (p 0), |
| 242 | (polygon.side j).map (p 0 - m63CellLeft N j))) x b) = _ |
| 243 | rw [hchain', ← htimeChain'] |
| 244 | exact (hgeom hpq).2.2.2.1 (x 1) htime |
| 245 | |
| 246 | end PoincareMT |