DISCRETE STRUCTURE
What are “RELATIONS”?
Relationships between elements of sets occur in many contexts. Every day we deal with
relationships such as those between a business and its telephone number, an employee and
his or her salary, a person and a relative, and so on. In mathematics we study relationships
such as those between a positive integer and one that it divides, an integer and one that it is
congruent to module 5, a real number and one that is larger than it, a real number x and the
value f(x) where f is a function, and so on. Relationships such as that between a program and
a variable it uses, and that between a computer language and a valid statement in this
language often arise in computer science.
Relationships between elements of sets are represented using the structure called a
relation, which is just a subset of the Cartesian product of the sets.
Relations can be used to solve problems such as determining which pairs of cities are linked
by airline flights in a network, finding a viable order for the different phases of a complicated
project, or producing a useful way to store information in computer databases.
In some computer languages, only the first 31 characters of the name of a variable matter.
INTRODUCTION:
The most direct way to express a relationship between elements of two
sets is to use ordered pairs made up of two related elements. For this reason, sets of ordered
pairs are called binary relations.
DEFINITION:
Let A and B be sets. A binary relation from A to B is a subset of A×B.
In other words, a binary relation from A to B is a set R of ordered pairs where the first element
of each ordered pair comes from A and the second element comes from B. We use the
notation a Rb to denote that (a, b) ∈ R and a Rb to denote that (a, b) / ∈ R. Moreover, when
(a, b) belongs to R, a is said to be related to b by R. Binary relations represent relationships
between the elements of two sets. We will introduce n-ary relations, which express
relationships among elements of more than two sets, later in this chapter. We will omit the
word binary when there is no danger of confusion.
FOR EXAMPLE:
Let A be the set of cities in the U.S.A., and let B be the set of the 50 states in the U.S.A. Define
the relation R by specifying that (a, b) belongs to R if a city with name a is in the state b. For
instance, (Boulder, Colorado), (Bangor, Maine), (Ann Arbor, Michigan), (Middletown, New
Jersey), (Middletown, New York), (Cupertino, California), and (Red Bank, New Jersey) are in
R.
RELATIONS ON A SET:
Relations from a set A to itself are of special interest.
DEFINITION: “A relation on a set A is a relation from A to A”.
FOR EXAMPLE:
1. Let A be the set {1,2,3,4}. In which ordered pairs are in the relation R ={(a, b) | a divides
b}?
Solution:
Because (a,b) is in R if and only if a and b are positive integers not exceeding 4 such
that a divides b,
we see that
R = {(1,1), (1,2), (1,3), (1,4), (2,2), (2,4), (3,3), (4,4)}.
FIGURE 1:
Displaying the Ordered Pairs in the Relation R from Example 1.
1 1 R 1 2 3 4
2 2 1
2
3 3
3
4 4 4
2. Consider these relations on the set of integers:
R1 = {(a, b) | a ≤ b},
R2 = {(a, b) | a>b},
R3 = {(a, b) | a = b or a =−b},
R4 = {(a, b) | a = b},
R5 = {(a, b) | a = b+1},
R6 = {(a, b) | a +b ≤ 3}.
Which of these relations contain each of the pairs (1,1), (1,2), (2,1), (1, −1), and (2,2)?
Solution:
The pair (1,1) is in R1, R3, R4, and R6; (1,2) is in R1 and R6; (2,1) is in R2, R5,
and R6; (1, −1) is in R2, R3, and R6; and finally, (2,2) is in R1, R3, and R4. It is not hard
to determine the number of relations on a finite set, because a relation on a set A is
simply a subset of A × A.
TYPES OF RELATIONS
There are many types of relations, two of them are as follows:
1. Recurrence Relations.
2. Equivalence Relations.
1. RECURRENCE RELATIONS:
A recursive definition of a sequence specifies one or more
initial terms and a rule for determining subsequent terms from those that precede them.
Also, recall that a rule of the latter sort (whether or not it is part of a recursive definition) is
called a recurrence relation and that a sequence is called a solution of a recurrence
relation if its terms satisfy the recurrence relation.
Such relations can be used to study and to solve counting problems. For example, suppose
that the number of bacteria in a colony doubles every hour. If a colony begins with five
bacteria, how many will be present in n hours? To solve this problem, let a n be the number
of bacteria at the end of n hours. Because the number of bacteria doubles every hour, the
relationship a n=2an−1 holds whenever n is a positive integer. This recurrence relation,
together with the initial condition a 0=5, uniquely determines a n for all non-negative integers
n. We can find a formula for a n using the iterative approach followed in Chapter 2, namely
that a n=5·2n for all non-negative integers n. Some of the counting problems that cannot be
solved using the techniques discussed in Chapter 6 can be solved by finding recurrence
relations involving the terms of a sequence, as was done in the problem involving bacteria.
In this section we will study a variety of counting problems that can be modeled using
recurrence relations. In Chapter 2 we developed methods for solving certain recurrence
relation. In Section 8.2 we will study methods for finding explicit formulae for the terms of
sequences that satisfy certain types of recurrence relations. We conclude this section by
introducing the algorithmic paradigm of dynamic programming. After explaining how this
paradigm works, we will illustrate its use with an example.
Modeling With Recurrence Relations:
We can use recurrence relations to model a wide variety of problems, such as finding
compound interest, counting rabbits on an island, determining the number of moves in the
Tower of Hanoi puzzle, and counting bit strings with certain properties.
EXAMPLE1 Rabbits and the Fibonacci:
Numbers Consider this problem, which was originally posed by Leonardo Pisano, also
known as Fibonacci, in the thirteenth century in his book Liberabaci. A young pair of rabbits
(one of each sex) is placed on an island. A pair of rabbits does not breed until they are 2
months old. After they are 2 months old, each pair of rabbits produces another pair each
month. Find a recurrence relation for the number of pairs of rabbits on the island after n
months, assuming that no rabbits ever die.
Solution:
Denote by fn the number of pairs of rabbits after n months. We will show that fn, n =1, 2, 3,
..., are the terms of the Fibonacci sequence. The rabbit population can be modeled using a
recurrence relation. At the end of the first month, the number of pairs of rabbits on the island
is f1 = 1. Because this pair does not breed during the second month, f2 = 1 also. To find the
number of pairs after n months, add the number on the island the previous month, fn−1, and
the number of newborn pairs, which equals fn−2, because each newborn pair comes from a
pair at least 2 months old. Consequently, the sequence {fn} satisfies the recurrence relation
fn = fn−1 +fn−2 for n ≥ 3togetherwiththeinitialconditionsf1 = 1andf2 = 1. Because this
recurrence relation and the initial conditions uniquely determine this sequence, the number
of pairs of rabbits on the island after n months is given by the nth Fibonacci number.
EXAMPLE 2 Codeword Enumeration:
A computer system considers a string of decimal digits a valid codeword if it contains an
even number of 0 digits. For instance, 1230407869 is valid, whereas 120987045608 is not
valid. Let an be the number of valid n-digit codewords. Find a recurrence relation for an.
Solution:
Note that a1 = 9 because there are 10 one-digit strings, and only one, namely, the string 0, is
not valid. A recurrence relation can be derived for this sequence by considering how a valid
n-digit string can be obtained from strings of n − 1 digits. There are two ways to form a valid
string with n digits from a string with one fewer digit.
First, a valid string of n digits can be obtained by appending a valid string of n − 1 digits with
a digit other than 0. This appending can be done in nine ways. Hence, a valid string with n
digits can be formed in this manner in 9an−1 ways.
Second, a valid string of n digits can be obtained by appending a 0 to a string of length n −1
that is not valid. (This produces a string with an even number of 0 digits because the invalid
string of length n − 1 has an odd number of 0 digits.) The number of ways that this can be
done equals the number of invalid (n − 1)-digit strings. Because there are 10n−1 strings of
length n −1, and an−1 are valid, there are 10n−1 − an−1 valid n-digit strings obtained by
appending an invalid string of length n − 1with a 0.
Because all valid strings of length n are produced in one of these two ways, it follows that
there are
an = 9an−1 +(10n−1 −an−1)
=8an−1 +10n−1
valid strings of length n
2. EQUVALENCE RELATIONS:
DEFINITION: “A relation on a set A is called an equivalence relation if it is reflexive,
symmetric, and transitive.”
Equivalence relations are important throughout mathematics and computer science. One
reason for this is that in an equivalence relation, when two elements are related it makes
sense to say they are equivalent.
It also has another definition:
DEFINITION: “Two elements a and b that are related by an equivalence relation are called
equivalent. The notation a ∼ b is often used to denote that a and b are equivalent elements
with respect to a particular equivalence relation”.
EXAMPLE 1: Let R be the relation on the set of integers such that a Rb if and only if a = b or
a =−b. R is reflexive, symmetric, and transitive. It follows that R is an equivalence relation.
EXAMPLE 2: Let R be the relation on the set of real numbers such that aRb if and only if
a − b is an integer. Is R an equivalence relation?
Solution:
Because a −a = 0 is an integer for all real numbers a, aRa for all real numbers a.
Hence, R is reflexive. Now suppose that a Rb. Then a−b is an integer, so b−a is also an integer.
Hence, bRa. It follows that R is symmetric. If aRb and bRc, then a −b and b−c are integers.
Therefore, a −c = (a −b) + (b−c) is also an integer. Hence, aRc. Thus, R is transitive.
Consequently, R is an equivalence relation. One of the most widely used equivalence
relations is congruence modulo m, where m is an integer greater than 1.
EXAMPLE 3:
Congruence Modulo m Let m be an integer with m>1.Showthat the relation
R ={(a, b) | a ≡ b(mod m)} is an equivalence relation on the set of integers.
Solution:
Recall from Section 4.1 that a ≡ b (mod m) if and only if m divides a − b. Note that
a −a = 0 is divisible by m, because 0 = 0·m. Hence, a ≡ a (mod m), so congruence modulo m
is reflexive. Now suppose that a ≡ b (mod m). Then a −b is divisible by m, so a −b=km, where
k is an integer. It follows that b − a = (−k) m, sob ≡ a (mod m). Hence, congruence modulo m
is symmetric. Next, suppose that a ≡ b (mod m) and b ≡ c (mod m). Then m divides both
a – b and b−c. Therefore, there care integers k and l with a − b = km and b −c = lm. Adding
these two equations shows that a − c = (a −b) + (b −c) = km + lm = (k +l) m. Thus, a ≡ c (mod
m). Therefore, congruence modulo m is transitive. It follows that congruence modulo m is an
equivalence relation.