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.ReducedGeometry.ReducedLength.Calculus.MixedPartials |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Comp |
| 3 | |
| 4 | /-! |
| 5 | # Actual smooth partial derivatives and the mixed variation jet |
| 6 | |
| 7 | Every partial is identified with the derivative of its actual slice. |
| 8 | Translation moves the mixed-partial calculation to any tested time. |
| 9 | -/ |
| 10 | |
| 11 | set_option autoImplicit false |
| 12 | |
| 13 | open scoped ContDiff Topology |
| 14 | open Filter |
| 15 | |
| 16 | namespace PoincareMT.ReducedLength |
| 17 | |
| 18 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 19 | |
| 20 | theorem contDiffOn_slice_deriv_fst (f : ℝ × ℝ → E) (U : Set (ℝ × ℝ)) (hU : IsOpen U) |
| 21 | (hf : ContDiffOn ℝ ∞ f U) : |
| 22 | ContDiffOn ℝ ∞ (fun z : ℝ × ℝ ↦ deriv (fun r ↦ f (r, z.2)) z.1) U := by |
| 23 | have hD : ContDiffOn ℝ ∞ (fderiv ℝ f) U := hf.fderiv_of_isOpen hU (by simp) |
| 24 | apply (hD.clm_apply (contDiffOn_const (c := ((1, 0) : ℝ × ℝ)))).congr |
| 25 | intro z hz |
| 26 | exact (hasDerivAt_slice_fst f z.1 z.2 |
| 27 | ((hf.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp))).deriv |
| 28 | |
| 29 | theorem contDiffOn_slice_deriv_snd (f : ℝ × ℝ → E) (U : Set (ℝ × ℝ)) (hU : IsOpen U) |
| 30 | (hf : ContDiffOn ℝ ∞ f U) : |
| 31 | ContDiffOn ℝ ∞ (fun z : ℝ × ℝ ↦ deriv (fun r ↦ f (z.1, r)) z.2) U := by |
| 32 | have hD : ContDiffOn ℝ ∞ (fderiv ℝ f) U := hf.fderiv_of_isOpen hU (by simp) |
| 33 | apply (hD.clm_apply (contDiffOn_const (c := ((0, 1) : ℝ × ℝ)))).congr |
| 34 | intro z hz |
| 35 | exact (hasDerivAt_slice_snd f z.1 z.2 |
| 36 | ((hf.contDiffAt (hU.mem_nhds hz)).differentiableAt (by simp))).deriv |
| 37 | |
| 38 | theorem hasDerivAt_partial_snd_of_fst (f : ℝ × ℝ → E) (s : ℝ) |
| 39 | (hf : ContDiffAt ℝ ∞ f (s, 0)) (k : ℝ → E) (w : E) |
| 40 | (hk : HasDerivAt k w 0) |
| 41 | (hjet : ∀ᶠ u in 𝓝 (0 : ℝ), HasDerivAt (fun r ↦ f (r, u)) (k u) s) : |
| 42 | HasDerivAt (fun r ↦ deriv (fun u ↦ f (r, u)) 0) w s := by |
| 43 | let Y : ℝ → E := fun r ↦ deriv (fun u ↦ f (r, u)) 0 |
| 44 | have htrans : ContDiffAt ℝ ∞ (fun z : ℝ × ℝ ↦ (s + z.1, z.2)) (0, 0) := |
| 45 | (contDiff_const.add contDiff_fst).prodMk contDiff_snd |>.contDiffAt |
| 46 | have hF : ContDiffAt ℝ ∞ (fun z : ℝ × ℝ ↦ f (s + z.1, z.2)) (0, 0) := by |
| 47 | have hf' : ContDiffAt ℝ ∞ f (s + 0, 0) := by simpa only [add_zero] using hf |
| 48 | exact hf'.comp (0, 0) htrans |
| 49 | have hjet' : ∀ᶠ u in 𝓝 (0 : ℝ), HasDerivAt (fun r ↦ f (s + r, u)) (k u) 0 := by |
| 50 | filter_upwards [hjet] with u hu |
| 51 | simpa only [Function.comp_def, id_eq, one_smul] using hu.scomp_of_eq 0 |
| 52 | ((hasDerivAt_id 0).const_add s) (add_zero s).symm |
| 53 | have hY : HasDerivAt (fun r ↦ Y (s + r)) w 0 := |
| 54 | hasDerivAt_partial_snd_of_initial_fst (fun z : ℝ × ℝ ↦ f (s + z.1, z.2)) |
| 55 | hF k w hk hjet' |
| 56 | have hback := hY.scomp_of_eq s ((hasDerivAt_id s).sub_const s) (sub_self s).symm |
| 57 | have hcancel (r : ℝ) : s + (r - s) = r := by ring |
| 58 | simpa only [Function.comp_def, id_eq, one_smul, hcancel, Y] using hback |
| 59 | |
| 60 | noncomputable def timeDerivativePhase (f : ℝ × ℝ → E) (z : ℝ × ℝ) : E × E := |
| 61 | (f z, deriv (fun r ↦ f (r, z.2)) z.1) |
| 62 | |
| 63 | theorem timeDerivativePhase_contDiffOn (f : ℝ × ℝ → E) (U : Set (ℝ × ℝ)) |
| 64 | (hU : IsOpen U) (hf : ContDiffOn ℝ ∞ f U) : |
| 65 | ContDiffOn ℝ ∞ (timeDerivativePhase f) U := |
| 66 | hf.prodMk (contDiffOn_slice_deriv_fst f U hU hf) |
| 67 | |
| 68 | theorem deriv_timeDerivativePhase_variation (f : ℝ × ℝ → E) (U : Set (ℝ × ℝ)) |
| 69 | (hU : IsOpen U) (hf : ContDiffOn ℝ ∞ f U) (s : ℝ) (hs : (s, 0) ∈ U) : |
| 70 | deriv (fun u ↦ timeDerivativePhase f (s, u)) 0 = |
| 71 | (deriv (fun u ↦ f (s, u)) 0, deriv (fun r ↦ deriv (fun u ↦ f (r, u)) 0) s) := by |
| 72 | let k : ℝ → E := fun u ↦ deriv (fun r ↦ f (r, u)) s |
| 73 | have hk : DifferentiableAt ℝ k 0 := by |
| 74 | have hpartial := (contDiffOn_slice_deriv_fst f U hU hf).contDiffAt (hU.mem_nhds hs) |
| 75 | exact ((hasDerivAt_slice_snd _ s 0 (hpartial.differentiableAt (by simp))).differentiableAt) |
| 76 | have hjet : ∀ᶠ u in 𝓝 (0 : ℝ), HasDerivAt (fun r ↦ f (r, u)) (k u) s := by |
| 77 | filter_upwards [(continuous_const.prodMk continuous_id).continuousAt.preimage_mem_nhds |
| 78 | (hU.mem_nhds hs)] with u hu |
| 79 | exact (hasDerivAt_slice_fst f s u |
| 80 | ((hf.contDiffAt (hU.mem_nhds hu)).differentiableAt (by simp))).differentiableAt.hasDerivAt |
| 81 | have hmixed := hasDerivAt_partial_snd_of_fst f s (hf.contDiffAt (hU.mem_nhds hs)) |
| 82 | k (deriv k 0) hk.hasDerivAt hjet |
| 83 | have hu := (hasDerivAt_slice_snd f s 0 |
| 84 | ((hf.contDiffAt (hU.mem_nhds hs)).differentiableAt (by simp))).differentiableAt.hasDerivAt |
| 85 | exact (hu.prodMk (hk.hasDerivAt.congr_deriv hmixed.deriv.symm)).deriv |
| 86 | |
| 87 | end PoincareMT.ReducedLength |