Documentation

Complexitylib.Algebraic.LowerBound.Cutwidth.MultiOutput.MatMul

Lower bounds for matrix multiplication #

Let matMul n : F ^ (n² + n²) → F ^ (n²) be the product C = A B of two n × n matrices over a field F, written in coordinates (MatMul.Defs; matMul_matMulInput). Consider circuits over F, over any signature whose gates have at most two arguments, so with arbitrary functions F × F → F, unary functions and constants as gates; over F = GF(2) these are the circuits over the full binary basis B₂ computing the Boolean matrix product modulo two. Over arbitrary fields K, also consider circuits with polynomial gates of fan-in at most two, and arithmetic circuits of additions, multiplications and free constants (Arithmetic.gateCost). The model is that of MultiOutput.FieldMul and MultiOutput.TotallyRegular: the size counts gates, inputs and output designations are free.

The terminal graph (MatMul.Tripartite). The inputs A i j, B j k and the outputs C i k are the edges of the complete tripartite graph on three copies I, J, K of Fin n. A split S of the wires places d v of the 2 n terminals at each vertex v; the charges R_I, R_J, R_K sum min (d, 2 n - d) over the vertices of each part.

The charge bounds (charges_le_of_matMul_of_totallyRegular, charges_le_add_of_matMul, charges_le_of_matMul_polynomial). Let S be crossed by w forward and backward signals.

If F has a totally regular n × n matrix (every square submatrix nonsingular), used for B₀, A₀ and Λ, every block has full rank and R_I, R_J, R_K ≤ w; this holds over ZMod q for a prime q ≥ 2 n with the Cauchy matrix cauchyZMod q n, and for polynomial gates over any field K by evaluating over K(t) with the generic Hankel matrix (totallyRegular_genericHankel). Over every finite field, in particular GF(2), a uniformly random n × n matrix has kernel blocks of average size at most twice the ideal size, so a matrix chosen after the split loses at most 4 n: R_I, R_J, R_K ≤ w + 4 n.

One component (mem_component_of_matMul). The component of the output C 0 0 is crossed by no signal, so with B₀ or A₀ a matrix unit, the slices separate; the unit vector at A i j moves C i k when B₀ = E j k, and the unit vector at B j k moves C i k when A₀ = E i j. So the component holds every input and output.

The finite bounds (half_sq_le_of_matMul_of_totallyRegular, sq_sub_le_of_matMul, half_sq_le_of_matMul_polynomial). The terminals lie on distinct wires (terminal_injective_of_matMul). Along the ranking of MultiOutput.exists_rank, the threshold prefix (Tripartite.exists_threshold), the first prefix with at least ⌈3 n/2⌉ heavy vertices (with at least n placed terminals), ends at a terminal and has at most ⌈3 n/2⌉ + 1 of them. Charging each terminal with one heavy and one light endpoint to its light endpoint if placed and to its heavy endpoint otherwise gives 3 n² ≤ 2 (R_I + R_J + R_K) + 3 (Tripartite.three_mul_sq_le_two_mul_charge). Charged to the component holding all 2 n² inputs, a circuit of size s therefore has (n² - 1)/2 ≤ (A + η) (s - 2 n²)⁺ + 3 log₂ (2 n² + 3 s) + C with a totally regular matrix or for polynomial gates over any field, and (n² - 8 n - 1)/2 ≤ (A + η) (s - 2 n²)⁺ + 3 log₂ (2 n² + 3 s) + C over every finite field.

The asymptotic bounds (eventually_lt_size_of_matMul, eventually_lt_size_of_matMul_polynomial, eventually_lt_arithmeticCost_of_matMul). With the edge-score ordering coefficient A = 2 κ_E, where κ_E = Gaussian.frontierCoefficient ≈ 0.14035, for every ε > 0 and all large n, every such circuit has more than (2 + 1/(4 κ_E) - ε) n² gates, the coefficient being 2 + π/(6 arccos((1 + 2√2)/4)) ≈ 3.7812; as 2 κ_E ≤ 9/32, also more than (34/9 - ε) n² gates. The threshold depends only on ε, not on the field or the signature. The bound holds

