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}