Course Description

Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
Cartesian product
Before considering the definition of a ‘relation’, it is necessary to recall the concept of
Cartesian product. During week 3 we discussed the following:
Definition:Let A and B be sets. Then, the Cartesian product of A and B, denoted by A x B, is the set
of all ordered pairs (a, b), where a  A and b  B.
Example 1
Consider the sets A = {x, y} and B = {3, 7, 10}. Then
A x B = {(x, 3), (x, 7), (x, 10), (y, 3), (y, 7), (y, 10)}
B x A = {(3, x), (3, y), (7, x), (7, y), (10, x), (10, y)}
Binary Relation:
A relation connects elements of sets.
Let A, B be sets. Then a binary relation R from A to B is a subset of the Cartesian
product A x B.
N.B. A and B may be the same set.
We say that
a is related to b, and write a R b (or aRb), if (a, b)  R
a is not related to b, and write a Ř b, if (a, b)  R
If aRb we may say “a is related to b (by relation R)”,
– or just “a relates to b (under relation R)”.
Let R be a (binary) relation from A to B. Then
 Domain (R) = the subset of A containing all the first elements of the ordered pairs in
the set R.
 Range (R) = the subset of B containing all the second elements of the ordered pairs in
the set R.
Remark:- Relations are a generalization of functions; they can be used to express a much
wider class of relationships between sets.
Example 2
Consider the sets A = {0, 1, 2} and B = {a, b}. Then {(0, a), (0, b), (1, a), (2, b)} is a
relation from A to B. This means, for instance, that 1 R a, but that 1 Ř b.
Example 3
For each of the following relations R on the set A = {1, 2, 3, 4, 5, 6, 7, 8, 9} write down
the list of ordered pairs of elements that are related by R,
a) a R b if and only if a = b + 2,
b) a R b if and only if a + b is even,
c) a R b if and only if a divides b. (This divides relation can easily be extended to the set
of positive integers - see Example 9 below).
Week 10
Page 1
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
Answer:
(a) {(3, 1), (4, 2), (5, 3), (6, 4), (7, 5), (8, 6), (9, 7)}
(b) {(1, 1), (1, 3), (1, 5), (1, 7), (1, 9), (2, 2), (2, 4), (2, 6),(2, 8), (3, 1), (3, 3), (3, 5),
(3, 7), (3, 9), (4, 2), (4, 4), (4, 6), (4, 8),(5, 1), (5, 3), (5, 5), (5, 7), (5, 9), (6, 2),
(6, 4), (6, 6), (6, 8), (7, 1), (7, 3), (7, 5), (7, 7), (7, 9), (8, 2), (8, 4), (8, 6), (8, 8),
(9, 1), (9, 3), (9, 5), (9, 7), (9, 9)}
(c) {(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (1, 8), (1, 9), (2, 2), (2, 4),
(2, 6), (2, 8), (3, 3), (3, 6), (3, 9), (4, 4), (4, 8), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9)}
Example 4
Files called file1, file2, file3, report1, report2, have been produced as part of a group
software project.
The members of the group are Mary, Andy and John, and these people only have
permission to access certain files. Mary has permission for ‘file1’, ‘file3’, ‘report2’, Andy
for ‘file2’ only, and John for ‘file1’ and ‘report1’. This information can be represented by
a relation, but first it is necessary to define two base sets: files = {file1, file2, file3, report1, report2}
members = {Mary, Andy, John}
The relation can_access from members to files, which states who can access what files,
can now be defined as follows: can_access = {(Mary, file1), (Mary, file3), (Mary, report2), (Andy, file2), (John, file1),
(John, report1)}.
So, for example, in the following few statement are true and few statements are false: John can_access file1 √
John can_access report2 χ
Andy can_access report1 χ
Mary can_access file3 √
Note that members x files is the set of all combinations of people and files (i.e. it is a
Cartesian product), whereas the relation can_access is a subset containing particular
combinations.
Note, also, that the relation can_access is not a function from members to files, since
Mary (and John) can access more than one file.
Relations on a single Set
A relation from the set A to the same set A is called a relation on the set A. In other
words, a relation on a set A is a subset of A x A.
Example 5
Take A = {1, 2, 3} then we can define the following relations on the set A:
R1 = {(1, 1), (1, 2), (1, 3)}
R2 = {(1, 2), (2, 3), (3, 1)}
R3 = {(1, 1), (1, 2), (2, 3), (3, 1)}
R4 = {(1, 1), (2, 2), (2, 3), (3, 2), (3, 3)}
Example 6
Week 10
Page 2
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
a) The “<” relation from N to N defined by, < : N↔N :≡ {(n, m) | n < m}is a relation
on the set N of natural numbers.
b) The (binary) identity relation IA on a set A is the set {(a, a)|aA}.
Example 7
Consider the set A = {1, 3, 5} and B = {2, 4, 6}.
a)
Represent the elements of A x B on a sketch graph.
b)
Consider the relation R defined as follows: For a  A and b  B,
a R b if the point (a, b) on the graph is above the line y = 2x – 4
1. Express the relation R as a set of ordered pairs.
2. What are the domain and range of this relation?
Answer:
(a)
(b)
R = {(1, 2), (1, 4), (1, 6), (3, 4), (3, 6)}
Domain(R) = {1, 3}
Range(R) = {2, 4, 6}
Properties of Relations
Let R be a relation from the set A to A (i.e. R is a subset of A x A). Then
1) R is reflexive if a R a, for all a in A.
2) R is symmetric if whenever a R b, then b R a.
3) R is anti-symmetric if a R b implies b Ř a, for all a, b in A such that a  b. (Note R is
anti-symmetric if  a  b(((a, b) R^(b, a)  R) -> (a = b)). (Note also that the terms
symmetric and anti-symmetric are not opposites, since a relation can have both of
these properties or may lack both of them.)
4) R is transitive if whenever a R b and b R c, then a R c.
Example 8 Consider the following relations on the set A= {1, 2, 3, 4}.
Week 10
Page 3
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)},
R2 = {(1, 1), (1, 2), (2, 1)},
R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)},
R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},
R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)},
R6 = {(3, 4)}.
Which of these relations are reflexive?
Solution: The relations R3 and R5 are reflexive since they both contain all pairs of the
form (a, a), namely, (1, 1), (2, 2), (3, 3), (4, 4). The other relations are not reflexive
(Why?).
Example 9 Is the “divides” relation on the set of positive integers reflexive?
Note this “divides” relation is a generalization the divide relation defined in Example 3-c.
Since a | a whenever a is a positive integer, the “divides” relation is reflexive.
Example 10 Which of the relations from Example 8 are symmetric and which are antisymmetric?
Solution: The relations R2 and R3 are symmetric, because in each case (b, a) belongs to
the relation whenever (a, b) does. The other relations are not symmetric (Why?).
The relations R4, R5 and R6 are all anti-symmetric. For each of these relations there is no
pair of elements a and b with a  b such that both (a, b) and (b, a) belong to the relation.
None of the other relations is anti-symmetric (Why?).
Example 11 Which of the relations from Example 8 are transitive?
Solution: The relations R4, R5 and R6 are transitive. For each of these relations, we can
show that it is transitive by verifying that if (a, b) and (b, c) belongs to this relation, then
(a, c) also does. The other relations are not transitive (Why?). Note a single element
relation, like R6, is always transitive.
Example 12 Is the “divides” relation on the set of positive integers transitive?
Solution: Suppose that a divides b and b divides c. Then there are positive integers k and l
such that b = ak and c = bl. Hence, c = bl= (ak)l = a(kl), so that a divides c. It follows
that this relation is transitive.
Equivalence Relations
Let A be a set and let R be a binary relation on A, which is reflexive, transitive, and
symmetric. Then R is called an equivalence relation on A, and it is denoted by ~.
For example, if (a, b)  R, then this means that a is related to b under the relation R. For
this reason we use the notation a ~ b to indicate that (a, b)  R. So, a ~ b is equivalent to
(a, b)  R. Hence instead of R, we can write ~.
Example 13 Following are various types of examples of relations on the set A= {1, 2, 3}.
1. Example on a not reflexive, symmetric, anti-symmetric and transitive relation:
R = {(1, 1)}.
Week 10
Page 4
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
2. Example on a not reflexive, not symmetric, not anti-symmetric and not transitive relation:
R = {(1, 2), (2, 1), (3, 1)}.
3. Example on a not reflexive, symmetric, not anti-symmetric and not transitive relation:
R = {(1, 2), (2, 1)}.
4. Example on a not reflexive, not symmetric, anti-symmetric and transitive relation:
R = {(1, 2)}.
5. Example on an equivalence and not anti-symmetric relation:
R = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)}.
6. Example on an equivalence and anti-symmetric relation:
R = {(1, 1), (2, 2), (3, 3)}.
Equivalence Classes
Let ~ be an equivalence relation on A and let a  A. Then the equivalence class of a
(denoted by a ) is defined to be all the elements related to a. To find this equivalence
class, you look for all the ordered pairs in ~ which start with a and you take the second
element of the ordered pair. Notice that there is no empty equivalence class, because if a
 A, then a ~ a, because ~ is reflexive. Remember R is reflexive iff (a, a) is in R for
