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.LineDeriv.IntegrationByParts |
| 2 | import Mathlib.Analysis.InnerProductSpace.Calculus |
| 3 | import Mathlib.Analysis.InnerProductSpace.Trace |
| 4 | |
| 5 | /-! |
| 6 | # Integration by parts for Euclidean divergence |
| 7 | |
| 8 | The finite trace is integrated in an orthonormal basis. Differentiability |
| 9 | is needed only on the other factor's support; the three integrability |
| 10 | premises of scalar integration by parts remain explicit here. |
| 11 | -/ |
| 12 | |
| 13 | set_option autoImplicit false |
| 14 | |
| 15 | open Set MeasureTheory |
| 16 | open scoped BigOperators |
| 17 | |
| 18 | namespace PoincareMT.ReducedVolume |
| 19 | |
| 20 | variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E] |
| 21 | [FiniteDimensional ℝ E] [MeasurableSpace E] [BorelSpace E] |
| 22 | {μ : Measure E} [Measure.IsAddHaarMeasure μ] |
| 23 | |
| 24 | /-- Integrating a scalar times the ordinary divergence gives minus its differential pairing. -/ |
| 25 | theorem integral_mul_trace_fderiv {ι : Type*} [Fintype ι] |
| 26 | (b : OrthonormalBasis ι ℝ E) {u : E → ℝ} {V : E → E} |
| 27 | (hu : ∀ x ∈ tsupport V, DifferentiableAt ℝ u x) |
| 28 | (hV : ∀ x ∈ tsupport u, DifferentiableAt ℝ V x) |
| 29 | (hleft : ∀ i, Integrable (fun x ↦ fderiv ℝ u x (b i) * inner ℝ (b i) (V x)) μ) |
| 30 | (hright : ∀ i, Integrable (fun x ↦ u x * inner ℝ (b i) (fderiv ℝ V x (b i))) μ) |
| 31 | (hprod : ∀ i, Integrable (fun x ↦ u x * inner ℝ (b i) (V x)) μ) : |
| 32 | Integrable (fun x ↦ u x * LinearMap.trace ℝ E (fderiv ℝ V x).toLinearMap) μ ∧ |
| 33 | Integrable (fun x ↦ fderiv ℝ u x (V x)) μ ∧ |
| 34 | (∫ x, u x * LinearMap.trace ℝ E (fderiv ℝ V x).toLinearMap ∂μ) = |
| 35 | -(∫ x, fderiv ℝ u x (V x) ∂μ) := by |
| 36 | classical |
| 37 | have hpair (x : E) : fderiv ℝ u x (V x) = |
| 38 | ∑ i, fderiv ℝ u x (b i) * inner ℝ (b i) (V x) := by |
| 39 | nth_rw 1 [← b.sum_repr' (V x)] |
| 40 | simp only [map_sum, map_smul, smul_eq_mul, mul_comm] |
| 41 | have htrace (x : E) : u x * LinearMap.trace ℝ E (fderiv ℝ V x).toLinearMap = |
| 42 | ∑ i, u x * inner ℝ (b i) (fderiv ℝ V x (b i)) := by |
| 43 | rw [LinearMap.trace_eq_sum_inner _ b, Finset.mul_sum] |
| 44 | rfl |
| 45 | have hcoordinate (i : ι) (x : E) : |
| 46 | u x * fderiv ℝ (fun y ↦ inner ℝ (b i) (V y)) x (b i) = |
| 47 | u x * inner ℝ (b i) (fderiv ℝ V x (b i)) := by |
| 48 | by_cases hx : u x = 0 |
| 49 | · simp only [hx, zero_mul] |
| 50 | · rw [fderiv_inner_apply ℝ (differentiableAt_const (b i)) (hV x (subset_closure hx))] |
| 51 | have hc : fderiv ℝ (fun _ : E ↦ b i) x = 0 := fderiv_const_apply (b i) |
| 52 | simp only [hc, zero_apply, inner_zero_left, add_zero] |
| 53 | have hparts (i : ι) : |
| 54 | (∫ x, u x * inner ℝ (b i) (fderiv ℝ V x (b i)) ∂μ) = |
| 55 | -(∫ x, fderiv ℝ u x (b i) * inner ℝ (b i) (V x) ∂μ) := by |
| 56 | have hsupp : tsupport (fun x ↦ inner ℝ (b i) (V x)) ⊆ tsupport V := by |
| 57 | apply closure_mono |
| 58 | intro x hx |
| 59 | change V x ≠ 0 |
| 60 | intro hz |
| 61 | exact hx (by simp only [hz, inner_zero_right]) |
| 62 | have h := integral_mul_fderiv_eq_neg_fderiv_mul_of_integrable |
| 63 | (v := b i) (hleft i) (by simpa only [hcoordinate] using hright i) (hprod i) |
| 64 | (fun x hx ↦ hu x (hsupp hx)) |
| 65 | (fun x hx ↦ (differentiableAt_const (b i)).inner ℝ (hV x hx)) |
| 66 | simpa only [hcoordinate] using h |
| 67 | have hrightSum := integrable_finsetSum Finset.univ (fun i _ ↦ hright i) |
| 68 | have hleftSum := integrable_finsetSum Finset.univ (fun i _ ↦ hleft i) |
| 69 | refine ⟨?_, ?_, ?_⟩ |
| 70 | · simpa only [← htrace] using hrightSum |
| 71 | · simpa only [← hpair] using hleftSum |
| 72 | · simp_rw [htrace, hpair] |
| 73 | rw [integral_finsetSum Finset.univ (fun i _ ↦ hright i), |
| 74 | integral_finsetSum Finset.univ (fun i _ ↦ hleft i)] |
| 75 | simp_rw [hparts] |
| 76 | exact Finset.sum_neg_distrib _ |
| 77 | |
| 78 | end PoincareMT.ReducedVolume |