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.Ramp.Analysis.Spatial.PartialDerivative |
| 2 | import PoincareLib.Geometry.CurveShortening.Ramp.LocalFlow.Ambient.CurveCoefficients |
| 3 | import PoincareLib.Geometry.CurveShortening.Ramp.LocalFlow.C2.GaugeWitnesses |
| 4 | import PoincareLib.Geometry.RicciFlow.CurveShortening.Evolution.Speed |
| 5 | import Mathlib.Analysis.Calculus.Deriv.Shift |
| 6 | |
| 7 | /-! |
| 8 | # Actual normal-label velocity |
| 9 | |
| 10 | The spatial derivative of the principal coefficient is the exact |
| 11 | speed-cubed coefficient in the normal-label equation. Its closed |
| 12 | regularity comes from actual ambient jets. MT2007 Claim 19.1, p. 437 |
| 13 | and Lemma 19.6, pp. 441-442; |
| 14 | `2026-09-22-ambient-label-velocity.md`, statements 2-3. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open Set |
| 21 | open scoped Manifold ContDiff |
| 22 | |
| 23 | universe u v |
| 24 | |
| 25 | namespace PoincareMT.M63 |
| 26 | |
| 27 | variable {n : ℕ} {M : Type u} [TopologicalSpace M] |
| 28 | [ChartedSpace (EuclideanSpace ℝ (Fin n)) M] [IsManifold (𝓡 n) ∞ M] |
| 29 | {ι : Type v} [Fintype ι] {a b : ℝ} |
| 30 | |
| 31 | local notation "W" => EuclideanSpace ℝ ι |
| 32 | |
| 33 | /-- The literal label velocity is smooth on the closed initial slab |
| 34 | and retains the spatial period. MT2007 Claim 19.1, p. 437; |
| 35 | ambient label-velocity derivation, statement 2. -/ |
| 36 | theorem ambientCurve_labelVelocity_regular (F : RicciFlow n M (Icc a b)) |
| 37 | {U : Set W} (hU : IsOpen U) {ρ : W → M} |
| 38 | (hρ : ContMDiffOn 𝓘(ℝ, W) (𝓡 n) ∞ ρ U) |
| 39 | {T L : ℝ} (hT : 0 < T) (hTb : a + T ≤ b) {q : ℝ → ℝ → W} |
| 40 | (hq : ContDiffOn ℝ ∞ (Function.uncurry q) (Icc 0 T ×ˢ univ)) |
| 41 | (hper : ∀ t ∈ Icc 0 T, Function.Periodic (q t) L) |
| 42 | (hguard : ∀ t ∈ Icc 0 T, ∀ x, q t x ∈ U ∧ |
| 43 | mfderiv 𝓘(ℝ, W) (𝓡 n) ρ (q t x) (deriv (q t) x) ≠ 0) : |
| 44 | let A := fun t x => ambientCurvePrincipal F ρ (a + t) (q t x) (deriv (q t) x) |
| 45 | let w := fun t x => deriv (A t) x / 2 |
| 46 | ContDiffOn ℝ ∞ (Function.uncurry w) (Icc 0 T ×ˢ univ) ∧ |
| 47 | ∀ t ∈ Icc 0 T, Function.Periodic (w t) L := by |
| 48 | let A := fun t x => ambientCurvePrincipal F ρ (a + t) (q t x) (deriv (q t) x) |
| 49 | have hqx := contDiffOn_spatial_deriv_of_uniqueDiffOn (uniqueDiffOn_Icc hT) |
| 50 | (m := ∞) (by simp) hq |
| 51 | have hparam : ContDiffOn ℝ ∞ (fun z : ℝ × ℝ => |
| 52 | ((a + z.1, q z.1 z.2), deriv (q z.1) z.2)) (Icc 0 T ×ˢ univ) := |
| 53 | ((contDiffOn_const.add contDiffOn_fst).prodMk hq).prodMk hqx |
| 54 | have hmap : MapsTo (fun z : ℝ × ℝ => |
| 55 | ((a + z.1, q z.1 z.2), deriv (q z.1) z.2)) (Icc 0 T ×ˢ univ) |
| 56 | {z : (ℝ × W) × W | z.1.1 ∈ Icc a b ∧ z.1.2 ∈ U ∧ |
| 57 | mfderiv 𝓘(ℝ, W) (𝓡 n) ρ z.1.2 z.2 ≠ 0} := by |
| 58 | intro z hz |
| 59 | exact ⟨⟨by linarith [hz.1.1], by linarith [hz.1.2]⟩, hguard z.1 hz.1 z.2⟩ |
| 60 | have hA : ContDiffOn ℝ ∞ (Function.uncurry A) (Icc 0 T ×ˢ univ) := |
| 61 | (ambientCurveCoefficients_contDiffOn F (e := fun _ => 0) contMDiff_const hU hρ).1.comp |
| 62 | hparam hmap |
| 63 | have hAx := contDiffOn_spatial_deriv_of_uniqueDiffOn (uniqueDiffOn_Icc hT) |
| 64 | (m := ∞) (by simp) hA |
| 65 | refine ⟨hAx.div_const 2, ?_⟩ |
| 66 | intro t ht x |
| 67 | have hqxper : Function.Periodic (deriv (q t)) L := by |
| 68 | intro y |
| 69 | rw [← deriv_comp_add_const, show (fun z => q t (z + L)) = q t from funext (hper t ht)] |
| 70 | have hAper : Function.Periodic (A t) L := by |
| 71 | intro y |
| 72 | dsimp only [A] |
| 73 | rw [hper t ht y, hqxper y] |
| 74 | change deriv (A t) (x + L) / 2 = deriv (A t) x / 2 |
| 75 | rw [← deriv_comp_add_const, show (fun y => A t (y + L)) = A t from funext hAper] |
| 76 | |
| 77 | /-- The actual principal derivative is the geometric coefficient that |
| 78 | cancels tangential velocity, for any C2 immersed projected slice. |
| 79 | MT2007 Lemma 19.6, pp. 441-442; label-velocity derivation, statement 3. -/ |
| 80 | theorem ambientCurve_labelVelocity_eq (F : RicciFlow n M (Icc a b)) |
| 81 | {U : Set W} (hU : IsOpen U) {ρ : W → M} |
| 82 | (hρ : ContMDiffOn 𝓘(ℝ, W) (𝓡 n) ∞ ρ U) (t : ℝ) |
| 83 | {f : ℝ → W} (hf : ContDiff ℝ 2 f) |
| 84 | (hguard : ∀ x, f x ∈ U ∧ mfderiv 𝓘(ℝ, W) (𝓡 n) ρ (f x) (deriv f x) ≠ 0) : |
| 85 | let c := fun y (_ : ℝ) => ρ (f y) |
| 86 | let A := fun x => ambientCurvePrincipal F ρ t (f x) (deriv f x) |
| 87 | let v := curveSpeed F c t |
| 88 | ∀ x, deriv A x / 2 = -(deriv v x / v x ^ 3) := by |
| 89 | let c := fun y (_ : ℝ) => ρ (f y) |
| 90 | let A := fun x => ambientCurvePrincipal F ρ t (f x) (deriv f x) |
| 91 | let v := curveSpeed F c t |
| 92 | change ∀ x, deriv A x / 2 = -(deriv v x / v x ^ 3) |
| 93 | have hspace : ContMDiff 𝓘(ℝ, ℝ) (𝓡 n) 2 (fun y => c y t) := |
| 94 | (hρ.of_le (ENat.natCast_le_of_coe_top_le_withTop le_rfl 2)).comp_contMDiff |
| 95 | hf.contMDiff (fun x => (hguard x).1) |
| 96 | have hvel (x : ℝ) : curveVelocity (n := n) (fun y => c y t) x = |
| 97 | mfderiv 𝓘(ℝ, W) (𝓡 n) ρ (f x) (deriv f x) := by |
| 98 | change (mfderiv 𝓘(ℝ, ℝ) (𝓡 n) (ρ ∘ f) x) 1 = _ |
| 99 | erw [mfderiv_comp x |
| 100 | ((hρ.contMDiffAt (hU.mem_nhds (hguard x).1)).mdifferentiableAt (by simp)) |
| 101 | ((hf.contMDiff x).mdifferentiableAt (by norm_num)), |
| 102 | ContinuousLinearMap.comp_apply, mfderiv_eq_fderiv] |
| 103 | rfl |
| 104 | have himm (x : ℝ) : curveVelocity (n := n) (fun y => c y t) x ≠ 0 := by |
| 105 | rw [hvel] |
| 106 | exact (hguard x).2 |
| 107 | have hv : ContDiff ℝ 1 v := speed_contDiff_of_c2 F c hspace himm |
| 108 | have hvpos (x : ℝ) : 0 < v x := Real.sqrt_pos.mpr ((F.metric t).pos _ _ (himm x)) |
| 109 | have hA : A = fun y => (v y ^ 2)⁻¹ := by |
| 110 | funext y |
| 111 | dsimp only [A, ambientCurvePrincipal] |
| 112 | rw [← hvel y] |
| 113 | exact congrArg (fun z : ℝ => z⁻¹) (M62.speed_sq F c t y).symm |
| 114 | intro x |
| 115 | have hne : v x ≠ 0 := (hvpos x).ne' |
| 116 | have hd : HasDerivAt A (-2 * deriv v x / v x ^ 3) x := by |
| 117 | rw [hA] |
| 118 | convert! (((hv.differentiable (by simp) x).hasDerivAt.pow 2).inv |
| 119 | (pow_ne_zero 2 (hvpos x).ne')) using 1 |
| 120 | simp only [Pi.pow_apply] |
| 121 | field_simp [hne] |
| 122 | ring |
| 123 | change deriv A x / 2 = -(deriv v x / v x ^ 3) |
| 124 | rw [hd.deriv] |
| 125 | ring |
| 126 | |
| 127 | end PoincareMT.M63 |