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.Rademacher |
| 2 | import Mathlib.Analysis.Calculus.ContDiff.Operations |
| 3 | |
| 4 | /-! |
| 5 | # Weak Green identities for Lipschitz functions |
| 6 | |
| 7 | The actual Frechet derivative of a locally Lipschitz function satisfies |
| 8 | integration by parts against compact smooth tests. A Lipschitz extension is |
| 9 | used only to invoke Rademacher's theorem and directional integration by parts. |
| 10 | |
| 11 | Adapted from AxelWorkspace, `WeakBusemann/LipschitzGreen.lean`, revision |
| 12 | `f1cdb30cabdc8781d2d3dec86d3d99ab1820f30e`. |
| 13 | -/ |
| 14 | |
| 15 | noncomputable section |
| 16 | |
| 17 | open Set Filter MeasureTheory |
| 18 | open scoped ContDiff Topology NNReal |
| 19 | |
| 20 | namespace Poincare.Analysis.WeakDerivative |
| 21 | |
| 22 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 23 | [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] |
| 24 | |
| 25 | /-- Rademacher's theorem on an open set for any additive Haar measure. -/ |
| 26 | theorem ae_differentiableAt_of_lipschitzOn |
| 27 | (μ : Measure E) [μ.IsAddHaarMeasure] {U : Set E} (hU : IsOpen U) |
| 28 | {f : E → ℝ} {C : ℝ≥0} (hf : LipschitzOnWith C f U) : |
| 29 | ∀ᵐ x ∂μ, x ∈ U → DifferentiableAt ℝ f x := by |
| 30 | obtain ⟨F, hF, heq⟩ := hf.extend_real |
| 31 | filter_upwards [hF.ae_differentiableAt (μ := μ)] with x hx hxU |
| 32 | exact hx.congr_of_eventuallyEq (heq.eventuallyEq_of_mem (hU.mem_nhds hxU)) |
| 33 | |
| 34 | /-- Directional weak Green identity, with integrability of both sides. -/ |
| 35 | theorem integral_mul_fderiv_eq_neg |
| 36 | (μ : Measure E) [μ.IsAddHaarMeasure] {U : Set E} (hU : IsOpen U) |
| 37 | {f w : E → ℝ} {C : ℝ≥0} (hf : LipschitzOnWith C f U) |
| 38 | (hw : ContDiff ℝ ∞ w) (hwc : HasCompactSupport w) |
| 39 | (hwU : tsupport w ⊆ U) (v : E) : |
| 40 | Integrable (fun x => fderiv ℝ f x v * w x) μ ∧ |
| 41 | Integrable (fun x => f x * fderiv ℝ w x v) μ ∧ |
| 42 | (∫ x, f x * fderiv ℝ w x v ∂μ) = |
| 43 | -∫ x, fderiv ℝ f x v * w x ∂μ := by |
| 44 | obtain ⟨F, hF, heq⟩ := hf.extend_real |
| 45 | have hderiv : ∀ x ∈ U, fderiv ℝ f x = fderiv ℝ F x := by |
| 46 | intro x hx |
| 47 | exact (heq.eventuallyEq_of_mem (hU.mem_nhds hx)).fderiv_eq |
| 48 | have hpair : (fun x => fderiv ℝ f x v * w x) =ᵐ[μ] |
| 49 | (fun x => lineDeriv ℝ F x v * w x) := by |
| 50 | filter_upwards [hF.ae_differentiableAt (μ := μ)] with x hx |
| 51 | by_cases hxw : x ∈ tsupport w |
| 52 | · rw [hderiv x (hwU hxw), hx.lineDeriv_eq_fderiv] |
| 53 | · simp [image_eq_zero_of_notMem_tsupport hxw] |
| 54 | have hwp : (fun x => f x * fderiv ℝ w x v) = |
| 55 | (fun x => F x * fderiv ℝ w x v) := by |
| 56 | funext x |
| 57 | by_cases hxw : x ∈ tsupport w |
| 58 | · rw [heq (hwU hxw)] |
| 59 | · rw [image_eq_zero_of_notMem_tsupport |
| 60 | (fun hx => hxw (tsupport_fderiv_apply_subset ℝ v hx)), mul_zero, mul_zero] |
| 61 | have hdw : ContDiff ℝ ∞ (fun x => fderiv ℝ w x v) := |
| 62 | (hw.fderiv_right (by simp)).clm_apply contDiff_const |
| 63 | have hwi := hw.continuous.integrable_of_hasCompactSupport (μ := μ) hwc |
| 64 | have hpairInt : Integrable (fun x => lineDeriv ℝ F x v * w x) μ := |
| 65 | hwi.mul_of_top_right (hF.memLp_lineDeriv _) |
| 66 | have hwpInt : Integrable (fun x => F x * fderiv ℝ w x v) μ := |
| 67 | (hF.continuous.mul hdw.continuous).integrable_of_hasCompactSupport |
| 68 | (hwc.fderiv_apply ℝ v).mul_left |
| 69 | refine ⟨hpairInt.congr hpair.symm, hwp ▸ hwpInt, ?_⟩ |
| 70 | obtain ⟨D, hD⟩ := ContDiff.lipschitzWith_of_hasCompactSupport hwc hw (by simp) |
| 71 | have hibp := hF.integral_lineDeriv_mul_eq (μ := μ) hD hwc v |
| 72 | simp_rw [(hw.differentiable (by simp)).differentiableAt.lineDeriv_eq_fderiv, |
| 73 | map_neg, neg_mul, integral_neg] at hibp |
| 74 | rw [hwp, integral_congr_ae hpair] |
| 75 | simpa only [mul_comm, neg_neg] using congrArg Neg.neg hibp.symm |
| 76 | |
| 77 | /-- Integration by parts for a finite smooth compactly supported flux. -/ |
| 78 | theorem integral_mul_sum_fderiv_eq_neg |
| 79 | (μ : Measure E) [μ.IsAddHaarMeasure] {U : Set E} (hU : IsOpen U) |
| 80 | {f : E → ℝ} {C : ℝ≥0} (hf : LipschitzOnWith C f U) |
| 81 | {ι : Type*} [Fintype ι] (v : ι → E) (w : ι → E → ℝ) |
| 82 | (hw : ∀ i, ContDiff ℝ ∞ (w i)) (hwc : ∀ i, HasCompactSupport (w i)) |
| 83 | (hwU : ∀ i, tsupport (w i) ⊆ U) : |
| 84 | Integrable (fun x => ∑ i, fderiv ℝ f x (v i) * w i x) μ ∧ |
| 85 | Integrable (fun x => f x * ∑ i, fderiv ℝ (w i) x (v i)) μ ∧ |
| 86 | (∫ x, f x * ∑ i, fderiv ℝ (w i) x (v i) ∂μ) = |
| 87 | -∫ x, ∑ i, fderiv ℝ f x (v i) * w i x ∂μ := by |
| 88 | classical |
| 89 | have hscalar i := integral_mul_fderiv_eq_neg μ hU hf (hw i) (hwc i) (hwU i) (v i) |
| 90 | simp_rw [Finset.mul_sum] |
| 91 | refine ⟨integrable_finsetSum _ (fun i _ => (hscalar i).1), |
| 92 | integrable_finsetSum _ (fun i _ => (hscalar i).2.1), ?_⟩ |
| 93 | rw [integral_finsetSum _ (fun i _ => (hscalar i).2.1), |
| 94 | integral_finsetSum _ (fun i _ => (hscalar i).1), ← Finset.sum_neg_distrib] |
| 95 | exact Finset.sum_congr rfl fun i _ => (hscalar i).2.2 |
| 96 | |
| 97 | end Poincare.Analysis.WeakDerivative |