import Mathlib /-! # Rank of the 4 × 4 matrix multiplication tensor over ℚ (record challenge) A *bilinear algorithm* with `r` products for `4 × 4` matrix multiplication over `ℚ` consists of `3r` coefficient matrices `U t, V t, W t` (`t < r`): it computes the `r` products `m t = (∑ i j, U t i j * A i j) * (∑ k l, V t k l * B k l)` of a linear form in the entries of `A` by a linear form in the entries of `B`, and returns `A * B = ∑ t, m t • W t`. The least such `r` is the bilinear complexity of `4 × 4` matrix multiplication over `ℚ`, which equals the tensor rank `R(⟨4,4,4⟩)` of the matrix multiplication tensor over `ℚ` ([BCS97, Ch. 14], [Bre70]: the identity above holds for all `A, B` iff the coefficients satisfy the Brent equations `∑ t, U t i j * V t k l * W t p q = δ_jk δ_pi δ_ql`). **Challenge.** Give such an algorithm (`answer`), prove it correct (`correct`) and prove its number of products (`metric_bound`, the score: lower is better). Coefficients are arbitrary rationals; scalar multiplications and additions are free, only the `r` products count. Practical hint: the identity can be reduced to the Brent equations (finitely many rational identities), which `decide +kernel` checks for a concrete scheme (see the tests published with this challenge). * Best known: 48, Dumas–Pernet–Sedoglavic [DPS25] (rational coefficients, valid in any ring of characteristic ≠ 2; a rational form of the complex AlphaEvolve 48-product scheme). Before 2025: 49 (Strassen applied twice [Str69]). * Lower bound: 34 over every field (Bläser's bound `R(⟨n,m,n⟩) ≥ 2mn + 2n − m − 2`, `m ≥ n ≥ 3` [Blä03]). *References.* * [Str69] V. Strassen, *Gaussian elimination is not optimal*, Numer. Math. 13 (1969), 354–356, https://doi.org/10.1007/BF02165411. * [DPS25] J.-G. Dumas, C. Pernet, A. Sedoglavic, *A non-commutative algorithm for multiplying 4 × 4 matrices using 48 non-complex multiplications*, arXiv:2506.13242 (2025, v7 2026), https://arxiv.org/abs/2506.13242. Coefficients: https://fmm.univ-lille.fr/4x4x4.html. * [Bre70] R. P. Brent, *Algorithms for matrix multiplication*, Tech. Report STAN-CS-70-157, Stanford University (1970) (the "Brent equations"). * [BCS97] P. Bürgisser, M. Clausen, M. A. Shokrollahi, *Algebraic Complexity Theory*, Grundlehren 315, Springer (1997), Chapter 14 (bilinear complexity and tensor rank). * [Blä03] M. Bläser, *On the complexity of the multiplication of matrices of small formats*, J. Complexity 19(1) (2003), 43–60. -/ namespace MatMulRank4 /-- The linear form on `n × n` rational matrices with coefficient matrix `X`: `linForm X A = ∑ i, ∑ j, X i j * A i j`. -/ def linForm {n : ℕ} (X A : Matrix (Fin n) (Fin n) ℚ) : ℚ := ∑ i, ∑ j, X i j * A i j /-- `IsMatMulDecomp U V W` : the `r` triples `(U t, V t, W t)` form a bilinear algorithm for `n × n` matrix multiplication over `ℚ`, i.e. for all rational matrices `A, B`, `A * B = ∑ t, (linForm (U t) A * linForm (V t) B) • W t`. Equivalently (Brent equations, [Bre70]), `∑ t, U t ⊗ V t ⊗ W t` is the matrix multiplication tensor, so the least `r` is the tensor rank of `⟨n,n,n⟩` over `ℚ` [BCS97, Ch. 14]. -/ def IsMatMulDecomp {n r : ℕ} (U V W : Fin r → Matrix (Fin n) (Fin n) ℚ) : Prop := ∀ A B : Matrix (Fin n) (Fin n) ℚ, A * B = ∑ t, (linForm (U t) A * linForm (V t) B) • W t /-- A candidate bilinear algorithm for `n × n` matrices over `ℚ`: a number `r` of products and, for each product `t : Fin r`, the coefficient matrices of its left factor (`U t`, a linear form in the entries of `A`), of its right factor (`V t`, in the entries of `B`) and of its contribution to the result (`W t`). -/ structure BilinearScheme (n : ℕ) where /-- the number of products (the metric) -/ r : ℕ /-- coefficients of the left factor of product `t` in the entries of `A` -/ U : Fin r → Matrix (Fin n) (Fin n) ℚ /-- coefficients of the right factor of product `t` in the entries of `B` -/ V : Fin r → Matrix (Fin n) (Fin n) ℚ /-- product `t` is added, with coefficient `W t p q`, to entry `(p, q)` of `A * B` -/ W : Fin r → Matrix (Fin n) (Fin n) ℚ /-- Your algorithm for `4 × 4` matrices (the only definition you fill). -/ def answer : BilinearScheme 4 := sorry /-- The main target: `answer` is a bilinear algorithm for `4 × 4` matrix multiplication over `ℚ`. -/ theorem correct : IsMatMulDecomp answer.U answer.V answer.W := sorry /-- The score: replace the hole by a number (the number of products of `answer`). Lower is better. -/ theorem metric_bound : answer.r ≤ sorry := sorry end MatMulRank4