every a in A. This means a ~ a. Thus, a is in the equivalence class of a.
Example 14 Let A = {1, 2, 3} and ~ = {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1)}. Then ~ is an
equivalence relation on A. The equivalence classes are:
1 = {all elements related to 1} = {1, 2}.
2 = {all elements related to 2} = {2, 1}.
So, 2 = 1 . Remember the order within the set is not important.
3 = {all elements related to 3} = {3}.
Notice that the equivalence class of 3 is disjoint from the equivalence class of 1 and from
the equivalence class of 2.
Notice also that the union of the equivalence classes is equal to A.
Facts:
(1) If a and b are any two elements of A, then their equivalence classes are either equal or
disjoint.
(2) If a ~ b, then their equivalence classes are equal.
(3) The equivalence classes partition A.
Example 15
Take A = {1, 2, 3} then we can define relations by
R1 = {(1, 1), (1,2), (1, 3)}
R2 = {(1, 2), (2, 3), (3, 1)}
R3 = {(1, 1), (1, 2), (2, 3), (3, 1)} R4 = {(1, 1), (2, 2), (2, 3), (3, 2), (3, 3)}
Which of the relations R1, R2, R3, R4 is an equivalence relation? Give the equivalence
classes.
Week 10
Page 5
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
ANSWERS
The only equivalence relation is R4 with equivalence classes {1} and {2, 3}.
Example 16
The relation R is defined on the set of real numbers by a R b if and only if a – b is even.
Prove that R is an equivalence relation and describe the equivalence classes.
ANSWERS
The classes are {odd numbers} and {even numbers}
Example 17
Define T on Z (the set of all integers) by a T b if and only if a + b = 8. T divides Z into
classes, such as {0, 8}, {2, 6}, {11, –3}, {4}. Why is T not an equivalence relation?
ANSWERS
It is enough to note that (0, 0)  T so T is not reflexive.
Partial Orders
Definition:- Let A be a set and let R be a binary relation on A, which is reflexive,
transitive, and anti-symmetric. Then R is called a partial order on A, and it is denoted by
 . The set (A,  ) is called a partially ordered set (poset).
