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.RicciFlow.Surgery.StandardCap.Uniqueness.Imports |
| 2 | import Mathlib.Geometry.Manifold.Diffeomorph |
| 3 | |
| 4 | /-! |
| 5 | # Total manifold derivatives through a diffeomorphism |
| 6 | |
| 7 | The coordinate transfer in Morgan-Tian Theorem 12.28, pp. 323-324, |
| 8 | uses total maps outside their neck domains. Postcomposition by a |
| 9 | diffeomorphism preserves nondifferentiability, so the totalized chain |
| 10 | rule also holds at those points without changing either map. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open scoped Manifold ContDiff |
| 16 | |
| 17 | namespace Diffeomorph |
| 18 | |
| 19 | variable {𝕜 : Type*} [NontriviallyNormedField 𝕜] |
| 20 | {E₁ : Type*} [NormedAddCommGroup E₁] [NormedSpace 𝕜 E₁] |
| 21 | {E₂ : Type*} [NormedAddCommGroup E₂] [NormedSpace 𝕜 E₂] |
| 22 | {E₃ : Type*} [NormedAddCommGroup E₃] [NormedSpace 𝕜 E₃] |
| 23 | {H₁ : Type*} [TopologicalSpace H₁] {H₂ : Type*} [TopologicalSpace H₂] |
| 24 | {H₃ : Type*} [TopologicalSpace H₃] |
| 25 | {I₁ : ModelWithCorners 𝕜 E₁ H₁} {I₂ : ModelWithCorners 𝕜 E₂ H₂} |
| 26 | {I₃ : ModelWithCorners 𝕜 E₃ H₃} |
| 27 | {M₁ : Type*} [TopologicalSpace M₁] [ChartedSpace H₁ M₁] |
| 28 | {M₂ : Type*} [TopologicalSpace M₂] [ChartedSpace H₂ M₂] |
| 29 | {M₃ : Type*} [TopologicalSpace M₃] [ChartedSpace H₃ M₃] |
| 30 | {n : ℕ∞ω} |
| 31 | |
| 32 | /-- The totalized chain rule for postcomposition by a diffeomorphism. |
| 33 | Used for the unchanged neck coordinates in Theorem 12.28, pp. 323-324. -/ |
| 34 | theorem mfderiv_comp (e : Diffeomorph I₂ I₃ M₂ M₃ n) (hn : n ≠ 0) |
| 35 | (f : M₁ → M₂) (x : M₁) : |
| 36 | mfderiv I₁ I₃ (e ∘ f) x = |
| 37 | (mfderiv I₂ I₃ e (f x)).comp (mfderiv I₁ I₂ f x) := by |
| 38 | by_cases hf : MDifferentiableAt I₁ I₂ f x |
| 39 | · exact _root_.mfderiv_comp x (e.contMDiff.mdifferentiable hn _) hf |
| 40 | · have hcomp : ¬ MDifferentiableAt I₁ I₃ (e ∘ f) x := by |
| 41 | intro h |
| 42 | have hback := (e.symm.contMDiff.mdifferentiable hn _).comp x h |
| 43 | have heq : e.symm ∘ (e ∘ f) = f := funext (fun y => e.symm_apply_apply (f y)) |
| 44 | rw [heq] at hback |
| 45 | exact hf hback |
| 46 | rw [mfderiv_zero_of_not_mdifferentiableAt hcomp, |
| 47 | mfderiv_zero_of_not_mdifferentiableAt hf, ContinuousLinearMap.comp_zero] |
| 48 | |
| 49 | /-- The derivatives of a coordinate diffeomorphism and its inverse cancel |
| 50 | even when the subsequent total map is not differentiable. Used in the |
| 51 | actual pullback transfer of Theorem 12.28, pp. 323-324. -/ |
| 52 | theorem mfderiv_cancel_left (e : Diffeomorph I₂ I₃ M₂ M₃ n) (hn : n ≠ 0) |
| 53 | (f : M₁ → M₃) (x : M₁) : |
| 54 | (mfderiv I₂ I₃ e (e.symm (f x))).comp (mfderiv I₁ I₂ (e.symm ∘ f) x) = |
| 55 | mfderiv I₁ I₃ f x := by |
| 56 | have h := e.mfderiv_comp (I₁ := I₁) hn (e.symm ∘ f) x |
| 57 | have heq : e ∘ (e.symm ∘ f) = f := funext (fun y => e.apply_symm_apply (f y)) |
| 58 | rw [heq] at h |
| 59 | exact h.symm |
| 60 | |
| 61 | end Diffeomorph |