Prior art. Lower bounds for matrix multiplication usually count the multiplications of bilinear or quadratic algorithms in arithmetic models: Bläser (STACS 2001) proves 5/2 n² - 3 n multiplications, and Shpilka (SICOMP 2003) 3 n² - o(n²) product gates over GF(2) for bilinear and quadratic circuits. We know of no earlier bound beyond the trivial ≈ 2 n² on the number of gates of circuits with arbitrary fan-in-two gates, or over B₂, computing the matrix product.

Matrix multiplication in coordinates #

theorem Algebraic.Cutwidth.MultiOutput.matMul_matMulInput {n : ℕ} {R : Type u_1} [Semiring R] (A B : Matrix (Fin n) (Fin n) R) (i k : Fin n) :
matMul n (matMulInput A B) (matMulOutput n i k) = (A * B) i k

matMul multiplies. On the input holding A and B, the output C i k is the entry (A * B) i k of the product.

Circuits for matrix multiplication #

The terminals lie on distinct wires. In a circuit over a field computing matMul n, the inputs A i j, B j k and the outputs C i k lie on 3 n² distinct wires.

theorem Algebraic.Cutwidth.MultiOutput.mem_component_of_matMul {σ : Signature} {n : ℕ} {F : Type u_1} [Field F] {I : Interpretation σ F} {c : Circuit σ (n * n + n * n) (n * n)} (hc : c.Computes I (matMul n)) (hn : 0 < n) :
(∀ (x : Fin (n * n + n * n)), Wire.input x ∈ component c.program (c.outputs (matMulOutput n ⟨0, hn⟩ ⟨0, hn⟩))) ∧ ∀ (o : Fin (n * n)), c.outputs o ∈ component c.program (c.outputs (matMulOutput n ⟨0, hn⟩ ⟨0, hn⟩))

All inputs and outputs lie in one component. If a circuit over a field, over any signature, computes matMul n and n ≥ 1, the component of its output C 0 0 in the wire graph contains every input and every output.

The charge bounds with a totally regular matrix. If a circuit over a finite field with a totally regular n × n matrix computes matMul n, then for every set S of its wires each of the charges R_I, R_J, R_K of the placed terminals is at most the number of forward and backward signals of S.

The charge bounds over every finite field. If a circuit over a finite field computes matMul n, then for every set S of its wires each of the charges R_I, R_J, R_K of the placed terminals is at most the number of forward and backward signals of S plus 4 n.

theorem Algebraic.Cutwidth.MultiOutput.half_sq_le_of_matMul_of_totallyRegular {σ : Signature} {n : ℕ} {F : Type u_1} [Field F] [Fintype F] {I : Interpretation σ F} {c : Circuit σ (n * n + n * n) (n * n)} {A η C : ℝ} (hAη : 0 ≤ A + η) (order : Multigraph.OrderingBound A η C) {M : Matrix (Fin n) (Fin n) F} (hM : TotallyRegular M) (hfan : c.FanInAtMost 2) (hc : c.Computes I (matMul n)) :
(↑n ^ 2 - 1) / 2 ≤ (A + η) * max (↑c.size - 2 * ↑n ^ 2) 0 + 3 * Real.logb 2 (2 * ↑n ^ 2 + 3 * ↑c.size) + C

The finite bound with a totally regular matrix. If a circuit over a finite field with a totally regular n × n matrix, over any signature with fan-in at most two, computes matMul n, then under the graph-ordering hypothesis (n² - 1)/2 ≤ (A + η) (s - 2 n²)⁺ + 3 log₂ (2 n² + 3 s) + C for its size s.

