arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Relational operators

hashtag
Purpose of relational operators

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.

hashtag
Converse

A relation can be altered by swapping the elements of every pair in the relation. Mathematically, is a different from . This operation is called the converse operator. It produces a new relation from an existing one. It is denoted by writing (pronounced 'wok' or ’flip’) after the relation name. This is how converse is defined:

If has type, then has type .

hashtag
Composition

The composition operator is denoted by a semicolon between two terms. It is pronounced as 'composed with'. Let us take a look at composed with . Let and be two relations, with the target of r being the same as the source of s. Then the composition of and is defined by:

If has typeand has type, then has type .

hashtag
How to type boolean operators in your script

shows how you can type boolean (and other) operators in your Ampersand script.

hashtag
Other explanation

Would you like a different explanation of the relational operators? explains the relational operators in terms of set theory. explains them in natural language. for some algebraic rules about relational operators.

(a,b)(a, b)(a,b)
(b,a)(b,a)(b,a)
\smallsmile\
a(r⌣)b ⇔ b r aa(r\smallsmile)b\ \Leftrightarrow\ b\ r\ aa(r⌣)b ⇔ b r a
rrr
[A×B][A\times B][A×B]
r\smallsmile\
[B×A][B\times A][B×A]
;;;
rrr
sss
r[A×B]r_{[A\times B]}r[A×B]​
s[B×C]s_{[B\times C]}s[B×C]​
rrr
sss
a(r;s)c ⇔ ∃b∈B ∙ a r b∧b s ca(r;s)c\ \Leftrightarrow\ ∃ b∈B\ ∙\ a\ r\ b ∧ b\ s\ ca(r;s)c ⇔ ∃b∈B ∙ a r b∧b s c
rrr
[A×B][A\times B][A×B]
sss
[B×C][B\times C][B×C]
r;sr;sr;s
[A×C][A\times C][A×C]
This page
This page
This page
Click here