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.FDeriv.Symmetric |
| 2 | import Mathlib.Analysis.Calculus.Deriv.Prod |
| 3 | import Mathlib.Analysis.Calculus.Deriv.Mul |
| 4 | |
| 5 | /-! |
| 6 | # Mixed partial derivatives of an initial variation jet |
| 7 | |
| 8 | The initial time derivative is prescribed as a function of the variation |
| 9 | parameter. Symmetry of the second derivative identifies the time derivative |
| 10 | of the actual variation field. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open scoped ContDiff Topology |
| 16 | open Filter |
| 17 | |
| 18 | namespace PoincareMT.ReducedLength |
| 19 | |
| 20 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 21 | |
| 22 | theorem hasDerivAt_slice_fst (f : ℝ × ℝ → E) (s u : ℝ) |
| 23 | (hf : DifferentiableAt ℝ f (s, u)) : |
| 24 | HasDerivAt (fun r ↦ f (r, u)) (fderiv ℝ f (s, u) (1, 0)) s := |
| 25 | hf.hasFDerivAt.comp_hasDerivAt s |
| 26 | ((hasDerivAt_id s).prodMk (hasDerivAt_const s u)) |
| 27 | |
| 28 | theorem hasDerivAt_slice_snd (f : ℝ × ℝ → E) (s u : ℝ) |
| 29 | (hf : DifferentiableAt ℝ f (s, u)) : |
| 30 | HasDerivAt (fun r ↦ f (s, r)) (fderiv ℝ f (s, u) (0, 1)) u := |
| 31 | hf.hasFDerivAt.comp_hasDerivAt u |
| 32 | ((hasDerivAt_const u s).prodMk (hasDerivAt_id u)) |
| 33 | |
| 34 | theorem hasDerivAt_partial_snd_of_initial_fst (f : ℝ × ℝ → E) |
| 35 | (hf : ContDiffAt ℝ ∞ f (0, 0)) (k : ℝ → E) (w : E) |
| 36 | (hk : HasDerivAt k w 0) |
| 37 | (hjet : ∀ᶠ u in 𝓝 (0 : ℝ), HasDerivAt (fun s ↦ f (s, u)) (k u) 0) : |
| 38 | HasDerivAt (fun s ↦ deriv (fun u ↦ f (s, u)) 0) w 0 := by |
| 39 | have htwo : (2 : ℕ∞ω) ≤ ∞ := ENat.natCast_le_of_coe_top_le_withTop le_rfl 2 |
| 40 | have hD : DifferentiableAt ℝ (fderiv ℝ f) (0, 0) := |
| 41 | (hf.fderiv_right (m := ∞) (by simp)).differentiableAt (by simp) |
| 42 | have htime : HasDerivAt (fun s ↦ fderiv ℝ f (s, 0) (0, 1)) |
| 43 | (fderiv ℝ (fderiv ℝ f) (0, 0) (1, 0) (0, 1)) 0 := by |
| 44 | simpa only [map_zero, add_zero] using |
| 45 | (hasDerivAt_slice_fst (fderiv ℝ f) 0 0 hD).clm_apply |
| 46 | (hasDerivAt_const 0 ((0, 1) : ℝ × ℝ)) |
| 47 | have hparameter : HasDerivAt (fun u ↦ fderiv ℝ f (0, u) (1, 0)) |
| 48 | (fderiv ℝ (fderiv ℝ f) (0, 0) (0, 1) (1, 0)) 0 := by |
| 49 | simpa only [map_zero, add_zero] using |
| 50 | (hasDerivAt_slice_snd (fderiv ℝ f) 0 0 hD).clm_apply |
| 51 | (hasDerivAt_const 0 ((1, 0) : ℝ × ℝ)) |
| 52 | have hnear : ∀ᶠ z in 𝓝 ((0, 0) : ℝ × ℝ), DifferentiableAt ℝ f z := |
| 53 | ((hf.of_le (show (1 : ℕ∞ω) ≤ ∞ by simp)).eventually (by simp)).mono |
| 54 | (fun z hz ↦ hz.differentiableAt (by simp)) |
| 55 | have hknear : (fun u ↦ fderiv ℝ f (0, u) (1, 0)) =ᶠ[𝓝 (0 : ℝ)] k := by |
| 56 | filter_upwards [hjet, |
| 57 | (continuous_const.prodMk continuous_id).continuousAt.eventually hnear] with u hu hd |
| 58 | exact (hasDerivAt_slice_fst f 0 u hd).unique hu |
| 59 | have heq := (hparameter.congr_of_eventuallyEq hknear.symm).unique hk |
| 60 | have hsymm := (hf.isSymmSndFDerivAt (by simpa using htwo)) ((1, 0) : ℝ × ℝ) (0, 1) |
| 61 | rw [hsymm, heq] at htime |
| 62 | apply htime.congr_of_eventuallyEq |
| 63 | filter_upwards [(continuous_id.prodMk continuous_const).continuousAt.eventually hnear] |
| 64 | with s hs |
| 65 | exact (hasDerivAt_slice_snd f s 0 hs).deriv |
| 66 | |
| 67 | theorem contDiffOn_partial_snd (f : ℝ × ℝ → E) (U : Set (ℝ × ℝ)) (hU : IsOpen U) |
| 68 | (hf : ContDiffOn ℝ ∞ f U) : |
| 69 | ContDiffOn ℝ ∞ (fun s ↦ deriv (fun u ↦ f (s, u)) 0) |
| 70 | ((fun s : ℝ ↦ (s, (0 : ℝ))) ⁻¹' U) := by |
| 71 | have hD := hf.fderiv_of_isOpen hU (m := ∞) (by simp) |
| 72 | have hcomp : ContDiffOn ℝ ∞ (fun s ↦ fderiv ℝ f (s, 0) (0, 1)) |
| 73 | ((fun s : ℝ ↦ (s, (0 : ℝ))) ⁻¹' U) := |
| 74 | (hD.comp (contDiff_id.prodMk contDiff_const).contDiffOn |
| 75 | (fun s hs ↦ hs)).clm_apply contDiffOn_const |
| 76 | apply hcomp.congr |
| 77 | intro s hs |
| 78 | exact (hasDerivAt_slice_snd f s 0 |
| 79 | ((hf.contDiffAt (hU.mem_nhds hs)).differentiableAt (by simp))).deriv |
| 80 | |
| 81 | end PoincareMT.ReducedLength |