theorem Algebraic.Cutwidth.MultiOutput.sq_sub_le_of_matMul {σ : Signature} {n : ℕ} {F : Type u_1} [Field F] [Fintype F] {I : Interpretation σ F} {c : Circuit σ (n * n + n * n) (n * n)} {A η C : ℝ} (hAη : 0 ≤ A + η) (order : Multigraph.OrderingBound A η C) (hfan : c.FanInAtMost 2) (hc : c.Computes I (matMul n)) :
(↑n ^ 2 - 8 * ↑n - 1) / 2 ≤ (A + η) * max (↑c.size - 2 * ↑n ^ 2) 0 + 3 * Real.logb 2 (2 * ↑n ^ 2 + 3 * ↑c.size) + C

The finite bound over every finite field. If a circuit over a finite field, over any signature with fan-in at most two, computes matMul n, then under the graph-ordering hypothesis (n² - 8 n - 1)/2 ≤ (A + η) (s - 2 n²)⁺ + 3 log₂ (2 n² + 3 s) + C for its size s.

The charge bounds for polynomial gates over any field. If a circuit with polynomial gates over any field K formally computes matMul n, then for every set S of its wires each of the charges R_I, R_J, R_K of the placed terminals is at most the number of forward and backward signals of S.

theorem Algebraic.Cutwidth.MultiOutput.half_sq_le_of_matMul_polynomial {σ : Signature} {n : ℕ} {A η C : ℝ} (hAη : 0 ≤ A + η) (order : Multigraph.OrderingBound A η C) {K : Type u_1} [Field K] (P : (op : σ.Op) → MvPolynomial (Fin (σ.Arity op)) K) {c : Circuit σ (n * n + n * n) (n * n)} (hfan : c.FanInAtMost 2) (hc : Taylor.FormallyComputes P c (matMul n MvPolynomial.X)) :
(↑n ^ 2 - 1) / 2 ≤ (A + η) * max (↑c.size - 2 * ↑n ^ 2) 0 + 3 * Real.logb 2 (2 * ↑n ^ 2 + 3 * ↑c.size) + C

The finite bound for polynomial gates over any field. If a fan-in-two circuit with polynomial gates over any field formally computes matMul n, then under the graph-ordering hypothesis (n² - 1)/2 ≤ (A + η) (s - 2 n²)⁺ + 3 log₂ (2 n² + 3 s) + C for its size s.

theorem Algebraic.Cutwidth.MultiOutput.half_sq_le_of_matMul_zmod {σ : Signature} {n : ℕ} {A η C : ℝ} (hAη : 0 ≤ A + η) (order : Multigraph.OrderingBound A η C) {q : ℕ} [Fact (Nat.Prime q)] (hq : 2 * n ≤ q) {I : Interpretation σ (ZMod q)} {c : Circuit σ (n * n + n * n) (n * n)} (hfan : c.FanInAtMost 2) (hc : c.Computes I (matMul n)) :
(↑n ^ 2 - 1) / 2 ≤ (A + η) * max (↑c.size - 2 * ↑n ^ 2) 0 + 3 * Real.logb 2 (2 * ↑n ^ 2 + 3 * ↑c.size) + C

The finite bound over ZMod q. For a prime q ≥ 2 n, the Cauchy matrix cauchyZMod q n is totally regular, so every circuit over ZMod q with fan-in at most two computing matMul n has (n² - 1)/2 ≤ (A + η) (s - 2 n²)⁺ + 3 log₂ (2 n² + 3 s) + C.

