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/CoordinateIntegration.lean` at |
| 2 | f927d9e1f0810042766d3b5f64d3f4da02ee93cc. See |
| 3 | `references/ricci-flow/mapher/local-theory/port.json`. -/ |
| 4 | |
| 5 | import PoincareLib.Geometry.Riemannian.Connection |
| 6 | import Mathlib.Analysis.Calculus.ParametricIntegral |
| 7 | |
| 8 | /-! |
| 9 | # Compactly supported coordinate integration |
| 10 | |
| 11 | Haar translation invariance and dominated differentiation give the integral |
| 12 | of a directional derivative. Local regularity and vanishing off the cutoff |
| 13 | support then give the localized product identity. |
| 14 | Derivation and source bindings: proof-work/tasks/M03/reviews/coordinate-integration-derivation.md. |
| 15 | -/ |
| 16 | |
| 17 | set_option autoImplicit false |
| 18 | |
| 19 | open scoped ContDiff Topology |
| 20 | open MeasureTheory Set |
| 21 | |
| 22 | namespace PoincareMT.RicciFlow.Local |
| 23 | |
| 24 | theorem integral_fderiv_eq_zero_of_hasCompactSupport |
| 25 | {n : ℕ} {P : EuclideanSpace ℝ (Fin n) → ℝ} |
| 26 | (hP : ContDiff ℝ 1 P) (hPc : HasCompactSupport P) |
| 27 | (v : EuclideanSpace ℝ (Fin n)) : |
| 28 | letI : MeasurableSpace (EuclideanSpace ℝ (Fin n)) := borel _ |
| 29 | letI : BorelSpace (EuclideanSpace ℝ (Fin n)) := ⟨rfl⟩ |
| 30 | (∫ x, fderiv ℝ P x v) = 0 := by |
| 31 | let : MeasurableSpace (EuclideanSpace ℝ (Fin n)) := borel _ |
| 32 | let : BorelSpace (EuclideanSpace ℝ (Fin n)) := ⟨rfl⟩ |
| 33 | classical |
| 34 | let H : ℝ → EuclideanSpace ℝ (Fin n) → ℝ := fun s x => P (x + s • v) |
| 35 | let D : ℝ → EuclideanSpace ℝ (Fin n) → ℝ := |
| 36 | fun s x => fderiv ℝ P (x + s • v) v |
| 37 | let K : Set (EuclideanSpace ℝ (Fin n)) := |
| 38 | (fun p : ℝ × EuclideanSpace ℝ (Fin n) => p.2 - p.1 • v) '' |
| 39 | (Icc (-1 : ℝ) 1 ×ˢ tsupport P) |
| 40 | have hK : IsCompact K := |
| 41 | (isCompact_Icc.prod hPc).image (continuous_snd.sub (continuous_fst.smul continuous_const)) |
| 42 | have hH : Continuous (fun p : ℝ × EuclideanSpace ℝ (Fin n) => H p.1 p.2) := |
| 43 | hP.continuous.comp (continuous_snd.add (continuous_fst.smul continuous_const)) |
| 44 | have hD : Continuous (fun p : ℝ × EuclideanSpace ℝ (Fin n) => D p.1 p.2) := |
| 45 | ((hP.continuous_fderiv (by decide)).comp |
| 46 | (continuous_snd.add (continuous_fst.smul continuous_const))).clm_apply continuous_const |
| 47 | have hDzero : ∀ s ∈ Icc (-1 : ℝ) 1, ∀ x ∉ K, D s x = 0 := by |
| 48 | intro s hs x hx |
| 49 | have hp : x + s • v ∉ tsupport P := by |
| 50 | intro hp |
| 51 | apply hx |
| 52 | exact ⟨(s, x + s • v), ⟨hs, hp⟩, by simp⟩ |
| 53 | change fderiv ℝ P (x + s • v) v = 0 |
| 54 | rw [fderiv_of_notMem_tsupport ℝ hp] |
| 55 | rfl |
| 56 | have hrect := (isCompact_Icc : IsCompact (Icc (-1 : ℝ) 1)).prod hK |
| 57 | obtain ⟨C, hC⟩ := hrect.exists_bound_of_continuousOn hD.continuousOn |
| 58 | have hbound : Integrable (K.indicator (fun _ => max C 0)) := |
| 59 | (integrableOn_const (C := max C 0) hK.measure_ne_top).integrable_indicator hK.isClosed.measurableSet |
| 60 | have hdiff : ∀ s x, HasDerivAt (fun r => H r x) (D s x) s := by |
| 61 | intro s x |
| 62 | simpa [H, D] using! ((hP.differentiable (by decide) (x + s • v)).hasFDerivAt.comp_hasDerivAt s |
| 63 | (HasDerivAt.const_add x ((hasDerivAt_id s).smul_const v))) |
| 64 | have hint : HasDerivAt (fun s : ℝ => ∫ x, H s x) (∫ x, D 0 x) 0 := by |
| 65 | refine (hasDerivAt_integral_of_dominated_loc_of_deriv_le |
| 66 | (F := H) (F' := D) (bound := K.indicator (fun _ => max C 0)) |
| 67 | (Icc_mem_nhds (by norm_num : (-1 : ℝ) < 0) (by norm_num : (0 : ℝ) < 1)) |
| 68 | ?_ ?_ ?_ ?_ hbound ?_).2 |
| 69 | · exact Filter.Eventually.of_forall fun s => |
| 70 | (hH.comp (.prodMk_right s)).aestronglyMeasurable |
| 71 | · simpa [H] using hP.continuous.integrable_of_hasCompactSupport hPc |
| 72 | · exact (hD.comp (.prodMk_right 0)).aestronglyMeasurable |
| 73 | · filter_upwards with x |
| 74 | intro s hs |
| 75 | by_cases hx : x ∈ K |
| 76 | · rw [indicator_of_mem hx] |
| 77 | exact (hC (s, x) ⟨hs, hx⟩).trans (le_max_left _ _) |
| 78 | · simp [indicator_of_notMem hx, hDzero s hs x hx] |
| 79 | · filter_upwards with x |
| 80 | intro s _ |
| 81 | exact hdiff s x |
| 82 | have heq : (fun s : ℝ => ∫ x, H s x) = fun _ => ∫ x, P x := by |
| 83 | funext s |
| 84 | exact integral_add_right_eq_self P (s • v) |
| 85 | rw [heq] at hint |
| 86 | simpa [D] using hint.unique (hasDerivAt_const (0 : ℝ) (∫ x, P x)) |
| 87 | |
| 88 | theorem integral_localized_mul_fderiv |
| 89 | {n : ℕ} {U : Set (EuclideanSpace ℝ (Fin n))} (hU : IsOpen U) |
| 90 | {f g φ : EuclideanSpace ℝ (Fin n) → ℝ} |
| 91 | (hf : ContDiffOn ℝ 1 f U) (hg : ContDiffOn ℝ 1 g U) |
| 92 | (hφ : ContDiff ℝ 1 φ) (hφc : HasCompactSupport φ) |
| 93 | (hφU : tsupport φ ⊆ U) (v : EuclideanSpace ℝ (Fin n)) : |
| 94 | letI : MeasurableSpace (EuclideanSpace ℝ (Fin n)) := borel _ |
| 95 | letI : BorelSpace (EuclideanSpace ℝ (Fin n)) := ⟨rfl⟩ |
| 96 | (∫ x, φ x ^ 2 * f x * fderiv ℝ g x v) = |
| 97 | -(∫ x, (φ x ^ 2 * fderiv ℝ f x v + |
| 98 | 2 * φ x * fderiv ℝ φ x v * f x) * g x) := by |
| 99 | let : MeasurableSpace (EuclideanSpace ℝ (Fin n)) := borel _ |
| 100 | let : BorelSpace (EuclideanSpace ℝ (Fin n)) := ⟨rfl⟩ |
| 101 | classical |
| 102 | let P : EuclideanSpace ℝ (Fin n) → ℝ := fun x => φ x ^ 2 * f x * g x |
| 103 | let A : EuclideanSpace ℝ (Fin n) → ℝ := fun x => φ x ^ 2 * f x * fderiv ℝ g x v |
| 104 | let B : EuclideanSpace ℝ (Fin n) → ℝ := |
| 105 | fun x => (φ x ^ 2 * fderiv ℝ f x v + 2 * φ x * fderiv ℝ φ x v * f x) * g x |
| 106 | have hP : ContDiff ℝ 1 P := by |
| 107 | apply contDiff_iff_contDiffAt.mpr |
| 108 | intro x |
| 109 | by_cases hx : x ∈ U |
| 110 | · exact (((hφ.contDiffAt.pow 2).mul (hf.contDiffAt (hU.mem_nhds hx))).mul |
| 111 | (hg.contDiffAt (hU.mem_nhds hx))) |
| 112 | · have hxφ : x ∉ tsupport φ := fun h => hx (hφU h) |
| 113 | apply (show ContDiffAt ℝ 1 (fun _ : EuclideanSpace ℝ (Fin n) => (0 : ℝ)) x from |
| 114 | contDiffAt_const).congr_of_eventuallyEq |
| 115 | filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hxφ] with y hy |
| 116 | simp [P, hy] |
| 117 | have hPc : HasCompactSupport P := |
| 118 | ((hφc.comp_left (g := fun y : ℝ => y ^ 2) (by simp)).mul_right (f' := f)).mul_right (f' := g) |
| 119 | have hpatch : ∀ Q : EuclideanSpace ℝ (Fin n) → ℝ, ContinuousOn Q U → |
| 120 | (∀ x ∉ tsupport φ, Q x = 0) → Continuous Q ∧ HasCompactSupport Q := by |
| 121 | intro Q hQ hzero |
| 122 | constructor |
| 123 | · apply continuous_iff_continuousAt.mpr |
| 124 | intro x |
| 125 | by_cases hx : x ∈ U |
| 126 | · exact hQ.continuousAt (hU.mem_nhds hx) |
| 127 | · have hxφ : x ∈ (tsupport φ)ᶜ := fun h => hx (hφU h) |
| 128 | apply continuousAt_const.congr_of_eventuallyEq |
| 129 | filter_upwards [(isClosed_tsupport φ).isOpen_compl.mem_nhds hxφ] with y hy |
| 130 | exact hzero y hy |
| 131 | · apply hφc.mono' |
| 132 | intro x hx |
| 133 | by_contra hxφ |
| 134 | exact hx (hzero x hxφ) |
| 135 | have hA : Continuous A ∧ HasCompactSupport A := hpatch A |
| 136 | (((hφ.continuous.continuousOn.pow 2).mul hf.continuousOn).mul |
| 137 | ((hg.continuousOn_fderiv_of_isOpen hU le_rfl).clm_apply continuousOn_const)) |
| 138 | (fun x hx => by simp [A, image_eq_zero_of_notMem_tsupport hx]) |
| 139 | have hB : Continuous B ∧ HasCompactSupport B := hpatch B |
| 140 | ((((hφ.continuous.continuousOn.pow 2).mul |
| 141 | ((hf.continuousOn_fderiv_of_isOpen hU le_rfl).clm_apply continuousOn_const)).add |
| 142 | (((continuousOn_const.mul hφ.continuous.continuousOn).mul |
| 143 | (((hφ.continuous_fderiv (by decide)).clm_apply continuous_const).continuousOn)).mul |
| 144 | hf.continuousOn)).mul hg.continuousOn) |
| 145 | (fun x hx => by simp [B, image_eq_zero_of_notMem_tsupport hx]) |
| 146 | have hformula : ∀ x, fderiv ℝ P x v = A x + B x := by |
| 147 | intro x |
| 148 | by_cases hx : x ∈ U |
| 149 | · have hf' := ((hf.contDiffAt (hU.mem_nhds hx)).differentiableAt (by decide)).hasFDerivAt |
| 150 | have hg' := ((hg.contDiffAt (hU.mem_nhds hx)).differentiableAt (by decide)).hasFDerivAt |
| 151 | have hφ' := (hφ.differentiable (by decide) x).hasFDerivAt |
| 152 | have hprod := ((hφ'.pow 2).mul hf').mul hg' |
| 153 | have heq : fderiv ℝ P x v = |
| 154 | (φ x ^ 2 * f x) * fderiv ℝ g x v + |
| 155 | g x * (φ x ^ 2 * fderiv ℝ f x v + f x * ((2 * φ x) * fderiv ℝ φ x v)) := by |
| 156 | simpa only [P, Pi.mul_apply, add_apply, smul_apply, |
| 157 | Nat.reduceSub, pow_one, nsmul_eq_mul, Nat.cast_ofNat, smul_eq_mul] using! |
| 158 | congrArg (fun L : EuclideanSpace ℝ (Fin n) →L[ℝ] ℝ => L v) hprod.fderiv |
| 159 | rw [heq] |
| 160 | dsimp only [A, B] |
| 161 | ring |
| 162 | · have hxφ : x ∉ tsupport φ := fun h => hx (hφU h) |
| 163 | have hPzero : P =ᶠ[𝓝 x] 0 := by |
| 164 | filter_upwards [notMem_tsupport_iff_eventuallyEq.mp hxφ] with y hy |
| 165 | simp [P, hy] |
| 166 | simp [fderiv_of_notMem_tsupport ℝ (notMem_tsupport_iff_eventuallyEq.mpr hPzero), |
| 167 | A, B, image_eq_zero_of_notMem_tsupport hxφ] |
| 168 | have hzero := integral_fderiv_eq_zero_of_hasCompactSupport hP hPc v |
| 169 | change (∫ x, fderiv ℝ P x v) = 0 at hzero |
| 170 | simp_rw [hformula] at hzero |
| 171 | rw [integral_add (hA.1.integrable_of_hasCompactSupport hA.2) |
| 172 | (hB.1.integrable_of_hasCompactSupport hB.2)] at hzero |
| 173 | change (∫ x, A x) = -(∫ x, B x) |
| 174 | linarith |
| 175 | |
| 176 | end PoincareMT.RicciFlow.Local |