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 | /- |
| 2 | Copyright (c) 2025 A Tucker. All rights reserved. |
| 3 | Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | |
| 5 | The private mean-value estimate below is adapted from |
| 6 | Mathlib.Analysis.Calculus.FDeriv.Partial.isLittleO_sub_sub_fderiv. |
| 7 | -/ |
| 8 | import Mathlib.Analysis.Calculus.MeanValue |
| 9 | import Mathlib.Analysis.Calculus.Deriv.Basic |
| 10 | |
| 11 | /-! |
| 12 | # Joint differentiation within product domains |
| 13 | |
| 14 | A spatial derivative and a continuous time derivative give a joint derivative |
| 15 | within a product, including the initial endpoint of a half-open time interval. |
| 16 | -/ |
| 17 | |
| 18 | open Set Filter Asymptotics |
| 19 | open scoped Topology Convex |
| 20 | |
| 21 | namespace Poincare |
| 22 | |
| 23 | -- The corresponding estimate in `FDeriv.Partial` is private to that module. |
| 24 | private theorem isLittleO_sub_sub_fderiv |
| 25 | {α E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 26 | [NormedAddCommGroup F] [NormedSpace ℝ F] |
| 27 | {u : E} {v w : α → E} {l : Filter α} |
| 28 | (hv : Tendsto v l (𝓝 u)) (hw : Tendsto w l (𝓝 u)) |
| 29 | (s : Set E) (seg : ∀ᶠ q in l, [w q -[ℝ] v q] ⊆ s) |
| 30 | {f : α → E → F} {f' : α → E → E →L[ℝ] F} |
| 31 | (hf : ∀ᶠ p in l ×ˢ 𝓝[s] u, |
| 32 | HasFDerivWithinAt (f p.1) (f' p.1 p.2) s p.2) |
| 33 | {φ : E →L[ℝ] F} (hc : Tendsto (Function.uncurry f') (l ×ˢ 𝓝[s] u) (𝓝 φ)) : |
| 34 | (fun q => f q (v q) - f q (w q) - φ (v q - w q)) =o[l] |
| 35 | (fun q => v q - w q) := by |
| 36 | rw [isLittleO_iff] |
| 37 | intro ε hε |
| 38 | have hd : ∀ᶠ q in l, ∀ z ∈ [w q -[ℝ] v q], |
| 39 | HasFDerivWithinAt (f q) (f' q z) s z := |
| 40 | hf.segment_of_prod_nhdsWithin hw hv seg |
| 41 | have hb : ∀ᶠ q in l, ∀ z ∈ [w q -[ℝ] v q], ‖f' q z - φ‖ < ε := by |
| 42 | simp_rw [Metric.tendsto_nhds, dist_eq_norm_sub] at hc |
| 43 | exact (hc ε hε).segment_of_prod_nhdsWithin hw hv seg |
| 44 | filter_upwards [seg, hd, hb] with q hseg hd hb |
| 45 | exact Convex.norm_image_sub_le_of_norm_hasFDerivWithin_le' |
| 46 | (fun z hz => (hd z hz).mono hseg) (fun z hz => (hb z hz).le) |
| 47 | (convex_segment ..) (left_mem_segment ..) (right_mem_segment ..) |
| 48 | |
| 49 | variable {P Q V : Type*} [NormedAddCommGroup P] [NormedSpace ℝ P] |
| 50 | [NormedAddCommGroup Q] [NormedSpace ℝ Q] |
| 51 | [NormedAddCommGroup V] [NormedSpace ℝ V] |
| 52 | |
| 53 | /-- A continuous second partial derivative gives joint differentiability within a |
| 54 | product whose second factor is convex. The first partial is only needed at the |
| 55 | point under consideration. -/ |
| 56 | theorem hasFDerivWithinAt_prod_of_continuous_partial |
| 57 | {f : P × Q → V} {U : Set P} {T : Set Q} (hT : Convex ℝ T) |
| 58 | {p : P × Q} (hp : p ∈ U ×ˢ T) {Dx : P →L[ℝ] V} |
| 59 | {Dt : P × Q → Q →L[ℝ] V} |
| 60 | (hx : HasFDerivAt (fun x => f (x, p.2)) Dx p.1) |
| 61 | (ht : ∀ q ∈ U ×ˢ T, |
| 62 | HasFDerivWithinAt (fun t => f (q.1, t)) (Dt q) T q.2) |
| 63 | (hDt : ContinuousWithinAt Dt (U ×ˢ T) p) : |
| 64 | HasFDerivWithinAt f (Dx.coprod (Dt p)) (U ×ˢ T) p := by |
| 65 | rw [hasFDerivWithinAt_iff_isLittleO] |
| 66 | have hfst : Tendsto (fun q : P × Q => q.1) (𝓝[U ×ˢ T] p) (𝓝 p.1) := |
| 67 | continuous_fst.continuousAt.tendsto.mono_left nhdsWithin_le_nhds |
| 68 | have hsnd : Tendsto (fun q : P × Q => q.2) (𝓝[U ×ˢ T] p) (𝓝 p.2) := |
| 69 | continuous_snd.continuousAt.tendsto.mono_left nhdsWithin_le_nhds |
| 70 | have hmap : Tendsto (fun q : (P × Q) × Q => (q.1.1, q.2)) |
| 71 | ((𝓝[U ×ˢ T] p) ×ˢ 𝓝[T] p.2) (𝓝[U ×ˢ T] p) := by |
| 72 | rw [nhdsWithin_prod_eq] at * |
| 73 | exact (tendsto_fst.comp tendsto_fst).prodMk tendsto_snd |
| 74 | have htime : |
| 75 | (fun q => f (q.1, q.2) - f (q.1, p.2) - Dt p (q.2 - p.2)) |
| 76 | =o[𝓝[U ×ˢ T] p] (fun q => q.2 - p.2) := by |
| 77 | apply isLittleO_sub_sub_fderiv hsnd tendsto_const_nhds T |
| 78 | (f := fun q t => f (q.1, t)) (f' := fun q t => Dt (q.1, t)) |
| 79 | · filter_upwards [self_mem_nhdsWithin] with q hq |
| 80 | exact hT.segment_subset hp.2 hq.2 |
| 81 | · exact hmap.eventually (eventually_mem_nhdsWithin.mono ht) |
| 82 | · exact (show Tendsto Dt (𝓝[U ×ˢ T] p) (𝓝 (Dt p)) from hDt).comp hmap |
| 83 | have hspace : |
| 84 | (fun q : P × Q => f (q.1, p.2) - f p - Dx (q.1 - p.1)) |
| 85 | =o[𝓝[U ×ˢ T] p] (fun q => q.1 - p.1) := by |
| 86 | simpa [Function.comp_def] using (hasFDerivAt_iff_isLittleO.mp hx).comp_tendsto hfst |
| 87 | have hspace' : |
| 88 | (fun q : P × Q => f (q.1, p.2) - f p - Dx (q.1 - p.1)) |
| 89 | =o[𝓝[U ×ˢ T] p] (fun q => q - p) := |
| 90 | hspace.trans_isBigO (isBigO_of_le _ (fun q => norm_fst_le (q - p))) |
| 91 | have htime' : |
| 92 | (fun q : P × Q => f (q.1, q.2) - f (q.1, p.2) - Dt p (q.2 - p.2)) |
| 93 | =o[𝓝[U ×ˢ T] p] (fun q => q - p) := |
| 94 | htime.trans_isBigO (isBigO_of_le _ (fun q => norm_snd_le (q - p))) |
| 95 | simpa [ContinuousLinearMap.coprod_apply, Prod.fst_sub, Prod.snd_sub, |
| 96 | sub_eq_add_neg, add_assoc, add_comm, add_left_comm] using hspace'.add htime' |
| 97 | |
| 98 | /-- Scalar-time version on a half-open interval, including its initial endpoint. -/ |
| 99 | theorem hasFDerivWithinAt_prod_Ico_of_continuous_partial |
| 100 | {f : P × ℝ → V} {U : Set P} {a b : ℝ} |
| 101 | {p : P × ℝ} (hp : p ∈ U ×ˢ Ico a b) {Dx : P →L[ℝ] V} |
| 102 | {Dt : P × ℝ → V} |
| 103 | (hx : HasFDerivAt (fun x => f (x, p.2)) Dx p.1) |
| 104 | (ht : ∀ q ∈ U ×ˢ Ico a b, |
| 105 | HasDerivWithinAt (fun t => f (q.1, t)) (Dt q) (Ico a b) q.2) |
| 106 | (hDt : ContinuousWithinAt Dt (U ×ˢ Ico a b) p) : |
| 107 | HasFDerivWithinAt f |
| 108 | (Dx.coprod (ContinuousLinearMap.toSpanSingleton ℝ (Dt p))) (U ×ˢ Ico a b) p := by |
| 109 | apply hasFDerivWithinAt_prod_of_continuous_partial (convex_Ico a b) hp hx |
| 110 | (fun q hq => (ht q hq).hasFDerivWithinAt) |
| 111 | exact ContinuousLinearMap.toSpanSingletonCLE.continuous.continuousAt.comp_continuousWithinAt hDt |
| 112 | |
| 113 | end Poincare |