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.Geometry.RicciFlow.ReducedGeometry.ReducedLength.Minimum.Variational.Recovery.Primitive |
| 2 | import Mathlib.MeasureTheory.Integral.IntervalIntegral.AbsolutelyContinuousFun |
| 3 | import Mathlib.Analysis.Distribution.AEEqOfIntegralContDiff |
| 4 | |
| 5 | /-! |
| 6 | # Weak momentum primitives |
| 7 | |
| 8 | An integrable momentum satisfying the weak Euler identity agrees almost |
| 9 | everywhere with a continuous integral primitive of its force. |
| 10 | -/ |
| 11 | |
| 12 | /-! |
| 13 | Adapted from Mapher `Proofs/M08/WeakMomentum.lean`, commit |
| 14 | `49331b7d7ecad38f53e4300c3b35d6a84b2cc648`. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | set_option backward.isDefEq.respectTransparency false |
| 19 | |
| 20 | open MeasureTheory Set Filter Topology |
| 21 | open scoped intervalIntegral ContDiff |
| 22 | |
| 23 | namespace PoincareMT.ReducedLengthMinimum.Variational |
| 24 | |
| 25 | theorem smooth_zero_integral_compact_primitive {a b : ℝ} (hab : a < b) |
| 26 | (d : ℝ → ℝ) (hd : ContDiff ℝ ∞ d) (hds : tsupport d ⊆ Ioo a b) |
| 27 | (hdint : (∫ s in a..b, d s) = 0) : |
| 28 | ∃ f : ℝ → ℝ, ContDiff ℝ ∞ f ∧ HasCompactSupport f ∧ |
| 29 | tsupport f ⊆ Ioo a b ∧ deriv f = d := by |
| 30 | obtain ⟨f, hf, hfa, hfb, hfd⟩ := smooth_primitive_fixed_endpoints hab 0 0 d hd |
| 31 | have hderiv (s : ℝ) : HasDerivAt f (d s) s := by |
| 32 | simpa only [hdint, sub_zero, smul_zero, add_zero] using hfd s |
| 33 | have hleft {s : ℝ} (hs : s ≤ a) : f s = 0 := |
| 34 | (primitive_eq_left_of_support hd.continuous hderiv hds hs).trans hfa |
| 35 | have hright {s : ℝ} (hs : b ≤ s) : f s = 0 := |
| 36 | (primitive_eq_right_of_support hd.continuous hderiv hds hs).trans hfb |
| 37 | have hsupp : Function.support f ⊆ Icc a b := by |
| 38 | intro s hs |
| 39 | constructor |
| 40 | · by_contra h |
| 41 | exact hs (hleft (le_of_not_ge h)) |
| 42 | · by_contra h |
| 43 | exact hs (hright (le_of_not_ge h)) |
| 44 | have htsupp : tsupport f ⊆ Icc a b := closure_minimal hsupp isClosed_Icc |
| 45 | have hnot (t : ℝ) (ht : t ∉ tsupport d) (hft : f t = 0) : t ∉ tsupport f := by |
| 46 | have hg : f =ᶠ[𝓝 t] fun _ ↦ 0 := by |
| 47 | simpa only [hft] using primitive_constant_germ hderiv ht |
| 48 | intro ht' |
| 49 | have hfreq := mem_closure_iff_frequently.mp ht' |
| 50 | obtain ⟨s, hs, hzero⟩ := (hfreq.and_eventually hg).exists |
| 51 | exact hs hzero |
| 52 | have ha : a ∉ tsupport f := hnot a |
| 53 | (fun h ↦ (lt_irrefl a) (hds h).1) hfa |
| 54 | have hb : b ∉ tsupport f := hnot b |
| 55 | (fun h ↦ (lt_irrefl b) (hds h).2) hfb |
| 56 | refine ⟨f, hf, isCompact_Icc.of_isClosed_subset (isClosed_tsupport f) htsupp, ?_, ?_⟩ |
| 57 | · intro s hs |
| 58 | exact ⟨lt_of_le_of_ne (htsupp hs).1 (fun h ↦ ha (h ▸ hs)), |
| 59 | lt_of_le_of_ne (htsupp hs).2 (fun h ↦ hb (h ▸ hs))⟩ |
| 60 | · funext s |
| 61 | exact (hderiv s).deriv |
| 62 | |
| 63 | theorem scalar_primitive_integration_by_parts {a b : ℝ} |
| 64 | {Q φ : ℝ → ℝ} (hQ : IntervalIntegrable Q volume a b) |
| 65 | (hφ : ContDiff ℝ ∞ φ) (hφa : φ a = 0) (hφb : φ b = 0) : |
| 66 | (∫ s in a..b, deriv φ s * (∫ r in a..s, Q r)) = |
| 67 | -(∫ s in a..b, φ s * Q s) := by |
| 68 | have hH := hQ.absolutelyContinuousOnInterval_intervalIntegral (c := a) left_mem_uIcc |
| 69 | have hφac : AbsolutelyContinuousOnInterval φ a b := |
| 70 | (hφ.of_le (by norm_num : (1 : ℕ∞ω) ≤ ∞)).contDiffOn.absolutelyContinuousOnInterval |
| 71 | have hparts := hH.integral_mul_deriv_eq_deriv_mul hφac |
| 72 | have heq : (∫ s in a..b, deriv (fun t ↦ ∫ r in a..t, Q r) s * φ s) = |
| 73 | ∫ s in a..b, Q s * φ s := by |
| 74 | apply intervalIntegral.integral_congr_ae |
| 75 | filter_upwards [hQ.ae_hasDerivAt_integral] with s hs hmem |
| 76 | rw [(hs (uIoc_subset_uIcc hmem) a left_mem_uIcc).deriv] |
| 77 | rw [heq, hφa, hφb] at hparts |
| 78 | simpa only [mul_zero, zero_mul, sub_self, zero_sub, mul_comm] using hparts |
| 79 | |
| 80 | variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] |
| 81 | |
| 82 | theorem weak_derivative_zero_ae_const {a b : ℝ} (hab : a < b) |
| 83 | (R : ℝ → E) (hR : IntervalIntegrable R volume a b) |
| 84 | (hweak : ∀ φ : ℝ → ℝ, ContDiff ℝ ∞ φ → HasCompactSupport φ → |
| 85 | tsupport φ ⊆ Ioo a b → (∫ s in a..b, deriv φ s • R s) = 0) : |
| 86 | ∃ c : E, ∀ᵐ s ∂volume.restrict (Icc a b), R s = c := by |
| 87 | obtain ⟨β, hβ, hβc, hβs, hβint⟩ := exists_interior_normalized_bump hab |
| 88 | let c : E := ∫ s in a..b, β s • R s |
| 89 | have htest (ψ : ℝ → ℝ) (hψ : ContDiff ℝ ∞ ψ) (hψc : HasCompactSupport ψ) |
| 90 | (hψs : tsupport ψ ⊆ Ioo a b) : |
| 91 | (∫ s in a..b, ψ s • (R s - c)) = 0 := by |
| 92 | let z : ℝ := ∫ s in a..b, ψ s |
| 93 | let d : ℝ → ℝ := fun s ↦ ψ s - z * β s |
| 94 | have hd : ContDiff ℝ ∞ d := hψ.sub (contDiff_const.mul hβ) |
| 95 | have hds : tsupport d ⊆ Ioo a b := |
| 96 | (tsupport_sub ψ (fun s ↦ z * β s)).trans |
| 97 | (union_subset hψs (tsupport_mul_subset_right.trans hβs)) |
| 98 | have hdint : (∫ s in a..b, d s) = 0 := by |
| 99 | change (∫ s in a..b, ψ s - z * β s) = 0 |
| 100 | rw [intervalIntegral.integral_sub (f := ψ) (g := fun s ↦ z * β s) |
| 101 | (hψ.continuous.intervalIntegrable a b) |
| 102 | (((continuous_const (y := z)).mul hβ.continuous).intervalIntegrable a b), |
| 103 | intervalIntegral.integral_const_mul, hβint, mul_one] |
| 104 | exact sub_self z |
| 105 | obtain ⟨f, hf, hfc, hfs, hfderiv⟩ := |
| 106 | smooth_zero_integral_compact_primitive hab d hd hds hdint |
| 107 | have hzero := hweak f hf hfc hfs |
| 108 | rw [hfderiv] at hzero |
| 109 | have hintψ : IntervalIntegrable (fun s ↦ ψ s • R s) volume a b := |
| 110 | hR.continuousOn_smul hψ.continuous.continuousOn |
| 111 | have hintβ : IntervalIntegrable (fun s ↦ β s • R s) volume a b := |
| 112 | hR.continuousOn_smul hβ.continuous.continuousOn |
| 113 | have hmain : (∫ s in a..b, ψ s • R s) - z • c = 0 := by |
| 114 | simp only [d, sub_smul, mul_smul] at hzero |
| 115 | rw [intervalIntegral.integral_sub (f := fun s ↦ ψ s • R s) |
| 116 | (g := fun s ↦ z • (β s • R s)) hintψ (hintβ.smul z), |
| 117 | intervalIntegral.integral_smul] at hzero |
| 118 | exact hzero |
| 119 | simp_rw [smul_sub] |
| 120 | rw [intervalIntegral.integral_sub (f := fun s ↦ ψ s • R s) |
| 121 | (g := fun s ↦ ψ s • c) hintψ |
| 122 | ((hψ.continuous.smul (continuous_const (y := c))).intervalIntegrable a b), |
| 123 | intervalIntegral.integral_smul_const] |
| 124 | exact hmain |
| 125 | have hRIoo : IntegrableOn R (Ioo a b) volume := |
| 126 | (intervalIntegrable_iff_integrableOn_Ioo_of_le hab.le).mp hR |
| 127 | have hlocal : LocallyIntegrableOn (fun s ↦ R s - c) (Ioo a b) volume := |
| 128 | hRIoo.locallyIntegrableOn.sub (locallyIntegrableOn_const c) |
| 129 | have hae := isOpen_Ioo.ae_eq_zero_of_integral_contDiff_smul_eq_zero hlocal |
| 130 | (fun ψ hψ hψc hψs ↦ by |
| 131 | rw [← intervalIntegral.integral_eq_integral_of_support_subset |
| 132 | (f := fun s ↦ ψ s • (R s - c)) |
| 133 | ((Function.support_smul_subset_left ψ (fun s ↦ R s - c)).trans |
| 134 | ((subset_tsupport ψ).trans (hψs.trans Ioo_subset_Ioc_self)))] |
| 135 | exact htest ψ hψ hψc hψs) |
| 136 | refine ⟨c, ?_⟩ |
| 137 | rw [← restrict_Ioo_eq_restrict_Icc, ae_restrict_iff' measurableSet_Ioo] |
| 138 | filter_upwards [hae] with s hs hmem |
| 139 | exact sub_eq_zero.mp (hs hmem) |
| 140 | |
| 141 | section InnerProduct |
| 142 | |
| 143 | variable {F : Type*} [NormedAddCommGroup F] [InnerProductSpace ℝ F] [CompleteSpace F] |
| 144 | |
| 145 | theorem primitive_integration_by_parts {a b : ℝ} |
| 146 | {Q : ℝ → F} {φ : ℝ → ℝ} (hQ : IntervalIntegrable Q volume a b) |
| 147 | (hφ : ContDiff ℝ ∞ φ) (hφa : φ a = 0) (hφb : φ b = 0) : |
| 148 | (∫ s in a..b, deriv φ s • (∫ r in a..s, Q r)) = |
| 149 | -(∫ s in a..b, φ s • Q s) := by |
| 150 | have hHcont : ContinuousOn (fun s ↦ ∫ r in a..s, Q r) (uIcc a b) := |
| 151 | intervalIntegral.continuousOn_primitive_interval' hQ left_mem_uIcc |
| 152 | have hL : IntervalIntegrable |
| 153 | (fun s ↦ deriv φ s • (∫ r in a..s, Q r)) volume a b := |
| 154 | ((hφ.continuous_deriv (by norm_num)).intervalIntegrable a b).smul_continuousOn hHcont |
| 155 | have hR : IntervalIntegrable (fun s ↦ φ s • Q s) volume a b := |
| 156 | hQ.continuousOn_smul hφ.continuous.continuousOn |
| 157 | apply ext_inner_left ℝ |
| 158 | intro z |
| 159 | let l : F →L[ℝ] ℝ := innerSL ℝ z |
| 160 | have hQl : IntervalIntegrable (fun s ↦ l (Q s)) volume a b := |
| 161 | ⟨l.integrable_comp hQ.1, l.integrable_comp hQ.2⟩ |
| 162 | have hprimitive (s : ℝ) (hs : s ∈ uIcc a b) : |
| 163 | l (∫ r in a..s, Q r) = ∫ r in a..s, l (Q r) := |
| 164 | (l.intervalIntegral_comp_comm (hQ.mono_set (uIcc_subset_uIcc left_mem_uIcc hs))).symm |
| 165 | change l (∫ s in a..b, deriv φ s • (∫ r in a..s, Q r)) = |
| 166 | l (-(∫ s in a..b, φ s • Q s)) |
| 167 | rw [map_neg, ← l.intervalIntegral_comp_comm hL, ← l.intervalIntegral_comp_comm hR] |
| 168 | simp only [map_smul, smul_eq_mul] |
| 169 | calc |
| 170 | _ = ∫ s in a..b, deriv φ s * (∫ r in a..s, l (Q r)) := by |
| 171 | apply intervalIntegral.integral_congr |
| 172 | intro s hs |
| 173 | exact congrArg (fun v : ℝ ↦ deriv φ s * v) (hprimitive s hs) |
| 174 | _ = _ := scalar_primitive_integration_by_parts hQl hφ hφa hφb |
| 175 | |
| 176 | theorem weak_momentum_primitive {a b : ℝ} (hab : a < b) |
| 177 | (P Q : ℝ → F) (hP : IntervalIntegrable P volume a b) |
| 178 | (hQ : IntervalIntegrable Q volume a b) |
| 179 | (hweak : ∀ φ : ℝ → ℝ, ContDiff ℝ ∞ φ → HasCompactSupport φ → |
| 180 | tsupport φ ⊆ Ioo a b → (∫ s in a..b, deriv φ s • P s) = |
| 181 | -(∫ s in a..b, φ s • Q s)) : |
| 182 | ∃ c : F, ∀ᵐ s ∂volume.restrict (Icc a b), |
| 183 | P s = c + ∫ r in a..s, Q r := by |
| 184 | let H : ℝ → F := fun s ↦ ∫ r in a..s, Q r |
| 185 | have hHcont : ContinuousOn H (uIcc a b) := |
| 186 | intervalIntegral.continuousOn_primitive_interval' hQ left_mem_uIcc |
| 187 | obtain ⟨c, hc⟩ := weak_derivative_zero_ae_const hab (fun s ↦ P s - H s) |
| 188 | (hP.sub hHcont.intervalIntegrable) (fun φ hφ hφc hφs ↦ by |
| 189 | have hφa : φ a = 0 := image_eq_zero_of_notMem_tsupport |
| 190 | (fun h ↦ (lt_irrefl a) (hφs h).1) |
| 191 | have hφb : φ b = 0 := image_eq_zero_of_notMem_tsupport |
| 192 | (fun h ↦ (lt_irrefl b) (hφs h).2) |
| 193 | have hD : Continuous (deriv φ) := hφ.continuous_deriv (by norm_num) |
| 194 | simp_rw [smul_sub] |
| 195 | rw [intervalIntegral.integral_sub (f := fun s ↦ deriv φ s • P s) |
| 196 | (g := fun s ↦ deriv φ s • H s) |
| 197 | (hP.continuousOn_smul hD.continuousOn) |
| 198 | ((hD.intervalIntegrable a b).smul_continuousOn hHcont), |
| 199 | hweak φ hφ hφc hφs] |
| 200 | change -(∫ s in a..b, φ s • Q s) - |
| 201 | (∫ s in a..b, deriv φ s • (∫ r in a..s, Q r)) = 0 |
| 202 | rw [primitive_integration_by_parts hQ hφ hφa hφb, sub_self]) |
| 203 | refine ⟨c, hc.mono ?_⟩ |
| 204 | intro s hs |
| 205 | exact sub_eq_iff_eq_add.mp hs |
| 206 | |
| 207 | end InnerProduct |
| 208 | |
| 209 | end PoincareMT.ReducedLengthMinimum.Variational |
| 210 |