More notations for relations
section relation_toolkit parents set_toolkit |
First component projection
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| first : X Y X |
|
 |
 |
 |
|
| x : X; y : Y first (x,y) = x |
|
For any ordered pair (x,y),
first (x,y) is the x component of the pair.
Second component projection
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| second : X Y Y |
|
 |
 |
 |
|
| x : X; y : Y second (x,y) = y |
|
For any ordered pair (x,y),
second (x,y) is the y component of the pair.
Maplet
function 10 leftassoc (_ _) |
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : X Y X Y |
|
 |
 |
 |
|
| x : X ; y : Y x y = ( x , y ) |
|
The maplet forms an ordered pair from two values;
x
y is just another notation for (x, y).
Domain
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| dom : (X Y) X |
|
 |
 |
 |
|
| r : X Y dom r = { p : r p.1 } |
|
The domain of a relation r is the set of first components of the ordered
pairs in r.
Range
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| ran : (X Y) Y |
|
 |
 |
 |
|
| r : X Y ran r = { p : r p.2 } |
|
The range of a relation r is the set of second components of the ordered
pairs in r.
Identity relation
id X == { x : X x x } |
The identity relation on a set X is the relation that relates every
member of X to itself.
Relational composition
function 40 leftassoc (_ _) |
|
|
[X,Y,Z] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : (X Y) (Y Z) (X Z) |
|
 |
 |
 |
|
| r : X Y ; s : Y Z  |
| r s = { p : r ; q : s | p.2 = q.1 p.1 q.2 } |
|
The relational composition of a relation r : X
Y and s : Y
Z
is a relation of type X
Z formed by taking
all the pairs p of r and q of s,
where the second component of p is equal to the first component of q,
and relating the first component of p with the second component of q.
Functional composition
function 40 leftassoc (_ _) |
|
|
[X,Y,Z] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : (Y Z) (X Y) (X Z) |
|
 |
 |
 |
|
| r : X Y ; s : Y Z s r = r s |
|
The functional composition of s and r is the same as
the relational composition of r and s.
Domain restriction
function 65 rightassoc (_ _) |
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : X ( X Y ) ( X Y ) |
|
 |
 |
 |
|
| a : X ; r : X Y a r = { p : r | p.1 a } |
|
The domain restriction of a relation r : X
Y by a set a :
X is
the set of pairs in r whose first components are in a.
Range restriction
function 60 leftassoc (_ _) |
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : ( X Y) Y ( X Y ) |
|
 |
 |
 |
|
| r : X Y ; b : Y r b = { p : r | p.2 b } |
|
The range restriction of a relation r : X
Y by a set b :
Y is
the set of pairs in r whose second components are in b.
Domain subtraction
function 65 rightassoc (_ _) |
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : X ( X Y ) ( X Y ) |
|
 |
 |
 |
|
| a : X ; r : X Y a r = { p : r | p.1 a } |
|
The domain subtraction of a relation r : X
Y by
a set a :
X
is the set of pairs in r whose first components are not in a.
Range subtraction
function 60 leftassoc (_ _) |
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : ( X Y) Y ( X Y ) |
|
 |
 |
 |
|
| r : X Y ; b : Y  |
| r b = { p : r | p.2 b } |
|
The range subtraction of a relation r : X
Y by a set b :
Y
is the set of pairs in r whose second components are not in b.
Relational inversion
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ ~ : ( X Y ) ( Y X ) |
|
 |
 |
 |
|
| r : X Y r ~ = { p : r p.2 p.1 } |
|
The inverse of a relation is the relation obtained by reversing every
ordered pair in the relation.
Relational image
function (_ _ ) |
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : ( X Y ) X Y |
|
 |
 |
 |
|
| r : X Y ; a : X r a = { p : r | p.1 a p.2 } |
|
The relational image of a set a :
X through a relation r : X
Y
is the set of values of type Y that are related under r to a value in a.
Overriding
function 50 leftassoc (_ _) |
|
|
[X,Y] |
|
 |
|
 |
|
 |
|
 |
|
| _ _ : ( X Y ) ( X Y ) ( X Y ) |
|
 |
 |
 |
|
| r , s : X Y r s = ( ( dom s ) r ) s |
|
If r and s are both relations between X and Y,
the overriding of r by s
is the whole of s together with those members of r
that have no first components that are in the domain of s.
Transitive closure
|
|
[X] |
|
 |
|
 |
|
 |
|
 |
|
| _ + : ( X X ) (X X ) |
|
 |
 |
 |
|
| r : X X  |
| r + = { s : X X | r s r s s } |
|
The transitive closure of a relation r : X
X is
the smallest set that contains r and
is closed under the action of composing r with its members.
Reflexive transitive closure
|
|
[X] |
|
 |
|
 |
|
 |
|
 |
|
| _ * : ( X X ) (X X ) |
|
 |
 |
 |
|
| r : X X r * = r + id X |
|
The reflexive transitive closure of a relation r : X
X is the
relation formed by extending the transitive closure of r by the identity
relation on X.
IT 5-Jan-2002