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.ContDiff.Comp |
| 2 | import Mathlib.Analysis.Calculus.FDeriv.Prod |
| 3 | import Mathlib.Analysis.Calculus.TangentCone.Prod |
| 4 | |
| 5 | /-! |
| 6 | # Spatial jets at time endpoints |
| 7 | |
| 8 | Joint smoothness within a time set preserves the ordinary spatial jets |
| 9 | on an open spatial domain. This supplies endpoint continuity in |
| 10 | Morgan--Tian, Lemma 16.8 and Corollary 16.9, pp. 372-373. |
| 11 | See M44 derivation 34. |
| 12 | -/ |
| 13 | |
| 14 | set_option autoImplicit false |
| 15 | |
| 16 | open Set |
| 17 | open scoped ContDiff Topology |
| 18 | |
| 19 | namespace PoincareMT.M44 |
| 20 | |
| 21 | variable {V E : Type*} [NormedAddCommGroup V] [NormedSpace ℝ V] |
| 22 | [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | |
| 24 | /-- Spatial differentiation uses the spatial restriction of the joint |
| 25 | within derivative, even at a time endpoint. Source: the fixed-coordinate |
| 26 | argument in Lemma 16.8, pp. 372-373; M44 derivation 34. -/ |
| 27 | theorem spatial_fderiv_eq_fderivWithin {f : ℝ × V → E} |
| 28 | {J : Set ℝ} {U : Set V} (hU : IsOpen U) {t : ℝ} (ht : t ∈ J) |
| 29 | {x : V} (hx : x ∈ U) (hf : DifferentiableWithinAt ℝ f (J ×ˢ U) (t, x)) : |
| 30 | fderiv ℝ (fun y => f (t, y)) x = |
| 31 | (fderivWithin ℝ f (J ×ˢ U) (t, x)).comp (ContinuousLinearMap.inr ℝ ℝ V) := by |
| 32 | have hi : HasFDerivAt (fun y : V => (t, y)) (ContinuousLinearMap.inr ℝ ℝ V) x := |
| 33 | (hasFDerivAt_const t x).prodMk (hasFDerivAt_id x) |
| 34 | exact ((hf.hasFDerivWithinAt.comp x hi.hasFDerivWithinAt |
| 35 | (fun y hy => ⟨ht, hy⟩)).hasFDerivAt (hU.mem_nhds hx)).fderiv |
| 36 | |
| 37 | /-- Ordinary spatial differentiation preserves smoothness on a product |
| 38 | with a uniquely differentiable time set. Source: Lemma 16.8, pp. 372-373; |
| 39 | M44 derivation 34. -/ |
| 40 | theorem contDiffOn_spatialFDeriv_within {f : ℝ × V → E} |
| 41 | {J : Set ℝ} {U : Set V} (hf : ContDiffOn ℝ ∞ f (J ×ˢ U)) |
| 42 | (hJ : UniqueDiffOn ℝ J) (hU : IsOpen U) : |
| 43 | ContDiffOn ℝ ∞ (fun z : ℝ × V => fderiv ℝ (fun x => f (z.1, x)) z.2) |
| 44 | (J ×ˢ U) := by |
| 45 | have hd := (hf.fderivWithin (hJ.prod hU.uniqueDiffOn) (m := ∞) (by simp)).clm_comp |
| 46 | (contDiffOn_const (c := ContinuousLinearMap.inr ℝ ℝ V)) |
| 47 | apply hd.congr |
| 48 | intro z hz |
| 49 | exact spatial_fderiv_eq_fderivWithin hU hz.1 hz.2 |
| 50 | ((hf z hz).differentiableWithinAt (by simp)) |
| 51 | |
| 52 | /-- Every ordinary spatial jet is jointly smooth through the time |
| 53 | endpoints. Source: Corollary 16.9, p. 373; M44 derivation 34. -/ |
| 54 | theorem contDiffOn_spatialJet_within {f : ℝ × V → E} |
| 55 | {J : Set ℝ} {U : Set V} (hf : ContDiffOn ℝ ∞ f (J ×ˢ U)) |
| 56 | (hJ : UniqueDiffOn ℝ J) (hU : IsOpen U) (m : ℕ) : |
| 57 | ContDiffOn ℝ ∞ (fun z : ℝ × V => iteratedFDeriv ℝ m (fun x => f (z.1, x)) z.2) |
| 58 | (J ×ˢ U) := by |
| 59 | induction m with |
| 60 | | zero => |
| 61 | let e := (continuousMultilinearCurryFin0 ℝ V E).symm.toContinuousLinearEquiv |
| 62 | exact e.toContinuousLinearMap.contDiff.comp_contDiffOn hf |
| 63 | | succ m ih => |
| 64 | let e := (continuousMultilinearCurryLeftEquiv ℝ (fun _ : Fin (m + 1) => V) E).symm |
| 65 | convert! e.toContinuousLinearEquiv.toContinuousLinearMap.contDiff.comp_contDiffOn |
| 66 | (contDiffOn_spatialFDeriv_within ih hJ hU) using 1 |
| 67 | |
| 68 | /-- Each spatial jet is smooth along its fixed time line within the |
| 69 | time set. Source: Corollary 16.9, p. 373; M44 derivation 34. -/ |
| 70 | theorem contDiffOn_spatialJet_time_within {f : ℝ × V → E} |
| 71 | {J : Set ℝ} {U : Set V} (hf : ContDiffOn ℝ ∞ f (J ×ˢ U)) |
| 72 | (hJ : UniqueDiffOn ℝ J) (hU : IsOpen U) (m : ℕ) {x : V} (hx : x ∈ U) : |
| 73 | ContDiffOn ℝ ∞ (fun t => iteratedFDeriv ℝ m (fun y => f (t, y)) x) J := |
| 74 | (contDiffOn_spatialJet_within hf hJ hU m).comp |
| 75 | (contDiffOn_id.prodMk contDiffOn_const) (fun _ ht => ⟨ht, hx⟩) |
| 76 | |
| 77 | end PoincareMT.M44 |