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.Geometry.Manifold.MFDeriv.NormedSpace |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Basic |
| 3 | |
| 4 | /-! |
| 5 | # Vector-valued differentiation along a manifold graph |
| 6 | |
| 7 | The coordinate chain rule for the pullback derivative in Morgan-Tian |
| 8 | Lemma 6.4, pp. 107-108. The base curve may only be differentiable within |
| 9 | its parameter set, including a closed endpoint. |
| 10 | -/ |
| 11 | |
| 12 | set_option autoImplicit false |
| 13 | |
| 14 | open scoped Manifold |
| 15 | |
| 16 | variable {𝕜 E H M F : Type*} [NontriviallyNormedField 𝕜] |
| 17 | [NormedAddCommGroup E] [NormedSpace 𝕜 E] |
| 18 | [TopologicalSpace H] {I : ModelWithCorners 𝕜 E H} |
| 19 | [TopologicalSpace M] [ChartedSpace H M] |
| 20 | [NormedAddCommGroup F] [NormedSpace 𝕜 F] |
| 21 | |
| 22 | -- The target tangent fibers reduce to the fixed normed vector space. |
| 23 | set_option backward.isDefEq.respectTransparency false in |
| 24 | /-- The vector-valued graph derivative splits into parameter and spatial |
| 25 | partials, with the actual within velocity; Lemma 6.4, pp. 107-108. -/ |
| 26 | theorem vector_graph_hasDerivWithinAt (f : 𝕜 × M → F) |
| 27 | {γ : 𝕜 → M} {J : Set 𝕜} {s : 𝕜} |
| 28 | (hf : MDifferentiableAt ((𝓘(𝕜, 𝕜)).prod I) (𝓘(𝕜, F)) f (s, γ s)) |
| 29 | (hγ : MDifferentiableWithinAt (𝓘(𝕜, 𝕜)) I γ J s) |
| 30 | (hJ : UniqueDiffWithinAt 𝕜 J s) : |
| 31 | HasDerivWithinAt (fun r => f (r, γ r)) |
| 32 | (deriv (fun r => f (r, γ s)) s + |
| 33 | mvfderiv I (fun p => f (s, p)) (γ s) |
| 34 | (mfderivWithin (𝓘(𝕜, 𝕜)) I γ J s (1 : 𝕜))) J s := by |
| 35 | have hgraph := mdifferentiableWithinAt_id.prodMk hγ |
| 36 | have hcomp := (hf.comp_mdifferentiableWithinAt s hgraph).differentiableWithinAt.hasDerivWithinAt |
| 37 | have h := congrArg (fun L => L (1 : 𝕜)) |
| 38 | (mfderiv_comp_mfderivWithin s hf hgraph hJ.uniqueMDiffWithinAt) |
| 39 | rw [mfderivWithin_prodMk mdifferentiableWithinAt_id hγ hJ.uniqueMDiffWithinAt, |
| 40 | mfderivWithin_id hJ.uniqueMDiffWithinAt] at h |
| 41 | change mfderivWithin (𝓘(𝕜, 𝕜)) (𝓘(𝕜, F)) (fun r => f (r, γ r)) J s (1 : 𝕜) = |
| 42 | mfderiv ((𝓘(𝕜, 𝕜)).prod I) (𝓘(𝕜, F)) f (s, γ s) |
| 43 | ((1 : 𝕜), mfderivWithin (𝓘(𝕜, 𝕜)) I γ J s (1 : 𝕜)) at h |
| 44 | erw [mfderiv_prod_eq_add_apply hf] at h |
| 45 | have hderiv (g : 𝕜 → F) : |
| 46 | mfderiv (𝓘(𝕜, 𝕜)) (𝓘(𝕜, F)) g s (1 : 𝕜) = deriv g s := by |
| 47 | have hg := congrArg (fun L : 𝕜 →L[𝕜] F => L 1) |
| 48 | (mfderiv_eq_fderiv (𝕜 := 𝕜) (f := g) (x := s)) |
| 49 | exact hg.trans fderiv_apply_one_eq_deriv |
| 50 | have hwithin (g : 𝕜 → F) : |
| 51 | mfderivWithin (𝓘(𝕜, 𝕜)) (𝓘(𝕜, F)) g J s (1 : 𝕜) = derivWithin g J s := by |
| 52 | exact congrArg (fun L : 𝕜 →L[𝕜] F => L 1) |
| 53 | (mfderivWithin_eq_fderivWithin (𝕜 := 𝕜) (f := g) (s := J) (x := s)) |
| 54 | dsimp only [Prod.fst, Prod.snd] at h |
| 55 | rw [hwithin, hderiv] at h |
| 56 | convert hcomp using 1 <;> first | rfl | exact h.symm |