Documentation

CslibFrontier.Computability.Circuit.Arithmetic.MatrixMultiplication.Exponent

The exponent of matrix multiplication #

A circuit C : Circuit (arithSignature K) (n * n + n * n) (n * n) computes n × n matrix multiplication (ComputesMatMul) when, fed with the variables, the entries of A followed by those of B in the row-major numbering finProdFinEquiv, its outputs are the entries of A * B as polynomials over K. This is the formal model of Bürgisser, Clausen and Shokrollahi, Chapter 15. Such a circuit computes the product over every commutative K-algebra (ComputesMatMul.eval_algebra), in particular on all matrices over K (ComputesMatMul.eval). Over a finite field the converse fails: a circuit can output the right values without the right polynomials. Over an infinite integral domain the two notions agree (computesMatMul_iff_eval). Its size C.size counts the gates: additions, multiplications and constants, each of cost one.

A real τ is an admissible exponent (AdmissibleExponent K τ) when for every ε > 0 there is a constant c such that, for every n ≥ 1, some circuit of size at most c n ^ (τ + ε) computes n × n matrix multiplication. The exponent of matrix multiplication omega K is the infimum of the admissible exponents. This is the definition of Pass, §1, with arithmetic circuits over K in place of integer arithmetic, and the formal arithmetic model of Bürgisser, Clausen and Shokrollahi, Chapter 15.

Block recursion (admissibleExponent_of_rank, Strassen; Pass, proof of Theorem 1.1): a bilinear algorithm with r multiplications for v × v matrices, that is Tensor.Rank r (Tensor.mm v v v), gives circuits of size O(n ^ τ) whenever r ≤ v ^ τ and τ > 2: apply the algorithm to v × v arrays of blocks, recursively, with linear encoding and decoding of the blocks costing O(r n ^ 2) per level.

Main definitions #

Main results #

References #

def Cslib.Circuits.Arithmetic.MatrixMultiplication.leftMatrix {U : Type u_1} {n : ℕ} (x : Fin (n * n + n * n) → U) :
Matrix (Fin n) (Fin n) U

The matrix A encoded by an input vector: its first n * n entries, row-major.

def Cslib.Circuits.Arithmetic.MatrixMultiplication.rightMatrix {U : Type u_1} {n : ℕ} (x : Fin (n * n + n * n) → U) :
Matrix (Fin n) (Fin n) U

The matrix B encoded by an input vector: its last n * n entries, row-major.

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.leftMatrix_apply {U : Type u_1} {n : ℕ} (x : Fin (n * n + n * n) → U) (i j : Fin n) :

Entry (i, j) of the left matrix is input (i, j) of the first block.

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.rightMatrix_apply {U : Type u_1} {n : ℕ} (x : Fin (n * n + n * n) → U) (i j : Fin n) :

Entry (i, j) of the right matrix is input (i, j) of the second block.

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.map_leftMatrix {U : Type u_1} {n : ℕ} {V : Type u_2} (f : U → V) (x : Fin (n * n + n * n) → U) :

Decoding commutes with mapping the entries.

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.map_rightMatrix {U : Type u_1} {n : ℕ} {V : Type u_2} (f : U → V) (x : Fin (n * n + n * n) → U) :

Decoding commutes with mapping the entries.

def Cslib.Circuits.Arithmetic.MatrixMultiplication.entry (K : Type u_1) {n : ℕ} (A : Matrix (Fin n) (Fin n) K) (t : Fin (n * n)) :
K

The entry t of a matrix, numbered row-major.

def Cslib.Circuits.Arithmetic.MatrixMultiplication.matrixInputs (K : Type u_1) {n : ℕ} (A B : Matrix (Fin n) (Fin n) K) :
Fin (n * n + n * n) → K

The inputs of a matrix multiplication circuit: the entries of A followed by those of B.

C computes n × n matrix multiplication formally: fed with the variables, the entries of A followed by those of B, it outputs the entries of A * B as polynomials over K (Bürgisser, Clausen and Shokrollahi, Chapter 15). Over a finite field this is stronger than outputting the right values (computesMatMul_iff_eval).

τ is an admissible exponent: for every ε > 0, circuits of size O(n ^ (τ + ε)) compute n × n matrix multiplication for every n ≥ 1.

The exponent of matrix multiplication: the infimum of the admissible exponents.

Admissibility is monotone.

Formal and semantic correctness #

@[simp]

The left matrix encoded by matrixInputs R A B is A.

@[simp]

The right matrix encoded by matrixInputs R A B is B.

@[simp]

The input vector is the encoding of the two matrices it encodes.

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.ComputesMatMul.eval_algebra {K : Type u_1} [CommSemiring K] {n : ℕ} {R : Type u_2} [CommSemiring R] {C : Circuit (arithSignature K) (n * n + n * n) (n * n)} [Algebra K R] (hC : ComputesMatMul K C) (A B : Matrix (Fin n) (Fin n) R) :

A circuit computing matrix multiplication formally computes it over every commutative K-algebra R, with its constants mapped into R.

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.ComputesMatMul.eval {K : Type u_1} [CommSemiring K] {n : ℕ} {C : Circuit (arithSignature K) (n * n + n * n) (n * n)} (hC : ComputesMatMul K C) (A B : Matrix (Fin n) (Fin n) K) :

A circuit computing matrix multiplication formally outputs the product of any two matrices over K.

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.computesMatMul_iff_eval {K : Type u_2} [CommRing K] [IsDomain K] [Infinite K] {n : ℕ} {C : Circuit (arithSignature K) (n * n + n * n) (n * n)} :
ComputesMatMul K C ↔ ∀ (A B : Matrix (Fin n) (Fin n) K), C.eval (arithInterpretation K) (matrixInputs K A B) = entry K (A * B)

Over an infinite integral domain, a circuit computes matrix multiplication formally exactly when it outputs the product of any two matrices.

Circuits from synthesis bounds #

Every admissible exponent is at least 2: a circuit computing n × n matrix multiplication has at least n ^ 2 gates, one for each output, since the entries of A * B are pairwise distinct functions of the inputs and none is an input.

Block recursion #

theorem Cslib.Circuits.Arithmetic.MatrixMultiplication.admissibleExponent_of_rank {K : Type u_1} [CommSemiring K] {v r : ℕ} (hv : 2 ≤ v) (hr : Tensor.Rank r (Tensor.mm v v v)) {τ : ℝ} (hτ : ↑r ≤ ↑v ^ τ) (h2 : 2 < τ) :

Block recursion (Strassen; Pass, §4.3): a bilinear algorithm with r multiplications for v × v matrices gives circuits of size O(n ^ τ) for every n, when r ≤ v ^ τ and 2 < τ. For every ε > 0, with R = v ^ (τ + ε) > r, the sizes S j of the circuits for v ^ j × v ^ j matrices satisfy S (j + 1) ≤ r S j + 9 r (v ^ (j + 1)) ^ 2 + 1, hence S j ≤ C R ^ j; a general n is padded to the next power of v, which is at most v n.