<aside> <img src="/icons/arrow-right-basic_gray.svg" alt="/icons/arrow-right-basic_gray.svg" width="40px" /> Thoughts are connections, and connections compose.

</aside>

We now define relation composition in binary logic, and see that it is dual to how relations transform.

Let $\mathrm{A,B,C}$ be sets, and let $R:\mathrm{A\,|\, B}$ and $S:\mathrm{B\,|\,C}$ be 0/1-relations.

comp.png

Example. $\mathrm{A}$ is animals, $\mathrm{B}$ is plants, and $\mathrm{C}$ is molecules. $R(\mathrm{a,b})$ is “animal $\mathrm{a}$ Eats plant $\mathrm{b}$” $S(\mathrm{b,c})$ is “plant $\mathrm{b}$ Contains molecule $\mathrm{c}$”

The composite relation $R\circ S: \mathrm{A\,|\, C}$ relates $\mathrm{a}$ to $\mathrm{c}$ when

$$ \text{there is some } \mathrm{b:B}\;\;\text{ so that }\\ R \text{ relates } \mathrm{a} \text{ to } \mathrm{b} \text{ and } S \text{ relates } \mathrm{b} \text{ to } \mathrm{c}. $$

Formally, we can write this as follows.

$$ (R\circ S)(\mathrm{a,c}) = \mathsf{\Sigma} \mathrm{b:B}.\; R(\mathrm{a,b}) \times S(\mathrm{b,c}) $$

So the composite relation is a sum of products: an $R\circ S$-connection from $\mathrm{a}$ to $\mathrm{c}$ is given by an $R$-connection and ($\times$) an $S$-connection, along some ($\mathsf{\Sigma}$) $\mathrm{b:B}$.

comp-sum.png

If you’ve ever done linear algebra, this is matrix multiplication: for each pair $\mathrm{a:A}$ and $\mathrm{c:C}$,

$\mathbf{R}$ $\mathrm{a}$ $\cdots$
$\mathrm{b}_1$ $R(\mathrm{a,b_1})$ $\cdots$
$\mathrm{b_2}$ $R(\mathrm{a,b_2})$ $\cdots$
$\cdots$ $\cdots$ $\cdots$
$\mathbf{S}$ $\mathrm{b}_1$ $\mathrm{b_2}$ $\cdots$
$\mathrm{c}$ $S(\mathrm{b_1,c})$ $S(\mathrm{b_2,c})$ $\cdots$
$\cdots$ $\cdots$ $\cdots$