Lecture 13: relations and matrices [00I6]
- January 19, 2024
- Jon Sterling, with contributions from Marcelo Fiore
These lecture notes were prepared by Jon Sterling using Marcelo Fiore’s lectures as source material. Any mistakes were introduced by Jon Sterling. Generative AI was not used to write these lecture notes.
Basic definitions [00J6]
- January 18, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Definition Relation [00I7]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
A (binary) relation R from a set A to a set B, written R\colon A\mathbin {\nrightarrow } B or R: \mathrm {Rel}{\mathopen {}\left (A,B\right )\mathclose {}} is defined to be a subset R\subseteq A\times B. We shall typically write a\mathrel {R}b for {\mathopen {}\left (a,b\right )\mathclose {}}: R. More generally, a relation between multiple sets {\mathopen {}\left (A_i\right )\mathclose {}}_{i: I} is defined to be a subset of the product \prod _{i: I} A_i.
Lemma Relational extensionality [00IM]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Let A and B be two sets, and let R,S\colon A\mathbin {\nrightarrow } B be two relations from A to B. Then we have R=S if and only if \forall {a: A}\mathpunct {.} \forall {b: B}\mathpunct {.} a\mathrel {R}b\Longleftrightarrow a\mathrel {S}b.
Proof.
- January 17, 2024
- Jon Sterling
We recall that relation from A to B is nothing more than a subset of A\times B. By the axiom of extensionality, two subsets of A\times B are equal if and only if they contain precisely the same elements.
Uses of relations in computer science [00I8]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Example Relations in program specification [00I9]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
In the simplest terms, a specification of a program is a relation that describes the possible input/output pairs that can occur. For example, the specification that a given program compute the square root is captured by the relation \mathsf {sq} \colon \mathbb {R}_{\geq 0} \mathbin {\nrightarrow } \mathbb {R} given by pairs {\mathopen {}\left (x,y\right )\mathclose {}} such that x = y^2.
Example Relations in operational semantics [00IA]
- January 17, 2024
- Jon Sterling
Let E represent the set of states in a machine; then the behavior of this machine is usually described by a pair of relations S \colon E\mathbin {\nrightarrow } E and V\colon E\mathbin {\nrightarrow } {\mathopen {}\left \{\star \right \}\mathclose {}}, such that e\mathrel {S} e' when it is possible for the machine to transition from state e to e' and such that e\mathrel {V} \star when the machine can halt in state e.
Example Relations in program typing [00IB]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Let E be the set of expression in a given programming language, and let T be the set of types in that programming language. Then the property of a given program having a certain type forms a relation E\mathbin {\nrightarrow } T.
Example Relations for program equivalence [00IC]
- January 17, 2024
- Jon Sterling
Let e,e' be two programs of type \tau . We say that e and e' are observationally equivalent when for any other program h\colon \tau \to {\mathopen {}\left (\right )\mathclose {}}, then h{\mathopen {}\left (e\right )\mathclose {}} terminates if and only if h{\mathopen {}\left (e'\right )\mathclose {}} terminates. If E_\tau is the set of programs of type \tau , observational equivalence therefore forms a relation E_\tau \mathbin {\nrightarrow } E_\tau .
Example Networks as relations [00ID]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
A network is given by a set of nodes N and a relation C\colon N\mathbin {\nrightarrow } N expressing with two nodes are connected.
Example Relations in databases [00IE]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
We now come to an example of a relation between multiple sets: we could define a relation R\subseteq \text {Movies}\times \text {Directors}\times \text {Years}\times \text {People} consisting of tuples {\mathopen {}\left (m,d,y,p\right )\mathclose {}} where m is a movie directed by d in year y with p as a cast member.
Formal examples of relations [00IF]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Example The empty relation [00IG]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
For any two sets A and B, we may form the empty relation \varnothing \colon A\mathbin {\nrightarrow } B that relates no elements. In other words, \varnothing is the empty subset of A\times B.
Example The full relation [00IH]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
For any two sets A and B, we may form the full relation {\mathopen {}\left (A\times B\right )\mathclose {}}\colon A\mathbin {\nrightarrow } B, also called the total relation, so that a\mathrel {{\mathopen {}\left (A\times B\right )\mathclose {}}}b for all a:A and b:B. In other words, {\mathopen {}\left (A\times B\right )\mathclose {}} is the total subset of A\times B.
Example The identity relation [00II]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
We have already seen the square root relation from positive reals to reals, which corresponds to a total but many-valued function. We can define an analogous relationship in Example [00IJ] below from positive integers (naturals) to integers, which will correspond to a partial and many-valued function.
Example The integer square root relation [00IJ]
- January 17, 2024
- Jon Sterling
The square root operation corresponds to a relation R_2\colon \mathbb {N}\mathbin {\nrightarrow }\mathbb {Z} such that m\mathrel {R_2} n if and only if m = n^2.
Visualising relations [00J5]
- January 18, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Notation Internal diagrams of relations [00IK]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
A useful way to visualise a relation between two sets is by means of internal diagrams: each set is depicted as a blob containing its elements, and lines are drawn from the elements of one blob to the elements of the second blob when they are related.
In particular, let R\colon \mathbb {N}\mathbin {\nrightarrow }\mathbb {Z} be the following relation:
R = {\mathopen {}\left \{ {\mathopen {}\left (0,0\right )\mathclose {}}, {\mathopen {}\left (1,-1\right )\mathclose {}}, {\mathopen {}\left (0,1\right )\mathclose {}}, {\mathopen {}\left (1,2\right )\mathclose {}}, {\mathopen {}\left (1,1\right )\mathclose {}}, {\mathopen {}\left (2,1\right )\mathclose {}} \right \}\mathclose {}}We can depict R by the following internal diagram:
Exercise An internal diagram [00IL]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Draw the internal diagram corresponding to the following relation:
\begin {aligned} S&\colon \mathbb {Z}\mathbin {\nrightarrow }\mathbb {Z}\\ S&= {\mathopen {}\left \{ {\mathopen {}\left (1,0\right )\mathclose {}}, {\mathopen {}\left (1,2\right )\mathclose {}}, {\mathopen {}\left (2,1\right )\mathclose {}}, {\mathopen {}\left (2,3\right )\mathclose {}} \right \}\mathclose {}} \end {aligned}Relational composition [00IQ]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Definition Relational composite [00IN]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Given relations R\colon A\mathbin {\nrightarrow } B and S\colon B\mathbin {\nrightarrow } C, we can define the relational composite S\circ R\colon A\mathbin {\nrightarrow } C in a way that generalises composition of functions. In particular, we define S\circ R to be the following subset of A\times C:
\begin {aligned} S\circ R &\colon A\mathbin {\nrightarrow } C\\ S\circ R &= {\mathopen {}\left \{ {\mathopen {}\left (a,c\right )\mathclose {}}: A\times C \,\middle \vert \, \exists b: B\mathpunct {.} a\mathrel {R}b \land b\mathrel {S} c \right \}\mathclose {}} \end {aligned}Example Negation invariance of the square root relation [00IO]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Recall the square root relation \mathsf {sq}\colon \mathbb {R}_{\geq 0}\mathbin {\nrightarrow } \mathbb {R} from Example [00I9], and let \mathsf {neg} \colon \mathbb {R}\mathbin {\nrightarrow }\mathbb {R} be the relation {\mathopen {}\left \{(x,y):\mathbb {R}^2\mid x = -y\right \}\mathclose {}}. Then the relational composite \mathsf {neg}\circ \mathsf {sq}\colon \mathbb {R}_{\geq 0}\mathbin {\nrightarrow }\mathbb {R} is equal to \mathsf {sq}.
Proof.
- January 17, 2024
- Jon Sterling
By relational extensionality, it suffices to check that for any x: \mathbb {R}_{\geq 0} and y: \mathbb {R}, we have x\mathrel {{\mathopen {}\left (\mathsf {neg}\circ \mathsf {sq}\right )\mathclose {}}} y if and only if x\mathrel {\mathsf {sq}}y. We compute:
\begin {aligned} x\mathrel {{\mathopen {}\left (\mathsf {neg}\circ \mathsf {sq}\right )\mathclose {}}} y &\Longleftrightarrow \exists z:\mathbb {R}\mathpunct {.} x\mathrel {\mathsf {sq}}z \land z \mathrel {\mathsf {neg}}y \\ &\Longleftrightarrow \exists z:\mathbb {R}\mathpunct {.} x=z^2 \land z =-y \\ &\Longleftrightarrow x={\mathopen {}\left (-y\right )\mathclose {}}^2 \\ &\Longleftrightarrow x = y^2 \\ &\Longleftrightarrow x\mathrel {\mathsf {sq}}y \end {aligned}Lemma Associativity and unit laws of relational composition [00IP]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Relational composition is associative and has the identity relation as a neutral element.
Proof.
- January 17, 2024
- Jon Sterling
To prove associativity, we fix relations R\colon A\mathbin {\nrightarrow } B, S\colon B\mathbin {\nrightarrow } C, and T\colon C\mathbin {\nrightarrow } D to prove {\mathopen {}\left (T\circ S\right )\mathclose {}}\circ R = T\circ {\mathopen {}\left (S\circ R\right )\mathclose {}}. To get started, we compute the intermediate composites:
\begin {aligned} b\mathrel {{\mathopen {}\left (T\circ S\right )\mathclose {}}}d &\Longleftrightarrow \exists c: C\mathpunct {.} b\mathrel {S}c\land c\mathrel {T}d \\ a\mathrel {{\mathopen {}\left (S\circ R\right )\mathclose {}}}c &\Longleftrightarrow \exists b: B\mathpunct {.} a\mathrel {R}b\land b\mathrel {S}c \end {aligned}Using the above, we can compute the full composites:
\begin {aligned} a\mathrel {{\mathopen {}\left ({\mathopen {}\left (T\circ S\right )\mathclose {}}\circ R\right )\mathclose {}}} d &\Longleftrightarrow \exists b : B\mathpunct {.} a\mathrel {R}b \land b\mathrel {{\mathopen {}\left (T\circ S\right )\mathclose {}}} d \\ &\Longleftrightarrow \exists b: B\mathpunct {.} a\mathrel {R}b \land \exists c: C\mathpunct {.} c\mathrel {S}c\land c\mathrel {T}d \\ &\Longleftrightarrow \exists b: B\mathpunct {.} \exists c: C\mathpunct {.} a\mathrel {R}b \land b\mathrel {S}c\land c\mathrel {T}d \\ &\Longleftrightarrow \exists c: C\mathpunct {.} {\mathopen {}\left (\exists b: B\mathpunct {.} a\mathrel {R}b\land b\mathrel {S}c\right )\mathclose {}}\land c\mathrel {T}d \\ &\Longleftrightarrow \exists c : C\mathpunct {.} a\mathrel {{\mathopen {}\left (S\circ R\right )\mathclose {}}}c\land c\mathrel {T}d \\ &\Longleftrightarrow a \mathrel {{\mathopen {}\left (T\circ {\mathopen {}\left (S\circ R\right )\mathclose {}}\right )\mathclose {}}}d \end {aligned}For the right and left neutrality, we must prove that R\circ \mathsf {id}_{A} = R = \mathsf {id}_{B}\circ R for all r\colon A\mathbin {\nrightarrow } B. We prove only the first law, as the other proof is analogous:
\begin {aligned} a \mathrel {{\mathopen {}\left (R\circ \mathsf {id}_{A}\right )\mathclose {}}} b &\Longleftrightarrow \exists a':A\mathpunct {.} a\mathrel {\mathsf {id}_{A}}a' \land a' \mathrel {R}b \\ &\Longleftrightarrow \exists a': A\mathpunct {.} a = a' \land a' \mathrel {R}b \\ &\Longleftrightarrow a \mathrel {R} b \end {aligned}Relations and matrices [00IR]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Relations between finite sets can be desribed in a more computationally friendly way by their tabulation as matrices. In particular, we shall see in § [00J1] that an {\mathopen {}\left (m\times n\right )\mathclose {}}-matrix over the boolean semiring is precisely the same thing as a relation from {\mathopen {}\left [m\right ]\mathclose {}} to {\mathopen {}\left [n\right ]\mathclose {}}, where {\mathopen {}\left [l\right ]\mathclose {}}={\mathopen {}\left \{i\mid 0\leq i < l\right \}\mathclose {}} is the set of natural numbers strictly smaller than l. Then we will see that relational composition is, under this correspondence, the same as matrix multiplication.
Definition Matrix over a semiring [00IS]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
For natural numbers m and n, an {\mathopen {}\left (m\times n\right )\mathclose {}}-matrix over a semiring {\mathopen {}\left (S,0,\oplus ,1,\odot \right )\mathclose {}} is given by entries M_{i,j}: S for all i:{\mathopen {}\left [m\right ]\mathclose {}} and j: {\mathopen {}\left [n\right ]\mathclose {}}. We will write \mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}} for the set of {\mathopen {}\left (m\times n\right )\mathclose {}}-matrices.
Notation Matrices as tables [00J4]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
{\mathopen {}\left (m\times n\right )\mathclose {}}-matrices can be depicted in tables or grids with rows in the first dimension and columns in the second dimension. For example, let M:\mathrm {Mat}_{\mathbb {B}}{\mathopen {}\left (3,2\right )\mathclose {}} be the matrix over the booleans defined by the following equation:
M_{i,j} = \begin {cases} \mathsf {true} &\text {if } \mathsf {parity}{\mathopen {}\left (i\right )\mathclose {}} = \mathsf {parity}{\mathopen {}\left (j\right )\mathclose {}} \\ \mathsf {false} &\text {otherwise} \end {cases}Then M is depicted by the following table with three rows and two columns:
M = \begin {bmatrix} \mathsf {true} & \mathsf {false}\\ \mathsf {false} & \mathsf {true}\\ \mathsf {true} & \mathsf {false} \end {bmatrix}Definition The identity matrix [00IT]
- January 17, 2024
- Jon Sterling
For any m: \mathbb {N}, we define the identity {\mathopen {}\left (m\times m\right )\mathclose {}}-matrix over a given semiring S as follows:
I^m_{i,j} = \begin {cases} 1&\text {if } i=j\\ 0&\text {otherwise} \end {cases}The identity matrix is sometimes called the diagonal matrix, for reasons that become apparent when visualising it according to Notation [00J4]:
I^4 = \begin {bmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end {bmatrix}Correspondence between matrices and finite relations [00J1]
- January 17, 2024
- Jon Sterling
Definition The matrix associated to a finite relation [00IY]
- January 17, 2024
- Jon Sterling
Let R\colon {\mathopen {}\left [m\right ]\mathclose {}}\mathbin {\nrightarrow }{\mathopen {}\left [n\right ]\mathclose {}} be a relation; for any semiring S, we may form the {\mathopen {}\left (n\times n\right )\mathclose {}}-matrix over S associated to R as follows:
{\mathopen {}\left (\operatorname {\underline {mat}}_S{R}\right )\mathclose {}}_{i:{\mathopen {}\left [m\right ]\mathclose {}},j:{\mathopen {}\left [n\right ]\mathclose {}}} = \begin {cases} 1&\text {if } i\mathrel {R}j \\ 0&\text {otherwise} \end {cases}We have defined a function \operatorname {\underline {mat}}_S\colon \mathrm {Rel}{\mathopen {}\left ({\mathopen {}\left [m\right ]\mathclose {}},{\mathopen {}\left [n\right ]\mathclose {}}\right )\mathclose {}} \to \mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}}.
Definition The relation associated to a matrix [00IZ]
- January 17, 2024
- Jon Sterling
Let M be an {\mathopen {}\left (n\times n\right )\mathclose {}}-matrix over a semiring S. We define the relation associated to M below:
\begin {aligned} \operatorname {\underline {rel}}_S{M} &\colon {\mathopen {}\left [m\right ]\mathclose {}}\mathbin {\nrightarrow }{\mathopen {}\left [n\right ]\mathclose {}} \\ i\mathrel {{\mathopen {}\left (\operatorname {\underline {rel}}_S{M}\right )\mathclose {}}} j &\Longleftrightarrow M_{i,j} = 1 \end {aligned}We have defined a function \operatorname {\underline {rel}}_S\colon \mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}}\to \mathrm {Rel}{\mathopen {}\left ({\mathopen {}\left [m\right ]\mathclose {}},{\mathopen {}\left [n\right ]\mathclose {}}\right )\mathclose {}}.
Lemma A retraction from matrices to finite relations [00J0]
- January 17, 2024
- Jon Sterling
The associated matrix function \operatorname {\underline {mat}}_S\colon \mathrm {Rel}{\mathopen {}\left ({\mathopen {}\left [m\right ]\mathclose {}},{\mathopen {}\left [n\right ]\mathclose {}}\right )\mathclose {}} \to \mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}} is a section of the associated relation function \operatorname {\underline {rel}}_S\colon \mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}}\to \mathrm {Rel}{\mathopen {}\left ({\mathopen {}\left [m\right ]\mathclose {}},{\mathopen {}\left [n\right ]\mathclose {}}\right )\mathclose {}} for any semiring S.
Proof.
- January 17, 2024
- Jon Sterling
We must check that \operatorname {\underline {rel}}_S\circ \operatorname {\underline {mat}}_S = \mathsf {id}_{\mathrm {Rel}{\mathopen {}\left ({\mathopen {}\left [m\right ]\mathclose {}},{\mathopen {}\left [n\right ]\mathclose {}}\right )\mathclose {}}}. Fixing a relation R\colon {\mathopen {}\left [m\right ]\mathclose {}}\mathbin {\nrightarrow }{\mathopen {}\left [n\right ]\mathclose {}}, we compute:
\begin {aligned} i\mathrel {{\mathopen {}\left (\operatorname {\underline {rel}}_S{\mathopen {}\left (\operatorname {\underline {mat}}_SR\right )\mathclose {}}\right )\mathclose {}}} j &\Longleftrightarrow {\mathopen {}\left (\operatorname {\underline {mat}}_SR\right )\mathclose {}}_{i,j} = 1 \\ &\Longleftrightarrow i\mathrel {R}j \end {aligned}The other composite \operatorname {\underline {mat}}_S\circ \operatorname {\underline {rel}}_S\colon \mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}}\to \mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}} is not in general the identity function, but is (necessarily) an idempotent on the set of matrices over S. We will see that this idempotent, in some sense, measures the degree to which the base semiring S is not boolean.
Lemma Finite relations as matrices over the booleans [00IX]
- January 17, 2024
- Jon Sterling
The idempotent {\operatorname {\underline {mat}}_\mathbb {B}\circ \operatorname {\underline {rel}}_\mathbb {B}\colon \mathrm {Mat}_{\mathbb {B}}{\mathopen {}\left (m,n\right )\mathclose {}}\to \mathrm {Mat}_{\mathbb {B}}{\mathopen {}\left (m,n\right )\mathclose {}}} is in fact the identity function on matrices over the boolean semiring \mathbb {B}.
Proof.
- January 17, 2024
- Jon Sterling
We fix a matrix M:\mathrm {Mat}_{\mathbb {B}}{\mathopen {}\left (m,n\right )\mathclose {}} and compute:
\begin {aligned} {\mathopen {}\left (\operatorname {\underline {mat}}_\mathbb {B}{\mathopen {}\left (\operatorname {\underline {rel}}_\mathbb {B} M\right )\mathclose {}}\right )\mathclose {}}_{i,j} &= \begin {cases} 1 &\text {if } i \mathrel {{\mathopen {}\left (\operatorname {\underline {rel}}_\mathbb {B} M\right )\mathclose {}}} j\\ 0 &\text {otherwise} \end {cases} \\ &= \begin {cases} 1 &\text {if } M_{i,j} = 1\\ 0 &\text {otherwise} \end {cases} \end {aligned}Because \mathbb {B} is the boolean semiring, any scalar s: S is either 0 or 1. Therefore, we conclude:
{\mathopen {}\left (\operatorname {\underline {mat}}_\mathbb {B}{\mathopen {}\left (\operatorname {\underline {rel}}_\mathbb {B} M\right )\mathclose {}}\right )\mathclose {}}_{i,j} = M_{i,j}Thus we conclude that an {\mathopen {}\left (m\times n\right )\mathclose {}}-matrix over the booleans is the same thing as a relation from {\mathopen {}\left [m\right ]\mathclose {}} to {\mathopen {}\left [n\right ]\mathclose {}}.
Multiplication of matrices [00IW]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Remark Matrix multiplication in geometry [00IU]
- January 17, 2024
- Jon Sterling
Although we do not explore it in this course, the viewpoint of matrix multiplication as relational composition generalises to a correct explanation of the role of matrices in geometry as presentations of linear maps between vector spaces in terms of an (uncanonical) choice of basis.
Definition Product of matrices [00IV]
- January 17, 2024
- Jon Sterling
Let M be an {\mathopen {}\left (l\times m\right )\mathclose {}}-matrix and let N be a {\mathopen {}\left (m\times n\right )\mathclose {}}-matrix. The product of M and N, written M\otimes N, is the following {\mathopen {}\left (l\times n\right )\mathclose {}}-matrix:
{\mathopen {}\left (N\otimes M\right )\mathclose {}}_{i: {\mathopen {}\left [l\right ]\mathclose {}},j:{\mathopen {}\left [n\right ]\mathclose {}}} = \bigoplus _{k: {\mathopen {}\left [m\right ]\mathclose {}}} N_{k,j}\odot M_{i,k}Lemma Associativity and unit laws of matrix products [00J3]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
The product of matrices is associative and has the identity matrix as neutral element.
Proof.
- January 17, 2024
- Jon Sterling
For associativity, fix matrices L:\mathrm {Mat}_{S}{\mathopen {}\left (k,l\right )\mathclose {}}, M:\mathrm {Mat}_{S}{\mathopen {}\left (l,m\right )\mathclose {}} and N:\mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}} to check that {\mathopen {}\left (N\otimes M\right )\mathclose {}}\otimes L = N\otimes {\mathopen {}\left (M\otimes L\right )\mathclose {}}. Below we use the associativity of multiplication, commutativity of addition, and distributivity of multiplication over addition in the semiring S:
\begin {aligned} {\mathopen {}\left ({\mathopen {}\left (N\otimes M\right )\mathclose {}}\otimes L\right )\mathclose {}}_{a,d} &= \bigoplus _{b:{\mathopen {}\left [l\right ]\mathclose {}}} {\mathopen {}\left (N\otimes M\right )\mathclose {}}_{b,d}\odot L_{a,b} \\ &= \bigoplus _{b:{\mathopen {}\left [l\right ]\mathclose {}}} {\mathopen {}\left ( \bigoplus _{c:{\mathopen {}\left [m\right ]\mathclose {}}} N_{c,d}\odot M_{b,c} \right )\mathclose {}} \odot L_{a,b} \\ &= \bigoplus _{b:{\mathopen {}\left [l\right ]\mathclose {}}} \bigoplus _{c: {\mathopen {}\left [m\right ]\mathclose {}}} N_{c,d}\odot M_{b,c}\odot L_{a,b} \\ &= \bigoplus _{c: {\mathopen {}\left [m\right ]\mathclose {}}} N_{c,d}\odot \bigoplus _{b:{\mathopen {}\left [l\right ]\mathclose {}}} M_{b,c}\odot L_{a,b} \\ &= \bigoplus _{c: {\mathopen {}\left [m\right ]\mathclose {}}} N_{c,d}\odot {\mathopen {}\left (M\otimes L\right )\mathclose {}}_{a,c} \\ &= {\mathopen {}\left (N\otimes {\mathopen {}\left (M\otimes L\right )\mathclose {}}\right )\mathclose {}}_{a,d} \end {aligned}For one unit law, we fix M:\mathrm {Mat}_{S}{\mathopen {}\left (m,n\right )\mathclose {}} and recall the definition of the identity matrix to check that M\otimes I^m = M.
\begin {aligned} {\mathopen {}\left (M\otimes I^m\right )\mathclose {}}_{i,j} &= \bigoplus _{k: {\mathopen {}\left [m\right ]\mathclose {}}} M_{k, j} \odot I^m_{i,k} \end {aligned}Unfolding the definition of I^m_{i,j} as given in Definition [00IT], we see that the iterated sum above expands to m-1 copies of 0\odot M_{k,j} for various k \not = i and one copy of 1\odot M_{i,j}. Thus, we conclude that M\otimes I^m_{i,j} = M_{i,j} using the absorption and unit laws for multiplication as well as the unit laws for addition in S.
The other unit law follows in an analogous way.
Lemma Matrix product is relational composition [00J2]
- January 17, 2024
- Jon Sterling, with contributions from Marcelo Fiore
Under the correspondence between boolean matrices and finite relations (§ [00J1], Lemma [00IX]), matrix products of boolean matrices correspond to relational composites. In particular, given M:\mathrm {Mat}_{\mathbb {B}}{\mathopen {}\left (l,m\right )\mathclose {}} and N:\mathrm {Mat}_{\mathbb {B}}{\mathopen {}\left (m,n\right )\mathclose {}}, we have:
\operatorname {\underline {rel}}_\mathbb {B}{\mathopen {}\left (N\otimes M\right )\mathclose {}} = \operatorname {\underline {rel}}_\mathbb {B} N\circ \operatorname {\underline {rel}}_\mathbb {B} MProof.
- January 17, 2024
- Jon Sterling
We use the fact that the additive operation of the boolean semiring is disjunction and the multiplicative operation is conjunction:
\begin {aligned} {\mathopen {}\left (N\otimes M\right )\mathclose {}}_{i,j} &= \bigoplus _{k:{\mathopen {}\left [m\right ]\mathclose {}}} N_{k,j}\odot M_{i,k} \\ &= \bigvee _{k:{\mathopen {}\left [m\right ]\mathclose {}}} N_{k,j}\land M_{i,k} \\ &= \exists k:{\mathopen {}\left [m\right ]\mathclose {}}\mathpunct {.} M_{i,k}\land N_{k,j} \end {aligned}