Maggie Johnson
Handout #9
CS103B
Relations
Key topics:
* Introduction and Definitions
* Graphs and Relations
* Properties of Relations
* Equivalence Relations
* Partial Orderings
* Composition of Relations
* Matrix Representation
* Closures
* Topological Sorting
* PERT and CPM; Scheduling
Suppose we have a set of Greek deities:
G
= { Zeus, Apollo, Cronus, Poseidon }
As everyone knows, Zeus is the father of Apollo, Cronus is the father of Poseidon, and Cronus is
also the father of Zeus.
It seems that there exists some combination of the elements of
G
that satisfy
the "is the father of" relation.
To express this more precisely:
A
relation
R
between two sets
A
and
B
is a subset of
A
X
B
.
In other words,
A
X
B
produces a set
of ordered pairs <
a
,
b
>,
a
coming from set
A
, and
b
from set
B
.
Some of these pairs will be
"interesting", i.e., will satisfy our relation.
For these pairs, we can write
a
R
b
, where
R
is the
symbol for our relation.
Alternatively, we can write <
a
,
b
>
∈
R
. (Note that
R
is a generic relation
symbol.
Some relations, such as "less-than" have their own symbol:
<.)
To be precise, what we have defined is a
binary relation
, so called because it operates on ordered
pairs.
We can also define
unary relations,
which operate on single elements, or ternary relations,
which operate on ordered triples.
In general an
n-ary relation
will operate on n-tuples.
Example 1
Let's consider the “is the father of” relation (which we will denote by
F
) on the set
G
X
G
.
We can
figure out that
G
X
G
= { <Zeus, Zeus>, <Zeus, Apollo>, <Zeus, Cronus>,
<Zeus, Poseidon>, <Apollo, Zeus>, <Apollo, Apollo>,
<Apollo, Cronus>, <Apollo, Poseidon>, <Cronus, Zeus>,
<Cronus, Apollo>, <Cronus, Cronus>, <Cronus, Poseidon>,
<Poseidon, Zeus>, <Poseidon, Apollo>,
<Poseidon, Cronus>, <Poseidon, Poseidon> }