For example, if (a, b)  R, then this means that a is related to be under the relation R. For
this reason, we use the notation a  b to indicate that (a, b)  R. So, a  b is equivalent
to (a, b)  R. Once again instead of R, we'll write  .
Example 18:- Take A to be the set of real numbers R, and take  to be  , then  is a
partial order on R and (R,  ) is a poset.
Exercise: Prove that the relations < (“is less than”) and > (“is greater than”) are not
partial orders on R.
Example 19:- Let S be any nonempty set. Take A to be the power set of S, and take  to
be  , then  is a partial order on A and (A,  ) is a poset. Notice that a and b are
related (i.e., (a, b) is in R) if and only if a  b. To prove that  is a partial order, we
need to show that  is reflexive, transitive, and anti-symmetric on A. To show it is
reflexive, we need to prove that a and a are related under the relation  . Notice that a
itself is a set here. Now to show that a is related to a here means that we need to show
that a  a. But, this is always true. So, our relation is reflexive. Now to show that it is
transitive, we need to show that for any elements a, b, and c of A, if a is related to b and b
is related to c, then a is related to c. Once again keep in mind here that a, b, and c are
sets. But now a is related to b means a  b and b is related to c means b  c. Thus, we
have a  b  c, which implies a  c. Thus, a is related to c.
Finally, we need to show that our relation is anti-symmetric. This means that we want to
show if a is related to b and b is related to a, then a = b. This must hold for any a and any
Week 10
Page 6
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
b in A. But, a is related to b means a  b and b is related to a means that b  a. Thus,
we have that a  b and b  a. Therefore a = b.
NOTE: Let S be a nonempty set. If T is any subset of the power set of S, then (T,  ) is a
poset.
Question: Is it possible to have a binary relation which is both equivalence and a partial
order? If yes, then give an example and explain the nature of such a binary relation.
Answer: Let A be any nonempty set and let R be a binary relation on A. In order for R to
be both equivalence and a partial order, we need R to be both reflexive, transitive,
symmetric, and anti-symmetric. But, in order for R to be anti-symmetric, if it has an
element of the form (a, b), and if a  b, then it cannot have (b, a). But, if (a, b) is in R
and (b, a) is not, then R becomes not symmetric. Thus, R cannot have elements of the
form (a, b) if a  b. Thus, the only elements which R can have are those of the form (a,
a). But, in order for R to be reflexive, we need (a, a) to be in R for every element a  A.
(Notice that we have not used transitivity.) For example, if A = {1, 2, 3}, then the only
equivalence relation and partial order on A is {(1, 1), (2, 2), (3, 3)}.
Definition:- Let (A,  ) be a poset and let a  A. Then a is said to be
1. maximum if x  a for every x in A.
2. minimum if a  x for every x in A.
3. maximal if whenever b is an element of A, such that a  b, then b = a.
4. minimal if whenever b is an element of A, such that b  a, then b = a.
Example 20: In all of the following examples, we'll take
 to be  . Notice that if A
