Notes of Module-I of Discrete Mathematics
Notes of Module-I of Discrete Mathematics
The materials included in discrete mathematics are logic, set theory, number theory, linear
algebra, abstract algebra, combinatorics, graph theory and probability theory (discrete part).
Logic
Proposition: A proposition or statement is a declarative sentence which is true or false but not both.
3. 1 + 1 = 2
4. 2 + 2 = 5
Truth Value: Something that adds sense or meaning to the proposition is called truth value.
3. 1 + 1 = 2 (True)
4. 2 + 2 = 5 (False)
Compound Proposition: Many propositions are composite, i.e. composed of sub propositions and
various connectives, such propositions are called compound propositions.
1
Primitives: Propositions that cannot be broken into simpler propositions are called primitives.
Connectives: Two or more primitives are joined into compound propositions by means of certain
words called connectives. Basically there are five connectives, they are and, or, not, if…then, if and
only if.
Truth Table: The truth value of a compound proposition is obtained y truth table.
2
p q P→q
T T T
T F F
F T T
F F T
Here, p: hypotheses or antecedent or premise.
q: conclusion or consequence.
Note: The statement p → q is called conditional statement because p → q
asserts that ‘q’ is true on the condition that ‘p’ holds.
p is the condition (holds). First Statement (antecedent/hypothesis)
q is the statement (to be executed). Second Statement (consequent/conclusion)
Truth Table:
p Q p→q q→p pq
T T T T T
T F F T F
F T T F F
F F T T T
Truth Table:
p q p→ q q→ p p q q→ p p→ q
(Conditional) (Converse) (Contrapositive) (Inverse)
T T T T F F T T
T F F T F T F T
3
F T T F T F T F
F F T T T T T T
Exclusive Or (XOR)():
Truth table for the “exclusive or” of two propositions:
p Q pq
T T F
T F T
F T T
F F F
Equivalent Propositions: When two composite propositions, say p and q, have the
same truth value, then they are called equivalent propositions. It is written as pq.
In other words, pq iff pq.
Construction of truth table: If the number of prime components is 2, then the table
contains 22=4 horizontal rows. Similarly, if the number of prime components is ‘n’
then there are ‘2n’ horizontal rows.
4
F T T T T T T T
F T F F F T F F
F F T F F F T F
F F F F F F F F
Questions:
1. What are the contrapositive, the converse and the inverse of the conditional statement
“The home team wins whenever it is raining”?
2. For a given conditional statement, which statement is equivalent to it: converse,
contrapositive and inverse? Explain.
3. Out of converse, contrapositive and inverse which two statements are equivalent.
Give a proof.
4. Construct a truth table for each of the following:
i ) p q q p
ii ) p q q p
iii ) p q p q
iv ) p q q r
v) p q r s
5. Show that: pp is a tautology.
6. Show that: pp is a contradiction.
7. Prove that ppp is a tautology.
8. Prove that (pq) (p q) (q p) is a tautology.
9. Prove that “If the sky is cloudy then it will rain and it will not rain” is a contradiction.
10. Show that [(p q) q] p is a tautology.
11. Show that pq and (p q) (q p) are equivalent.
5
12. Using truth table prove the following:
i) p q r q p r
ii) p q p q
iii ) p q p r q r is a tautology.
iv) p q p q
v) p q p q
13. There are two hotels. One says “Good food is not cheap” and the other says “Cheap
food is not good”. Are they saying the same thing?
14. Verify that the two propositions ((pq) (pr)) s and (p(qr)) s are
equivalent.
1. p q( p→ q) ( q→ p)
2. p q pq
3. p q (pq) (pq)
4. ( pq) p q
Questions:
1. Without using truth table show that (p(pq)) and pq are logically
equivalent.
2. Show that (pq) →(pq) is a tautology without using truth table.
3. Using laws show that (pq) (pq) p without using truth table.
4. Show that (p→q) (r→q) (pr) →q without using truth table.
5. Show that {[(pq) →r] (p )} →( q → r) is a tautology without using truth
tables.
6. Is the statement ((p→q) (q→r)) → (p→r) a tautology? Prove it without using
truth table.
Quantifiers:
7
1) One way predicates can be statements is by assigning specific values to their
variables.
2) Another way is by adding quantifiers.
Definition: Quantifiers are words that refer to quantities such a “some” or “all” and
indicate how frequently a certain statement is true.
Quantifiers are classified into two types:
1. Universal Quantifier
2. Existential Quantifier
3. Negating Quantifiers:
8
Consider the statement: 1. “All the students in this class are intelligent.”
Negation:
2. It is not the case that all the students in the class are intelligent.
3. There is a student in the class who is not intelligent.
Let, P(x): x is intelligent and S denotes the set of all students in a class.
Then, Statement-1 implies x S : p( x) .
Statement-2 and 3 can be expressed as x S : p x and x S : p ( x ) .
Since, statement-2 and 3 are equivalent so, x S : p x x S : p( x)
Summary:
Value Statement Negation
All True x p x x p x at least one false.
At least one false x p x x p x all true.
All False x p x x P x at least one true
At least one true x P x x P x all false
9
2. yx P x, y Everyone meets Somebody.
3. xy P x, y : Someone meets Somebody.
4. yx P x, y : Someone meets Everybody
5. x y P x, y : Everybody is met by Everyone.
6. y x P x, y : Everybody is met by someone.
7. y x P x, y : There is somebody whom everyone meets.
8. x y P x, y : There is somebody whom someone meets.
Note: 1 & 2, 7 & 8 are logically equivalent.
********
Methods of Proof
Rules of Inferences:
1. Hypotheses: The propositions that are assumed to be true are called premises
or hypotheses.
2. Conclusion: The propositions derived by using the rules of inferences is called
conclusion.
3. Valid Argument: The process of deriving conclusions based on the assumption
of premises is called a valid argument.
Note: In valid argument we are concerned with the process of arriving at the
conclusion rather than obtaining the conclusion.
Table:
Rule of Inference Tautological Form Name
p p p q Addition
1.
pq
pq p q p Simplification
2.
p
p Conjunction
( p) ( q) p q
3. q
pq
pq p q p q Modus Ponens
p
4.
q
pq p q q p Modus Tollens
q
5.
p
10
pq p q q r ( p r ) Hypothetical Syllogism
qr
6.
pr
pq p q p q Disjunction Syllogism
p
7.
q
p q (r s) ( p q ) (r s) ( p r ) (q s) Constructive Dilemma
pr
8.
q s
p q (r s) ( p q ) ( r s ) ( q s ) Destructive Dilemma
q s ( p r )
9.
p s
pq p q (p r ) (q r ) Resolution
p r
10.
q r
Examples:
1. Modus Ponens or The Law of Detachment:
Find the conclusion of the following statements:
i. “If it snows today, then we will go skiing.” “It is snowing today.”
Conclusion: We will go skiing.
ii. “If n is greater than 3, then n2 is greater than 9.” “ n is greater than 3.”
Conclusion: “ n2 is greater than 9.”
iii. “If John has a B in calculus, he will graduate.” “John does have a B in
calculus.”
Conclusion: “ Therefore he will graduate.”
2. Modus Tollens or Method of Denying:
i. Harvey is a dentist, then Harvey drills teeth. Harvey does not drill teeth.
Conclusion: Harvey is not a dentist.
3. Disjunction Syllogism:
i. Either elephants are blue or monkeys are green. Elephants are grey.
Conclusion: Monkeys are green.
4. Hypothetical Syllogism:
P: Mary is senior, Q: Mary wears a pin, R: Mary will graduate.
Conclusion: If Mary is a senior , then Mary will graduate.
Examples:
Question: State which rule of inference is the basis of the following argument:
11
1. “It is below freezing now.” Therefore, it is either below freezing or raining now.”
Solution: Addition Rule. Explanation: p p q
2. “It is below freezing and raining now.” “Therefore, it is below freezing now.”
Solution: Simplification Rule.
Question:
3. Show that the hypotheses “It is not sunny this afternoon and it is colder than
yesterday”, “We will go swimming only if it is sunny”, “If we do not go
swimming, then we will take a canoe trip”, and “If we take a canoe trip, then we
will be home by sunset” lead to the conclusion “We will be home by sunset”.
Solution:
p: It is sunny this afternoon. q: It is colder than yesterday. r: We will go
swimming. s: We will take a canoe trip. t: We will be home by sunset.
So, we have the following,
hypotheses: p q, r p, r s, s t and
conclusion: t (To Prove)
Proof: No. Step Reason
1. p q Hypothesis
2. p Simplification by 1
3. r p Hypothesis
4. r Modus tollens by 2 & 3
5. r s Hypothesis
6. s Modus ponens by 4 & 5
7. s t Hypothesis
8. t Modus ponens by 6 & 7
4. Show that the hypotheses “If you send me an e-mail message, then I will finish
writing the program”, “If you do not send me an e-mail message, then I will go to
sleep early”, and “If I go to sleep early, then I will wake up feeling refreshed” lead
to the conclusion “If I do not finish writing the program, then I will wake up
feeling refreshed”.
Solution:
p: You send me an e-mail message. q: I will finish writing the program.
r: I will go to sleep early. s: I will wake up feeling refreshed.
So, we have the following,
hypotheses: p q , p r , r s . and
conclusion: q s (To Prove)
12
Proof: No. Step Reason
1. pq Hypothesis
2. q p Contrapositive
3. p r Hypothesis
4. q r Hypothetical Syllogism
2&3
5. rs Hypothesis
6. q s Hypothetical Syllogism
4 & 5 (required
conclusion)
***********
13
2. The empty string is the string that has no terms. It is denoted by λ. Its
length is zero.
Thus, if {an}is a sequence with the terms a1 , a2 , a3 , , an , , then the sum of the
terms a1 a2 a3 an (say), is termed series or summation of the sequence
{an}.
n
It is denoted as S n a1 a2 a3 an or by the notation S n am , where ‘m’ is
m 1
arbitrary and is called the index of summation, ‘1’ is the lower limit, ‘n’ is the
upper limit.
Examples:
1
1. Express the sum of the first 100 terms of the sequence {an}, where an .
n
5
2
2. What is the value of j
j 1
?
14
100
2
3. Find the value of k
k 50
.
4 3
4. Evaluate: ij.
i 1 j 1
ar n 1 a n
, if r 1
Theorem: If ‘a’ and ‘r’ are real numbers and r 0, then ar j r 1 .
j 0 n 1 a , if r 1
n
Proof: Let, S ar j
j 0
n n n1
rS r ar j ar j 1 ar k (byshiftingindex, k j 1)
j 0 j 0 k 1
n
n n
ar k ar n1 ar k ar 0 ar n1 ar 0 ar k ar n1 a
k 1 k 1 k 0
n
rS S ar n1 a S ar j , j beingarbitrary
j 0
r 1 S ar n1 a
S
ar n1
a
, r 1.
r 1
and for r = 1, we have,
n n 1
S
j 0
a a (by sh iftin g in dex )
j 1
a a a ( n 1) tim es
( n 1) a .
15
n 2
4. k 1
k3 n 2 n 1
4
xk , x 1 1
5. k 0
1 x
*********
Mathematical Induction
Example:
1. 2 divides 6. True
2. Jaipur is the capital of Rajasthan. True
3. There are five days in a week. False
4. (x+1) is a factor of x 2 3 x 2. False
5. A B B A True
Let P(n) be a statement involving the natural number ‘n’, such that
(II) P(m+1) is true, whenever P(m) is true, i.e. P(m) is true P(m+1) is true.
Let P(n) be a statement involving the natural number ‘n’, such that
16
Then, P(n) is true for all natural numbers.
2. Prove by the principle of mathematical induction that for all ∈ N, ‘ n 2 n ’is even
natural number.
17
2
m 1 m 1 is an even natural number
P(m 1)is true.
18
Hence, by the principle of mathematical induction, the given statement is
true for all n .
4. Prove that 4n 15n 1 is divisible by 9 for all natural numbers ‘n’.
Solution: Let P(n) be the statement given by
P(n): 4n 15n 1 is divisible y 9.
Step-I: For n=1, P(1):
19
1 1 1 1
1 2 2
4 9 n n
1 1 1 1 1 1 1
1 2 2 adding the term on both sides
4 9 n n 1 2 n n 1 2 n 1
2
1 1 1 1 1 1
1 2 2
4 9 n n 1 2 n n 1 2
1 1 1 1 n 2 2n 1 n
1 2 2
4 9 n n 1 2 n n 1 2
1 1 1 1 n2 n 1
1 2 2
4 9 n n 1 2 n n 12
1 1 1 1 n n 1 1 n n 1
1 2 2
2 2
2
2
4 9 n n 1 n n 1 n n 1 n n 1 2
1 1 1 1 1
1 2 2
2
4 9 n n 1 n 1
⇒ P(k+1) is true.
Therefore, P(n) is true for all n 2, n N.
14. 3n n ! if n and n 6.
15. 2n n 2 if n and n 4.
16. 1+3+5+…+(2k1)=k2.
17. 1+2+22+…+2n =2n+11.
n
ar n 1 a
18. ar i , r 1.
i 0 r 1
19. n 2n , n .
20. 2n n !, n , n 4.
21. Prove by induction that any positive integer n greater than or equal to 2 is either a
prime or product of primes.
Solution: Let, P(n): ‘n’ is a prime or product of primes, where ‘n’ is an integer and
n 2.
Basis step: For n 2, P 2 2.1 2, which is a prime.
For n 3, P 3 3.1 3, which is a prime.
For n 4, P 4 2.2 4, which is product of prime.
Inductive Hypothesis: Assume that P j is true for all positive integer j with j k .
Inductive step: To Prove: P k 1 is true.
20
There are two cases:
Case I : k 1 is prime.
If k 1 is prime, then this is obviously true and hence nothing to prove.
Case II : k 1 is composite, then k 1 can be written as product of two integers. a
and b with 2 a b k 1.
Now by induction hypothesis, both a and b can be written as the product of
primes.
Thus, if k 1 is composite, it can be written as the product of primes, that is, those
primes in the factorization of a and those primes in the factorization of b .
Hence, P k is true P k 1 is true.
Therefore, P n is true.
************
Eg: The sequence an 2n , n 0,1, 2, , can also be expressed in recursive method as
a0 1, an 1 2an , n 0,1, 2,3,...
Recursive Step: Give a rule for finding its value at an integer from its values at
smaller integers.
Examples:
21
0
Basis Step: F(0)= am a0 .
m 0
n 1 n
Inductive Step: F(m+1)= am am an1
m 0 m 0
********
22
1. Determine whether the sequence {an} is a Solution of the recurrence
relation an 2an1 an 2 for n=2,3,4,…, where
i) an=3n,
ii) an=2n
iii) an=5, for every nonnegative integer ‘n’.
Solution:
i) Suppose, an=3n for every non-negative integer ‘n’. Then, for n 2, we
have 2an 1 an 2 2 3 n 1 3 n 2 3n an . Hence, {an}, where an=3n is a
Solution of the recurrence relation.
ii) Suppose, an=2n for every non-negative integer ‘n’. Then, for n 2, we
1 3
have 2an 1 an2 2 2n1 2n 2 2 n 2n 2 2n 1 2
2n. an . Hence, {an},
2 4
where an=2n is not a Solution of the recurrence relation.
iii) Let, an=5 for every non-negative integer ‘n’. Then, for n 2, we have
2an 1 an 2 2 5 5 10 5 5 an . Therefore, {an}, where an=5 is a Solution of
the recurrence relation.
23
a0 2 1 2 and
a1 7 21 2 1
On solving the above simultaneous linear equations, we get,
1 3 and 2 1
Hence, the Solution to the recurrence relation and initial conditions is {an}
with an=3.2n - (-1)n.
2. Find an explicit formula for the Fibonacci numbers.
Solution: The sequence of numbers 1,1,2,3,5,8,13,… is called Fibonacci
numbers which is given by the recurrence relation f n f n1 f n 2 -------(1)
with initial conditions f 0 0 and f1 1 whose Solution is obtained by putting
an r n where r is a constant and n = 0,1,2,3,… in (1),
1 1
i.e. r n r n 1 r n 2 1
2 r 2 r 1 0
r r
1 5 1 5
r1 and r1
2 2
Thus the Fibonacci numbers can also be given by
n n
1 5 1 5
Fn 1 2 (2) for some constants 1 and 2 .
2 2
Using the initial conditions f 0 0 and f1 1 in (2), we obtain,
f 0 1 2 0 and
1 5 1 5
f1 1 2 1
2 2
On solving the above two simultaneous linear equations, we obtain,
1 1
1 and 2
5 5
n n
1 1 5 1 1 5
Hence, the Fibonacci numbers are given by Fn .
5 2 5 2
Formula-2: Let C1 and C2 be real numbers with C2 0 and r 2 C1r C2 0
has only one root r0. Then the relation an C1an1 C2an 2 has a solution
obtained by an 1r0 n 2 nr0 n , n = 0,1,2,3,…, 1 & 2 are constants.
3. What is the solution of the recurrence relation an 6an1 9an 2 with initial
condition a0 1 and a1 6 ?
24
Solution: Putting an=rn where r is a constant, n=0,1,2,3,… in an 6an1 9an 2
we have, r n 6r n1 9r n 2 r 2 6r 9 0 r 3 (repeated).
Hence, the solution to this recurrence relation is an 1 3n 2 n3n for some 1
and 2 .
Now, from the initial conditions, we have,
a0 1 1 and
a1 6 1 .3 2 .3
On solving the above two simultaneous equations, we get, 1 1 and 2 1
Hence, the solution is {an} with an=3n+n3n.
4. Find the Solution to the recurrence relation an 6an1 11an 2 6an3 with the
initial conditions a0 = 2, a1 = 5 and a2 =15.
Solution: Given, recurrence relation is an 6 an 1 11a n 2 6 a n 3 ------(1) with
initial conditions a0 = 2, a1 = 5 and a2 =15.
Putting, an= rn in (1), we get,
r n 6 r n 1 1 1 r n 2 6 r n 3 r 3 6 r 2 1 1 r 6 0 r 1, r 2 , r 3 .
Hence, the Solution to the recurrence relation is an 1 1n 2 2n 3 3n , ---
(2), for some constants 1, 2, 3.
Using the initial conditions, we obtain,
a0 2 1 2 3 ,
a1 5 1 2 2 3 3 ,
a2 15 1 4 2 9 3 .
On solving the above three simultaneous linear equations, we get,
1 1, 2 1and 3 2.
Hence, the unique Solution to this recurrence relation and the given initial
conditions is the sequence {an} with an 1 2 n 2 3n .
25
Formula-4: Let C1 , C2 , C3 , , Ck be real numbers. Suppose the characteristic
equation r k C1r k 1 Ck 0 has ‘t’ distinct roots r1 , r2 , , rt with
multiplicities m1 , m2 , , mt respectively, so that mi1 for i=1, 2, …,t and
m1+m2+…+mt = k. Then a sequence {an} is a Solution of the recurrence
relation an C1an 1 C2 an 2 Ck an k if and only if
an 1,0 1,1n 1, m1 1n m1 1 r
n
1 2,0 2,1 n 2, m2 1n m2 1 r n
2
t ,0 t ,1 n t , mt 1 n mt 1 r n
t
for n 0,1, 2, , where i , j are constants
for 1 i t and 0 j mi 1.
5. Find the Solution to the recurrence relation an 3an1 3an2 an3 with
initial conditions a0 = 1, a1= -2, a2 = -1.
Solution: Given, an 3an1 3an2 an3 -------- (1) with initial conditions a0
= 1, a1= -2, a2 = -1.
Let, an=rn, where ‘r’ is a constant, n=0,1,2,3,… . So (1) becomes,
r n 3 r n 1 3 r n 2 r n 3
r 3 3r 2 3r 1 0
3
r 1 0
i.e. r = -1 is a root of multiplicity 3 of the characteristic equation. Hence, the
Solution of the recursive relation (1) is of the form
n n n n
an 1,0 1,1n 1,2 n 2 1 1,0 1 1,1n 1 1,2 n 2 1 ------- (2), where
26
Linear Non-Homogeneous Recurrence Relation With
Constant Coefficients:
The recurrence relation of the form an=C1 an-1+ C2 an-2+…+ Ck an-k+F(n)
where C1 ,C2 ,…, Ck are real numbers and F(n) is a function not identically
zero depending only on ‘n’ is called linear non-homogeneous recurrence
relation with constant coefficients.
E.g.: (i ) a 3a 2n
n n 1
27
i) F (n) 3n
ii ) F (n) n3n
iii ) F (n) n 2 2 n
iv) F ( n) n 2 1 3n ?
Solution:
Associated linear homogeneous recurrence relation is a n 6 a n 1 9 a n 2 .
2
Characteristic equation is r 2 6r 9 0 r 3 0 r 3 (multiplicity 2).
Particular Solution:
i. F n 3n , so particular Solution will be of the form an P0 n 2 3n (Since, s=3
is a root of characteristic equation with multiplicity 2.)
ii. F n n3n , so particular Solution will be of the form an n 2 p1n p0 3n.
iii. F n n 2 2n , so particular Solution will be of the form
an p2 n 2 p1n p0 2n (since, s=2 is not a root of the characteristic
equation.)
iv. F n n 2 1 3n , so particular Solution will be of the form
an n 2 p2 n 2 p1n p0 3n .
7. Find all Solutions of the recurrence relation an 3an1 2n. What is the
Solution with a1=3?
28
cn d 3 c n 1 d 2n
cn d 3cn 3c 3d 2n
2c 2 n 3c 2d 0 0 n 0.
On comparing, we get,
2c 2 0 and 3c 2d 0
3
c 1 and d .
2
3
Thus, a particular Solution is of the form an p n .
2
3
Hence, the general Solution or total Solution an an h an p n 3n ,
2
where ‘’ is constant.
To find the Solution with a1 3 , let n=1, we have,
3
a1 3 1 31
2
11 .
6
3
So, the required Solution with a1 3 is an n 11 6 3n.
2
8. Find all Solutions of the recurrence relation an 5an 1 6an 2 7n .
29
c 7 n 5 c 7 n 1 6 c 7 n 2 7 n
7n 7n
c 7 n 5c
6c 2 7 n
7 7
5 6
c c c 1
7 49
49
c .
20
49 n
Hence, the particular Solution is an p 7 .
20
49 n
Hence the total Solution is an an h an p 1 3n 2 2n 7 .
20
9. Let an be the sum of the first ‘n’ positive integers. Form a recurrence
relation with an initial condition. Determine a formula for an by solving this
recurrence relation.
Solution:
*********
Generating Function
The generating function for the sequence a0, a1,…, ak,... of real numbers is
the infinite series G x a0 a1 x ak x k ak x k .
k 0
Questions:
30
1. What is the generating function for the sequence 1, 1, 1, 1, 1, 1 ?
6
k x6 1
2 3 4 6
Solution: Here, ak=1. So, ak x 1 x x x x x G x
k 0 x 1
2. What is the generating function for the sequence 1, 1, 1, … ?
Solution: Here, ak=1. So,
1
G x ak x k x k 1 x x 2 x 3 for x 1.
k 0 k 0 1 x
sequence {ak}.
Given, recurrence relation is ak 3ak 1 for k = 1, 2, 3, … with initial
condition a0 = 2.
k k 1
Now, from (1), xG ( x ) x ak x ak x a j 1 x j by shifting index
k 0 k 0 j 1 0
a j 1 x j a k 1 x k ' k ' being arbitrary
j 1 k 1
31
Now given,
ak 3ak 1 ak 3ak 1 0 (1)
Now,Consider G x 3xG(x)
ak x 3ak 1xk k
k 0 k 1
a0 ak xk 3ak 1xk
k 1 k 1
a0 ak 3ak 1 xk
k 1
a0 0 xk a0 2(fromthegiveninitialcondition)
k 1
1 3x G x 2
2 1
G x 23k xk 1 ax a2 x2 a3 x3 k 0 ak xk
1 3x k 0 1 ax
G x 2 3k xk . Thus, ak 2 3k.
k 0
2. For the recurrence relation an 8an 1 10n 1 and the initial condition a0 1 ,
find an explicit formula for an, using generating functions.
n
Solution: Let, G x an x be the generating function of the sequence a0, a1,
n 0
… -------(1)
n 1
The given recurrence relation is an 8an 1 10 ------(2) with initial condition
a1 = 9.
a n x n 8 a n 1 x n 10 n 1 x n
an x n 8an 1 x n 10 n 1 x n Taking summation on both sides
n 1 n 1 n 1
an x a 0 a 0 8 a n 1 x 10 n 1 x n
n n
n 1 n 1 n 1
32
G x 1 8 x an 1 x n 1 x 10n 1 x n 1
n 1 n 1
8 x an x n x 10n x n
n 0 n 0
x
8 xG x
1 10 x
x 1 9x
G x 8 xG x 1
1 10 x 1 10 x
1 9x 1 1 1
G x
1 10 x 1 8 x 2 1 8 x 1 10 x
1
1
8n x n 10n x n 8n 10 n x n
2 n 0 n 0 n 0 2
1 n
Hence, the Solution is {an}, with an
2
8 10n .
n
3. Use generating function to show that C (n, k ) 2 C (2n, n) , where ‘n’ is a positive
k 0
integer.
Solution: By the binomial theorem, we have,
2n
1 x 2 nC0 2 nC1 2 nC2 2 nCn 2 nC2 n ----------- (1)
From, (1) we have coefficient of x n C 2n, n --------- (2)
Again,
2n n 2 2
1 x 1 x C n, 0 C n,1 x C n, 2 x 2 C n, n x n
C n, 0 C n,1 x C n, 2 x 2 C n, n x n C n, 0 C n,1 x C n, 2 x 2 C n, n x n
4. Use generating function to solve the recurrence relation ak 7 ak 1 with the initial
condition a0 5 .
33
5. Use generating function to solve the recurrence relation ak 3ak 1 2 with the initial
condition a0 1 .
6. Use generating function to solve the recurrence relation ak 3ak 1 4 k 1 with the initial
condition a0 1 .
7. Use generating function to solve the recurrence relation ak 5ak 1 6ak 2 with the
initial condition a0 6 and a1 30.
***************
Inclusion-Exclusion Principle
Examples:
1. Let A and B be two sets such that, n( A) 20, n( A B ) 42 and n( A B ) 4.
Find i) n(B), ii) n(A-B), iii) n(B-A).
Solution:
2. A survey shows that 76% of the Indians like oranges, where as 62% like bananas.
What percentage of the Indians like both oranges and bananas?
3. Out of the members of three athletic teams in a certain school, 21 are in the
basketball team, 26 in hockey team and 29 in the football team. 14 play hockey
and basketball, 15 play hockey and football, 12 play football and basketball and 8
play all the three games. How many members are there in all?
34
4. In a group of 1000 people, there are 750 who can speak Hindi and 400 who can
speak Telugu. How many can speak Hindi only? How many can speak Telugu
only? How many can speak both Hindi and Telugu?
Solution:
5. How many bit strings of length eight either start with a ‘1’ bit or end with the two
bits ‘00’?
6. How many bit strings of length seven either begin with two 0’s or end with three
1’s ?
Solution:
***************
Relations on a Set
Cartesian Product: Let A and B be two non-empty sets. The Cartesian product of A and B is
defined and denoted as A B x, y x A and y B. Eg: A 1, 2,3 , B 2,5. Then,
A B 1, 2 , 2, 2 , 3, 2 , 1,5 , 2, 5 , 3,5 .
Relation:
Properties:
1. Reflexive: A relation on a set ‘A’ is called reflexive if (a,a)R for every element
aA.
2. Symmetric: (b,a) R whenever (a,b) R, for all a,b A.
35
3. Anti-Symmetric: A relation ‘R’ on a set ‘A’ is defined such that (a,b) R and (b,a)
R only if a = b, for all a,b A is called anti symmetric.
4. Transitive: A relation R on a set ‘A’ is called transitive if whenever (a,b) R and
(b,c) R, then (a,c) R for all a,b,cA.
2
Note: There are 2n relations on a set with ‘n’ elements.
5. Composite: Let ‘R’ be a relation from a set A to a set B and ‘S’ is a relation from
set ‘B’ to set ‘C’. The composite of ‘R’ and ‘S’ is the relation consisting of
ordered pairs (a,c) where a A and c C and for which there exists an element b
B such that (a,b) R and (b,c) S. The composite of ‘R’ and ‘S’ is denoted by
S R.
6. Powers of a Relation ‘R’: Let ‘R’ be a relation on the set A. The powers
R n , n 1, 2, 3, are defined recursively by R1 R and R n 1 R n R.
So, R 2 R R , R 3 R 2 R R R R and so on.
Note: The relation ‘R’ on a set ‘A’ is transitive iff R n R for n = 1,2,3,…
Closures of Relation:
36
Consider a Set A={1,2,3,4}. Let a relation be defined by R={(1,3), (1,4), (2,1),
(3,2)}. The given relation is not a transitive relation as the following elements
(1, 2), (2, 3), (2, 4), (3, 1) are missing in ‘R’. However including them still the
relation ‘R’ is not transitive because (3, 4) cannot be included.
Warshall’s Algorithm:
It is an efficient method for computing the transitive closure of a relation, which uses
the concept of the interior vertices of a path.
We know an algorithm is a step-by-step specification on how to perform a certain
task. Here we basically deal with the applications of the theory of digraphs and
relations to the study of algorithms. There are many aspects of an algorithm. One of
the most basic aspects is the correctness of an algorithm. An algorithm is considered
to be correct if, when performed on input that satisfies its input requirements, the
algorithm terminates and yields output that satisfies its output requirements.
Basic Idea:
For each vertex ‘vk’ and all the paths through it, the main loop of the algorithm
considers all of the possible two step paths from vi to vj that go into and out of vk and
if any are found, the algorithm builds a bypass (vi, vj), provided such a bypass doesn’t
already exist.
Ultimately, each vertex is by passed, which means that for each path in the original
graph there will be a direct connection (edge) in the result.
Application:
Start with M0, the adjacency matrix of the relation ‘R’, and then successively
construct the matrices M1, M2, …, Mn, where ‘n’ is the number of vertices for the
relation ‘R’.
Moreover, for each k1, we can construct Mk in terms of the previously constructed
matrices Mk-1.
Mk(i, j) can be obtained from the condition (*) (mentioned above)
37
Warshall observed that Mk[i, j]=1 can occur only if one of the following two cases
occurs:
i. There is a simple path from vi to vj which does not use any other vertices except
possibly v1, v2, …, vk-1; Mk-1[i, j]=1.
ii. There is a simple path from vi to vk and a simple path from vk to vj where each
simple path does not use any other vertices except possibly v1, v2, …, vk-1, hence
Mk-1[i, j] = 1 and Mk-1[k, j] = 1
(1) vi … vj (2) vi … vk … vj
Here, “ … ” denotes part of a simple path which does not use any other vertices
except possibly v1, v2, …, vk-1.
Accordingly, the elements of Mk can be obtained by
M k i, j M k 1 i, j M k 1 i, k M k 1 k , j ,
where ‘’ & ‘’ are the usual logical operators ‘AND’ and ‘OR’, respectively.
In other words, we can obtain each entry in the matrix Mk by looking at only three
entries in the matrix Mk-1.
38
Answer the following questions:
1. Let R be the relation with directed graph as shown in the figure below. Let a, b, c, d
be a listing of the elements of the set. By Warshall’s algorithm find the matrices W0,
W1, W2, W3, and W4, where W4 is the transitive closure of R.
Solution: Let v1 a, v2 b, v3 c, v4 d .
v1 v2 v3 v4
v1 0 0 0 1
v 1
The matrix of the relation= W0 = 2
0 1 0
v3 1 0 0 1
v4 0 0 1 0
a b c d
a 0 0 0
1
1
First transitive matrix with only ‘a’ as interior=W1= b
0 1
1 b,a,d
c 1 0 0 1
d 0 0 1 0
a b c d
a 0 0 0 1
1 1
Second transitive matrix with ‘b’ as interior element=W2= b
0 1
c 1 0 0 1
d 0 0 1 0
a b c d
a 0 0 0 1
1 0 1 1
b
Third transitive matrix with ‘a’ & ‘b’ as interior=W3=
c 1 0 0 1
d 1 0 1 1
Fourth transitive matrix with ‘a’, ‘b’, ‘c’ as interior and/or ‘d’ as interior = W4 =
a b c d
a 1 0 1 1
b 1 0 1
1
c 1 0 1 1
d 1 0 1 1
39
The last matrix i.e. W4 is the matrix of the transitive closure because all the vertices a, b,
c, d are interior vertices as such there is entry ‘1’ if and only if there is a path from vi to
vj.
or
v1 v2 v3 v4 v5
v1 1 1 0 0 0
v2 0 0 1 0 0
The matrix of the relation = MR = W0 = v 3 0 0 0 1 1
v4 0 0 0 0 1
v 5 0 0 0 0 0
v1 v2 v3 v4 v5
v1 1 1 0 0 0
v2 0 0 1 0 0
First transitive matrix with only ‘a’ as interior = W1 = v 3 0 0 0 1 1
v4 0 0 0 0 1
v 5 0 0 0 0 0
This matrix is same as the original matrix i.e. W0 = W1 because with the vertex ‘a’ as the
interior vertex no new edge is formed.
40
Second transitive matrix with ‘a’ and/or ‘b’ as interior element = W2 =
v1 v2 v3 v4 v5
v1 1 1 1 0 0
v2 0 0 1 0 0
ab
v3 0 0 0 1 1 abc i.e.The path ac.
bc
v4 0 0 0 0 1
v 5 0 0 0 0 0
Third transitive matrix with ‘a, b’ and/or ‘c’ as interior =W3=
v1 v2 v3 v4 v5
v1 1 1 1 1 1 v3
v2 v4 v2 v4
v2 0 0 1 1 1
v2 ,v3
v1 v4 v1v4
v3 0 0 0 1 1 v3 Paths
v2 v5 v2 v5
v4 0 0 0 0 1
v3
v1 v5 v1v5
v 5 0 0 0 0 0
Fourth transitive matrix with ‘a, b, c’ and/or ‘d’ as interior = W 4 =
v1 v 2 v 3 v 4 v 5
v1 1 1 1 1 1
v2 0 0 1 1 1
v3 0 0 0 1 1
v4 0 0 0 0 1
v 5 0 0 0 0 0
We observe that W3 = W4 i.e. with the above stated vertices as interior vertices, no new
edge is formed.
Fifth transitive matrix: Finally with ‘a, b, c, d’ and /or ‘e’ as the interior vertices still there
will be no changes. Viewing in another way we see W4 has 1 in several positions of
column 5 but no 1’s in row 5. Thus, no new 1’s need be added to W4.
3. Using Warshall’s algorithm, compute the adjacency matrix of the transitive closure of the
digraph given below:
a b c d
● ● ● ●
Solution:
41
4. Using Warshall’s algorithm, compute the adjacency matrix of the transitive closure of
the digraph given below:
5. Using Warshall’s algorithm, compute the adjacency matrix of the transitive closure of
the digraph G a, b, c, d , e , a, b , b, c , c, d , d , e , e, d .
Solution:
6. Let ‘R’ be a relation on A a, b, c, d , e whose adjacency matrix is given. Compute the
adjacency matrix of the transitive closure R using Warshall’s algorithm.
0 1 0 0 1 0 0 1 1 1 0 0
1 0 1 0 1 1 0 0 1 0 0 0
a , b , c ,
0 0 0 1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 0 1 0
1 0 0 1 0 1 0 0 1 0 0 1
0 0 1 1 0 0 0 1 0 1 1 0
d , e , f
0 0 1 1 0 1 0 0 0 1 1 0
1 0 0 1 0 0 1 0 1 0 0 1
************
42
Examples:
Answer the following questions:
1. Let ‘m’ be a positive integer with m 1 . Show that the relation R a, b a b mod m
is an equivalence relation on the set of integers.
2. Let ‘R’ be the relation on the set of real numbers such that aRb if and only if ab is an
integer. Is ‘R’ an equivalence relation?
3. Suppose that ‘R’ is the relation on the set of strings of English letters such that aRb if
and only if l a l b , where l x is the length of the string x. Is ‘R’ an equivalence
relation?
4. Show that the “divides” relation on the set of positive integers is not an equivalence
relation.
5. Let ‘R’ be the relation on the set of real numbers such that xRy if and only if x and y are
real numbers that differ by less than 1, that is x y 1. Show that ‘R’ is not an
equivalence relation.
**************
Equivalence Class: Let ‘R’ be an equivalence relation on a set ‘A’. The set of all elements
that are related to an element ‘a’ of ‘A’ is called the eqiovalence class of ‘a’. The
equivalence class of ‘a’ with respect to ‘R’ is denoted by [a]R or [a].
43
equivalence relation on a set ‘A’. The following statements are equivalent:
(i ) a R b
(ii ) [a] [b]
(iii )[a] [b]
Partitions:
A partition or quotient set of a nonempty set A is a collection P of nonempty subsets of A
such that
1. Each element of A belongs to one of the sets in P.
2. If A1 and A2 are distinct elements of P, then A1 A2 .
The sets in P are called the blocks or cells of the partition. Figure 4.2 shows a partition P
A1 , A2 , A3 , A4 , A5 , A6 , A7 into seven blocks.
Figure-1
44
Z set of all integers,
A1 = set of all even integers, and
A2 =set of all odd integers.
Then A1 , A2 is a partition of Z .
Since the members of a partition of a set A are subsets of A , we see that the partition is a
subset of P A , the power set of A . That is, partitions can be considered as particular
kinds of subsets of P A .
The following result shows that if P is a partition of a set A, then P can be used to
construct an equivalence relation on A.
Theorem-1: Let P be a partition of a set A. The sets in P are called the blocks of P.
Define the relation R on A as follows: a R b if and only if a and b are members of the
same block. Then R is an equivalence relation on A.
Example : Let A 1, 2,3, 4 and consider the partition P 1, 2, 3, ,4 of A. Find the
equivalence relation R on A determined by P.
Solution: The blocks of P are 1, 2,3 and 4 . Each element in a block is related to
every other element in the same block and only to those elements. Thus, in this case,
R 1,1 , 1, 2 , 1, 3 , 2,1 , 2, 2 , 2,3 , 3,1 , 3, 2 , 3, 3 , 4, 4
45
Lemma-1: Let R be an equivalence relation on a set A, and let a A and b A. Then
a R b if and only if R a R b .
Proof: First suppose that R a R b . Since R is reflexive, b R b ; therefore,
b R a , so a R b. Conversely, suppose that a R b. Then note that
1. b R a by definition. Therefore, since R is symmetric,
2. a R b , since a relation R on a set A is symmetric means that a R b if and only if
b R a .
We must show that R a R b . First, choose an element x R b . Since R is
transitive, the fact that x R b , together with (1), implies by the transitivity of R means
that if b R a and c R b , then c R a , that x R a . Thus R b R a . Now
choose y R a . This fact and (2) imply, as before, that y R b . Thus R a R b , so
we must have R a R b .
Theorem-: Let R be an equivalence relation on A, and let P be the collection of all
distince relative sets R a for a in A. Then P is a partition of A, and R is the
equivalence relation determined by P.
Proof: According to the definition of a partition, we must show the following two
properties:
(a) Every element of A belongs to some relative set.
(b) If R a and R b are not identical, then R a R b .
Now property (a) is true, since a R a by reflexivity of R. To show property (b) we
prove the following equivalent statement:
If R a R b , then R a R b .
To prove this, we assume that c R a R b . Then a R c and b R c.
Since R is symmetric, we have c R b. Then a R c and c R b, so, by transitivity of R, a R b.
The above lemme tells us that R a R b . We have now proved that P is a partition,
Hence by the above lemma we see that a R b if and only if a and b belong to the same
block of P. Thus P determines R , and hence the theorem is proved.
46
Example: Let A 1, 2,3, 4 and let R 1,1 , 1, 2 , 2,1 , 2, 2 , 3, 4 , 4, 3 , 3,3 , 4, 4
be the relation on A. Determine A / R.
Solution: Since R 1 1, 2 R 2 . Also R 3 3, 4 R 4 . Hence
A / R 1, 2 , 3, 4.
Example: Let A Z and let
R a, b A A | a and b yield the same remainder when divided by 2.
Solution: Here R is in fact the congruence mod 2 relation which is an equivalence
relation.
Now first, R 0 , 6, 4, 2, 0, 2, 4, 6,8, , the set of even integers, since the
remainder is zero when each of these numbers is divided by
2. R 1 , 5, 3, 1,1,3, 5, 7, , the set of odd integers, since each gives a remainder of
1 when divided by 2. Hence A / R consists of the set of even integers and the set of odd
integers.
Thus we can extract a general procedure for determining partitions A / R for A finite or
countable.
Procedure:
Step 1: Choose any element of A and compute the equivalence class R a .
Step 2: If R a A, choose an element b, not included in R a , and compute the
equivalence class R b .
Step 3: If A is not the union of previously computed equivalence classes, then choose
an element x of A that is not in any of those equivalence classes and compute R x .
Step 4: Repeat step 3 until all elements of A are included in the computed equivalence
classes. If A is countable, this process could continue indefinitely. In that case, continue
until a pattern emerges that allows you to describe or give a formula for all equivalence
classes.
Partial Ordering: A relation on a set ‘A’ is called a partial ordering if it is reflexive, anti-
symmetric and transitive. A set ‘S’ together with a partial ordering ‘R’ is called a
partially ordered set or poset and is denoted by (S,R).
Example:
Answer the following question:
1. Show that the “greater than or equal” relation () is a partial ordering on the set of
integers.
Solution: Reflexive: Since, a a, for every integer ‘a’. so, is reflexive.
Anti-Symmetric: If a b and b a a = b. Thus, is anti-Symmetric.
Transitive: Since, a b and b c a c. Thus, is transitive.
Hence, is a partial ordering on the set of integers and (Z, ) is a poset.
Note: A poset is also denoted by S , where denotes the relation in any poset.
47
Comparable: The elements ‘a’ and ‘b’ of a poset S , are called comparable if either a
b or b a.
When ‘a’ and ‘b’ are elements of S such that neither ab nor ba , then ‘a’ and ‘b’ are
called incomparable.
Examples:
Answer the following questions:
1. Investigate the lexicographic ordering constructed from the relation ‘’on , of the
following 1,3, 5, 7 1,3, 7,9 .
2. Investigate the lexicographic ordering on the set of strings:
a. discreet discrete
b. discreet discreetness
Hasse Diagrams: The partial ordering on a finite set can be represented using graphical
representation, without showing loops and which is non-directed. Such a diagram
contains sufficient information to find the partial ordering. This diagram is called Hasse
diagram.
Examples:
Answer the following questions:
1. Draw the Hasse diagram representing the partial ordering a, b a divides b on
1, 2,3, 4,6,8,12.
2. Draw the Hasse diagram for the partial ordering A, B | A B on the power set P(S)
where S={a,b,c}.
3. Draw the Hasse diagram for the partial ordering a, b | a b on the set {1, 2, 3, 4}.
Examples:
Answer the following questions:
1. Which elements of the poset 2, 4, 5,10,12, 20, 25, ,| are maximal and which are
minimal?
48
Greatest Element: An element ‘a’ is the greatest element of the poset S , if ba for all
b S . The greatest element is unique when it exists.
Least Element: An element ‘a’ is the least element of S , if ab for all b S . The least
element is unique when it exists.
Lower Bound: If ‘l’ is an element of ‘S’ such that l a for all elements a A , then ‘l’ is
called a lower bound of A.
Upper Bound: If ‘u’ is an element of ‘S’ such that a u for all elements a A , then ‘u’ is
called an upper bound of A.
Least Upper Bound: The element ‘x’ is called the least upper bound of the subset ‘A’ if
‘x’ is an upper bound that is less than every other upper bound of A.
Greatest Lower Bound: The element ‘y’ is called the greatest lower bound of the subset
‘A’ if ‘y’ is greater than all other lower bounds of ‘A’.
Example:
Answer the following questions:
1. Find the greatest lower bound and the least upper bound of the sets 3,9,12 and
1, 2, 4,5,10 if they exist in the poset
,| .
Lattice: A partially ordered set in which every pair of elements has both a least upper
bound and a greatest lower bound is called a lattice.
Examples:
Answer the following questions:
1. Determine whether the posets 1, 2,3, 4, 5 ,| and 1, 2, 4,8,16 ,| are lattices.
Solution: In the poset S 1, 2,3, 4,5 ,| though they have ‘1’ as the g.l.b of any two
elements of the set lying in the set, but 2 and 3 have no upper bounds in the given poset.
The LCM of 2 and 3 is 6 which is not in the given poset. So, ‘S’ is not a lattice.
Again, in the poset P 1, 2, 4,8,16 ,| the g.l.b of any two elements of P is smaller of the
elements and the l.u.b of two elements in this poset is the larger of the elements which
lies in the set too. Since, the given poset contains both g.l.b and l.u.b, so the given poset
is a lattice.
49
*****End of Module-I*****
50