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.