This chapter discusses the boolean operators and the relational operators in the following sections.
The boolean operators of Ampersand behave as one would expect in any boolean algebra. Union () and intersection () are both idempotent, commutative, and associative operators. In Ampersand we use a binary difference operator over with the usual semantics: . The (more customary) complement operator is a partial function, because Ampersand supports heterogeneous relation algebra.
The operator (union) satisfies the following axioms:
(commutativity of )
(associativity of )
(idempotence of )
The difference is the smallest relation that satisfies . Smallest means: If there is a for which , this implies that .
The intersection is defined as:
The complement operator is defined as . The type comes from the term(s) in which is embedded. If that type does not exist or if it is ambiguous, Ampersand will refuse to compile with an appropriate error message.
This page shows how you can write these things in your Ampersand script.
To say things such as "the name of the owner", we want to string together multiple relations (viz. name
and owner
). Relational operators allow us to make such statements.
There are two relational operators: the converse () and the composition (semicolon ). This page discusses the most important laws about these operators.
There are two things you should know about the converse operator. The first is that the converse of the converse gives you the relation itself, whatever that relation may be:
The second thing you should know is that arguments switch places if the converse is brought outside (or inside) brackets
The composition operator is denoted by a semicolon (;) between two terms. It is pronounced as 'composed with', in this case: composed with .
Composition is associative, which means:
The meaning stays the same, no matter how you place the brackets. So Ampersand lets you omit brackets entirely. You may write instead of or .
Composition has a left and a right identity. Let be a relation, then
This page shows how you can write these things in your Ampersand script.
Would you like a different explanation of the semantics of the relational operators? Click here for an explanation in sets. This page explains them in natural language. This page explains the relational operators in logic.