is a set of sets, then (A,  ) is a poset. In this case, an element a of A is maximum if it
contains all other elements of A and it is a maximal if it is not a subset of any other
element of A. It is minimum if it is (I mean a) a subset of all elements of A and it is
minimal if no element of A is a subset of a. Notice that every minimum is a minimal and
every maximum is a maximal, but the opposite is not necessarily true. Notice also that a
poset can have both minimum and maximal or just one of them or none. Notice also that
if the maximum exists, then it is unique and if the minimum exists, then it is also unique
(the maximum and minimum elements are also called the greatest element and the least
element of the poset (A,  ) respectively). Notice also that an element can be both
minimal and maximal at the same time. Also a minimal element does not have to be
unique. Similarly, a maximal element is not necessarily unique.
Question: Can an element be both minimum and maximum at the same time. If yes, then
when?
1. Maximum but no minimum: Consider the poset (A,  ), where A = {{a}, {b}, {a, b}}.
Then {a, b} is maximum because it contains all other elements of A (namely {a}, {b}).
But, there is no minimum because no element of A is a subset of all other elements.
Notice also that {a, b} is maximal and each of {a} and {b} is minimal, because no
Week 10
Page 7
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
element of A (other than {a} itself) is contained in {a} and no element of A (other than
{b} itself) is contained in {b}.
2. Minimum but no maximum: Consider the poset (A,  ), where A = {{a}, {a, b}, {a,
c}}. Then {a} is both minimum and minimal, but A has no maximum. Notice also that
both of {a, b} and {a, c} are maximal.
3. Minimum and maximum: Consider the poset (A,  ), where A = {{a},{a, b},{a, b, c}}.
Then {a} is both minimum and minimal, and {a, b, c} is both maximum and maximal.
Notice that {a, b} is neither minimal nor maximal (and of course neither minimum nor
maximum).
4. No minimum and no maximum: Consider the poset (A,  ), where A = {{a}, {b}, {a,
c}}. Here we have no minimum and no maximum. But, {a} and {b} are both minimal
and {b} and {a, c} are both maximal. Thus, {b} is both minimal and maximal.
5. Consider the poset (A,  ), where A = {{1}, {1, 2}}. Here {1} is both minimum and
minimal and {1, 2} is both maximum and maximal.
6. Consider the poset (A,  ), where A = {{1, 2}, {1, 3}}. Here there is no minimum and
no maximum and {1, 2} and {1, 3} are both minimal and maximal.
Fact: Let (A,  ) be a poset and let a  A. If a is minimum/maximum, then it is also
minimal/maximal and it is the only minimal/maximal.
Definition:- Let (A,  ) be a poset and let a, b  A. Then a and b are called comparable
iff either a  b or b  a.
Example 21:- Consider the poset (A,  ), where A = {{1}, {2}, {2, 3}}. Then {2} and
{2}, {3}} are comparable, because the first is a subset of the second. On the other hand,
{1} and {2} are not comparable, because neither one is a subset of the other.
Definition:- Let  be a partial order on A. If for every a and b in A, we have either a  b
or b  a, then  is called a total order or a linear order and (A,  ) is called a totally
ordered or linearly ordered set. A totally ordered set is also called a chain.
Example 22:- (A,  ), where A = {{1}, {1, 2}, {1, 2, 3}} is a total order.
Example 23:- (A,  ), where A = {{1}, {2}, {1, 3}} is not a total order, because neither
one of {1} and {2} is a subset of each other.
Example 24:- The poset (Z,  ) is totally ordered, since a  b or b  a whenever a and b
are integers.
Example 25:- The poset (Z+, |) is not totally ordered since it contains elements that are
incomparable, such as 5 and 7.
Definition:- The poset (S,  ) is called well-ordered set if it is a totally ordered set for
which every non-empty subset contains a smallest element.
Example 26:- Which of the following sets and their ordering relations are partially
ordered, totally ordered, or well-ordered:
Week 10
Page 8
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
1.
2.
3.
4.
S is any set. Define a  b if a = b
S is any set, and P(S) the power set of S. Define A  B if A  B
S is the set of real numbers between [0, 1]. Define a  b if a is less than or equal to
b (i.e. the 'usual' interpretation of the symbol )
S is the set of real numbers between [0, 1]. Define a  b if a is greater than or
equal to b.
1. S is any set. Define a  b if a = b.
This is a trivial partial ordering. Since no element is related to an element different from
itself, this is not an ordered set. Without more information about S we can not determine
anything else.
This example shows that any set can be partially ordered.
2. S is any set, and P(S) the power set of S. Define A  B if A  B
Recall that if A  B and B  A then A = B. Therefore, this is indeed a partial ordering.
Without more information about the set S we can not determine anything else.
3. S is the set of real numbers between [0, 1]. Define a  b if a is less than or equal to
b (i.e. the 'usual' interpretation of the symbol )
This is clearly an ordering, and the set [0, 1] with this ordering is usually represented as a
subset of the number line. It is not a well-ordered set, because the subset (0, 1] has no
smallest element.
4. S is the set of real numbers between [0, 1]. Define a  b if a is greater than or
equal to b.
This is also an ordering. The set is not well-ordered, however, because the subset [0, 1)
has no smallest element. Note that 1 is the smallest element in the set [0, 1], according to
our convention. Here it is important to distinguish between the conventional meaning of
the symbol  and its meaning as we choose to define it for a particular situation.
Example 27:- Which of the following sets are well-ordered?
1. The number systems N, Z, Q, or R?
2. The set of all rational numbers in [0, 1]?
3. The set of positive rational numbers whose denominator equals 3?
The natural numbers N are well-ordered:
Week 10
Page 9
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
A subset of natural numbers may not have a largest element, but it must have a
smallest element.
The integers Z are not well-ordered:
While many subsets of Z has a smallest element, the set Z itself does not have a
smallest element.
The rationals Q are not well-ordered:
The set Q itself does not have a smallest element.
The real numbers R are not well-ordered:
R itself does not have a smallest element.
The set of all rational numbers in [0, 1] is not well-ordered:
While the set itself does have a smallest element (namely 0), the subset of all
rational numbers in (0, 1) does not have a smallest element.
The set of all positive rational numbers whose denominator equals 3 is well-ordered:
This set is actually the same as the set of natural numbers, because we could
simply re-label a natural number n to look like the symbol n / 3. Then both sets are
the same, and hence this set is well-ordered.
Induction Principle
Let S be a well-ordered set with the additional property that every element except for the
smallest one has an immediate predecessor. Then: if Q is a property such that:
1. the smallest element of S has the property Q
2. if s S has property Q then the successor of s also has property Q
Then the property Q holds for every element in S
Proof:
It is not quite obvious what it is that we have to prove: we need to show that if a property
holds for the smallest element of a well-ordered set S, and it holds for every successor of
a general element of that set, then it is indeed true for the whole set S.
We will prove this by contradiction: Suppose property Q is true for the smallest element
of a well-ordered set S, denoted by the symbol 1. Suppose also that property Q is true for
the successor n + 1 of the general element n of that set, if it is assumed to be true for that
element n.

