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.ImplicitContDiff |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Add |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Comp |
| 4 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 5 | |
| 6 | /-! |
| 7 | # Actual derivatives of inverse real label families |
| 8 | |
| 9 | The genuine scalar implicit equation identifies its branch with the |
| 10 | actual order inverse. Differentiating the inverse identity gives its |
| 11 | witnessed parameter derivative. MT2007 Claim 19.1, p. 437; |
| 12 | `2026-09-22-differentiable-inverse-labels.md`, statements 1-2. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open Filter |
| 18 | open scoped ContDiff Topology |
| 19 | |
| 20 | namespace PoincareMT.M63 |
| 21 | |
| 22 | /-- A genuine Ck forward-label germ with nonzero label derivative gives |
| 23 | the same regularity for the actual inverse family. Prior inverse-family |
| 24 | continuity is unnecessary. MT2007 Claim 19.1, p. 437; inverse-label |
| 25 | regularity derivation, statement 1. -/ |
| 26 | theorem contDiffAt_inverse_orderIso_family |
| 27 | {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 28 | (phi : E → (ℝ ≃o ℝ)) {z : E} {y d : ℝ} {k : ℕ∞ω} (hk : k ≠ 0) |
| 29 | (hphi : ContDiffAt ℝ k (fun p : E × ℝ => phi p.1 p.2) (z, (phi z).symm y)) |
| 30 | (hderiv : HasDerivAt (phi z) d ((phi z).symm y)) (hd : d ≠ 0) : |
| 31 | ContDiffAt ℝ k (fun p : E × ℝ => (phi p.1).symm p.2) (z, y) := by |
| 32 | let x := (phi z).symm y |
| 33 | let H : (E × ℝ) × ℝ → ℝ := fun p => phi p.1.1 p.2 - p.1.2 |
| 34 | have hmap : ContDiffAt ℝ k (fun p : (E × ℝ) × ℝ => (p.1.1, p.2)) ((z, y), x) := |
| 35 | contDiffAt_fst.fst.prodMk contDiffAt_snd |
| 36 | have hH : ContDiffAt ℝ k H ((z, y), x) := |
| 37 | (hphi.comp (f := fun p : (E × ℝ) × ℝ => (p.1.1, p.2)) |
| 38 | (g := fun p : E × ℝ => phi p.1 p.2) ((z, y), x) hmap).sub contDiffAt_fst.snd |
| 39 | have hprod : (0 : ℝ →L[ℝ] E × ℝ).prod (ContinuousLinearMap.id ℝ ℝ) = |
| 40 | ContinuousLinearMap.inr ℝ (E × ℝ) ℝ := by |
| 41 | apply ContinuousLinearMap.ext |
| 42 | intro u |
| 43 | rfl |
| 44 | have hslice : HasFDerivAt (fun u => H ((z, y), u)) |
| 45 | ((fderiv ℝ H ((z, y), x)).comp (ContinuousLinearMap.inr ℝ (E × ℝ) ℝ)) x := by |
| 46 | simpa only [Function.comp_def, hprod] using |
| 47 | (hH.differentiableAt hk).hasFDerivAt.comp x |
| 48 | ((hasFDerivAt_const (z, y) x).prodMk (hasFDerivAt_id x)) |
| 49 | have hactual : HasDerivAt (fun u => H ((z, y), u)) d x := hderiv.sub_const y |
| 50 | have hpartial : (fderiv ℝ H ((z, y), x)).comp |
| 51 | (ContinuousLinearMap.inr ℝ (E × ℝ) ℝ) = d • ContinuousLinearMap.id ℝ ℝ := by |
| 52 | rw [hslice.unique hactual.hasFDerivAt] |
| 53 | apply ContinuousLinearMap.ext |
| 54 | intro u |
| 55 | change u * d = d * u |
| 56 | exact mul_comm _ _ |
| 57 | have hinv : ((fderiv ℝ H ((z, y), x)).comp |
| 58 | (ContinuousLinearMap.inr ℝ (E × ℝ) ℝ)).IsInvertible := by |
| 59 | rw [hpartial] |
| 60 | apply ContinuousLinearMap.IsInvertible.of_inverse |
| 61 | (g := d⁻¹ • ContinuousLinearMap.id ℝ ℝ) |
| 62 | · apply ContinuousLinearMap.ext |
| 63 | intro u |
| 64 | simp only [ContinuousLinearMap.comp_apply, smul_apply, |
| 65 | ContinuousLinearMap.id_apply, smul_smul, mul_inv_cancel₀ hd, one_smul] |
| 66 | · apply ContinuousLinearMap.ext |
| 67 | intro u |
| 68 | simp only [ContinuousLinearMap.comp_apply, smul_apply, |
| 69 | ContinuousLinearMap.id_apply, smul_smul, inv_mul_cancel₀ hd, one_smul] |
| 70 | let q := hH.implicitFunction hk hinv |
| 71 | have hzero : H ((z, y), x) = 0 := by |
| 72 | simp only [H, x, OrderIso.apply_symm_apply, sub_self] |
| 73 | have heq : (fun p : E × ℝ => (phi p.1).symm p.2) =ᶠ[𝓝 (z, y)] q := by |
| 74 | have hlocal := hH.eventually_apply_implicitFunction hk hinv |
| 75 | filter_upwards [hlocal] with p hp |
| 76 | apply (phi p.1).injective |
| 77 | rw [OrderIso.apply_symm_apply] |
| 78 | have hroot : phi p.1 (q p) - p.2 = 0 := hp.trans hzero |
| 79 | exact (sub_eq_zero.mp hroot).symm |
| 80 | exact (hH.contDiffAt_implicitFunction hk hinv).congr_of_eventuallyEq heq |
| 81 | |
| 82 | /-- The witnessed two forward partials determine the actual inverse |
| 83 | label's time derivative. The label derivative is explicitly nonzero. |
| 84 | MT2007 Claim 19.1, p. 437; inverse-label regularity, statement 2. -/ |
| 85 | theorem hasDerivAt_time_inverse_orderIso_family |
| 86 | (phi : ℝ → (ℝ ≃o ℝ)) {t y dx dt : ℝ} |
| 87 | (hphi : ContDiffAt ℝ 1 (fun p : ℝ × ℝ => phi p.1 p.2) (t, (phi t).symm y)) |
| 88 | (hx : HasDerivAt (phi t) dx ((phi t).symm y)) |
| 89 | (ht : HasDerivAt (fun s => phi s ((phi t).symm y)) dt t) (hdx : dx ≠ 0) : |
| 90 | HasDerivAt (fun s => (phi s).symm y) (-dt / dx) t := by |
| 91 | let psi : ℝ → ℝ := fun s => (phi s).symm y |
| 92 | let x := psi t |
| 93 | let w := deriv psi t |
| 94 | have hinv := contDiffAt_inverse_orderIso_family phi (by norm_num) hphi hx hdx |
| 95 | have hpsi : HasDerivAt psi w t := |
| 96 | ((hinv.comp (f := fun s : ℝ => (s, y)) |
| 97 | (g := fun p : ℝ × ℝ => (phi p.1).symm p.2) t |
| 98 | (contDiffAt_id.prodMk contDiffAt_const)).differentiableAt |
| 99 | (by norm_num)).hasDerivAt |
| 100 | let G : ℝ × ℝ → ℝ := fun p => phi p.1 p.2 |
| 101 | let D := fderiv ℝ G (t, x) |
| 102 | have hD : HasFDerivAt G D (t, x) := (hphi.differentiableAt (by norm_num)).hasFDerivAt |
| 103 | have hDt : D (1, 0) = dt := |
| 104 | (hD.comp_hasDerivAt (f := fun s : ℝ => (s, x)) t |
| 105 | ((hasDerivAt_id t).prodMk (hasDerivAt_const t x))).unique ht |
| 106 | have hDx : D (0, 1) = dx := |
| 107 | (hD.comp_hasDerivAt (f := fun u : ℝ => (t, u)) x |
| 108 | ((hasDerivAt_const x t).prodMk (hasDerivAt_id x))).unique hx |
| 109 | have hvalue : D (1, w) = dt + w * dx := by |
| 110 | have hp : ((1 : ℝ), w) = (1, 0) + w • ((0 : ℝ), (1 : ℝ)) := by |
| 111 | ext <;> simp |
| 112 | rw [hp, map_add, map_smul, hDt, hDx, smul_eq_mul] |
| 113 | have hcomp : HasDerivAt (fun s => phi s (psi s)) (D (1, w)) t := |
| 114 | hD.comp_hasDerivAt (f := fun s => (s, psi s)) t |
| 115 | ((hasDerivAt_id t).prodMk hpsi) |
| 116 | have heq : (fun s => phi s (psi s)) = fun _ => y := |
| 117 | funext fun s => (phi s).apply_symm_apply y |
| 118 | rw [heq] at hcomp |
| 119 | have hzero : dt + w * dx = 0 := hvalue.symm.trans (hcomp.unique (hasDerivAt_const t y)) |
| 120 | apply hpsi.congr_deriv |
| 121 | apply (eq_div_iff hdx).mpr |
| 122 | linarith only [hzero] |
| 123 | |
| 124 | end PoincareMT.M63 |