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.Operations |
| 2 | import Mathlib.Analysis.Calculus.IteratedDeriv.Defs |
| 3 | |
| 4 | /-! |
| 5 | # Spatial derivatives with an arbitrary boundary parameter set |
| 6 | |
| 7 | On a product with an open spatial set, taking spatial derivatives |
| 8 | preserves joint within-smoothness, even if the parameter set has a |
| 9 | boundary. This is the endpoint calculus needed for the fixed-chart |
| 10 | limit in Morgan-Tian Theorem 12.5, p. 297; see fixed-chart-endpoint.md. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set Filter |
| 16 | open scoped ContDiff Topology |
| 17 | |
| 18 | variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] |
| 19 | {E F G : Type*} [NormedAddCommGroup E] [NormedSpace 𝕜 E] |
| 20 | [NormedAddCommGroup F] [NormedSpace 𝕜 F] [NormedAddCommGroup G] [NormedSpace 𝕜 G] |
| 21 | |
| 22 | /-- Spatial differentiation preserves smoothness with arbitrary parameter |
| 23 | set and open spatial set (Theorem 12.5, p. 297, endpoint calculus). -/ |
| 24 | theorem ContDiffOn.fderiv_snd_of_isOpen {f : E × F → G} {S : Set E} {U : Set F} |
| 25 | (hf : ContDiffOn 𝕜 ∞ f (S ×ˢ U)) (hU : IsOpen U) : |
| 26 | ContDiffOn 𝕜 ∞ (fun z : E × F => fderiv 𝕜 (fun y => f (z.1, y)) z.2) |
| 27 | (S ×ˢ U) := by |
| 28 | intro z hz |
| 29 | have hmap : MapsTo (fun p : (E × F) × F => (p.1.1, p.2)) |
| 30 | ((S ×ˢ U) ×ˢ U) (S ×ˢ U) := fun _ hp => ⟨hp.1.1, hp.2⟩ |
| 31 | have hh : ContDiffWithinAt 𝕜 ∞ |
| 32 | (fun p : (E × F) × F => f (p.1.1, p.2)) ((S ×ˢ U) ×ˢ U) (z, z.2) := |
| 33 | (hf z hz).comp (z, z.2) |
| 34 | (contDiffWithinAt_fst.fst.prodMk contDiffWithinAt_snd) hmap |
| 35 | have hd : ContDiffWithinAt 𝕜 ∞ |
| 36 | (fun p : E × F => fderivWithin 𝕜 (fun y : F => f (p.1, y)) U p.2) |
| 37 | (S ×ˢ U) z := hh.fderivWithin (f := fun (p : E × F) (y : F) => f (p.1, y)) |
| 38 | (g := fun p : E × F => p.2) contDiffWithinAt_snd hU.uniqueDiffOn (by simp) hz |
| 39 | (fun _ hp => hp.2) |
| 40 | apply hd.congr_of_eventuallyEq_of_mem _ hz |
| 41 | filter_upwards [self_mem_nhdsWithin] with p hp |
| 42 | exact (fderivWithin_of_isOpen hU hp.2).symm |
| 43 | |
| 44 | /-- Every iterated spatial derivative preserves within-smoothness up to |
| 45 | the parameter boundary (Theorem 12.5, p. 297, endpoint calculus). -/ |
| 46 | theorem ContDiffOn.iteratedFDeriv_snd_of_isOpen {f : E × F → G} {S : Set E} {U : Set F} |
| 47 | (hf : ContDiffOn 𝕜 ∞ f (S ×ˢ U)) (hU : IsOpen U) (m : ℕ) : |
| 48 | ContDiffOn 𝕜 ∞ |
| 49 | (fun z : E × F => iteratedFDeriv 𝕜 m (fun y => f (z.1, y)) z.2) (S ×ˢ U) := by |
| 50 | induction m with |
| 51 | | zero => |
| 52 | let e := (continuousMultilinearCurryFin0 𝕜 F G).symm.toContinuousLinearEquiv |
| 53 | exact e.toContinuousLinearMap.contDiff.comp_contDiffOn hf |
| 54 | | succ m ih => |
| 55 | let e := (continuousMultilinearCurryLeftEquiv 𝕜 (fun _ : Fin (m + 1) => F) G).symm |
| 56 | convert! e.toContinuousLinearEquiv.toContinuousLinearMap.contDiff.comp_contDiffOn |
| 57 | (ih.fderiv_snd_of_isOpen hU) using 1 |