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.Calculus.WeakDerivative.LipschitzGreen |
| 2 | import Mathlib.Analysis.Distribution.AEEqOfIntegralContDiff |
| 3 | import Mathlib.MeasureTheory.Integral.DominatedConvergence |
| 4 | |
| 5 | /-! # Identification of almost-everywhere directional derivative limits -/ |
| 6 | |
| 7 | noncomputable section |
| 8 | set_option autoImplicit false |
| 9 | set_option backward.isDefEq.respectTransparency false |
| 10 | |
| 11 | open Set Filter MeasureTheory |
| 12 | open scoped ContDiff Topology NNReal ENNReal |
| 13 | |
| 14 | namespace Poincare.Analysis.Elliptic |
| 15 | |
| 16 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] |
| 17 | [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] |
| 18 | {μ : Measure E} [μ.IsAddHaarMeasure] |
| 19 | |
| 20 | theorem memLp_top_directional_fderiv_of_lipschitzOn |
| 21 | {U : Set E} (hU : IsOpen U) {u : E → ℝ} {L : ℝ≥0} |
| 22 | (hu : LipschitzOnWith L u U) (w : E) : |
| 23 | MemLp (fun x => fderiv ℝ u x w) ∞ (μ.restrict U) := by |
| 24 | obtain ⟨v, hv, heq⟩ := hu.extend_real |
| 25 | refine (memLp_congr_ae ?_).mp (hv.memLp_lineDeriv (μ := μ.restrict U) w) |
| 26 | filter_upwards [ae_restrict_mem hU.measurableSet, |
| 27 | ae_restrict_of_ae (hv.ae_differentiableAt (μ := μ))] with x hx hdx |
| 28 | have hnear : u =ᶠ[𝓝 x] v := heq.eventuallyEq_of_mem (hU.mem_nhds hx) |
| 29 | rw [hdx.lineDeriv_eq_fderiv, hnear.fderiv_eq] |
| 30 | |
| 31 | theorem setIntegral_mul_fderiv_eq_neg_of_lipschitzOn |
| 32 | {U : Set E} (hU : IsOpen U) {u φ : E → ℝ} {L : ℝ≥0} |
| 33 | (hu : LipschitzOnWith L u U) (hφ : ContDiff ℝ ∞ φ) |
| 34 | (hφc : HasCompactSupport φ) (hφU : tsupport φ ⊆ U) (w : E) : |
| 35 | (∫ x in U, u x * fderiv ℝ φ x w ∂μ) = |
| 36 | -(∫ x in U, fderiv ℝ u x w * φ x ∂μ) := by |
| 37 | have h := WeakDerivative.integral_mul_fderiv_eq_neg μ hU hu hφ hφc hφU w |
| 38 | have hleft : (∫ x in U, u x * fderiv ℝ φ x w ∂μ) = |
| 39 | ∫ x, u x * fderiv ℝ φ x w ∂μ := |
| 40 | setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => by |
| 41 | rw [image_eq_zero_of_notMem_tsupport |
| 42 | (fun h => hx (hφU (tsupport_fderiv_apply_subset ℝ w h))), mul_zero]) |
| 43 | have hright : (∫ x in U, fderiv ℝ u x w * φ x ∂μ) = |
| 44 | ∫ x, fderiv ℝ u x w * φ x ∂μ := |
| 45 | setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => by |
| 46 | rw [image_eq_zero_of_notMem_tsupport (fun h => hx (hφU h)), mul_zero]) |
| 47 | rw [hleft, hright] |
| 48 | exact h.2.2 |
| 49 | |
| 50 | theorem ae_directional_fderiv_eq_of_tendsto |
| 51 | {U : Set E} (hU : IsOpen U) [IsFiniteMeasure (μ.restrict U)] |
| 52 | {u : ℕ → E → ℝ} {v F : E → ℝ} {L : ℝ≥0} {C : ℝ} |
| 53 | (hu : ∀ᶠ k in atTop, LipschitzOnWith L (u k) U) |
| 54 | (hv : LipschitzOnWith L v U) |
| 55 | (hub : ∀ᶠ k in atTop, ∀ x ∈ U, ‖u k x‖ ≤ C) |
| 56 | (hlim : ∀ x ∈ U, Tendsto (fun k => u k x) atTop (𝓝 (v x))) |
| 57 | (w : E) (hF : IntegrableOn F U μ) |
| 58 | (hdlim : ∀ᵐ x ∂μ.restrict U, |
| 59 | Tendsto (fun k => fderiv ℝ (u k) x w) atTop (𝓝 (F x))) : |
| 60 | (fun x => fderiv ℝ v x w) =ᵐ[μ.restrict U] F := by |
| 61 | have hdv := memLp_top_directional_fderiv_of_lipschitzOn (μ := μ) hU hv w |
| 62 | have hdvi : IntegrableOn (fun x => fderiv ℝ v x w) U μ := hdv.integrable le_top |
| 63 | have hzero := hU.ae_eq_zero_of_integral_contDiff_smul_eq_zero |
| 64 | ((hF.sub hdvi).locallyIntegrableOn) (fun φ hφ hφc hφU => by |
| 65 | change (∫ x, φ x • (F x - fderiv ℝ v x w) ∂μ) = 0 |
| 66 | have hφi : IntegrableOn φ U μ := |
| 67 | (hφ.continuous.integrable_of_hasCompactSupport (μ := μ) hφc).integrableOn |
| 68 | have hφd : ContDiff ℝ ∞ (fun x => fderiv ℝ φ x w) := |
| 69 | (hφ.fderiv_right (by simp)).clm_apply contDiff_const |
| 70 | have hφdi : IntegrableOn (fun x => fderiv ℝ φ x w) U μ := |
| 71 | (hφd.continuous.integrable_of_hasCompactSupport |
| 72 | (μ := μ) (hφc.fderiv_apply ℝ w)).integrableOn |
| 73 | have hut : Tendsto (fun k => ∫ x in U, u k x * fderiv ℝ φ x w ∂μ) atTop |
| 74 | (𝓝 (∫ x in U, v x * fderiv ℝ φ x w ∂μ)) := by |
| 75 | apply tendsto_integral_filter_of_dominated_convergence |
| 76 | (fun x => C * ‖fderiv ℝ φ x w‖) |
| 77 | · exact hu.mono fun k hk => |
| 78 | (hk.continuousOn.aestronglyMeasurable hU.measurableSet).mul |
| 79 | hφd.continuous.aestronglyMeasurable |
| 80 | · filter_upwards [hub] with k hk |
| 81 | filter_upwards [ae_restrict_mem hU.measurableSet] with x hx |
| 82 | rw [norm_mul] |
| 83 | exact mul_le_mul_of_nonneg_right (hk x hx) (norm_nonneg _) |
| 84 | · exact hφdi.norm.const_mul C |
| 85 | · filter_upwards [ae_restrict_mem hU.measurableSet] with x hx |
| 86 | exact (hlim x hx).mul_const _ |
| 87 | have hdt : Tendsto (fun k => ∫ x in U, fderiv ℝ (u k) x w * φ x ∂μ) atTop |
| 88 | (𝓝 (∫ x in U, F x * φ x ∂μ)) := by |
| 89 | apply tendsto_integral_filter_of_dominated_convergence |
| 90 | (fun x => (L : ℝ) * ‖w‖ * ‖φ x‖) |
| 91 | · exact hu.mono fun k hk => |
| 92 | (memLp_top_directional_fderiv_of_lipschitzOn (μ := μ) hU hk w).aestronglyMeasurable.mul |
| 93 | hφ.continuous.aestronglyMeasurable |
| 94 | · filter_upwards [hu] with k hk |
| 95 | filter_upwards [ae_restrict_mem hU.measurableSet] with x hx |
| 96 | rw [norm_mul] |
| 97 | apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) |
| 98 | exact ((fderiv ℝ (u k) x).le_opNorm w).trans |
| 99 | (mul_le_mul_of_nonneg_right |
| 100 | (norm_fderiv_le_of_lipschitzOn ℝ (hU.mem_nhds hx) hk) (norm_nonneg _)) |
| 101 | · exact hφi.norm.const_mul ((L : ℝ) * ‖w‖) |
| 102 | · exact hdlim.mono fun x hx => hx.mul_const _ |
| 103 | have hid : (∫ x in U, v x * fderiv ℝ φ x w ∂μ) = -(∫ x in U, F x * φ x ∂μ) := by |
| 104 | apply tendsto_nhds_unique hut |
| 105 | apply hdt.neg.congr' |
| 106 | filter_upwards [hu] with k hk |
| 107 | exact (setIntegral_mul_fderiv_eq_neg_of_lipschitzOn hU hk hφ hφc hφU w).symm |
| 108 | have hvibp := setIntegral_mul_fderiv_eq_neg_of_lipschitzOn |
| 109 | (μ := μ) hU hv hφ hφc hφU w |
| 110 | have hpair : (∫ x in U, F x * φ x ∂μ) = ∫ x in U, fderiv ℝ v x w * φ x ∂μ := by |
| 111 | linarith |
| 112 | obtain ⟨D, hD⟩ := hφc.exists_bound_of_continuous hφ.continuous |
| 113 | have hFφ : IntegrableOn (fun x => F x * φ x) U μ := |
| 114 | hF.mul_bdd hφ.continuous.aestronglyMeasurable (Eventually.of_forall hD) |
| 115 | have hdφ : IntegrableOn (fun x => fderiv ℝ v x w * φ x) U μ := |
| 116 | hdvi.mul_bdd hφ.continuous.aestronglyMeasurable (Eventually.of_forall hD) |
| 117 | have heq : (∫ x in U, φ x • (F x - fderiv ℝ v x w) ∂μ) = |
| 118 | ∫ x, φ x • (F x - fderiv ℝ v x w) ∂μ := |
| 119 | setIntegral_eq_integral_of_forall_compl_eq_zero (fun x hx => by |
| 120 | rw [image_eq_zero_of_notMem_tsupport (fun h => hx (hφU h)), zero_smul]) |
| 121 | rw [← heq] |
| 122 | simp_rw [smul_eq_mul, mul_sub, mul_comm (φ _)] |
| 123 | rw [integral_sub hFφ hdφ, hpair, sub_self]) |
| 124 | filter_upwards [ae_restrict_of_ae hzero, ae_restrict_mem hU.measurableSet] with x hx hxU |
| 125 | exact (sub_eq_zero.mp (hx hxU)).symm |
| 126 | |
| 127 | end Poincare.Analysis.Elliptic |