The red-blue pebble game: the ordinary algorithm for matrix multiplication, as a graph #
Support module of MiscMath.Computability.RedBluePebbleGame, where the results are stated and
where the reader should start. Nothing here is a result on its own.
The graph of the ordinary algorithm for the product of an m × k matrix A by a k × n matrix
B, each entry of the product summed left to right (MatMulChain.edge). Its vertices are the
entries of A and B, the products A i l * B l j, and for each entry (i, j) of the product
the partial sums of its products at positions 0, …, r + 1, for r < k - 1. The inputs are the
vertices with no predecessor and the outputs those with no successor.
For m, k, n ≥ 1 it is an IsMatMulEvaluation (MatMulChain.isMatMulEvaluation), and it has a
complete calculation exactly when S ≥ 3 (MatMulChain.complete_iff): the witness of
exists_isMatMulEvaluation. Three red pebbles suffice for any finite graph whose non-inputs each
have exactly two predecessors and which some rank orders (hasCompleteCalculation_of_rank, which
generalises the FFT graph's fft_run_union): load the two predecessors, compute, store, clear.
A rank that every edge raises rules out cycles.
In a graph ordered by a rank, in which every non-input has exactly two predecessors, every predecessor-closed set of non-inputs can be computed and stored with three red pebbles.
Three red pebbles suffice for a finite graph ordered by a rank, in which every non-input has exactly two predecessors, whatever its outputs: compute and store every vertex, then delete the blue pebbles off the vertices that are not outputs.
The vertices of the graph of the ordinary algorithm for the product of an m × k matrix A by
a k × n matrix B, each entry of the product summed left to right.
- a
{m k n : ℕ}
(i : Fin m)
(l : Fin k)
: Vertex m k n
The entry
A i l. - b
{m k n : ℕ}
(l : Fin k)
(j : Fin n)
: Vertex m k n
The entry
B l j. - prod
{m k n : ℕ}
(i : Fin m)
(l : Fin k)
(j : Fin n)
: Vertex m k n
The product
A i l * B l j. - sum
{m k n : ℕ}
(i : Fin m)
(r : Fin (k - 1))
(j : Fin n)
: Vertex m k n
The partial sum of the products
A i l * B l jforl ≤ r + 1.
Instances For
Equations
- One or more equations did not get rendered due to their size.
The edges: each product from its two factors, the first partial sum of an entry from its first two products, and each later partial sum from the one before it and the next product. Indices are compared as natural numbers.
Equations
- One or more equations did not get rendered due to their size.
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.edge x✝¹ x✝ = False
Instances For
Equations
- One or more equations did not get rendered due to their size.
A rank raised by every edge.
Equations
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.rank (MiscMath.Computability.RedBluePebbleGame.MatMulChain.Vertex.a a a_1) = 0
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.rank (MiscMath.Computability.RedBluePebbleGame.MatMulChain.Vertex.b a a_1) = 0
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.rank (MiscMath.Computability.RedBluePebbleGame.MatMulChain.Vertex.prod a a_1 a_2) = 1
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.rank (MiscMath.Computability.RedBluePebbleGame.MatMulChain.Vertex.sum a a_1 a_2) = ↑a_1 + 2
Instances For
The entry of the product that a product or a partial sum belongs to.
Equations
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.entry (MiscMath.Computability.RedBluePebbleGame.MatMulChain.Vertex.prod i l j) = some (i, j)
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.entry (MiscMath.Computability.RedBluePebbleGame.MatMulChain.Vertex.sum i r j) = some (i, j)
- MiscMath.Computability.RedBluePebbleGame.MatMulChain.entry x✝ = none
Instances For
The inputs: the vertices with no predecessor.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The outputs: the vertices with no successor.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Every vertex that is not an input has exactly two predecessors.