Professional Documents
Culture Documents
b, a, c) = a, b, b, a, c)
Head
head : seq
1
A A
s : seq
1
A head(s) = s(1)
e.g.
c, b, b) = c
Tail
tail : seq
1
A seqA
s : seq
1
A head(s))
tail(s) = s
e.g.
tailc, b, b) = b, b)
28
Domain and Range Restriction
Suppose R : A B and S A and T B; then
S R is the set (a, b) : R [ a S
R T is the set (a, b) : R [ b T
Notice that both
S R A B and R T A B
are true.
e.g. if
has sibling : People People
then
female has sibling is the relation is sister of
has sibling female is the relation has sister
29
Domain and Range Subtraction
Suppose R : A B and S A and T B; then
S R is the set (a, b) : R [ a , S
R T is the set (a, b) : R [ b , T
The following predicates are true
S R = (A S) R
R T = R (B T)
S R A B
R T A B
e.g.
female has sibling is the relation is brother of
has sibling female is the relation has brother
30
Function Overriding
Suppose f , g : A B; then
f g is the function (domg f ) g
i.e. the following predicates are true
domf g = domf domg
a : domg (f g)(a) = g(a)
a : domf domg (f g)(a) = f (a)
f g A B
e.g.
a x, b y, c x a y
= a y, b y, c x
31
Other notation
Predicates
1
x : X P(x) there exists exactly one element x in
X such that the predicate P(x) is true
let x == e P(x) the predicate P(e)
Sets
x : X [ P(x) e(x) the set of all values e(x) for each
element x in X for which the predicate P(x) is true
Functions and relations
id identity relation
R
1
o
9 R
2
relational composition
R
1
R
2
backward relational composition
R
relational inverse
R
+
transitive closure
R
reexive-transitive closure