Denote by E the set of all elements from S for which property Q is not true
Since S is well-ordered, the subset E contains a smallest element, say n. If n = 1, we
would have a contradiction immediately. If n > 1, then it must have an immediate
predecessor, denoted by the element n-1.
Week 10
Page 10
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
For that element the property Q holds true, and therefore, being true for n - 1 it must be
true for (n-1) + 1 = n, by assumption. Hence, the set E must be empty, and property Q is
therefore true for all of S.
Question - Why the additional property that every element except the smallest one must
have an immediate predecessor is necessary for the induction principle?
Answer – We will illustrate it by means of the following examples:
Example 28:- The set of natural numbers, with the usual ordering, is well-ordered, and
in addition every element except of 1 has an immediate predecessor. Now impose a
different ordering labeled << on the natural numbers:
o
if n and m are both even, then define n << m if n < m
o
if n and m are both odd, then define n << m if n < m
o
if n is even and m is odd, we always define n << m
Is the set of natural numbers, together with this new ordering << well-ordered? Does it
have the property that every element has an immediate predecessor?
Solution:- The natural numbers, ordered by the ordering <<, could be listed in order as
follows:
2, 4, 6, 8, ....., 1, 3, 5, 7, 9, ..... ,
To show it is well-ordered, take any subset A of natural numbers.



