arrow-left

All pages
gitbookPowered by GitBook
1 of 5

Loading...

Loading...

Loading...

Loading...

Loading...

Residual operators

Residual operatorsarrow-up-right are used when "material implicationarrow-up-right" is involved.

  • right residual : a (r\s) b ⇔ ∀x:x r a→x s ba\ (r\backslash s)\ b\ \Leftrightarrow\ \forall x: x\ r\ a\rightarrow x\ s\ ba (r\s) b ⇔ ∀x:x r a→x s b . In other words: (a,b)(a,b)(a,b) is in the right residual of rrr and sss means that for every xxx, pair (x,a)(x,a)(x,a) is in relation rrr implies that pair (x,b)(x,b)(x,b) is in sss.

  • left residual : . In words: is in the left residual of and

    means that for every pair is in relation implies that pair is in .

  • diamond: . In words: For every , both and are true or both are false.

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 residual operators? explains them in natural language. for visualized examples about residual operators.

a (s/r) b ⇔ ∀x:b r x→a s xa\ (s/r)\ b\ \Leftrightarrow\ \forall x: b\ r\ x\rightarrow a\ s\ xa (s/r) b ⇔ ∀x:b r x→a s x
(a,b)(a,b)(a,b)
sss
rrr
xxx
(b,x)(b,x)(b,x)
rrr
(a,x)(a,x)(a,x)
sss
a(r♢s)b ⇔ ∀x:a r x = x s ba (r♢s) b\ \Leftrightarrow\ \forall x: a\ r\ x\ =\ x\ s\ ba(r♢s)b ⇔ ∀x:a r x = x s b
xxx
a r xa\ r\ xa r x
x s bx\ s\ bx s b
This page
This page
Click here

Boolean operators

The notation a r ba\ r\ ba r b means that the pair (a,b) is in relation rrr. This page defines when pair (a,b) is in relation r∩sr ∩ sr∩s (the intersection of rrr and sss), r∪sr ∪ sr∪s (the union of rrr and sss), r−sr-sr−s (the difference of rrr and sss).

  • intersection : a (r∩s) b ⇔ a r b ∧ a s ba\ (r ∩ s)\ b\ \Leftrightarrow\ a\ r\ b\ ∧\ a\ s\ ba (r∩s) b ⇔ a r b ∧ a s b . In other words: if the pair (a,b)(a,b)(a,b) is both in relation rrr and sss, then it is in the intersection of rrr and sss.

  • union : . In words: if the pair is in the relation or in , then it is in the union of and .

  • difference : . In other words, the term contains all pairs from that are not in .

The complement (or negation) of a relation is defined by means of the difference operator:

  • complement : If is defined as , then is the set of all tuples in (the Cartesian product) that are not contained in . So

Note that the complement is defined in terms of and . So, two relations with an identical population yet a different type may have different complements.

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 boolean operators? explains the boolean operators in terms of set theory.

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 (r∪s) b ⇔ a r b ∨ a s ba\ (r ∪ s)\ b\ \Leftrightarrow\ a\ r\ b\ \vee\ a\ s\ ba (r∪s) b ⇔ a r b ∨ a s b
(a,b)(a,b)(a,b)
rrr
sss
rrr
sss
a (r−s) b ⇔ a r b ∧ ¬(a s b)a\ (r-s)\ b\ \Leftrightarrow\ a\ r\ b\ ∧\ \neg(a\ s\ b)a (r−s) b ⇔ a r b ∧ ¬(a s b)
r−sr-sr−s
rrr
sss
r[AxB]r_{[A x B]}r[AxB]​
rrr
rA×Br_{A\times B}rA×B​
r‾\overline{r}r
A×BA\times BA×B
rrr
r‾=V[A×B]−r\overline{r} = V_{[A\times B]} - rr=V[A×B]​−r
AAA
BBB
This page
This page

Semantics in logic

(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

Primitive terms

hashtag
Relations

When a relation is used in a term, it stands for all pairs it contains at the moment it is evaluated. Those pairs (also referred to as the contents or population of the relation) can change over time as users add or delete pairs from it.

When a relation is used in a term, we can just use its name if that is unambiguous. For instance the name owner refers to RELATION owner[Person*Building] if that is the only relation the ampersand-compiler can link it to. In some cases, however the name alone is ambiguous. For example if there are two relations with the same name and different signatures. In such cases Ampersand will try to infer the type from the context. That however does not always succeed. In such cases, Ampersand generates an error message that asks you to remove the ambiguity by adding the correct type.

If a pair is an element of a relation , we write . Alternatively we may write , since we know that is a set.

hashtag
Identity

For every concept , the term exists. It refers to the identity relation. It means that for every and we have:

The type of is . In Ampersand code you write I[C].

hashtag
Complete relation

For every pair of concepts and the term refers to the complete relation. For every and we have:

The type of is . In Ampersand code you write V[A*B].

hashtag
Other explanation

Would you like a different explanation of the primitive terms? explains the primitive terms in terms of set theory. for the explanation of primitive terms in natural language.

(a,b)(a,b)(a,b)
rrr
a r ba\ r\ ba r b
(a,b)∈r(a,b)\in r(a,b)∈r
rrr
CCC
I[C]I_{[C]}I[C]​
a∈Ca\in Ca∈C
b∈Cb\in Cb∈C
a=b ⇔ a I[C] ba = b\ \Leftrightarrow\ a\ I_{[C]}\ ba=b ⇔ a I[C]​ b
I[C]I_{[C]}I[C]​
[C∗C][C*C][C∗C]
AAA
BBB
V[A∗B]V_{[A*B]}V[A∗B]​
a∈Aa\in Aa∈A
b∈Bb\in Bb∈B
a V[A∗B] ba\ V_{[A*B]}\ ba V[A∗B]​ b
V[A∗B]V_{[A*B]}V[A∗B]​
[A∗B][A*B][A∗B]
This page
Click here