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 | /- Adapted from Mapher `PoincareMT/Proofs/M03/LocalizedDivergenceFlux.lean` at |
| 2 | f927d9e1f0810042766d3b5f64d3f4da02ee93cc. See |
| 3 | `references/ricci-flow/mapher/local-theory/port.json`. -/ |
| 4 | |
| 5 | import PoincareLib.Geometry.RicciFlow.Local.Energy.Localization.CoordinateIntegration |
| 6 | |
| 7 | /-! |
| 8 | # Localized divergence flux estimate |
| 9 | |
| 10 | Directional integration by parts and two Young inequalities control the |
| 11 | divergence integral. The cutoff constant is chosen before the fields and |
| 12 | the absorption parameter. |
| 13 | Derivation: proof-work/tasks/M03/localized-divergence-flux-lead.md. |
| 14 | -/ |
| 15 | |
| 16 | set_option autoImplicit false |
| 17 | |
| 18 | open scoped ContDiff Topology BigOperators |
| 19 | open MeasureTheory Set |
| 20 | |
| 21 | namespace PoincareMT.RicciFlow.Local |
| 22 | |
| 23 | theorem exists_localized_divergence_flux_bound |
| 24 | {n : ℕ} {V : Set (EuclideanSpace ℝ (Fin n))} (hV : IsOpen V) |
| 25 | {φ : EuclideanSpace ℝ (Fin n) → ℝ} |
| 26 | (hφ : ContDiff ℝ 1 φ) (hφc : HasCompactSupport φ) |
| 27 | (hφV : tsupport φ ⊆ V) : |
| 28 | letI : MeasurableSpace (EuclideanSpace ℝ (Fin n)) := borel _ |
| 29 | letI : BorelSpace (EuclideanSpace ℝ (Fin n)) := ⟨rfl⟩ |
| 30 | ∃ A : ℝ, 0 ≤ A ∧ ∀ epsilon : ℝ, 0 < epsilon → |
| 31 | ∀ f : EuclideanSpace ℝ (Fin n) → ℝ, |
| 32 | ContDiffOn ℝ 1 f V → |
| 33 | ∀ U : EuclideanSpace ℝ (Fin n) → Fin n → ℝ, |
| 34 | (∀ i, ContDiffOn ℝ 1 (fun x => U x i) V) → |
| 35 | (∫ x, φ x ^ 2 * f x * |
| 36 | ∑ i, fderiv ℝ (fun y => U y i) x (EuclideanSpace.single i 1)) ≤ |
| 37 | epsilon * (∫ x, φ x ^ 2 * |
| 38 | ∑ i, (fderiv ℝ f x (EuclideanSpace.single i 1)) ^ 2) + |
| 39 | A * (∫ x in tsupport φ, f x ^ 2) + |
| 40 | (1 + 1 / (4 * epsilon)) * (∫ x, φ x ^ 2 * ∑ i, (U x i) ^ 2) := by |
| 41 | let : MeasurableSpace (EuclideanSpace ℝ (Fin n)) := borel _ |
| 42 | let : BorelSpace (EuclideanSpace ℝ (Fin n)) := ⟨rfl⟩ |
| 43 | classical |
| 44 | let e (i : Fin n) : EuclideanSpace ℝ (Fin n) := EuclideanSpace.single i 1 |
| 45 | let d (i : Fin n) (x : EuclideanSpace ℝ (Fin n)) : ℝ := fderiv ℝ φ x (e i) |
| 46 | let S (x : EuclideanSpace ℝ (Fin n)) : ℝ := ∑ i, d i x ^ 2 |
| 47 | have hd (i : Fin n) : Continuous (d i) := |
| 48 | (hφ.continuous_fderiv (by decide)).clm_apply continuous_const |
| 49 | have hS : Continuous S := continuous_finsetSum _ (fun i _ => (hd i).pow 2) |
| 50 | obtain ⟨b, hb⟩ := hφc.exists_bound_of_continuousOn hS.continuousOn |
| 51 | let A : ℝ := max b 0 |
| 52 | have hbound : ∀ x ∈ tsupport φ, S x ≤ A := by |
| 53 | intro x hx |
| 54 | exact (le_abs_self (S x)).trans ((hb x hx).trans (le_max_left b 0)) |
| 55 | refine ⟨A, le_max_right b 0, ?_⟩ |
| 56 | intro epsilon hepsilon f hf U hU |
| 57 | let p (i : Fin n) (x : EuclideanSpace ℝ (Fin n)) : ℝ := fderiv ℝ f x (e i) |
| 58 | have hp (i : Fin n) : ContinuousOn (p i) V := |
| 59 | (hf.continuousOn_fderiv_of_isOpen hV le_rfl).clm_apply continuousOn_const |
| 60 | have hpatch : ∀ Q : EuclideanSpace ℝ (Fin n) → ℝ, ContinuousOn Q V → |
| 61 | (∀ x ∉ tsupport φ, Q x = 0) → Integrable Q := by |
| 62 | intro Q hQ hzero |
| 63 | have hQc : HasCompactSupport Q := by |
| 64 | apply hφc.mono' |
| 65 | intro x hx |
| 66 | by_contra hxφ |
| 67 | exact hx (hzero x hxφ) |
| 68 | have hQc' : Continuous Q := by |
| 69 | apply continuous_iff_continuousAt.mpr |
| 70 | intro x |
| 71 | by_cases hx : x ∈ V |
| 72 | · exact hQ.continuousAt (hV.mem_nhds hx) |
| 73 | · have hxφ : x ∈ (tsupport φ)ᶜ := fun h => hx (hφV h) |
| 74 | apply continuousAt_const.congr_of_eventuallyEq |
| 75 | filter_upwards [(isClosed_tsupport φ).isOpen_compl.mem_nhds hxφ] with y hy |
| 76 | exact hzero y hy |
| 77 | exact hQc'.integrable_of_hasCompactSupport hQc |
| 78 | let L (i : Fin n) (x : EuclideanSpace ℝ (Fin n)) : ℝ := |
| 79 | φ x ^ 2 * f x * fderiv ℝ (fun y => U y i) x (e i) |
| 80 | let R (i : Fin n) (x : EuclideanSpace ℝ (Fin n)) : ℝ := |
| 81 | (φ x ^ 2 * p i x + 2 * φ x * d i x * f x) * U x i |
| 82 | let G (x : EuclideanSpace ℝ (Fin n)) : ℝ := φ x ^ 2 * ∑ i, p i x ^ 2 |
| 83 | let H (x : EuclideanSpace ℝ (Fin n)) : ℝ := φ x ^ 2 * ∑ i, (U x i) ^ 2 |
| 84 | have hLi (i : Fin n) : Integrable (L i) := hpatch _ |
| 85 | (((hφ.continuous.continuousOn.pow 2).mul hf.continuousOn).mul |
| 86 | (((hU i).continuousOn_fderiv_of_isOpen hV le_rfl).clm_apply continuousOn_const)) |
| 87 | (fun x hx => by simp [L, image_eq_zero_of_notMem_tsupport hx]) |
| 88 | have hRi (i : Fin n) : Integrable (R i) := hpatch _ |
| 89 | ((((hφ.continuous.continuousOn.pow 2).mul (hp i)).add |
| 90 | (((continuousOn_const.mul hφ.continuous.continuousOn).mul |
| 91 | (hd i).continuousOn).mul hf.continuousOn)).mul (hU i).continuousOn) |
| 92 | (fun x hx => by simp [R, image_eq_zero_of_notMem_tsupport hx]) |
| 93 | have hGi : Integrable G := hpatch _ |
| 94 | ((hφ.continuous.continuousOn.pow 2).mul |
| 95 | (continuousOn_finsetSum _ (fun i _ => (hp i).pow 2))) |
| 96 | (fun x hx => by simp [G, image_eq_zero_of_notMem_tsupport hx]) |
| 97 | have hHi : Integrable H := hpatch _ |
| 98 | ((hφ.continuous.continuousOn.pow 2).mul |
| 99 | (continuousOn_finsetSum _ (fun i _ => (hU i).continuousOn.pow 2))) |
| 100 | (fun x hx => by simp [H, image_eq_zero_of_notMem_tsupport hx]) |
| 101 | have hKi : Integrable ((tsupport φ).indicator (fun x => f x ^ 2)) := |
| 102 | (ContinuousOn.integrableOn_compact hφc |
| 103 | ((hf.continuousOn.pow 2).mono hφV)).integrable_indicator (isClosed_tsupport φ).measurableSet |
| 104 | have hibp (i : Fin n) : (∫ x, L i x) = -(∫ x, R i x) := |
| 105 | integral_localized_mul_fderiv hV hf (hU i) hφ hφc hφV (e i) |
| 106 | have hsum : (∫ x, ∑ i, L i x) = -(∫ x, ∑ i, R i x) := by |
| 107 | rw [integral_finsetSum _ (fun i _ => hLi i), integral_finsetSum _ (fun i _ => hRi i)] |
| 108 | simp only [hibp, Finset.sum_neg_distrib] |
| 109 | have hyoung (u v : ℝ) : -u * v ≤ epsilon * u ^ 2 + (1 / (4 * epsilon)) * v ^ 2 := by |
| 110 | apply (mul_le_mul_iff_left₀ (show 0 < 4 * epsilon by positivity)).mp |
| 111 | field_simp |
| 112 | nlinarith [sq_nonneg (2 * epsilon * u + v)] |
| 113 | have hpoint : ∀ x, -(∑ i, R i x) ≤ epsilon * G x + |
| 114 | A * (tsupport φ).indicator (fun y => f y ^ 2) x + |
| 115 | (1 + 1 / (4 * epsilon)) * H x := by |
| 116 | intro x |
| 117 | by_cases hx : x ∈ tsupport φ |
| 118 | · have hterm (i : Fin n) : -R i x ≤ epsilon * (φ x * p i x) ^ 2 + |
| 119 | (f x * d i x) ^ 2 + (1 + 1 / (4 * epsilon)) * (φ x * U x i) ^ 2 := by |
| 120 | have hfirst := hyoung (φ x * p i x) (φ x * U x i) |
| 121 | have hsecond := sq_nonneg (f x * d i x + φ x * U x i) |
| 122 | dsimp only [R] |
| 123 | nlinarith only [hfirst, hsecond] |
| 124 | have htotal : -(∑ i, R i x) ≤ epsilon * G x + f x ^ 2 * S x + |
| 125 | (1 + 1 / (4 * epsilon)) * H x := by |
| 126 | calc |
| 127 | -(∑ i, R i x) = ∑ i, -R i x := by rw [Finset.sum_neg_distrib] |
| 128 | _ ≤ ∑ i, (epsilon * (φ x * p i x) ^ 2 + (f x * d i x) ^ 2 + |
| 129 | (1 + 1 / (4 * epsilon)) * (φ x * U x i) ^ 2) := |
| 130 | Finset.sum_le_sum (fun i _ => hterm i) |
| 131 | _ = _ := by |
| 132 | simp only [G, H, S, mul_pow, Finset.sum_add_distrib, Finset.mul_sum] |
| 133 | have hrem := mul_le_mul_of_nonneg_left (hbound x hx) (sq_nonneg (f x)) |
| 134 | rw [indicator_of_mem hx] |
| 135 | nlinarith only [htotal, hrem] |
| 136 | · simp [R, G, H, indicator_of_notMem hx, image_eq_zero_of_notMem_tsupport hx] |
| 137 | change (∫ x, φ x ^ 2 * f x * ∑ i, fderiv ℝ (fun y => U y i) x (e i)) ≤ |
| 138 | epsilon * (∫ x, G x) + A * (∫ x in tsupport φ, f x ^ 2) + |
| 139 | (1 + 1 / (4 * epsilon)) * (∫ x, H x) |
| 140 | have hleft : (∫ x, φ x ^ 2 * f x * ∑ i, fderiv ℝ (fun y => U y i) x (e i)) = |
| 141 | ∫ x, ∑ i, L i x := by |
| 142 | apply integral_congr_ae |
| 143 | filter_upwards with x |
| 144 | simp only [L, Finset.mul_sum] |
| 145 | rw [hleft, hsum, ← integral_neg] |
| 146 | calc |
| 147 | (∫ x, -(∑ i, R i x)) ≤ ∫ x, epsilon * G x + |
| 148 | A * (tsupport φ).indicator (fun y => f y ^ 2) x + (1 + 1 / (4 * epsilon)) * H x := |
| 149 | integral_mono (integrable_finsetSum _ (fun i _ => hRi i)).neg |
| 150 | (((hGi.const_mul _).add (hKi.const_mul _)).add (hHi.const_mul _)) hpoint |
| 151 | _ = _ := by |
| 152 | have hsumI : Integrable (fun x => epsilon * G x + |
| 153 | A * (tsupport φ).indicator (fun y => f y ^ 2) x) := |
| 154 | (hGi.const_mul _).add (hKi.const_mul _) |
| 155 | rw [integral_add hsumI (hHi.const_mul _), |
| 156 | integral_add (hGi.const_mul _) (hKi.const_mul _), |
| 157 | integral_const_mul, integral_const_mul, integral_const_mul, |
| 158 | integral_indicator (isClosed_tsupport φ).measurableSet] |
| 159 | |
| 160 | end PoincareMT.RicciFlow.Local |