If it contains only odd numbers, then the smallest number in the usual ordering is
the smallest element of A
If it contains only even numbers, then the smallest number in the usual ordering is
the smallest element of A
If it contains both even and odd numbers, then the smallest of the even numbers in
the usual ordering is the smallest element of A
Hence, the set is well-ordered.
But, not every element has an immediate predecessor. For example, the set:
A = {1, 3, 5, 7, ...}
has a smallest element (namely 1), but 1 does not have an immediate predecessor, since
every even number is smaller than 1 by definition.
Example 29:- Suppose the induction principle defined above does not contain the
assumption that every element except for the smallest has an immediate predecessor.
Then show that it could be proved that every natural number must be even (which is, of
course, not true so the additional assumption on the induction principle is necessary).
In other words, we assume that the induction principles was stated as follows:

Let S be a well-ordered set Then: if Q is a property such that:
Week 10
Page 11
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10

1. the smallest element of S has the property Q
2. if s S has property Q then the successor of s also has property Q
Then the property Q holds for every element in S
If this principle was true, we could prove that every natural number must be even as
follows:
Consider the natural numbers with the ordering << defined above.
We have already proved that this set is well-ordered. We want to show that every number
is even. Therefore:
Q is the property that every element is even.

The smallest element of our set in the << ordering is 2, which is even.

