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.Matrix.Order |
| 2 | |
| 3 | /-! |
| 4 | Adapted from Mapher `PoincareMT/Proofs/M49/Mathlib/TensorContraction.lean` at |
| 5 | revision `f927d9e1f0810042766d3b5f64d3f4da02ee93cc`. |
| 6 | |
| 7 | # Nonnegative finite tensor contractions |
| 8 | |
| 9 | Morgan-Tian Definition 2.16, p. 30, sums squared tensor norms. |
| 10 | For raw coordinate arrays the inverse-Gram formula is nonnegative by |
| 11 | the Schur product theorem. This supplies the sign needed to extract a |
| 12 | single term from the frozen round-cylinder jet sum. |
| 13 | -/ |
| 14 | |
| 15 | set_option autoImplicit false |
| 16 | |
| 17 | open scoped BigOperators Matrix |
| 18 | |
| 19 | namespace Matrix |
| 20 | |
| 21 | -- The Schur-product API uses the same real operations through its RCLike instance. |
| 22 | set_option backward.isDefEq.respectTransparency false in |
| 23 | /-- A positive-semidefinite contraction is nonnegative for every finite |
| 24 | coefficient array (MT Definition 2.16, p. 30, used in Lemma 17.12, p. 410). -/ |
| 25 | theorem tensor_contraction_nonneg {ι σ : Type*} [Fintype ι] [Fintype σ] [DecidableEq σ] |
| 26 | {G : Matrix ι ι ℝ} (hG : G.PosSemidef) (T : (σ → ι) → ℝ) : |
| 27 | 0 ≤ ∑ a : σ → ι, ∑ b : σ → ι, |
| 28 | (∏ j : σ, G (a j) (b j)) * T a * T b := by |
| 29 | classical |
| 30 | have hK (s : Finset σ) : |
| 31 | (show Matrix (σ → ι) (σ → ι) ℝ from |
| 32 | fun a b => ∏ j ∈ s, G (a j) (b j)).PosSemidef := by |
| 33 | induction s using Finset.induction_on with |
| 34 | | empty => |
| 35 | simpa only [Finset.prod_empty, vecMulVec, of, Equiv.refl_apply, Pi.star_apply, |
| 36 | star_one, mul_one] using! |
| 37 | posSemidef_vecMulVec_self_star (fun _ : σ → ι => (1 : ℝ)) |
| 38 | | @insert j s hj ih => |
| 39 | have h := (hG.submatrix (fun a : σ → ι => a j)).hadamard ih |
| 40 | simpa only [Finset.prod_insert hj, hadamard, submatrix, of] using! h |
| 41 | have h := (hK Finset.univ).dotProduct_mulVec_nonneg T |
| 42 | simpa only [star_trivial, dotProduct, mulVec, Finset.mul_sum, |
| 43 | mul_left_comm, mul_assoc] using h |
| 44 | |
| 45 | end Matrix |