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.Analysis.Elliptic.Regularity.Sobolev.Iterated.Multiply |
| 2 | |
| 3 | /-! |
| 4 | # Test function derivatives for weak elliptic equations |
| 5 | |
| 6 | The mixed derivative calculation is adapted from Chow--Liao--Qin, |
| 7 | `Analysis/Elliptic/Regularity/Iterated/VariationalIdentity/InductiveSuccessor.lean`, |
| 8 | revision `1b535dd102b94cc42b107cca27059687888f08b3` (Apache-2.0). |
| 9 | -/ |
| 10 | |
| 11 | noncomputable section |
| 12 | |
| 13 | open Set MeasureTheory Function Filter Topology |
| 14 | open scoped ENNReal ContDiff |
| 15 | |
| 16 | namespace Poincare.Analysis.Elliptic.Iteration |
| 17 | |
| 18 | variable {n : ℕ} |
| 19 | |
| 20 | local notation "E" => EuclideanSpace ℝ (Fin n) |
| 21 | |
| 22 | /-- A classical coordinate derivative, used only on smooth coefficients and tests. -/ |
| 23 | def partialDeriv (i : Fin n) (f : E → ℝ) : E → ℝ := |
| 24 | fun x => (fderiv ℝ f x) (EuclideanSpace.single i 1) |
| 25 | |
| 26 | theorem contDiff_partial {f : E → ℝ} (hf : ContDiff ℝ ∞ f) (i : Fin n) : |
| 27 | ContDiff ℝ ∞ (partialDeriv i f) := |
| 28 | Sobolev.Euclidean.contDiff_partial_eta hf i |
| 29 | |
| 30 | theorem hasCompactSupport_partial {f : E → ℝ} (hf : HasCompactSupport f) (i : Fin n) : |
| 31 | HasCompactSupport (partialDeriv i f) := hf.fderiv_apply (𝕜 := ℝ) _ |
| 32 | |
| 33 | theorem tsupport_partial_subset (i : Fin n) (f : E → ℝ) : |
| 34 | tsupport (partialDeriv i f) ⊆ tsupport f := |
| 35 | tsupport_fderiv_apply_subset ℝ _ |
| 36 | |
| 37 | theorem partial_comm {f : E → ℝ} (hf : ContDiff ℝ ∞ f) (i j : Fin n) : |
| 38 | partialDeriv i (partialDeriv j f) = partialDeriv j (partialDeriv i f) := by |
| 39 | funext x |
| 40 | have hfd : Differentiable ℝ (fderiv ℝ f) := |
| 41 | ((contDiff_infty_iff_fderiv.1 hf).2).differentiable (by simp) |
| 42 | have hflip : ∀ k : Fin n, fderiv ℝ (partialDeriv k f) x = |
| 43 | (fderiv ℝ (fderiv ℝ f) x).flip (EuclideanSpace.single k 1) := by |
| 44 | intro k |
| 45 | unfold partialDeriv |
| 46 | rw [fderiv_clm_apply (hfd x) (differentiableAt_const _)] |
| 47 | simp |
| 48 | have hsymm : IsSymmSndFDerivAt ℝ f x := |
| 49 | hf.contDiffAt.isSymmSndFDerivAt (by |
| 50 | rw [minSmoothness_of_isRCLikeNormedField] |
| 51 | decide) |
| 52 | change (fderiv ℝ (partialDeriv j f) x) (EuclideanSpace.single i 1) = |
| 53 | (fderiv ℝ (partialDeriv i f) x) (EuclideanSpace.single j 1) |
| 54 | rw [hflip j, hflip i] |
| 55 | exact hsymm _ _ |
| 56 | |
| 57 | theorem integrable_mul_test {O : Set E} {f φ : E → ℝ} |
| 58 | (hf : LocallyIntegrable f (volume.restrict O)) |
| 59 | (hφ : ContDiff ℝ ∞ φ) (hφc : HasCompactSupport φ) : |
| 60 | Integrable (fun x => f x * φ x) (volume.restrict O) := by |
| 61 | simpa only [smul_eq_mul] using |
| 62 | hf.integrable_smul_right_of_hasCompactSupport hφ.continuous hφc |
| 63 | |
| 64 | theorem integrable_mul_partial_test {O : Set E} {f φ : E → ℝ} |
| 65 | (hf : LocallyIntegrable f (volume.restrict O)) |
| 66 | (hφ : ContDiff ℝ ∞ φ) (hφc : HasCompactSupport φ) (i : Fin n) : |
| 67 | Integrable (fun x => f x * partialDeriv i φ x) (volume.restrict O) := |
| 68 | integrable_mul_test hf (contDiff_partial hφ i) (hasCompactSupport_partial hφc i) |
| 69 | |
| 70 | /-- Weak second derivatives commute whenever both are locally integrable. -/ |
| 71 | theorem weakPartial_comm_ae |
| 72 | {O : Set E} (hO : IsOpen O) {u p q r s : E → ℝ} {i j : Fin n} |
| 73 | (hp : Sobolev.Weak.HasWeakPartialDeriv i p u O) |
| 74 | (hq : Sobolev.Weak.HasWeakPartialDeriv j q u O) |
| 75 | (hr : Sobolev.Weak.HasWeakPartialDeriv j r p O) |
| 76 | (hs : Sobolev.Weak.HasWeakPartialDeriv i s q O) |
| 77 | (hrint : LocallyIntegrable r (volume.restrict O)) |
| 78 | (hsint : LocallyIntegrable s (volume.restrict O)) : |
| 79 | r =ᵐ[volume.restrict O] s := by |
| 80 | suffices h : (fun x => r x - s x) =ᵐ[volume.restrict O] 0 by |
| 81 | filter_upwards [h] with x hx |
| 82 | exact sub_eq_zero.mp hx |
| 83 | change ∀ᵐ x ∂volume.restrict O, r x - s x = 0 |
| 84 | rw [ae_restrict_iff' hO.measurableSet] |
| 85 | apply hO.ae_eq_zero_of_integral_contDiff_smul_eq_zero |
| 86 | (locallyIntegrableOn_of_locallyIntegrable_restrict (hrint.sub hsint)) |
| 87 | intro φ hφ hφc hφO |
| 88 | have hp' := hp (partialDeriv j φ) (contDiff_partial hφ j) |
| 89 | (hasCompactSupport_partial hφc j) ((tsupport_partial_subset j φ).trans hφO) |
| 90 | have hq' := hq (partialDeriv i φ) (contDiff_partial hφ i) |
| 91 | (hasCompactSupport_partial hφc i) ((tsupport_partial_subset i φ).trans hφO) |
| 92 | have hr' := hr φ hφ hφc hφO |
| 93 | have hs' := hs φ hφ hφc hφO |
| 94 | change (∫ x in O, u x * partialDeriv i (partialDeriv j φ) x) = |
| 95 | -(∫ x in O, p x * partialDeriv j φ x) at hp' |
| 96 | change (∫ x in O, u x * partialDeriv j (partialDeriv i φ) x) = |
| 97 | -(∫ x in O, q x * partialDeriv i φ x) at hq' |
| 98 | rw [partial_comm hφ i j] at hp' |
| 99 | change (∫ x in O, p x * partialDeriv j φ x) = -(∫ x in O, r x * φ x) at hr' |
| 100 | change (∫ x in O, q x * partialDeriv i φ x) = -(∫ x in O, s x * φ x) at hs' |
| 101 | have heq : (∫ x in O, r x * φ x) = ∫ x in O, s x * φ x := by linarith |
| 102 | have hzero : ∀ x, x ∉ O → φ x • (r - s) x = 0 := by |
| 103 | intro x hx |
| 104 | simp [image_eq_zero_of_notMem_tsupport (fun h => hx (hφO h))] |
| 105 | rw [← setIntegral_eq_integral_of_forall_compl_eq_zero hzero] |
| 106 | simp only [Pi.sub_apply, smul_eq_mul, mul_sub] |
| 107 | have hrφ := integrable_mul_test hrint hφ hφc |
| 108 | have hsφ := integrable_mul_test hsint hφ hφc |
| 109 | simp_rw [mul_comm (φ _)] |
| 110 | rw [integral_sub hrφ hsφ, heq, sub_self] |
| 111 | |
| 112 | end Poincare.Analysis.Elliptic.Iteration |