Also, if s has property Q then so does the successor of s. That is because in our
ordering, the successor of an even number is always the next even number, never
an odd number, and if s has property Q, then s must be even.
Therefore, by the incorrect induction principle, every natural number is even - which is,
of course, not true.
The actual induction principle as we have defined it does, however, not apply to this
example, since 1 does not have an immediate predecessor.
This example was suggested by Karl Hahn who pointed out that there is another
principle, called Transfinite Induction which - suitably stated - does apply to every wellordered set. He also suggested the book Set Theory and Logic by Stoll, published by
Dover, for further reference on this and other set theoretical topics.
Still More Definitions
Inverse Relations
Definition:- Any binary relation R:A, B has an inverse relation R−1:B, A, defined by
R−1 :≡ {(b, a) | (a, b)R}.
• E.g., <−1 = {(b, a) | a<b} = {(b, a) | b>a} = >.
• E.g., if R: People→Foods is defined by
aRb  a eats b, then:
bR−1a  b is eaten by a. (Passive voice.)
Complementary Relations
Week 10
Page 12
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
• Let R: A, B be any binary relation.
• Then, R : A, B, the complement of R, is the binary relation defined by
R :≡ {(a, b) | (a, b)R} = (A×B) − R
Example:  = {(a, b) | (a, b)<} = {(a, b) | ¬a<b} = ≥
Definition:- A relation is irreflexive iff its complementary relation is reflexive.
– Example: < is irreflexive, because ≥ is reflexive.
– Note “irreflexive” ≠ “not reflexive”!
• Example: “likes” between people is not reflexive, but it is not
irreflexive either.
– Not everyone likes themselves, but not everyone dislikes
themselves either!
Note:- An alternative way to define the same concept is:- A relation R on the set A is
irreflexive if for every a  A, (a, a)  R. That is, R is irreflexive if no element in A is
related to itself.
Definition:- A relation R is called asymmetric if (a, b)  R implies that (b, a)  R.
Representing Relations
There are many ways to present a relation between finite sets. As we have seen, one way
is to list its ordered pairs. We now discuss two alternative methods for representing
relations. One method uses zero-one matrices. The other method use directed graphs. The
first method is appropriate for the representation of relations in computer programs. The
second method is useful for understanding the properties of these relations.
Representing Relations Using Matrices
Let R be relation from the set A= {a1, a2,…, am} to the set B= {b1, b2,…, bn}. The relation
R can be represented by the matrix MR = [mij], where
1 if
0 if
mij = 
(ai, bj)  R
(ai, bj)  R
The matrix MR is called adjacency matrix of the relation R.
Example 30:- Let us consider the Likes relation - Joe likes Susan and Mary, Fred likes
Mary, and Mark likes Sally.
Susan Mary Sally
The 0-1 matrix
Joe  1
1
0 
representation

Fred  0
1
0 
of that “Likes”
Mark  0
0
1 
relation is:
Week 10
Page 13
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
Module #21 - Relations
Zero-One Reflexive, Symmetric
• Terms: Reflexive, non-reflexive, irreflexive,
symmetric, asymmetric, and antisymmetric.
– These relation characteristics are very easy to
recognize by inspection of the zerozero-one matrix.
ng
hi
Symmetric:
all identical
(c)2001-2003, Michael
P. Frank
across
diagonal
 0

1
0 1

 0



 0

yt

0



an
3/26/2004
ng
Reflexive:
Irreflexive:
all 1’s on diagonal all 0’s on diagonal
 1
1



 0
hi
any- 
0
 0 thing 



0 
anything

0

yt
an
any-
1
thing
 1



 any- 1 
 thing

1