Asymptotic bounds #

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul_of_orderingBound {A : ℝ} (hA : 0 < A) (order : ∀ (η : ℝ), 0 < η → ∃ (C : ℝ), Multigraph.OrderingBound A η C) {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (F : Type u) [inst : Field F] [Fintype F] (σ : Signature) (I : Interpretation σ F) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → c.Computes I (matMul n) → (2 + 1 / (2 * A) - ε) * ↑n ^ 2 < ↑c.size

The asymptotic bound with a general ordering coefficient. If the graph-ordering hypothesis holds with coefficient A > 0 for every positive slack, then for every ε > 0 and all large n, every fan-in-two circuit over a finite field computing matMul n has more than (2 + 1/(2 A) - ε) n² gates.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (F : Type u) [inst : Field F] [Fintype F] (σ : Signature) (I : Interpretation σ F) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → c.Computes I (matMul n) → (2 + 1 / (4 * Gaussian.frontierCoefficient) - ε) * ↑n ^ 2 < ↑c.size

Matrix multiplication needs (2 + 1/(4 κ_E) - ε) n² gates. For every ε > 0 and all large n, every circuit over a finite field, over any signature with fan-in at most two, computing the product of two n × n matrices has more than (2 + 1/(4 κ_E) - ε) n² gates, where κ_E = Gaussian.frontierCoefficient; the coefficient is 2 + π/(6 arccos((1 + 2√2)/4)) ≈ 3.7812.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul_thirtyFour_div_nine {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (F : Type u) [inst : Field F] [Fintype F] (σ : Signature) (I : Interpretation σ F) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → c.Computes I (matMul n) → (34 / 9 - ε) * ↑n ^ 2 < ↑c.size

Matrix multiplication needs (34/9 - ε) n² gates.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_matMul_zmod_two {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (σ : Signature) (I : Interpretation σ (ZMod 2)) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → c.Computes I (matMul n) → (2 + 1 / (4 * Gaussian.frontierCoefficient) - ε) * ↑n ^ 2 < ↑c.size

Boolean matrix multiplication modulo two needs (2 + 1/(4 κ_E) - ε) n² binary gates. For every ε > 0 and all large n, every circuit over GF(2) = ZMod 2 with fan-in at most two, so in particular every circuit over the full binary basis B₂, computing the product of two n × n matrices over GF(2) has more than (2 + 1/(4 κ_E) - ε) n² ≈ (3.7812 - ε) n² gates.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_matMul_zmod_two_thirtyFour_div_nine {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (σ : Signature) (I : Interpretation σ (ZMod 2)) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → c.Computes I (matMul n) → (34 / 9 - ε) * ↑n ^ 2 < ↑c.size

Boolean matrix multiplication modulo two needs (34/9 - ε) n² binary gates.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul_polynomial_of_orderingBound {A : ℝ} (hA : 0 < A) (order : ∀ (η : ℝ), 0 < η → ∃ (C : ℝ), Multigraph.OrderingBound A η C) {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] (σ : Signature) (P : (op : σ.Op) → MvPolynomial (Fin (σ.Arity op)) K) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → Taylor.FormallyComputes P c (matMul n MvPolynomial.X) → (2 + 1 / (2 * A) - ε) * ↑n ^ 2 < ↑c.size

The asymptotic bound for polynomial gates with a general ordering coefficient.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul_polynomial {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] (σ : Signature) (P : (op : σ.Op) → MvPolynomial (Fin (σ.Arity op)) K) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → Taylor.FormallyComputes P c (matMul n MvPolynomial.X) → (2 + 1 / (4 * Gaussian.frontierCoefficient) - ε) * ↑n ^ 2 < ↑c.size

Matrix multiplication needs (2 + 1/(4 κ_E) - ε) n² polynomial gates over every field. For every ε > 0 and all large n, every circuit with polynomial gates of fan-in at most two over any field, of any degree and with any coefficients, formally computing the product of two n × n matrices has more than (2 + 1/(4 κ_E) - ε) n² gates.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul_polynomial_thirtyFour_div_nine {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] (σ : Signature) (P : (op : σ.Op) → MvPolynomial (Fin (σ.Arity op)) K) (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → Taylor.FormallyComputes P c (matMul n MvPolynomial.X) → (34 / 9 - ε) * ↑n ^ 2 < ↑c.size

Matrix multiplication needs (34/9 - ε) n² polynomial gates over every field.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul_of_infinite {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] [Infinite K] (σ : Signature) (I : Interpretation σ K), Polynomial.IsPolynomial I → ∀ (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → c.Computes I (matMul n) → (2 + 1 / (4 * Gaussian.frontierCoefficient) - ε) * ↑n ^ 2 < ↑c.size

Matrix multiplication with polynomial gates over an infinite field. For every ε > 0 and all large n, over every infinite field, every circuit whose operations are polynomial functions of at most two arguments and which computes matrix multiplication as a function has more than (2 + 1/(4 κ_E) - ε) n² gates.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_size_of_matMul_of_infinite_thirtyFour_div_nine {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] [Infinite K] (σ : Signature) (I : Interpretation σ K), Polynomial.IsPolynomial I → ∀ (c : Circuit σ (n * n + n * n) (n * n)), c.FanInAtMost 2 → c.Computes I (matMul n) → (34 / 9 - ε) * ↑n ^ 2 < ↑c.size

Matrix multiplication with polynomial gates over an infinite field needs (34/9 - ε) n² gates.

theorem Algebraic.Cutwidth.MultiOutput.matMul_nonconstant {n : ℕ} {K : Type u_1} [Field K] (o : Fin (n * n)) :
∃ (x : Fin (n * n + n * n) → K) (y : Fin (n * n + n * n) → K), matMul n x o ≠ matMul n y o

Every output entry of matrix multiplication is a nonconstant function.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_arithmeticCost_of_matMul {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] [Infinite K] (Kc : Type v) (constant : Kc → K) (c : Circuit (Arithmetic.signature Kc) (n * n + n * n) (n * n)), c.Computes (Arithmetic.interpretation constant) (matMul n) → (2 + 1 / (4 * Gaussian.frontierCoefficient) - ε) * ↑n ^ 2 < ↑(c.cost Arithmetic.gateCost)

Arithmetic circuits with free constants. For every ε > 0 and all large n, over every infinite field, every circuit of additions, multiplications and constants computing the product of two n × n matrices performs more than (2 + 1/(4 κ_E) - ε) n² additions and multiplications; constants are free.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_arithmeticCost_of_matMul_thirtyFour_div_nine {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] [Infinite K] (Kc : Type v) (constant : Kc → K) (c : Circuit (Arithmetic.signature Kc) (n * n + n * n) (n * n)), c.Computes (Arithmetic.interpretation constant) (matMul n) → (34 / 9 - ε) * ↑n ^ 2 < ↑(c.cost Arithmetic.gateCost)

Arithmetic circuits with free constants need (34/9 - ε) n² operations.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_arithmeticCost_of_matMul_formal {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] (Kc : Type v) (constant : Kc → K) (c : Circuit (Arithmetic.signature Kc) (n * n + n * n) (n * n)), Taylor.FormallyComputes (Taylor.arithmeticPolynomial constant) c (matMul n MvPolynomial.X) → (2 + 1 / (4 * Gaussian.frontierCoefficient) - ε) * ↑n ^ 2 < ↑(c.cost Arithmetic.gateCost)

Arithmetic circuits with free constants over every field. For every ε > 0 and all large n, over every field K, every circuit of additions, multiplications and constants of K formally computing the product of two n × n matrices performs more than (2 + 1/(4 κ_E) - ε) n² additions and multiplications; constants are free.

theorem Algebraic.Cutwidth.MultiOutput.eventually_lt_arithmeticCost_of_matMul_formal_thirtyFour_div_nine {ε : ℝ} (hε : 0 < ε) :
∀ᶠ (n : ℕ) in Filter.atTop, ∀ (K : Type u) [inst : Field K] (Kc : Type v) (constant : Kc → K) (c : Circuit (Arithmetic.signature Kc) (n * n + n * n) (n * n)), Taylor.FormallyComputes (Taylor.arithmeticPolynomial constant) c (matMul n MvPolynomial.X) → (34 / 9 - ε) * ↑n ^ 2 < ↑(c.cost Arithmetic.gateCost)

Arithmetic circuits with free constants over every field need (34/9 - ε) n² operations.