Antisymmetric:
all 1’s are across
from 0’s
24
Digraphs
A digraph consists of vertices connected by directed edges (also called directed graph).
[If the edges are not directed then we have a (undirected) graph.]
A relation on the set A, which is a subset of A x A, can be represented by a digraph (i.e.
a directed graph). E.g. the following figure shows digraphs used to visualize the less-than
relation and less-than or equal to relation on {1,2,3,4}.
Week 10
Page 14
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
To draw a digraph of a relation on a set, we first draw a circle, called a vertex, for each
member of the domain and range of the relation and then establish relationship between
different vertices with the help of edges with associated arrow.
Module #21 - Relations
Using Directed Graphs
• A directed graph or digraph G=(V
=(VG,EG) is a set VG of
vertices (nodes) with a set EGVG×VG of edges
(arcs,links)
arcs,links). Visually represented using dots for nodes,
and arrows for edges. Notice that a relation R:A,B can be
represented as a graph GR=(V
=(VG=AB, EG=R).
MR
Susan
 1
Fred  0
Mark  0
Joe
3/26/2004
Mary Sally
1
0 
1
0 
0
1 
Edge set EG
(blue arrows)
GR
Joe
Fred
Susan
Mary
Mark
Sally
(c)2001-2003, Michael P. Frank
Node set VG
(black dots)
25
Module #21 - Relations
Digraph Reflexive, Symmetric
It is extremely easy to recognize the reflexive/irreflexive
reflexive/irreflexive//
symmetric/antisymmetric
symmetric/antisymmetric properties by graph inspection.
 

 
 
Reflexive:
Every node
has a self-loop
 
Irreflexive:
No node
links to itself
Asymmetric, non-antisymmetric
3/26/2004
Symmetric:
Every link is
bidirectional
 
Antisymmetric:
No link is
bidirectional
Non-reflexive, non-irreflexive
(c)2001-2003, Michael P. Frank
26
Example 31:
A small college runs three short courses and three members of staff are involved in the
teaching of these. More specifically, the staff involved on each courses are as follows: -
Week 10
Page 15
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
Course 1: Mary, Joe Course 2: Jim, Sarah Course 3: Jim, Mary, Sarah
Define the set
Staff = {Joe, Jim, Mary, Sarah}
and let the relation teaches_with on staff be defined as follows:For all x  staff and y  staff x teaches_with y if x and y are both involved on the
same short course
Then the digraph of this relation is:
Example 32:
Let A = {0, 1, 2, 3, 4} and define the relations S and T as follows:a) S = {(0, 0), (0, 2), (0, 3), (2, 2), (2, 3), (3, 3)}
b) T = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (2, 4), (3, 3), (4, 1), (4, 4)}
Then the digraph of each relation is:
a)
b)
Week 10
Page 16
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
Example 33:- Let A = {1, 2, 3, 4, 5, 6} be the set. Following are various relations and
their representations on the set A:
R1 = {(2, 1), (3, 2), (4, 3), (5, 4), (6, 5)}
0
1

0
M1  
0
0

0
1
0 0 0 0 0
0 0 0 0 0
1 0 0 0 0

0 1 0 0 0
0 0 1 0 0

0 0 0 1 0
2
6
3
4
5
R2 = {(1, 2), (1, 4), (1,6), (2, 1), (2, 3), (2, 5), (3, 2), (3, 4), (3, 6), (4, 1), (4, 3),
(4, 5), (5, 2), (5, 4), (5, 6), (6, 1), (6, 3), (6, 5)}
1
0
1

0
1

0

1
1 0 1 0 1
0 1 0 1 0

1 0 1 0 1
0 1 0 1 0 
1 0 1 0 1

0 1 0 1 0
2
6
3
5
4
Partial orders can be represented by a Hasse diagram, which is a simplification of a
digraph. Since the relation is reflexive loops are understood, and are omitted; similarly
transitive lines are omitted; also all directional lines are written pointing upwards, and so
arrows are removed.
Example 34:
The Hasse diagram for the relation “divides” on the set {1, 2, 3, 4, 6, 8, 12, 16,
24} is
24
12
16
6
8
3
4
2
1
Week 10
Page 17
Department of Computer Science
University of Karachi
BSCS - 411 -- Discrete Mathematics (Binary Relations) -- Week 10
Example 35:
The relation  on the power set P({a, b, c}) ={, {a}, {b}, {c}, {a, b}, {a,
c}, {b, c}, {a, b, c}} is shown by
{a, b, c}
{a, b}
{a}
{a, c}
{b, c}
{b}
{c}

Exercise 1: Which of the relations are reflexive symmetric, anti-symmetric, transitive,
equivalence relations and partial orders?
a) x is a multiple of y
(x, y  R+)
b) x lives in the same street as y
(x, y  {people})
c) y = 2x
(x, y  R)
d) y = 2x
(x, y  {0})
Exercise 2: The relation R is defined on {1, 2, 3, 4, 5, 6} by a R b if and only if a + b  5.
Which properties (reflexive, symmetric, etc) does R have?
Exercise 3: Draw the Hasse diagram representing the partial ordering {(a, b) | a divides b}
on {1, 2, 3, 4, 6, 8, 12}.
Week 10
Page 18