II CSE Discrete Notes
II CSE Discrete Notes
A K Lal S Pati
General Instructions
Throughout this book, an item with a label 2.1.3 means the 3-rd item of the 1-st section
of Chapter 2. While defining a new term or a new notation we shall use bold face letters. The
symbol := is used at places we are defining a term using equality symbol. A symbol !! at
the end of a statement reminds the reader to verify the statement by writing a proof, if
necessary.
We assume that the reader is familiar with the very basic of counting. A reader who is
not, may avoid the counting items in the initial parts till we start to discuss counting.
We also assume that the reader is familiar with some very basic definitions involving sets.
This book is written with the primary purpose of making the reader understand the discussion.
We do not intend to write elaborate proofs for the reader to read, as there is no end to
elaboration. We request the reader to take each statement in the book with the best possible
natural meaning.
Here are a few collected quotes, mainly intended to inspire the authors.
Albert Einstein
• The value of a college education is not the learning of many facts but the training of
the mind to think.
• Imagination is more important than knowledge. For knowledge is limited, whereas
imagination embraces the entire world, stimulating progress, giving birth to evolution.
It is, strictly speaking, a real factor in scientific research.
• Everything should be made as simple as possible, but no simpler.
• Do not worry about your difficulties in Mathematics. I can assure you mine are still
greater.
Contents
4 Introduction to Logic 59
4.1 Propositional Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
4.2 Predicate Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6 Counting 91
6.1 Permutations and Combinations .. . . . . . . . . . . . . . . . . . . . . . . . . . 91
6.1.1 Multinomial theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
6.2 Circular Permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
6.3 Solutions in Non-negative Integers . . . . . . . . . . . . . . . . . . . . . . . . . . 104
6.4 Set Partitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
6.5 Lattice Paths and Catalan Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 112
6.6 Some Generalizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
4 CONTENTS
8 Graphs 147
8.1 Basic Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
8.2 Connectedness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
8.3 Isomorphism in Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
8.4 Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
8.5 Connectivity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
8.6 Eulerian Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
8.7 Hamiltonian Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
8.8 Bipartite Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
8.9 Matching in Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
8.10 Ramsey Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
8.11 Degree Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
8.12 Planar Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
8.13 Vertex Coloring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
8.14 Adjacency Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
8.15 More Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Index 188
CONTENTS 5
1 1 1
Remained changed to Remainder. 1 + + + · · · + is not an integer.
2 3
n
6 CONTENTS
Chapter 1
The following are some notations we shall follow throughout this document.
N : the set of natural numbers
N0 : the set N ∪ {0}, called the set of whole numbers
Z : the set of integers
Q : the set of rational numbers
R : the set of real numbers
[n] : the set {1, 2, . . . , n}
c
A : the complement of a set A in some set that will be clear from the context
P (A) : the power set of A
A×B : the cartesian product of A and B
∅ : the empty set
p|a : the integer p divides the integer a
1.2 Preliminaries
5. [Set union] The union of A and B, denoted A ∪ B, is the set that exactly contains all the
elements of A and all the elements of B. Specifically, A ∪ B = {x | x ∈ A or x ∈
B}.
6. [Set intersection] The intersection of A and B, denoted A ∩ B, is the set that
only contains the common elements of A and B. Specifically, A ∩ B = {x | x ∈ A and x
∈ B}. The set A and B are said to be disjoint if A ∩ B = ∅.
7. [Set difference] The set difference of A and B, denoted A \ B, is a set that contains
all those elements of A which are not in B. Specifically, A \ B = {x ∈ A | x 6∈ B}.
8. [Symmetric difference] The symmetric difference of A and B, denoted A∆B, equals
(A \ B) ∪ (B \ A).
Example 1.2.2. Let A = {{b, c}, {{b}, {c}}, b} and B = {a, b, c}. Then
1. A ∩ B = {b},
2. A ∪ B = {a, b, c, {b, c}, {{b}, {c}} },
3. A \ B = {{b, c}, {{b}, {c}}},
4. B \ A = {a, c}, and
5. A∆B = {{b, c}, {{b}, {c}}, a, c}.
The following are a few well known facts. The readers are supposed to verify them for clarity.
3. For any set A and B, the sets A \ B, A ∩ B and B \ A are pairwise disjoint. Thus, A ∪ B
is their disjoint union. That is,
A ∪ B = (A \ B) ∪ (A ∩ B) ∪ (B \ A). (1.1)
4. For any set A and B, the sets A \ B and A ∩ B are disjoint. Thus, A is their disjoint union.
That is,
A = (A \ B) ∪ (A ∩ B) (1.2)
Definition 1.2.4. [Power set] Let A be a set and B ⊆ A. Then, the set that contains
all subsets of B is called the power set of B, denoted P (A).
3. Let A = {a, b, c}. Then, P (A) = {∅, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}}.
1.2.
1 PRELIMINARIES CHAPTER 1. BASIC SET THEORY
1
0 0
4. Let A = {{b, c}, {{b}, {c}}}. Then, P (A) = {∅, {{b, c}}, {{{b}, {c}}}, {{b, c}, {{b}, {c}}} }.
Definition 1.2.6. [Relation, domain set and codomain set] Let A and B be two sets. A
relation f from A to B, denoted f : A → B, is a subset of A × B. The set A is called
the domain set and the set B is called the codomain set. Thus, for any sets A and B the
sets ∅ and A × B are always relations from A to B.
Example 1.2.7. Let A = [3], B = {a, b, c} and f = {(1, a), (1, b), (2, c)}. Then, f : A → B is
a relation. We can draw a picture for f .1
1 a
2 b
3 c
1
We use pictures to help our understanding and they are not parts of proof.
2
The domain set is the set from which we define our relations but dom f is the domain of the particular relation
f . They are different.
1.2. PRELIMINARIES
10 CHAPTER 1. BASIC SET THEORY
10
Proof. We will prove only one way implication. The other way is left for the
reader.
Part 1: Since f (S) = ∅, one can find a ∈ S ∩ A and b ∈ B such that (a, b) ∈ f . This, in
turn, implies that a ∈ dom(f ). As a ∈ S, a ∈ dom(f ) ∩ S.
Part 2: Since rng(f ) ∩ S = ∅, one can find b ∈ rng(f ) ∩ S and a ∈ A such that (a, b) ∈ f .
− −
This, in turn, implies that a ∈ f 1 (b) ⊆ f 1 (S) as b ∈ S.
Convention:
Let p(x) be a polynomial in x with integer coefficients. Then, by writing ‘f : Z → Z
is a function defined by f (x) = p(x)’, we mean the function f = {(a, p(a)) | a ∈ Z}.
For example, the function f (x) = x2 stands for the set {(a, a2 ) | a ∈ Z}.
Example 1.2.12. 1. In Definition 1.2.9, the function g2 is one-one whereas g1 is not one-one.
2. The function f : Z → Z defined by f (x) = x2 is not one-
one.
3. The function f : N → N0 defined by f (x) = x2 is one-
one.
4. The function f : [3] → {a, b, c, d} defined by f (1) = c, f (2) = b and f (3) = a, is one-
one.
Verify that there are 24 one-one functions f : [3] → {a, b, c, d}.
5. Let ∅ = A ( B. Then, f (x) = x is a one-one map from A to
B.
6. There is no one-one function from the set [3] to its proper subset [2].
7. There are one-one functions f from the set N to its proper subset {2, 3, . . .}. One of
them is given by f (1) = 3, f (2) = 2 and f (n) = n + 1, for n ≥ 3.
2. There are 6 onto functions from [3] to [2]. For example, f (1) = 1, f (2) = 2 and f (3) =
2 is one such function.
(
y if y ∈ A,
3. Let ∅ = A ( B. Choose a ∈ A. Then, g(y) = is an onto map from
a if y ∈ B \ A.
B to A.
4. There is no onto function from the set [2] to its proper superset [3].
5. There are onto functions f from the set {2, 3, . . .} to its proper superset N. One of
them is f (x) = x − 1.
Definition 1.2.18. [Bijection and equivalent set] Let A and B be two sets. A function
f : A → B is said to be a bijection if f is one-one as well as onto. The sets A and B are said
to be equivalent if there exists a bijection f : A → B.
Example 1.2.19. 1. In Definition 1.2.9, the function g2 is a bijection.
2. The function f : [3] → {a, b, c} defined by f (1) = c, f (2) = b and f (3) = a, is a bijection.
Thus, the set {a, b, c} is equivalent to [3].
3. Let ∅ = A ⊆ A. Then, f (x) = x is a bijection. Thus, the set A is equivalent to itself.
−1
4. If f : A → B is a bijection then f : B → A is a bijection. Thus, if A is equivalent to B
then B is equivalent to A.
5. The set N is equivalent to {2, 3, . . .}. Indeed the function f : N → {2, 3, . . .} defined by
f (1) = 3, f (2) = 2 and f (n) = n + 1, for n ≥ 3 is a bijection.
1. 1 ∈ S and
2. k + 1 ∈ S whenever k ∈ S.
Then, S = N.1
Fact 1.2.21. 1. Let A, B and C be sets and let f : A → B and g : B → C be
bijections.
Then, h : A → C defined by h(x) = g(f (x)) is a bijection.
1
PMI is actually a part of Peano’ axioms that defines N as: a) 1 ∈ N. b) For each n ∈ N, the successor
s(n) ∈ N. c) 1 is not a successor of any natural number. d) If s(m) = s(n) happens for natural numbers m and
n, then m = n. e) Let S ⊆ N such that 1 ∈ S and s(k) ∈ S, for each k ∈ S. Then, S = N.
1.2. PRELIMINARIES
13 CHAPTER 1. BASIC SET THEORY
13
Proof. h is one-one: Let if possible h(x) = h(y), for some x, y ∈ A. Then, by definition,
g(f (x)) = g(f (y)), for some f (x), f (y) ∈ B. As g is one-one, we get f (x) = f (y).
Now, using f is one-one, we get x = y and hence h is one-one.
h is onto: Let c ∈ C . Then, the condition that g is onto implies that there exists b ∈
B such that g(b) = c. Also, for b ∈ B, the condition that f is onto implies that there
exists a ∈ A such that f (a) = b. Thus, we see that h(a) = g(f (a)) = g(b) = c and
hence the required result follows.
2. Let A and B be two disjoint sets and let f : A → [n] and g (
: B → [m] be two bijections.
f (x) if x ∈ A
Then, the function h : A ∪ B → [m + n] defined by h(x) is a
= g(x) + n if x ∈ B
bijection.
3. Fix n ≥ 2 and let f : A → [n] be a bijection such that for(a fixed element a ∈ A, one has
f (x) if f (x) ≤ k − 1
f (a) = k. Then, g : A \ {a} → [n − 1] defined by g(x) is
= f (x) −1 if f (x) ≥ k + 1
a bijection.
4. For any positive integers n and k, there is no bijection from [n] to [n + k].
Proof. Let us fix k and prove the result by induction on n. The result is clearly true for
n = 1 as k + 1 ≥ 2. So, let the result be true for n. We need to prove it for n + 1.
On the contrary, assume that there exists a bijection f : [n + 1] → [n + 1 + k].
Then, by Fact 1.2.21.3, we get a bijection g : [n] → [n + k], where a = n + 1. Thus, we
arrive at a contradiction to the induction assumption.
Proof. Let |S| = n, for some n ∈ N. Then, there is a bijection f : S → [n]. Let T ⊆
S. If T is empty then there is nothing to prove. Else, consider the map fT : T → f
(T ).
1.2. PRELIMINARIES
15 CHAPTER 1. BASIC SET THEORY
15
This map is a bijection. By Fact 1.2.23.2, f (T ) ⊆ [n] is finite and hence T is finite
(use
Fact 1.2.21.1).
4. Let A and B be two finite sets, then |A ∪ B| = |A| + |B| − |A ∩ B|.
Proof. Using (1.1), A ∪ B = (A \ B) ∪ (A ∩ B) ∪ (B \ A). As the sets A \ B, A ∩ B
and
B \ A are finite and pairwise disjoint, the result follows from Fact
1.2.23.1.
5. Let A be a nonempty finite set. Then, for any set B, |A| = |A \ B| + |A ∩ B|.
Proof. As A is finite, A \ B and A ∩ B are also finite. Now, use Fact
1.2.23.1.
6. Let A be a nonempty finite set and B ⊆ A, then |B| ≤ |A|. In particular, if B ( A then
|B| < |A|.
Proof. Since B = A ∩ B, the result follows from Fact
1.2.23.5.
7. Let n and k be two fixed positive integers. Then, there is no one-one function from [n + k]
to [n].
Proof. Suppose there exists a one-one function f : [n + k] → [n], for some n and k.
Put B = f ([n + k]) ⊆ [n]. Then, notice that f : [n + k] → B is a bijection and hence the
sets B and [n + k] are equivalent. Thus, by definition and Fact 1.2.23.6, n + k = |B| ≤ n
< n + 1. Or equivalently, k < 1 contradicting the assumption that k ≥ 1.
8. The set N is infinite.
Proof. Assume that the set N is finite and |N| = n, for some natural number n. Let
f : N → [n] be a bijection. Then, f[n+1] is the restriction of f on [n + 1]. Thus, by
Proposition 1.2.15, f[n+1] is also one-one, contradicting Fact 1.2.23.7.
9. Let A be a finite nonempty set and x be a fixed symbol. Now, consider the set B =
{(x, a) | a ∈ A}. Then, |A| = |
B|.
Proof. Define the function f : A → B by f (a) = (x, a), for all a ∈ A. Then, f is
a bijection.
10. Let A be an infinite set and B ⊇ A. Then, B is infinite.
Proof. If B is finite then by Fact 1.2.23.3, A is finite. A contradiction to A being
an infinite set.
11. Let A be an infinite set and B be a finite set. Then, A \ B is also infinite. In particular,
if a ∈ A, then A \ {a} is also infinite.
Proof. If A \ B is finite, then by Fact 1.2.23.1, the set (A \ B) ∪ B is also finite.
But A ⊆ (A \ B) ∪ B and hence by Fact 1.2.23.3, A is finite as well. A contradiction to A
being an infinite set.
1.2. PRELIMINARIES
16 CHAPTER 1. BASIC SET THEORY
16
1. Do there exist unique sets X and Y such that X \ Y = {1, 3, 5, 7} and Y \ X = {2, 4, 8}?
2. In a class of 60 students, all the students play either football or cricket. If 20 students play
both football and cricket, determine the number of players for each game if the number of
students who play football is
1. 1 ∈ S and
1. k0 ∈ S and
2. k + 1 ∈ S whenever {k0 , k0 + 1, . . . , k} ⊆
S. Then, {k0 , k0 + 1, . . .} ⊆ S.
The next result is commonly known as the Well-Ordering Principle which states that
“every nonempty subset of natural numbers contains its least element”.
Theorem 1.3.3. [Application of PMI in strong form: A nonempty subset of N contains its
minimum] Let ∅ = A ⊆ N. Then, the least element of A is a member of A.
Proof. For each fixed positive integer k, let P (k) mean the statement ‘each nonempty subset
A
of N that contains k, also contains its minimum’.
Notice that P (1) is true. Now, assume that P (1), . . . , P (k) are true. We need to show
that P (k + 1) is true as well. Hence, consider a set A such that k + 1 ∈ A. If {1, . . . , k} ∩
A = ∅, then k + 1 = min A, we are done. If r ∈ {1, . . . , k} ∩ A, then r ≤ k and hence by
induction hypothesis, P (r) is true. So, P (k + 1) is true. Hence, by the strong form of PMI
the required
result follows.
By using Theorem 1.3.2, we can also prove the following generalization of Theorem 1.3.3. The
proof is similar to the proof of Theorem 1.3.3 and is left to the reader.
Theorem 1.3.6. [Equivalence of PMI in weak form and PMI in strong form] Fix a
natural number k0 and let P (n) be a statement about a natural number n. Suppose that P
means the
statement ‘P (n) is true, for each n ∈ N, n ≥ k0 ’. Then, ‘P can be proved using the weak
form
of PMI’ if and only if ‘P can be proved using the strong form of
PMI’.
1.3. MORE ON THE PRINCIPLE OF MATHEMATICAL
17 CHAPTER
INDUCTION
1. BASIC SET THEORY
17
Proof. Let us assume that the statement P has been proved using the weak form of PMI.
Hence, P (k0 ) is true. Further, whenever P (n) is true, we are able to establish that P (n + 1)
is true. Therefore, we can establish that P (n + 1) is true if P (k0 ), . . . , P (n) are true. Hence,
P can be proved using the strong form of PMI.
So, now let us assume that the statement P has been proved using the strong form of
PMI. Now, define Q(n) to mean ‘P (ℓ) holds for ℓ = k0 , k0 + 1, . . . , n’. Notice that Q(k0 )
is true. Suppose that Q(n) is true (this means that P (ℓ) is true for ℓ = k0 , k0 + 1, . . . , n). By
hypothesis, we know that P has been proved using the strong form of PMI. That is, P (n+1) is
true whenever P (ℓ) is true for ℓ = k0 , k0 + 1, . . . , n. This, in turn, means that Q(n + 1) is
true. Hence, by the
weak form of PMI, Q(n) is true for all n ≥ k0 . Thus, we are able to prove P using the weak
form of PMI.
Theorem 1.3.7. [Optional: Application of PMI in weak form: AM-GM inequality] Fix a
positive integer n and let a1 , a2 , . . . , an be non-negative real numbers. Then
a1 + · · · + √
Arithmetic Mean (AM) := ≥ a1 · · · an =: (GM) Geometric Mean.
an n
n
Proof. The inequality clearly holds for n = 1 and 2. Assume that it holds for every choice of n
non-negative real numbers. Now, let a1 , . . . , an , an+1 be a set of n + 1 non-negative real
a +a
numbers with a1 = max{a1 , . . . , an+1 } and an+1 = min{a1 , . . . , an+1 }. Define A = 1 2
···
+ +an+1 n+1
. Then, note that a1 ≥ A ≥ an+1 . Hence, (a1 − A)(A − an+1 ) ≥ 0, i.e., A(a1 + an+1
− A) ≥ a1 an+1 . Now, apply induction hypothesis on the n non-negative real numbers a2 , . . . ,
an , a1 + an+1 − A to get
p a2 + · · · + an + (a1 + an+1 −
a2 · · · · · an · (a1 + an+1 −
n
A) = A.
A) ≤ n
So, we have A n+1
≥ (a2 · a3 · · · · · an · (a1 + an+1 − A)) · A ≥ (a2 · a3 · · · · · an ) a1 an+1 .
Therefore, by PMI, the inequality holds, for each n ∈ N.
In the next example, we illustrate the use of PMI to establish some given identities (properties,
statements) involving natural numbers.
n(n + 1)
Example 1.3.8. Prove that 1 + 2 + · · · + n .
2
=
n(n+1)
Ans: The result is clearly true for n = 1. So, let us assume that 1 + 2 + · · · + n = 2 .
Then, using the induction hypothesis, we have
n(n + 1) n+1
1 + 2 + · · · + n + (n + 1) + (n + 1) (n + 2) .
= = 2
2
Thus, the result holds for n + 1 and hence by the weak form of PMI, the result follows.
Practice 1.3.10. [Wrong use of PMI: Can you find the error?] The following is an
incorrect proof of ‘if a set of n balls contains a green ball then all the balls in the set are
green’. Find the error.
Proof. The statement holds trivially for n = 1. Assume that the statement is true for n ≤ k.
Take a collection Bk+1 of k + 1 balls that contains at least one green ball. From Bk+1 , pick
a collection Bk of k balls that contains at least one green ball. Then, by the induction
hypothesis, each ball in Bk is green. Now, remove one ball from Bk and put the ball which
was left out in
the beginning. Call it B ′k . Again by induction hypothesis, each ball in Bk′ is green. Thus, each
ball in Bk+1 is green. Hence, by PMI, our proof is complete.
Exercise 1.3.11. [Optional]
Pn xn+1 − 1
1. Let x ∈ R with x = 1. Then, prove that 1 + x + x2 + · · · + xn xk = .
=
k=0 x−1
2. Let a, a + d, a + 2d, . . . , a + (n − 1)d be the first n terms of an arithmetic progression. Then,
X
n−1
n
S= (a + id) = a + (a + d) +· · · + (a + (n− 1)d) = (2a + (n 1)d) .
i=0
2
−
−1
3. Let a, ar, ar 2 , . . . , ar n
be the first n terms of a geometric progression, with r = 1. Then,
P i
n−1 rn − 1
S = a + ar + · · · + ar n−1 ar = a .
=
i=0 r−1
4. Prove that
9. [Informative] Prove that, for all n ≥ 40, there exist nonnegative integers x and y
such that n = 5x + 11y.
10. For every positive integer n ≥ 3 prove that 2n > n2 > 2n + 1.
1.3. MORE ON THE PRINCIPLE OF MATHEMATICAL
21 CHAPTER
INDUCTION
1. BASIC SET THEORY
21
13. [Informative] By an L-shaped piece, we mean a piece of the type shown in the picture.
Consider a 2n × 2n square with one unit square cut. See picture.
α A B β
C γ
L-shaped piece 4 × 4 and 8 × 8 squares with a unit square cut
Show that a 2n × 2n square with one unit square cut, can be covered with L-shaped pieces.
14. [Informative] Verify that (k +1)5 −k5 = 5k 4 +10k 3 +10k 2 +5k +1. Now, put k = 1, 2, . . . , n
P
n P 3
n nP nP n P
and add to get (n + 1)5 − 1 = 5 k4 + 10 k + 10 k2 + 5 k+ 1. Now, use
k=1 k=1 k=1 k=1 k=1
P
n P
n Pn P
n Pn
the formula’s for k3 , k2 , k and 1 to get a expression for k4 .
k=1 k=1 k=1 k=1 k=1
15. [Informative: A general result than AM-GM]
(a) Let a1 , . . . , a9 be nonnegative real numbers such that the sum a1 + · · · + a9 = 5.
a1 +a2 a1 +a2
Assume that a1 = a2 . Consider 2 , 2 , a3 , . . . , a9 . Argue that a1 · · · a9 ≤
2
a1 +a2
2 a3 · · · a 9.
(b) Let a1 , . . . , an be any nonnegative real numbers such that the sum a1 + · · · + an =
r0 .
Argue that the highest value of a1 · · · an is obtained when a1 = · · · = an = r0
/n.
(c) Let a1 , . . . , an be fixed nonnegative real numbers such that the sum a1 + · · · + an =
r0 .
Conclude from the previous item that (r0 /n)n ≥ a1 · · · an , the AM-GM
inequality.
1.4 Integers
In this section, we study some properties of integers. We start with the ‘division algorithm’.
Lemma 1.4.1. [Division algorithm] Let a and b be two integers with b > 0. Then, there
exist unique integers q, r such that a = qb + r, where 0 ≤ r < b. The integer q is called the
quotient and r, the remainder.
1.3. MORE ON THE PRINCIPLE OF MATHEMATICAL
22 CHAPTER
INDUCTION
1. BASIC SET THEORY
22
2. [Greatest common divisor] Let a and b be two nonzero integers. Then, the set S
of their common positive divisors is nonempty and finite. Thus, S contains its
greatest element. This element is called the greatest common divisor of a and b and is
denoted gcd(a, b). On similar lines one can define the greatest common divisor of non-zero
integers a1 , a2 , . . . , an as the largest positive integer that divides each of a1 , a2 , . . . ,
an , denoted gcd(a1 , . . . , an ).
The next remark follows directly from the definition and the division algorithm.
Remark 1.4.3. Let a, b ∈ Z \ {0} and d = gcd(a, b). Then, for any positive common divisor
c
of a and b, one has c | d.
The next result is often stated as ‘the gcd(a, b) is an integer linear combination of a and b’.
Theorem 1.4.4. [Be´zout’s identity] Let a and b be two nonzero integers. Then, there exist
integers x0 , y0 such that d = ax0 + by0 , where d = gcd(a, b).
Hence, r is a positive integer in S which is strictly less than d. This contradicts the fact that d
is the least element of S. Thus, r = 0 and hence d|a. Similarly, d|b.
The division algorithm gives us an idea to algorithmically compute the greatest common divisor
of two integers, commonly known as the Euclid’s algorithm.
Discussion 1.4.5. 1. Note that d, the number obtained by the application of the Well-
ordering principle in the proof of Theorem 1.4.4 has the property that d divides ax +
by,
for all x, y ∈ Z. So, for every choice of integers x, y, gcd(a, b) divides ax + by.
2. Let a, b ∈ Z \ {0}. By division algorithm, a = |b|q + r, for some integers q, r ∈ Z with
0 ≤ r < |b|. Then,
gcd(a, b) = gcd(a, |b|) = gcd(|b|, r).
To show the second equality, note that r = a − |b|q and hence gcd(a, |b|) | r.
Thus, gcd(a, |b|) | gcd(|b|, r). Similarly, gcd(|b|, r) | gcd(a, |b|) as a = |b|q + r.
3. We can now apply the above idea repeatedly to find the greatest common divisor of
two given nonzero integers. This is called the Euclid’s algorithm. For example, to
find gcd(155, −275), we proceed as follows
Also, note that 275 = 5·55 and 155 = 5·31 and thus, 5 = (9+31x)·(−275)+(16+55x)·155,
for all x ∈ Z. Therefore, we see that there are infinite number of choices for the pair
(x, y) ∈ Z2 , for which d = ax + by.
4. [Euclid’s algorithm] In general, given two nonzero integers a and b, the algorithm
proceeds as follows:
The process will take at most b − 1 steps as 0 ≤ r0 < b. Also, note that gcd(a, b) = rℓ+1
and rℓ+1 can be recursively obtained, using backtracking. That is,
rℓ+1 = rℓ−1 − rℓ qℓ+1 = rℓ−1 − qℓ+1 (rℓ−2 − rℓ−1 qℓ ) = rℓ−1 (1 + qℓ+1 qℓ ) − qℓ+1 rℓ−2 = · · · .
1.4. INTEGERS
21 CHAPTER 1. BASIC SET THEORY
21
5. Euclid’s algorithm can sometimes be applied to check whether two numbers which are
func- tions of an unknown integer n, are relatively prime or not? For example, we can
use the
algorithm to prove that gcd(2n + 3, 5n + 7) = 1 for every n ∈ Z.
6. [Informative] Suppose a milkman has only 3 cans of sizes 7, 9 and 16 liters. If the
milkman has 16 litres of milk then using the 3 cans, specified as above, what is the
minimum number of operations required to deliver 1 liter of milk to a customer?
Explain.
We are now ready to prove an important result that helps us in proving the
fundamental theorem of arithmetic.
Lemma 1.4.8. [Euclid’s lemma] Let p be a prime and let a, b ∈ Z. If p | ab then either p | a
or p | b.
Proof. If p | a, we are done. So, assume that p ∤ a. As p is a prime, gcd(p, a) = 1. Thus, we can
find integers x, y such that 1 = ax + py. As p | ab, we have
Now, we are ready to prove the fundamental theorem of arithmetic that states that ‘every
positive integer greater than 1 is either a prime or is a product of primes. This product
is unique, except for the order in which the prime factors appear’.
Proof. We prove the result using the strong form of the principle of mathematical
induction. The result is clearly true for n = 2. So, let the result be true for all m, 2 ≤ m ≤ n −
1. If n is a prime, then we have nothing to prove. Else, n has a prime divisor p. Then, apply
induction on
n
p to get the required result.
Proof. On the contrary assume that the number of primes is finite, say p1 = 2, p2 = 3, . . . , pk
. Now, consider the positive integer N = p1 p2 · · · pk + 1. Then, we see that none of the
primes p1 , p2 , . . . , pk divides N which contradicts Theorem 1.4.10. Thus, the result follows.
1 1 1
Example 1.4.12. Prove that for all n ≥ 2, the number 1 + + + · · · + is not an integer.
2 3 n
1 1 1
Proof. Suppose there exists n ≥ 2 such that 1 + + + · · · + = N , for some positive
2 3 n
1
integer N . Now, let r be the largest positive integer such that 2 ≤ n. Then, N − r =
r
2
1 1 1 1
1+ +· · · r + r +··· . Also, let K = lcm(2, 3, . . . , 2r− 1, 2r + 1, . . . , n). Then,
+ 2 2 −1 2 +1 n
+
note that 2r does not divide K as r was the largest positive integer such that 2r ≤ n. Also, we
see that
N · 2r − 1 M
r
=
2 K
for some positive integer M . Or equivalently, 2 M = K (N · 2r − 1). Thus, we arrive at
r
a contradiction that 2r divides the left-hand-side whereas it does not divide the right-hand-
side.
Proposition 1.4.13. [Primality testing] Let n ∈ N with n ≥ 2. Suppose that for every prime
√
p ≤ n, p does not divide n, then n is prime.
√ √
Proof. Suppose n = xy, for 2 ≤ x, y < n. Then, either x ≤ n or y ≤ n. Without loss of
√
generality, assume x ≤ n. If x is a prime, we are done. Else, take a prime divisor of x to get
a contradiction.
Exercise 1.4.14. [Informative] Prove that there are infinitely many primes of the form 4n − 1.
1.4. INTEGERS
24 CHAPTER 1. BASIC SET THEORY
24
Definition 1.4.15. [Least common multiple] Let a, b ∈ Z. Then, the least common mul-
tiple of a and b, denoted lcm(a, b), is the smallest positive integer that is a multiple of both
a
and b.
1.4. INTEGERS
25 CHAPTER 1. BASIC SET THEORY
25
Theorem 1.4.16. Let a, b ∈ N. Then, gcd(a, b) · lcm(a, b) = ab. Thus, lcm(a, b) = ab if and
only if gcd(a, b) = 1.
Proof. Let d = gcd(a, b). Then, d = as + bt, for some s, t ∈ Z, a = a1 d, b = b2 d, for some
a1 , b1 ∈ N. We need to show that lcm(a, b) = a1 b1 d = ab1 = a1 b, which is clearly a multiple
of both a and b. Let c ∈ N be any common multiple of a and b. To show, a1 b1 d divides c.
Note
that
c cd c(as + c c
= = bt) s+ t∈Z
a1 b1 d (a1 d) · (b1 d) =b a
ab
c c
as , ∈ Z and s, t ∈ Z. Thus, a1 b1 d = lcm(a, b) divides c and hence lcm(a, b) is indeed the
a b
smallest. Thus, the required result follows.
Exercise 1.4.17. 1. If gcd(b, c) = 1, then gcd(a, bc) = gcd(a, b) · gcd(a, c).
2. If gcd(a, b) = d, then gcd(an , bn ) = dn for all n ∈ N.
Definition 1.4.18. [Modular Arithmetic] Fix a positive integer n. Then, ‘an integer a is said
to be congruent to an integer b modulo n’, denoted a ≡ b (mod n), if n divides a − b.
Example 1.4.19. 1. The numbers ±10 and 22 are equivalent modulo 4 as 4 | 12 = 22 − 10
and 4 | 32 = 22 − (−10).
2. Let n ∈ N be a perfect square. That is, there exists an integer m such that n = m2 . Then,
n ≡ 0, 1 (mod 4) as any integer m ≡ 0, ±1, 2 (mod 4) and hence m2 ≡ 0, 1 (mod 4).
3. Let S = {15, 115, 215, . . . }. Then, S doesn’t contain any perfect square as for each s ∈ S,
s ≡ 3 (mod 4).
4. It can be easily verified that any two even (odd) integers are equivalent modulo 2 as
2 | 2(l − m) = 2l − 2m (2 | 2(l − m) = ((2l + 1) − (2m + 1))).
5. Let n be a fixed positive integer and let S = {0, 1, 2, . . . , n − 1}.
(a) Then, by division algorithm, for any a ∈ Z there exists a unique b ∈ S such that b ≡ a
(mod n). The number a (mod n) (in short, b) is called the residue of a modulo n.
S
n−1
(b) Thus, the set of integers, Z = {a + kn : k ∈ Z}. That is, every integer is congruent
a=0
to an element of S. The set S is taken as the standard representative for the set
of residue classes modulo n.
Theorem 1.4.20. Let n be a positive integer. Then, the following results hold.
1. Let a ≡ b (mod n) and b ≡ c (mod n), for some a, b, c ∈ Z. Then, a ≡ c (mod n).
2. Let a ≡ b (mod n), for some a, b ∈ Z. Then, a + c ≡ b + c (mod n), a − c ≡ b − c (mod
n)
and ac ≡ bc (mod n), for all c ∈ Z.
3. Let a ≡ b (mod n) and c ≡ d (mod n), for some a, b, c, d ∈ Z. Then, a ± c ≡ b ± d (mod
n)
≡
and ac bd (mod n). In particular, a m
≡ bm (mod n), for all m ∈ N.
4. Let ac ≡ bc (mod n), for some non-zero a, b, c ∈ Z. Then, a ≡ b (mod n), whenever
n
1.4. INTEGERS
26 CHAPTER 1. BASIC SET THEORY
26
Proof. We will only prove two parts. The readers should supply the proof of other parts.
Part 3: Note that ac − bd ≡ ac − bc + bc − bd ≡ c(a − b) + b(c − d). Thus, n | ac − bd,
whenever
n | a − b and n | c − d.
In particular, taking c = a and d = b and repeatedly applying the above result, one has
a ≡ bm (mod n), for all m ∈ N.
m
Proof. Note that if p|n, then obviously, np ≡ n (mod p). So, let us assume that gcd(p, n) = 1.
−1
Then, we need to show that np ≡ 1 (mod p).
To do this, we consider the set S = {n (mod p), 2n (mod p), . . . , (p − 1)n (mod p)}.
Since, gcd(p, n) = 1, by second and fourth parts of Theorem 1.4.20, an ≡ bn (mod p) if and
only if a ≡ b (mod p). Thus, S ≡ {1, 2, . . . , p − 1}. Hence,
−
np 1 (p − 1)! = n · 2n · · · · · (p − 1)n ≡ 1 · 2 · · · · · (p −
1).
−1
Thus, the condition gcd((p − 1)!, p) = 1 implies that np ≡ 1 (mod p).
Before coming to the next result, we look at the following examples.
Example 1.4.22. 1. As gcd(251, 13) = 1, we see that 25112 ≡ 1 (mod 13). Hence, 25112
leaves the remainder 1, when divided by 13.
2. As 255 ≡ 2 (mod 23), gcd(255, 23) = 1. Hence,
25527 ≡ (25522 ) · (2555 ) (mod 23) ≡ 25 (mod 23) ≡ 32 (mod 2)3 ≡ 9 (mod 2)3.
3. Note that 3 · 9 + 13 · (−2) ≡ 1 (mod 13). So, the system 9x ≡ 4 (mod 13) has the solution
x ≡ x · 1 ≡ x · (3 · 9 + 13 · (−2)) ≡ 3 · 9x ≡ 3 · 4 ≡ 12 (mod
13).
4. Verify that 9 · (−5) + 23 · (2) = 1. Hence, the system 9x ≡ 1 (mod 23) has the solution
5. The system 3x ≡ 15 (mod 30) has solutions x = 5, 15, 25, whereas the system 7x = 15
has only the solution x = 15. Also, verify that the system 3x ≡ 5 (mod 30) has no
solution.
Theorem 1.4.23. [Linear Congruence] Let n be a positive integer and let a and b be non-zero
integers. Then, the system ax ≡ b (mod n) has at least one solution if and only if gcd(a, n) | b.
Moreover, if d = gcd(a, n) then ax ≡ b (mod n) has exactly d solutions in {0, 1, 2, . . . , n − 1}.
1.4. INTEGERS
29 CHAPTER 1. BASIC SET THEORY
29
Proof. Let x0 be a solution of ax ≡ b (mod n). Then, by definition, ax0 − b = nq, for some
q ∈ Z. Thus, b = ax0 − nq. But, gcd(a, n) | a, n and hence gcd(a, n) | ax0 − nq = b.
Suppose d = gcd(a, n) | b. Then, b = b1 d, for some b1 ∈ Z. Also, by Euclidean algorithm,
there exists x0 , y0 ∈ Z such that ax0 + ny0 = d. Hence,
a(x0 b1 ) ≡ b1 (ax0 ) ≡ b1 (ax0 + ny0 ) ≡ b1 d ≡ b (mod
n).
This completes the proof of the first part.
To proceed further, assume that x1 , x2 are two solutions. Then, ax1 ≡ ax2 (mod n) and
n n
hence, by Theorem 1.4.20.4, x1 ≡ x2 (mod ). Thus, we can find x2 ∈ {0, 1, . . . , } such that
d d
n
x = x2 + k is a solution of ax ≡ b (mod n), for 0 ≤ k ≤ d − 1. Verify that these x’s are distinct
d
and lie between 0 and n − 1. Hence, the required result follows.
Exercise 1.4.24. 1. Prove Theorem 1.4.20.
2. Prove that the numbers 19, 119, 219, . . . cannot be perfect squares.
3. Prove that the numbers 10, 110, 210, . . . cannot be perfect squares.
4. Prove that the system 3x ≡ 4 (mod 28) is equivalent to the system x ≡ 20 (mod 28).
5. Determine the solutions of the system 3x ≡ 5 (mod 65).
6. Determine the solutions of the system 15x ≡ 295 (mod 100).
7. Prove that the pair of systems 3x ≡ 4 (mod 28) and 4x ≡ 2 (mod 27) is equivalent to
the pair x ≡ 20 (mod 28) and x ≡ 14 (mod 27). Hence, prove that the above system is
equivalent to solving either 20 + 28k ≡ 14 (mod 27) or 14 + 27k ≡ 20 (mod 28) for the
unknown quantity k. Thus, verify that k = 21 is the solution for the first case and k = 22
for the other. Hence, x = 20 + 28 · 21 = 608 = 14 + 22 · 27 is a solution of the above
pair.
p p!
8. Let p be a prime. Then, prove that p | k = , for 1 ≤ k ≤ p − 1.
k!(p − k)!
9. [Informative] Let p be a prime. Then, the set
(a) Zp = {0, 1, 2, . . . , p − 1} has the following
properties:
i. for every a, b ∈ Zp , a + b (mod p) ∈ Zp .
ii. for every a, b ∈ Zp , a + b = b + a (mod p).
iii. for every a, b, c ∈ Zp , a + (b + c) ≡ (a + b) + c (mod p).
iv. for every a ∈ Zp , a + 0 ≡ a (mod p).
v. for every a ∈ Zp , a + (p − a) ≡ 0 (mod p).
∗
p Z = {1, 2, . . . , p − 1} has the following
(b)
properties:
∗
i. for every a, b ∈ Zp , a · b (mod p) ∈ Zp .
∗
ii. for every a, b ∈ Zp , a · b = b · a (mod p).
∗
iii. for every a, b, c ∈ Zp , a · (b · c) ≡ (a · b) · c (mod p).
∗
iv. for every a ∈ Zp , a · 1 ≡ a (mod p).
∗
v. for every a ∈ Zp , a · b ≡ 1 (mod p). To see this, note that gcd(a, p) = 1. Hence,
1.4. INTEGERS
30 CHAPTER 1. BASIC SET THEORY
30
In algebra, any set, say F, in which ‘addition’ and ‘multiplication’ can be defined
in such a way that the above properties are satisfied then F is called a field. So,
Zp = {0, 1, 2, . . . , p − 1} is an example of a field. In general, the well known examples
of fields are:
i. Q, the set of rational numbers.
ii. R, the set of real numbers.
iii. C, the set of complex numbers.
(c) From now on let p be an odd prime.
i. Then, the equation x2 ≡ 1 (mod p) has exactly two solutions, namely x = 1 and
∗
x = p − 1 in Z . This is true as p is a prime dividing x2 − 1 = (x − 1)(x + 1)
p ∗
implies that either p|x − 1 or p|x + 1. Also, 0 is the only number in Z that is
p
divisible by p.
∗
ii. Then, for a ∈ {2, 3, . . . , p − 2}, we can find a number b ∈ {2, 3, . . . , p − 2} ⊆pZ
with a · b ≡ 1 (mod p) and b = a.
−
iii. Thus, for 1 ≤ i ≤ p 2 1 , we have pairs {ai , bi } that are pairwise disjoint and satisfy
p−1
S
2
ai · bi ≡ 1 (mod p). Moreover, {ai , bi } = {2, 3, . . . , p − 2}.
i=1
iv. Hence, 2 · 3 · · · · · (p − 2) ≡ 1 (mod p).
v. We thus have the following famous theorem called the Wilson’s Theorem: Let
p be a prime. Then, (p − 1)! ≡ −1 (mod p).
Proof. Note that from the previous step, we have
Theorem 1.4.25. [Chinese remainder theorem] Fix a positive integer m and let n1 , n, . . . , nm
be pairwise co-prime positive integers. Then, the linear system
x ≡ a1 (mod n1 )
x ≡ a2 (mod n2 )
.
x ≡ am (mod nm )
Example 1.4.26. 1. Let us come back to Exercise 1.4.24.7. In this case, note that a1 =
20, a2 = 14, n1 = 28 and n2 = 27. So, M = 28 · 27 = 756, M1 = 27 and M2 = 28. As,
27 · (−1) + 28 · 1 = 1, we see that x1 = −1 and x2 = 1. Thus,
But, −148 ≡ 608 (mod 756) and hence x0 = 608 is the required answer.
2. Let x be a number which when divided by 8, 15 and 17 gives remainders 5, 6 and
8, respectively. Then, what will be the remainder when x is divided by 2040?
Ans: Note that the question reduces to finding x ∈ N such that
Give reasons for your answer. What if we replace 6 or 4 with an odd number?
4. [Informative] Let n be a positive integer. Then, the set
1.4. INTEGERS
33 CHAPTER 1. BASIC SET THEORY
33
(
(c) Fix a positive integer m and for all n ∈ N, consider the function δm (n) = 1 if n = m
0 otherwise.
(d) Recall that a number n ∈ N is called squarefree, if for any prime p, p divides n but
p2 doesn’t divide n. Consider the function µ : N → C, defined by
0 if n is not squarefree,
µ(n) = 1 if n is squarefree and has even number of prime factors,
−1 if n is squarefree and has odd number of prime factors,
This function is commonly known as the Mo¨bius function. For example, µ(1) =
1, µ(2) = −1, σ(3) = −1, µ(4) = 0, . . . , µ(10) = 1, . . ..
(e) Consider the function ϕ : N → C, defined by ϕ(n) = |{k : 1 ≤ k ≤ n, gcd(k, n) =
1}|, for all n ∈ N. This function is popularly known as the totient /phi /Euler phi
function
and it counts the number of positive integers less than or equal to n that are co-
prime to n. For example, ϕ(1) = 1, ϕ(2) = 1, ϕ(3) = 2, ϕ(4) = 2, . . . , ϕ(10) = 4, . .
..
i. Let m, n ∈ N with gcd(m, n) = 1. Then, use Exercise 1.4.6.1b to prove that
ϕ(mn) = ϕ(m) · ϕ(n). So, the function ϕ is a multiplicative function. Hence,
we need to only determine ϕ(pn ) for every prime p and n ∈ N.
−
ii. Show that if p is a prime and n ∈ N then ϕ(pn ) = pn 1 (p − 1) = pn 1 − 1p .
iii. [Euler’s Theorem] Let n ∈ N and let a ∈ Z such that gcd(a, n) = 1. Then,
aϕ(n) ≡ 1 (mod n).A generalization of Fermat’s little theorem.
(f ) Consider the function π : N → C, defined by π(n) = |{k : 1 ≤ k ≤ n, k is a prime}|,
for all n ∈ N. This function counts the number of primes less than or equal to n. For
example, π(1) = 0, π(2) = 1, π(3) = 2, π(4) = 2, . . . , π(10) = 4, . . ..
P
(g) Consider the function d : N → C, defined by d(n) = 1, for all n ∈ N. This
function
r|n
counts the number of positive divisors of n. For example, d(1) = 1, d(2) = 2, d(3) =
2, d(4) = 3, . . . , d(10) = 4, . . ..
P
(h) Consider the function σ : N → C, defined by σ(n) = d, for all n ∈ N. This
function
d|n
gives the sum of the positive divisors of n. For example, σ(1) = 1, σ(2) = 3, σ(3) =
4, σ(4) = 7, . . . , σ(10) = 18, . . ..
(i) Fix a positive integer k and consider the function σk : N → C, defined by σk (n) =
P k
d , for all n ∈ N. This function gives the sum of the k-th powers of the
positive d|n
divisors of n. For example, σk (1) = 1, σk (2) = 1 + 2k , σ(3) = 1 + 3k , . . . , σ(10) =
1 + 2k + 5k + 10k , . . .. Also, note that σ0 (n) = d(n) and σ1 (n) = σ(n), for all n ∈ N.
1.4. INTEGERS
36 CHAPTER 1. BASIC SET THEORY
36
(j) Let f be an arithmetic function. Then, we define a function D from the set of
P
arithmetic functions to itself, called the divisor sum function, by (Df )(n) = f
(d).
d|n
30 CHAPTER 1. BASIC SET THEORY
Chapter 2
Definition 2.1.2. Let {Bα }α∈S be a nonempty class of sets. We define their
1. union as ∪ Bα = {x | x ∈ Bα , for some α}, and
α∈S
2. intersection as ∩ Bα = {x | x ∈ Bα , for all α}.
α∈S
3. Convention: Union of an empty class is ∅. The intersection of an empty class of
subsets of X is X 1 .
Example 2.1.3. 1. Take A = [3], A1 = {1, 2}, A o2 = {2, 3} and A3 = {4, 5}. Then, {Aα |
n 1 2 3
α ∈ A} = {A , A , A } ={1, 2}, {2, 3}, {4, 5} . Thus, Aα = [5] and ∩ Aα = ∅.
∪ α∈A α∈A
We now give a set of important rules whose proofs are left for the reader.
Theorem 2.1.4. [Algebra of union and intersection] Let {Aα }α∈L be a nonempty class
of subsets of X and B be any set. Then, the following statements are true.
1. B ∩ ∪ Aα = ∪ (B ∩ Aα ).
α∈ L α∈ L
2. B ∪ ∩ Aα = α∩
∈L
(B ∪ Aα ).
α∈ L
3. ∪ c
= ∩ Acα .
α∈L Aα α∈ L
1
The way we see this convention is as follows: First we agree that the intersection of an empty class of subsets
is a subset of X . Now, let x ∈ X such that x 6∈ ∩ Bα . This implies that there exists an α ∈ S such that x 6∈ Bα .
α∈S
Since S is empty, such an α does not exist.
2.2. MORE ON RELATIONS
32 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
32
4. ∩ c
= ∪ Acα .
α∈L Aα α∈ L
Proof. We give the proofs for Part 1 and 4. For Part 1, we see that
x∈B∩ ∪ Aα ⇔ x ∈ B and x ∈ ∪ Aα ⇔ x ∈ B and x ∈ Aα , for some α ∈ L
α∈ L α L
∈
⇔ x ∈ B ∩ Aα , for some α ∈ L ⇔ x ∈ ∪ (B ∩ Aα ).
α∈ L
x∈ ∩ Aα
c
⇔ x 6∈ Aα ⇔ x 6∈ Aα , for some α ∈ L ⇔ x ∈ Ac , for some α ∈
α∈ L
∩
α∈ L
L Ac . α
⇔ x∈ ∪∈ α
α L
Proof. Part 1:
y∈f ∪ A ⇔ (x, y) ∈ f, for some x ∈ ∪ Aα ⇔ (x, y) ∈ f with x ∈ Aα , for some α ∈ L
α∈ L α ∈ α L
Remark 2.2.2. It is important to note the following in the proof of the above
theorem:
‘y ∈ f (Aα ), for all α ∈ L’ implies that ‘for each α ∈ L, we can find some xα ∈ Aα such that
(xα , y) ∈ f ’. That is, the xα ’s need not be the same. This gives you an idea to construct
a counterexample.
Define f : {1, 2, 3, 4} → {a, b} by f = {(1, a), (2, a), (2, b), (3, b), (4, b)}. Take A1 = {1, 3}
and A2 = {1, 2, 4} and verify that the inclusion in Part 2 of Theorem 2.2.1 is strict. Also,
find the xi ’s for b.
It is a relation. The composition f ◦ g is defined similarly. In case, both f and g are functions
then (f ◦ g)(x) = f (g(x)).
Example 2.2.4. Take f = {(β, a), (3, b), (3, c)} and g = {(b, β), (c, β)}. Then, g ◦ f = {(3,
β)}
and f ◦ g = {(b, a), (c,
a)}.
are: (a) R = A × A.
(b) R = {(a, a), (b, b), (c, c), (d, d), (a, b), (a, c), (b, c)}.
(c) R = {(a, a), (b, b), (c, c)}.
2.2. MORE ON RELATIONS
35 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
35
(d) R = {(a, a), (a, b), (b, a), (b, b), (c, d)}.
(e) R = {(a, a), (a, b), (b, a), (a, c), (c, a), (c, c), (b,
4. Consider the set R2 . Also, let us write x = (x1 , x2 ) and y = (y1 , y2 ). Then, some of
the relations on R2 are as follows:
i. R = {(x, y) ∈ S × S | x1 = y1 , x2 =
−y2 }. ii. R = {(x, y) ∈ S × S | x = −y}.
5. Let A be the set of triangles in the plane. Then, R = {(a, b) ∈ A2 | a ≈ b}, where ≈
stands for similarity of triangles.
7. Let A be any nonempty set and consider the set P (A). Then, one can define a relation R
on P (A) by R = {(S, T ) ∈ P (A) × P (A) | S ⊆ T }.
2.2. MORE ON RELATIONS
36 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
36
5 5 5
3 4 3 4 3 4
1 2 1 2 1 2
I f g
Proposition 2.2.11. [Equivalence relation divides a set into disjoint classes] Let f be
an equivalence relation on X . Then, the following statements are true.
1. (a, b) ∈ f if and only if Ea = Eb .
2. (a, b) ∈/ f if and only if Ea ∩ Eb = ∅.
3. Furthermore, X = ∈∪ Ea .
a X
Example 2.2.12. Let f be an equivalence relation on [5] whose equivalence classes are {1,
2},
{3, 5} and {4}. Then, f must be I ∪ {(1, 2), (2, 1), (3, 5), (5,
3)}.
2.2. MORE ON RELATIONS
37 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
37
Exercise 2.2.14. 1. Let X and Y be two nonempty sets and f : X → Y be a relation. Let
Ix and Iy be the identity relations on X and Y , respectively. Then,
−1
(a) is it necessary that f ◦ f ⊆ Ix ?
−1
(b) is it necessary that f ◦ f ⊇ Ix ?
−1
(c) is it necessary that f ◦ f ⊆ Iy
−1
? (d) is it necessary that f ◦ f ⊇
Iy ?
3. Write down the equivalence classes for the equivalence relations that appear in
Exam- ples 2.2.7 and 2.2.8.
4. Take A = ∅. Is A × A an equivalence relation on A? If yes, what are the
equivalence classes?
5. On a nonempty set A, what is the smallest equivalence relation (in the sense that every
other equivalence relation will contain this equivalence relation; recall that a relation is
a set)?
3. Some books use the word ‘map’ in place of ‘function’. So, both the words are used
inter- changeably throughout the notes.
Example 2.3.2. 1. Let A = {a, b, c}, B = {1, 2, 3} and C = {3, 4}. Then, verify that
the examples given below are indeed functions.
Exercise 2.3.3. Do the following relations represent functions? Give reasons for your answer.
1. Let f : Z → Z be defined by
Definition 2.3.6. Fix a set A and let IdA : A → A be defined by IdA (a) = a, for all a ∈
A. Then, the function eA is called the identity function or map on A.
2.3. MORE ON FUNCTIONS
39 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
39
The subscript A in Definition 2.3.6 will be removed, whenever there is no chance of confusion
about the domain of the function.
2. the map f ◦ Id = f .
3. the map Id ◦ g = g.
Proof. Part 1: Let Id = IdA . Then, by definition, Id(a) = a, for all a ∈ A and hence it is
clear that Id is one-one and onto.
Part 2: By definition, (f ◦ Id)(a) = f (Id(a)) = f (a), for all a ∈ A. Hence, f ◦ Id = f .
Part 3: The readers are advised to supply the proof.
Proof. Let g ◦ f (i) = i, for each i ∈ A. Then, the assumption f (i) = f (j) implies that
i = g ◦ f (i) = g ◦ f (j) = j. Thus, f is one-one and the proof of the first part is over.
For the second part, let f ◦ g(j) = j, for each j ∈ B. To see that f is onto, let b ∈ B and put
a = g(b) ∈ A. Then, by the given assumption, f (a) = f (g(b)) = b.
Lemma 2.3.10. [Cantor] Let S be a set and f : S → P (S) be a function. Then, there
exists
A ∈ P (S) which does not have a pre-image. That is, there is no surjection from S to P
(S).
2. Are the following relations single valued functions, one-one, onto, and/or
bijections? (a) f : R → R defined by f = {(x, sin x) | x ∈ R}.
(b) f = {(x, y) | x2 + y 2 = 1, x, y ∈ R} from dom(f ) to rng(f )
(c) f = {(x, y) | x2 + y 2 = 1, x ≥ 0, y ≥ 0} from dom(f ) to rng(f )
(d) f : R → R defined by f = {(x, tan x) | −2π < x <2π }.
Experiment 1:
Make a horizontal list of the elements of N using ‘· · · ’ only once. Now, horizontally
list the elements of Z just below the list of N using ‘· · · ’ once. Draw vertical lines to
supply a bijection from N to Z. Can you supply another by changing the second list a
little bit?
Experiment 1:
a+b
Suppose that you have an open interval (a, b). Its center is c = 2 and the distance of the
center from one end is l b−a
2 = 2 . View this as a line segment on the real line. Stretch (a, b)
2.3. MORE ON FUNCTIONS
41 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
41
uniformly without disturbing the center and make its length equal to L.
Where is c now (in R)? Where is c − 2l ? Where is c + 2l ? Where is c − α × 2l , for a fixed
α ∈ (−1, 1)?
Now, use the above idea to find a bijection from (a, b) to (s, t)? [Hint: Fix the center first.]
2.4. SUPPLYING BIJECTIONS
41 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
41
Exercise 2.4.1. 1. Supply two bijections from (1, ∞) to (5, ∞), one by ‘scaling’ and the
other by ‘translating’.
2. Take reciprocal to supply a bijection from (0, 1) to (1, ∞). You can also use the
exponential function to get this.
3. Supply a bijection from (−1, 1) to (−∞, ∞).
4. Supply a bijection from (0, 1) × (0, 1) to R × R.
Theorem 2.4.2. Let A be a set containing the set {a1 , a2 , . . . , } and let f : A → B be a
bijection. Then, prove that, for any collection
1. {c1 , . . . , ck } of elements that are outside A, the function
f (x) if x ∈ A \ {a1 , a2 , . . .}
h(x) = (a ) if x =i a ∈
f i+k ,i N
f (ai ) if x = ci , i = 1, 2, . . . , k.
B. Proof. Exercise.
1 1
2 2
3 3
4 4
5 5
6 6
7 7
.
.
We want to create a bijection h from X to Y by erasing some of these lines.
1. Thus, h(1) must be 3. So, the dotted line (3, 4) cannot be used for h.
2. So, h(4) must be 6. So, the dotted line (6, 7) cannot be used for h.
3. So, h(7) must be 9. Continue two more steps to realize what is happening.
(
f (x), if x = 3n − 2, n ∈ N
So, the bijection h : X → Y is given by h(x) = −1
g (x), otherwise.
Exercise 2.4.4. Take X = Y = N. Supply bijections using the given injections f : X → Y and
g:Y → X.
1. f (x) = x + 1 and g(x) = x + 2.
2. f (x) = x + 1 and g(x) = x + 3.
3. f (x) = x + 1 and g(x) = 2x.
2.4. SUPPLYING BIJECTIONS
44 CHAPTER 2. ADVANCED TOPICS IN SET THEORY
44
Proof. If g is onto, we have nothing to prove. So, assume that g is not onto. Put O = A \ g(B),
φ = g ◦ f and E = O ∪ φ(O) ∪ φ2 (O) ∪ · · · . Use φ0 (O) to denote O. Notice that
∞ ∞
g f (E) = φ(E) = φ ∪ φn (O) = ∪ φn (O) = E \ O,
n=0 n=1
as g does not map to O. Hence, g maps f (E) to E \ O bijectively. Recall that O is the set of
points in A that are not mapped by g, O ⊆ E and g has already (mapped f (E) onto E \ O.
g −1 (x) if x ∈ E c ,
Hence, g must map f (E)c to E c bijectively. So, the function h(x) = is a
f (x) if x ∈ E,
bijection from A to B.
Alternate. If g is onto, we have nothing to prove. So, assume that g is not onto. Put
O = A \ g(B), φ = g ◦ f and E = O ∪ φ(O) ∪ φ2 (O) ∪ · · · . Use φ (O) to denote O. Notice that
0
∞ ∞
φ(E) = g f (E) = φ(E) = φ ∪ φn (O) = ∪ φn (O) = E \ O,
n=0 n=1
g
g(f (T )c ) f (T )
c
T f f (T )
g f (U )c = g f ∪ c
∪ f (T )
c
∩ f (T )
c
= ∩
c
g (f (T ) ) ⊆ ∩ T c = U c.
T ∈F T =g
T ∈F
=g
T ∈F T ∈F T ∈F
1
Recall that every real number has a unique nonterminating decimal representation.
Chapter 3
3.1 Countable-Uncountable
Definition 3.1.1. A set which is either finite or equivalent to N is called a countable set. A
set which is not countable is an uncountable set.
Definition 3.1.2. Let A be a countably infinite set. Then, by definition, there is a bijection
f : N → A. So, we can list all the elements of A as f (1), f (2), . . .. This list is called an
enumeration of the elements of A.
Example 3.1.3. 1. We know that Z is a countably infinite set.
2. The set N \ [99] is a countably infinite set.
3. The set P (N) is uncountable by Cantor’s lemma.
4. Let S be the set of all 0-1-sequences x = x1 , x2 , . . .. Define f : S → P (N) as f (x) = {n |
xn = 1}. Then f is a bijection. Hence, S is uncountable by Cantor’s lemma.
5. Let T = {x ∈ (0, 1) | x has a decimal expansion containing the digits 0 and 1 only}. Then
T is uncountable.
Proof. One proof follows by the previous idea.
Theorem 3.1.4. A set A is infinite if and only if it has a countably infinite subset.
Proof. If B is finite then by definition, it is countable. So, assume that B is infinite. Hence, by
Theorem 3.1.4, B has a countable infinite subset, say C = {c1 , c2 , . . .}. Thus, f : A → C ⊆
B, defined by f (ai ) = ci , i = 1, 2, . . . is a one-one map. On the other hand, I dB : B → A
is a one-one map. Hence, by Schro¨der-Bernstein theorem, B and A are equivalent.
As a corollary, we have the following result.
Proof. As S is infinite, there is a one-one map, say f : N → S. Now, define a map g : P (N) →
P (S) as g(A) = f (A). Then, g is clearly one-one and hence g P (N) is uncountable (by
Cantor’s
lemma). Hence, P (S), being a superset is uncountable, by Corollary 3.1.6.
Theorem 3.1.8. Countable union of countable sets (union of a countable class of countable
sets) is countable.
Proof. Let {Ai }i∈N be a countable class of countable sets and put X = ∪ Ai . If X is
finite then we are done. So, let X be infinite. Hence, by Fact 1.2.23.12, therei is a one-one
map f : N → X . Define g : X → N as g(x) = 2i 3k , if i is the smallest positive integer for
which x ∈ Ai and x appears at the k-th position in the enumeration of Ai . Then g is one-one.
Now,
by Schro¨der-Bernstein theorem A is equivalent to
N.
Theorem 3.1.9. The set P (N) is equivalent to [0, 1). Furthermore, P (N) is equivalent to R.
Proof. We already know a one-one map f : P (N) → [0, 1) (see Examples 3.1.3.4 and
3.1.3.5). Let r ∈ (0, 1). Consider the nonterminating binary representation of r. Denote by Fr
the set of
positions of 1 in this representation. Now, define g : [0, 1) → P (N) by g(r) = Fr , if r = 0
and
g(0) = ∅. Then g is one-one. Now, by Schro¨der-Bernstein theorem P (N) is equivalent to [0,
1).
The next statement follows as [0, 1) is equivalent to (0, 1) (see Exercise 2.4.6.5) and (0, 1)
is equivalent to R.
ℵ0
4. The cardinal numbers ℵ0 = N, 2 = R, 22ℵ0 , . . . are called the infinite cardinal num-
bers.
5. The ‘generalized continuum hypothesis’ says that there is no cardinal number between
an infinite cardinal number x and 2x .
Example 3.1.12. 1. Let A be the set of all infinite sequences formed using 0, 1 and B
be the set of all infinite sequences formed using 0, 1, 2. Which one has larger cardinality
and why?
3. Let S be a countable set of points on the unit circle in R2 . Consider the line segments
Ls with one end at the origin and the other end at a point s ∈ S. Fix these lines.
We are allowed to rotate the circle anticlockwise (the lines do not move). Let T be
another countable set of points on the unit circle. Can we rotate the circle by an angle
θ so that no line Ls touches any of the points of T ?
Ans: Let θij be the angle of rotation required so that point pi touches line lj . The set of
all θij is countable and the set [0, 2π) is uncountable.
3. [Linear ordered set] The tuple (X, f ) is said to be a linearly ordered set if f is a linear
order on X . You may imagine the elements of a linearly ordered set as points on a line.
4. [Chain] A linearly ordered subset of a poset is called a chain. The maximum size of a
chain is called the height of a poset.
2. The poset in Example 3.2.2.1b has height 2 (resp. chain is {1, 2}) and width 4 (resp.
anti-chain is {2, 3, 4, 5} or {1, 3, 4, 5}).
3. The poset in Example 3.2.2.1d has height 2 (resp. chain is {1, 2} or {3, 4}) and width
3 (resp. anti-chain is {1, 3, 5}). Find other anti-chains?
4. The set N with the usual order is a linearly ordered set.
5. If (X, f ) is a nonempty linearly ordered set, then the height of X is X and the width of
X is 1.
6. The set N with a ≤ b if a divides b, is not linearly ordered. However, the set {1, 2, 4, 8,
16} is a chain. This is just a completely ordered subset of the poset. There are larger
chains, for example, {2k | k = 0, 1, 2, . . .}. It has height N and width N .
7. The poset (P ([5]), ⊆) is not linearly ordered. However, {∅, [2], [5]} is a chain in it. So, is
{∅, {2}, [2], [3], [4], [5]}. Its height is 6. What is its width?
Definition 3.2.6. Let (Σ, ≤) be a nonempty finite linearly ordered set (like the English al-
∗
phabets with a ≤ b ≤ c ≤ · · · ≤ z) and Σ be the set of all words of elements of Σ.
∗
For a ≡ a1 a2 · · · an , b ≡ b1 b2 · · · bm ∈ Σ define a ≤ b if
(a) a1 < b1 or
(c) ai = bi for i = 1, . . . , n.
∗
Then (Σ , ≤) is a linearly ordered set. This ordering is called the lexicographic or dictionary
ordering. Sometimes Σ is called the ‘alphabet set’ and Σ∗ is called the ‘dictionary’.
Exercise 3.2.7. Let D1 be the dictionary of words made from a, b, c and D2 be the
dictionary of words made from a, b, d. Are these two sets equivalent?
18
2 3
1
Definition 3.2.9. [Hasse diagram] The Hasse diagram of a nonempty finite poset (X, ≤) is
a picture drawn in the following way.
1. Each element of X is represented by a point and is labeled with the element.
2. If a ≤ b then the point representing a must appear at a lower height than the
point representing b and further the two points are joined by a line.
Later, we shall show that for every nonempty finite poset (X, ≤) a Hasse diagram can
be drawn.
Example 3.2.10. Hasse diagram for A = {1, 2, 3, 9, 18} with the ‘divides’ relation.
18
2 3
Exercise 3.2.11. Draw the Hasse diagram for [3] × [4] under lexicographic order.
Proposition 3.2.12. Let F be a nonempty family of single valued relations such that either
f ⊆ g or g ⊆ f , that is, F is linearly ordered. Let h = ∈F
∪ f . Then the following are true.
f
1. h is single valued.
2. dom(h) = ∈F ∪ dom(f ).
f
∪ rng(f ).
3. rng(h) = ∈F
f
4. If every element of F is one-one (from its domain to its range) then h is also one-one.
1. Let x ∈ dom(h) and (x, y), (x, z) ∈ h. Then there are f, g ∈ F , such that (x, y) ∈ f and
(x, z) ∈ g. As F is a chain, either f ⊆ g or g ⊆ f , say f ⊆ g. Then, g is not single
valued, a contradiction.
2. Note that x ∈ dom(h) means (x, y) ∈ h for some y. This means (x, y) ∈ f for some f .
That is, x ∈ dom(f ), for a function f . This means x ∈ ∪ dom(f ).
f ∈F
Definition 3.2.13. 1. [Bounds] Let (X, f ) be a poset and A ⊆ X . We say x ∈ X is
an upper bound if for each z ∈ A, (z, x) ∈ f . In words, it means ‘each element of A is
≤ x’. The term lower bound is defined analogously.
Example 3.2.14. Consider the two posets described by the following picture.
b c b c
a a
(X) (Y)
1. Consider the poset in Figure 3.1 and let X = A = {a, b, c}. Then
(a) the maximal elements of A are b and c,
(b) the only minimal element of A is a,
(c) a is the lower bound of A in X ,
(d) A has no upper bound in X ,
(e) A has no maximum element,
(f ) a is the minimum element of A,
(g) no element of X is the lub of A and
(h) a is the glb of A in X .
3.2.
52 PARTIAL
CHAPTERORDERS
3. COUNTABILITY, CARDINAL NUMBERS* AND PARTIAL ORDER
52
2. Consider the posets in Figures 3.1. Then, the definitions are illustrated in the following
table. Note that X = {a, b, c} and Y = {a, b, c, d}.
A = {b, c} ⊆ X A = {a, c} ⊆ X A = {b, c} ⊆
Maximal element(s) of A b, c c Y
Minimal element(s) of A b, c a b,
b, cc
Lower bound(s) of A in X/Y a a a
Upper bound(s) of A in X/Y doesn’t exist c d
Maximum element of A doesn’t exist c doesn’t exist
Minimum element of A doesn’t exist a doesn’t exist
lub of A in X/Y doesn’t exist c d
glb of A in X/Y a a a
Exercise 3.2.15. Determine the maximal elements, minimal elements, lower bounds, upper
bounds, maximum, minimum, lub and glb of A in the following posets (X, f ).
1. Take X = Z with usual order and A = Z.
2. Take X = N, f = {(i, i) : i ∈ N} and A = {4, 5, 6, 7}.
Discussion 3.2.16. [Bounds of empty set] Let (X, f ) be a nonempty poset. Then each x ∈
X
is an upper bound for ∅ as well as a lower bound for ∅. So, an lub for ∅ may or may not exist.
For example, if X = [3] and f is the usual order, then lub ∅ = 1. Whereas, if X = Z and f is
the usual order, then an lub for ∅ does not exist. Similar statements hold for glb.
Definition 3.2.17. A linear order f on X is said to be a well order if each nonempty subset
A of X has a minimal element (in A). We call (X, f ) a well ordered set to mean that f is a
well order on X . Note that ‘a minimal element’, if it exists, is ‘a minimum’ in this case.
Example 3.2.18.
1. The set Z with usual ordering is not well ordered, as {−1, −2, . . . , } is a nonempty
subset with no minimal element.
2. The ordering 0 ≤ 1 ≤ −1 ≤ 2 ≤ −2 ≤ 3 ≤ −3 ≤ · · · describes a well order on Z.
3. The set N with the usual ordering is well ordered.
4. The set R with the usual ordering is not well ordered as the set (0, 1) doesn’t have its
minimal element in (0, 1).
Exercise 3.2.19. Consider the dictionary order on N2 . Show that this is a well order.
Definition 3.2.20. Let (W, ≤) be well ordered and a ∈ W . The initial segment of a
is defined as I (a) := {x | x ∈ W, x < a}.
Example 3.2.21. Take N with the usual order. Then I (5) = [4] and I (1) =
∅.
Proof. To see this, let p(n) be a statement which needs to be proved by mathematical induction.
Put A = {n ∈ N | p(n) is true}. Assume that we have been able to show that ‘I (n) ⊆ A ⇒ n
∈ A’. It means, we have shown that 1 ∈ A, as ∅ = I (1) ⊆ A. Also we have shown that for n
≥ 2,
if {p(1), . . . , p(n − 1)} are true then p(n) is true as well, as I (n) = [n −
1].
Moreover, if A1 and A2 are finite sets then |A1 × A2 | = |A1 | · |A2 |. In general, we define
the
product of the sets in {Aα }α∈L , L = ∅,
as Y
Aα = f | f : L → ∪
α∈L Aα is a function with f (α) ∈ Aα , for each α ∈ L .
α∈ L
Q
Example 3.2.25. 1. Take L = N and An = {0, 1}. Then Aα is the class of functions
α∈ L
f : L → {0, 1}. That is, it is the class of all 0-1-sequences.
2. By definition, product of a class of sets among which one of them is ∅ is empty.
What about product of a class of sets in which no one is empty? Is it nonempty? This could
not be proved using the standard set theory. In fact, it is now proved that this question
cannot be answered using the standard set theory. So, a new axiom, called the axiom of
choice, was introduced.
Axiom 3.2.26. [Axiom of Choice] The product of a nonempty class of nonempty sets is
nonempty.
Proof. Let g : A → B be onto. We shall find an injection from B to A. To start with, notice
− Q −1 Q
that for each b ∈ B, the set g 1 (b) = ∅. Then, by axiom of choice g (b) = ∅. Let f ∈
−
g 1 (b).
b∈B b∈B
−1
Then, by Definition 3.2.24, f : B → A is a function. As g is a function, g (b)’s are disjoint and
hence f is one-one.
3.2.
54 PARTIAL
CHAPTERORDERS
3. COUNTABILITY, CARDINAL NUMBERS* AND PARTIAL ORDER
54
Exercise 3.2.31. 1. Does there exist a poset with exactly 5 maximal chains of size
(number of elements in it) 2, 3, 4, 5, 6, respectively and 2 maximal elements? If yes, draw
the Hasse diagram. If no, argue it.
2. Let (X, f ) be a nonempty poset and ∅ = Y ⊆ X . Define fY = {(a, b) ∈ f | a, b ∈ Y }.
Show that fY is a partial order on Y . This is the induced partial order on Y .
3. Apply induction to show that a nonempty finite poset has a maximal element and a minimal
element.
Discussion 3.2.32. [Drawing the Hasse diagram of a finite poset (X, f )] Let x1 , . . . , xk be
the minimal elements of X . Draw k points on the same horizontal line and label them x1 , . . .
, xk . Now consider Y = X \ {x1 , . . . , xk } and fY . By induction, the picture of (Y, fY ) can be
drawn. Put it above those k dots. Let y1 , . . . , ym be the minimal elements of Y . Now, draw
the lines (xi , yj ) if (xi , yj ) ∈ f . This is the Hasse diagram of (X, f ).
1
When we ask for more than one example, we encourage the reader to get examples of different types,
if possible.
3.2.
55 PARTIAL
CHAPTERORDERS
3. COUNTABILITY, CARDINAL NUMBERS* AND PARTIAL ORDER
55
Discussion 3.2.33. [Existence of Hamel basis] Let V be a vector space with at least
two
elements. Recall that the collection F of linearly independent subsets of V is a family of finite
character. Recall that a basis or a Hamel basis is a maximal linearly independent subset of V.
As V has at least 2 elements, it has a nonzero element, say a. Then {a} ∈ F . Hence, F =
∅.
Thus, by Tukey’s lemma, the set F has a maximal element. This maximal set is the
required basis. Hence, we have proved that every vector space with at least 2 elements has a
Hamel basis.
Exercise 3.2.34. 1. Let n ∈ N. Define Pn = {k ∈ N | k divides n}. Define a relation ≤n
on Pn as ≤n = {(a, b) | a divides b}. Show that (Pn , ≤n ) is a poset, for each n ∈ N. Give
a necessary and sufficient condition on n so that (Pn , ≤n ) is a completely ordered
set.
n o n o
2. Take X = (1, 1), (1, 2), (1, 3), . . . ∪ (2, 1)(3, 1), (4, 1), . . . . The ordering defined
is
n o[ n o
f = ∪ (1, m), (1, n) ∪ (m, 1), (n, 1) .
m, n ∈ N m, n ∈ N
m ≤n m ≤n
(m) A nonempty finite poset in which each nonempty finite set has a minimum, must be
well ordered.
(n) An infinite poset in which each nonempty finite set has a minimum, must be
well ordered.
4. Let S = {(x, y) : x2 + y 2 = 1, x ≥ 0}. It is a relation from R → R. Draw a picture of
the inverse of this relation.
5. Construct the Hasse diagram for the ⊆ relation on P ({a, b, c}).
6. Draw the Hasse diagram for the partial order describing the ‘divides’ relations on the set
{2, 3, 4, 5, 6, 7, 8}.
7. Draw the Hasse diagram of {1, 2, 3, 6, 9, 18} with ‘divides’
relation. (a) What is its height? What is its width.
(b) Let A = {2, 3, 6}. What are the maximal elements, minimal elements, maximum,
minimum, lower bounds, upper bounds, glb and lub of A.
9. Let (X, f ) be a nonempty poset. Show that there exists a linear order g on X such that
f ⊆ g.
10. Let G be a non-Abelian group and H be an Abelian subgroup of G. Show that there is
a maximal Abelian subgroup J of G such that H ⊆ J .
11. Let F be a family of finite character and B be a chain in F . Show that ∪ ∈F.
A∈B A
12. Let A = ∅ and F be a field. Let F := {f : f is a function from A to F}. Let Γ := {f ∈
A
21. Suppose that u ≤ v are two infinite cardinal numbers. Then show that u + v = v and
uv = v.
3.2.
58 PARTIAL
CHAPTERORDERS
3. COUNTABILITY, CARDINAL NUMBERS* AND PARTIAL ORDER
58
Chapter 4
Introduction to Logic
We study logic to differentiate between valid and invalid arguments. An argument is a set
of statements which has two parts: premise and conclusion. There can be many statements in
the premise. Conclusion is just one statement. An argument has the structure
premise: Statement1 , . . ., Statementk ; therefore conclusion: Statementc
. Consider the following examples.
We understand that the first one is a valid argument, whereas the next three are not. In order
to differentiate between valid and invalid argument, we need to analyze an argument. And
in order to do that, we first have to understand ‘what is a statement’. A simple statement is
an expression which is either false or true but not both. We create complex statements from
the old ones by using ‘and’, ‘or’ and ‘not’.
For example, ‘today is Monday’ is a statement. ‘Today is Tuesday’ is also a statement.
‘Today is Monday and today is Tuesday’ is also a statement. ‘Today is not Monday’ is also a
statement.
4.1. PROPOSITIONAL LOGIC
60 CHAPTER 4. INTRODUCTION TO LOGIC
60
One way to analyze an argument is by writing it using symbols. The following definition
captures the notion of a ‘statement’.
Definition 4.1.1. 1. [Atomic formulae and truth values] Consider a nonempty finite set
of symbols F . We shall call an element of F as an atomic formula (also called
atomic variable). (These are our simple statements). The truth value of each
element in F is exactly one of T (for TRUE) and F (for FALSE). Normally, we use
symbols p, q, p1 , p2 , . . . for atomic formulae.
2. [Operations to create new formulae] We use three symbols ‘∨’ (called disjunction/or),
‘∧’ (called conjunction/and), and ‘¬’ (called negation) to create new formulae.
The way they are used and the way we attribute the truth value to such a new
formula is described below.
If p and q are formulae, then p ∧ q, p ∨ q, and ¬p are formulae. The truth value of p ∧ q is
defined to be T when the truth values of both p and q are T . Its truth value is defined to be F
in all other cases. The truth value of p ∨ q is defined to be T when the truth values of at least
one of p and q are T . Its truth value is defined to be F when the truth values of both p and
q are F . The truth value of ¬p is defined to be T if the truth value of p is F . The truth value
of
¬p is defined to be F if the truth value of p is T .
Understanding ∨, ∧ and ¬
The following tables describe how we attribute the truth values to p ∨ q, p ∧ q and ¬p.
p q p∧q p q p∨q
T T T T T T p ¬p
T F F T F T T F
F T F F T T F T
F F F F F F
How do we read these tables? Look at row 3 of the leftmost table (exclude the header). It
tells that the formula p ∧ q takes the truth value F if p takes truth value F and q takes T
.
Remark 4.1.2. We use brackets while creating new formulae to make the meaning
unambiguous. For example, the expression p ∨ q ∧ r is ambiguous, where as p ∨ (q ∧ r) is
unambiguous.
Definition 4.1.3. 1. Sometimes we write ‘f (p1 , . . . , pk ) is a formula’ to mean that ‘f is
a formula involving the atomic formulae p1 , . . . , pk ’.
2. Let f (p1 , . . . , pk ) be a formula. Then, the truth value of f is determined based on the
truth values of the atomic formulae p1 , . . . , pk . Since, there are 2 assignments for each pi ,
1 ≤ i ≤ k, there are 2k ways of assigning truth values to these atomic formulae. An
4.1. PROPOSITIONAL LOGIC
61 CHAPTER 4. INTRODUCTION TO LOGIC
61
assignment of truth values to these atomic formulae is nothing but a function A : {p1 , . .
. , pk } → {T , F }.
3. By saying ‘T F T is an assignment to the atomic variables p, q, r’, we mean that the
truth value of p is T , that of q is F and that of r is T . Keeping this in mind, all
possible
4.1. PROPOSITIONAL LOGIC
62 CHAPTER 4. INTRODUCTION TO LOGIC
62
assignments to p, q, r are listed below. (Notice that, it is in the dictionary order, that
is,
‘F F F appears before F F T in the list as if they are words in a dictionary’. The reader
will notice that in the table given above, we have followed the reverse dictionary order
while writing a truth table, which is natural to us. This should not create any
confusion.)
p q r
F F F
F F T
F T F
F T T
T F F
T F T
T T F
T T T
4. A truth table for a formula f (p1 , . . . , pk ) is a table which systematically lists the
truth values of f under every possible assignment of truth values to the involved atomic
formulae. The following is a truth table for the formulae p ∨ (q ∧ r).
p q r q ∧ r p ∨ (q ∧ r)
F F F F F
F F T F F
F T F F F
F T T T T
T F F F T
T F T F T
T T F F T
T T T T T
5. In the previous table, if we fill the fourth column arbitrarily using T ’s and F ’s, will it be
a truth table of some formula involving p, q and r? We shall talk about it later.
We have already noted that we use ∨, ∧ and ¬ to create new formulae from old ones. Some
of them will indeed be very important.
p q (¬p) ∨ q
T T T
T F F
F T T
F F T
4.1. PROPOSITIONAL LOGIC
64 CHAPTER 4. INTRODUCTION TO LOGIC
64
Observe
a) p → q takes the truth value F if and only if p takes the truth value T and q takes
the truth value F .
b) If under some assignment ‘p → q takes the truth value T ’ and that ‘in this assignment
p is T ’, then it follows that in this assignment q must be T . This is why p → q is called
‘if p then q’.
c) Other phrases used for ‘if p then q’ are ‘p is sufficient for q’ or ‘p only if q’ or ‘q is a
necessary condition for p’.
d) We sometimes use p ← q to mean q → p.
2. [p if and only if q] The formula (p ↔ q) (called ‘p if and only if q’) means (p → q)∧(q → p).
Note that (p ↔ q) takes the truth value ‘T whenever p and q take the same truth values’
and takes the truth value ‘F whenever p and q take different truth values’. Its truth
table is
p q p↔ q
T T T
T F F
F T F
F F T
The formula p → q is false if ‘p is true and q is false’, which means ‘you attend the class and do
not understand the subject’.
Example 4.1.7. 1. p ∧ ∨q, ∨q, p ∨ q∧ are not wff, as they do not make sense.
Example 4.1.9. The table on the left describes a truth function f and that on the right
describes the truth table for a particular formula.
p q f p q (p ∧ q) ∨ (p ∧ (¬q))
T T F T T T
T F T T F T
F T T F T F
F F F F F F
2. Can both the formulae p → q and q → p be false for some assignment on p and q?
Example 4.1.12. 1. Is p → q ≡ ¬q → ¬p? Yes, because they have the same truth tables.
p q f = p → q g = ¬q → ¬p
4.1. PROPOSITIONAL LOGIC
66 CHAPTER 4. INTRODUCTION TO LOGIC
66
T T T T
T F F F
F T T T
F F T T
4.1. PROPOSITIONAL LOGIC
67 CHAPTER 4. INTRODUCTION TO LOGIC
67
p q f = p g = p ∧ (q ∨ (¬q))
T T T T
T F T T
F T F F
F F F F
Remark 4.1.13. 1. There is another way to establish equivalence of two formulae f and
g.
We show that f has a truth value T (or F ) if and only if g has the same truth value.
For example, to show that p → q ≡ ¬q → ¬p, proceed in the following way.
Step 1: Suppose that p → q has a truth value F for an assignment a. Then a(p) = T and
a(q) = F . But then, under that assignment, we have ¬q is T and ¬p is F . That is, under
a, we have ¬q → ¬p is F .
Step 2: Suppose that p → q has a truth value T for an assignment a. Then a ∈
{T T , F T , F F }. Under T T , we have ¬p is F and ¬q is F , so that ¬q → ¬p is T .
Under
F T , we have ¬p is T and ¬q is F , so that ¬q → ¬p is T . Under F F , we have ¬p is T
and
¬q is T , so that ¬q → ¬p is T
. Thus, both are equivalent.
2. Let f (p1 , . . . , pk ) be a formula and q1 , . . . , qr be some new atomic variables. Then f
≡ f ∧ (q1 ∨ (¬q1 )) ∧ · · · ∧ (qr ∨ (¬qr )). This can be argued using induction. Thus f
can be viewed as a formula involving atomic variables p1 , . . . , pk , q1 , . . . , qr .
3. We have seen that
(a) p → q ≡ ¬p ∨ q, and
(b) p ↔ q ≡ (p → q) ∧ (q → p).
Thus, the connectives ∨, ∧ and ¬ are enough for writing a formula in place of the 5
connectives ∨, ∧, ¬, → and ↔.
4. Recall that a formula on variables p, q and r is a truth function. So there are exactly
223 = 28 nonequivalent formulae on variables p, q and
r.
(p → ¬q) → p → (p → ¬q)
4.1. PROPOSITIONAL LOGIC
69 CHAPTER 4. INTRODUCTION TO LOGIC
69
The following result is one of the most fundamental results of the subject.
The proof of the next result is left as an exercise for the readers.
3. p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r), p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) (distributive)
4. ¬(p ∨ q) ≡ ¬p ∧ ¬q, ¬(p ∧ q) ≡ ¬p ∨ ¬q (De Morgan’s law)
5. p ∨ p ≡ p, p ∧ p ≡ p (idempotence)
4.1. PROPOSITIONAL LOGIC
66 CHAPTER 4. INTRODUCTION TO LOGIC
66
6. F ∨ p ≡ p, F ∧ p ≡ F
7. T ∨ p ≡ T, T ∧ p ≡ p
8. ¬(¬p) ≡ p
9. p ∨ (p ∧ q) ≡ p, p ∧ (p ∨ q) ≡ p (absorption law)
Proof. First six may be proved suing direct arguments and the rest by using the first six.
Exercise 4.1.23. Does the absorption law imply p ∨ (p ∧ (¬q)) ≡ p and p ∧ (p ∨ (¬q)) ≡ p?
Discussion 4.1.24. The above rules can be used to simplify a formula or to show equivalence
of formulae. For example,
p → (q → r) ≡ ¬p ∨ (¬q ∨ r) as p → p ≡ (¬p) ∨ q
≡ ¬p ∨ ¬q ∨ r Associativity
≡ ¬(p ∧ q) ∨ r De Morgan’s law
≡ (p ∧ q) → r as p → p ≡ (¬p) ∨ q
Experiment
Consider the variables p, q, r.
Give a formula which takes value T only on the assignment T T T .
Give a formula which takes value T only on the assignment T T F . (p ∧ q ∧
(¬r)) Give a formula which takes value T only on the assignment F T F .
Give a formula which takes value T only on the assignments T T F and F T F .
Give a formula which takes value T only on the assignments T F T , T T F and T F F .
Give a formula f which takes value T only on the assignments F T F and F F F or
whose truth table is the following
p q r f
T T T F
T T F F
T F T F
T F F F
F T T F
F T F T
F F T F
F F F T
Lemma 4.1.25. Let f be a truth function involving the variables p1 , . . . , pk . Then, there is
a formula g involving p1 , . . . , pk , whose truth table is described by f .
p q f
T T T
T F T
F T F
F F F
Definition 4.1.27. [Normal forms] An atomic formula or it’s negation is called a literal. We
say that a formula f is in disjunctive normal form (in short, DNF) if it is expressed as a
4.1. PROPOSITIONAL LOGIC
68 CHAPTER 4. INTRODUCTION TO LOGIC
68
Example 4.1.28. p, p ∨ q, p ∨ ¬q, (p ∧ ¬q) ∨ ¬r, (p ∧ ¬q) ∨ (q ∧ ¬r) ∨ (r ∧ s) are in DNF. Write
5 formulae in CNF involving p, q, r.
Theorem 4.1.29. Any formula is equivalent to a formulae in DNF. Similarly, Any formula is
equivalent to a formulae in CNF.
Proof. The proof of the first assertion follows from Lemma 4.1.25. For the second assertion,
we can write one proof in a similar way.
An alternate proof: take f , consider ¬f , get a DNF P for ¬f , and consider ¬P .
Exercise 4.1.30. Write all the truth functions on two variables and write formulae for them.
Exercise 4.1.32. Use induction on the number of connectives to show that any formula is
equivalent to a formulae in DNF and a formula in CNF.
∗
Definition 4.1.33. [Dual] The dual P of a formula P involving the connectives ∨, ∧, ¬
is obtained by interchanging ∨ with ∧ and the special variable T with the special variable F.
Lemma 4.1.35. Let A(p1 , . . . , pk ) be a formula in the atomic variables pi involving connectives
∨, ∧ and ¬. If A(¬p1 , . . . , ¬pk ) is obtained by replacing pi with ¬pi in A, then A(¬p1 , . . . , ¬pk ) ≡
∗
¬A (p1 , . . . , pk ).
The remaining parts are similar and hence left for the reader.
∗ ∗
Theorem 4.1.36. Let f, g be formulae using connectives ∨, ∧ and ¬. If f ≡ g, then f ≡ g .
∗ ∗
Thus, f ≡ g .
4.1. PROPOSITIONAL LOGIC
71 CHAPTER 4. INTRODUCTION TO LOGIC
71
∨ ∧
¬
r q p
Definition 4.1.38. [Polish notation] A formula may be expressed using Polish notation.
It is defined inductively as follows.
This notation does not use brackets. Here the connectives are written in front of the expressions
they connect. Advantage: it takes less space for storage. Disadvantage: it’s complicated look.
Exercise 4.1.40. Write a formula involving 8 connectives and the variables p, q, r. Draw
it’s tree. Write it’s Polish notation.
Definition 4.1.41. 1. [Satisfiable] A formula is satisfiable if it is not a contradiction.
2. [Order of operations] To reduce the use of brackets, we fix the order of operations: ¬,
∧, ∨, →, ↔.
Discussion 4.1.42. There is another way of making a truth table for a formula. Consider
(p ∨ q) ∨ ¬r. Draw a table like the following and give the truth values to the atomic formulae.
Evaluate the connectives for the subformulae one by one. In this example, the sequence of
column operations is: 5, 2, 4.
(p ∨ q) ∨ ¬ r (p ∨ q) ∨ ¬ r
T T T T T T T F T
T T F T T T T T F
T F T T T F T F T
T F F T T F T T F
F T T F T T T F T
F T F F T T T T F
F F T F F F F F T
F F F F F F T T F
Definition 4.1.43. [Inference] We say g is a logical conclusion of {f1 , · · · , fn } if (f1
∧ f2 ∧ · · · ∧ fn ) → g is a tautology. We denote this by {f1 , . . . , fn } ⇒ g. At times, we
write f1 , . . . , fn ⇒ g to mean {f1 , . . . , fn } ⇒ g. Here, g is called the conclusion and {f1 , . .
. , fn } is called the hypothesis/premise.
4.1. PROPOSITIONAL LOGIC
70 CHAPTER 4. INTRODUCTION TO LOGIC
70
Alternate. Suppose that conclusion is F . This means that ¬m → (¬f ∨ p) takes the
The first one implies that ¬f ∨ p takes the value F and ¬m takes the value T . Hence,
we see that the variables m, f and p take values F, T and F , respectively.
The second one implies that all the three expressions (q ∧ a) → m, f → q, and ¬p → a
take the value T . Since the second statement takes the value T and f has the value T
, we see that q has to take the value T . Similarly, using the third statement, we see that
a has to take the value T . So, we see that the first statement (q ∧ a) → m takes the
value T with the assignment of both q and a being T . So, we must have m to have the
value T , contradicting the value F taken by m in the previous paragraph.
Exercise 4.1.47. 1. List all the nonequivalent formulae involving variables p and q which
take truth value T on exactly half of the assignments.
2. We assume F ≤ T . Let f and g be two truth functions on the variables p1 , . . . , p9 .
Suppose that for each assignment a, we have f (a) ≤ g(a). Does this imply ‘f → g is a
tautology’ ?
4.1. PROPOSITIONAL LOGIC
73 CHAPTER 4. INTRODUCTION TO LOGIC
73
(a) p → (r ∨ s) ∧ (q ∧ r) → s .
4.1. PROPOSITIONAL LOGIC
74 CHAPTER 4. INTRODUCTION TO LOGIC
74
(b) (p ∨ r) ∨ (s → p) ∧ p → (s → r) .
(c) q → s.
(d) s → (q ∨ r) ∧ (q ∧ s) → r .
(e) (p ∨ s) ∨ (q → p) ∧ p → (q → s) .
6. Let p be a formula written only using connectives ∧, ∨ and → and involving the atomic
variables p1 , · · · , pk , for some k. Show that the truth value of p is T under the
assignment f (pi ) = T , for all i.
7. Is {→, ∨, ∧} adequate?
8. Verify the following assertions.
(a) P ∧ Q ⇒ P
(b) P ⇒ P ∨ Q
(c) ¬P ⇒ P → Q
(d) ¬(P → Q) ⇒ P
(e) ¬P, P ∨ Q ⇒ Q
(f ) P, P → Q ⇒ Q
(g) ¬Q, P → Q ⇒ ¬P
(h) P → Q, Q → R ⇒ P → R
(i) P ∨ Q, P → R, Q → R ⇒ R
(j) P ↔ Q ⇔ (P ∧ Q) ∨ (¬P ∧ ¬Q)
(k) {p ∧ q, p ∨ q} ⇒ q → r
(l) {p → q, ¬p} ⇒ ¬q
(m) {p0 → p1 , p1 → p2 , . . . , p9 → p10 } ⇒ p0 ∨ p5 .
12. Consider the set S of all nonequivalent formulae written using two atomic variables p and
q. For f, g ∈ S, define f ≤ g if f ⇒ g. Prove that this is a partial order on S. Draw
it’s Hasse diagram.
13. Consider the set S of all nonequivalent formulae written using three atomic variables p, q, r.
For f, g ∈ S define f ≤ g if f ⇒ g. Let f1 and g1 be two formulae having the truth tables
p q r f1 p q r g1
T T T T T T T T
T T F F T T F F
T F T T T F T T
T F F T T F F F
F T T F F T T T
F T F T F T F F
F F T F F F T T
F F F F F F F F
14. How many assignments of truth values to p, q, r and w are there for which (p → q) →
Example 4.2.2. Let p(x) mean ‘x > 0’. Then p(x) is a 1-place predicate on some UD.
Let
p(x, y) mean ‘x2 + y 2 = 1’. Then p(x, y) is a 2-place predicate on some UD.
Definition 4.2.3. [Quantifiers] We call the symbols ∀ and ∃, the quantifiers. Formulae
involving them are called quantified formulae. The statement ∀x p(x) is true if for each x
(in the UD) the property p(x) is T . The statement ∃x p(x) is T if p(x) is T for some x in the
UD.
Example 4.2.4. Let UD be the set of all human beings. Consider the 2-place predicate F (x, y):
‘x runs faster than y’. Then
1. ∀x ∀y F (x, y) means ‘each human being runs faster than every human being’.
4.2. PREDICATE LOGIC
74 CHAPTER 4. INTRODUCTION TO LOGIC
74
2. ∀x ∃y F (x, y) means ‘for each human being there is a human being who runs slower’.
3. ∃x ∃y F (x, y) means ‘there is a human being who runs faster than some human being’.
4. ∃x ∀y F (x, y) means ‘there is a human being who runs faster than every human being ’.
4.2. PREDICATE LOGIC
75 CHAPTER 4. INTRODUCTION TO LOGIC
75
Example 4.2.6. In ∃x p(x, y) the occurrence of y is free and both the occurrences of x are
bound. In ∀y ∃x p(x, y) all the occurrences of x and y are bound.
Definition 4.2.7. 1. A quantified formulae is well formed if it is created using the following
rules.
(a) Any atomic formula (of the form P , P (x, y), P (x, b, y)) is a
wff.
(b) If A and B are wffs, then A ∨ B, A ∧ B, A → B, A ↔ B, and ¬A are wffs.
(c) If A is a wff and x is any variable, then ∀x A and ∃x A are wffs.
2. Let f be a formula. An interpretation (for f ) means the process of specifying the UD,
specifications of the predicates, and assigning values to the free variables from the UD. By
an interpretation of f , we mean the formula f under a given interpretation.
Discussion 4.2.9. [Translation] We expect to see that ‘our developments on logic’ help
us in drawing appropriate conclusions. In order to do that, we must know how to translate
an
‘English statement’ into a ‘formal logical statement’ that involves no English words. We
may have to introduce appropriate variables and required predicates. We may have to
specify the UD, but normally we use the most general UD.
Example 4.2.10. 1. Translate: ‘each person in this class room is either a BTech student
or an MSc student’.
No. All it says is, if there is a person, then it has certain properties. Let P (x) mean ‘x is
a person in this class room’; B(x) mean ‘x is a BTech student’; and M (x) mean ‘x is an
2. Translate: ‘there is a student in this class room who speaks Hindi or English’.
4.2. PREDICATE LOGIC
77 CHAPTER 4. INTRODUCTION TO LOGIC
77
Note that ∃x S(x) → (H (x) ∨ E(x)) is not the correct expression. Why?
Remember
∃x (S(x) → T (x)) never asserts S(x) BUT ∃x(S(x) ∧ T (x)) asserts both S(x) and T (x).
Definition 4.2.12. A quantified formula is called valid if every interpretation of it has truth
value T . Two quantified formulae A and B are called equivalent (A ≡ B) if A ↔ B is valid.
Example 4.2.13. 1. ∀x P (x) ∨ ∃x ¬P (x) is valid.
2. Is ∃x ∃y p(x, y) ≡ ∃y ∃x p(x, y)?
A: Yes. Denote ∃x ∃y p(x, y) by L and ∃y ∃x p(x, y) by R. Suppose that L → R is F .
This means, we have an interpretation in which L is T and R is F . As R is F , we see
that p(x, y) is F , for each x, y in the UD. In that case, L is F , a contradiction. So, L →
R is T . Similarly, R → L is T .
4.2. PREDICATE LOGIC
78 CHAPTER 4. INTRODUCTION TO LOGIC
78
is valid. Suppose that this is invalid. So there is an interpretation such that Right hand
side is F and Left hand side is T. As Right hand side is F, we see that ∃x, say x0 ,
for which ∃y r(x) → r(y) ∧ p(x, y) is F. That is, ∀y the formula r(x0 ) → r(y) ∧ p(x0 ,
y) is F. That is, r(x0 ) is T and for each y we see that r(y) ∧ p(x0 , y) is F. That is, r(x0 )
is T and ∃y(r(y) ∧ p(x0 , y)) is F. That is, the formula r(x0 ) → ∃y(r(y) ∧ p(x0 , y)) is F.
That is,
∀x r(x) → ∃y r(y) ∧ p(x, y) is F, a contradiction. The other part is an exercise.
Then notice that r(x0 ) → ∃y r(y) ∧ p(x0 , y) and ∃y r(x0 ) → r(y) ∧ p(x0 , y) have the
same truth value.
Thus A ≡ B. Hence ∀xA ≡ ∀xB.
6. Any student who appears in the exam and gets a score below 30, gets an F grade. Mr x0
is a student who has not written the exam. Therefore, x0 should get an F grade. Do you
agree?
A: Let S(x) mean ‘x is a student’, E(x) mean ‘x writes the exam’, B(x) mean ‘x gets
a score below 30’, and F (x) mean ‘x gets F grade’.
n o
We want to see whether ∀x[S(x) ∧ E(x) ∧ B(x) → F (x)], S(x0 ) ∧ ¬E(x0 ) ⇒ F (x0 )?
Take the following
a√rational interpretation:
number’, B(x) S(x) is ‘x
is ‘x is an integer’, is aispositive
F (x) real number’,
‘x is a natural number’,E(x)
and isx0‘x= is
2.
4.2. PREDICATE LOGIC
79 CHAPTER 4. INTRODUCTION TO LOGIC
79
In this interpretation, statements in the premise mean ‘every positive integer is a natural
√
number’ and ‘ 2 is a positive real number which is not rational’. They both are true.
√
Whereas the conclusion means ‘ 2 is a natural number’ which is false. So, the argument
is incorrect.
4.2. PREDICATE LOGIC
80 CHAPTER 4. INTRODUCTION TO LOGIC
80
5. (a) Give an interpretation to show that ∀x r(x) → ∃y r(y) ∧ p(x, y) is not valid.
4.2. PREDICATE LOGIC
82 CHAPTER 4. INTRODUCTION TO LOGIC
82
¬q(x) .
6. Write a formal statement taking UD:= all students in all IIT’s in India, for the following.
‘For each student in IITG there is a student in IITG with more CPI.’
7. Let UD= R, p(x): x is an integer, and q(x): x is a rational number. Translate
the following statements into English.
(a) ∀x p(x) → q(x)
(b) ∃x ¬p(x) ∧ q(x)
8. Take the most general UD. Check whether the following conclusion is valid or not.
Each student writes the exam using blue ink or black ink. A student who writes the exam
using black ink and does not write his/her roll number gets an F grade. A student who
writes the exam using blue ink and does not have his/her ID card gets an F grade.
A student who has his/her ID card has written the exam with black ink. Therefore, a
student who passes the exam must have written his roll number.
Ans: Let S(x) : x is a student, B(x) : x writes the exam using blue ink, Bl(x) : x writes
the exam using black ink, R(x) : x writes his/her roll number, I (x) : x has his/her
ID card, F (x) : x gets an F grade. We have to determine, whether the following
conclusion is valid. (Continue.)
Chapter 5
5.1 Lattices
1. A poset (L, ≤) is called a lattice if each pair x, y ∈ L has a lub denoted ‘x ∨ y’ and a glb
denoted ‘x ∧ y’.
Example 5.1.3. 1. Let L = {0, 1} ⊆ Z and define a ∨ b = max{a, b} and a ∧ b = min{a, b}.
Then, L is a chain as well as a distributive lattice.
5.1. LATTICES
80 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
80
2. The set N with usual order and ∨ := max and ∧ := min is a distributive lattice. We
consider two cases to verify that a ∨ (b ∧ c) = (a ∨ b) ∧ (a ∨ c). The second
distributive identity is left as an exercise for the reader.
(b) Case 2: a < min{b, c}. Then, a < b and a < c. Hence,
4 6 6 10 15 4 6 9
2 3 2 3 5 2 3
1 1 1
Exercise 5.1.4. 1. Fix a prime p and a positive integer n. Draw the Hasse diagram of
n
D(p ). Does this correspond to a chain? Give reasons for your answer.
2. Let n be a positive integer. Then, prove that D(n) is a chain if and only if n = pm ,
for some prime p and a positive integer m.
3. Let (X, f ) be a nonempty chain with ∨ := lub and ∧ := glb. Is it a distributive lattice?
(a) The operations ∨ and ∧ are idempotent, i.e., ‘lub{a, a} = a and glb{a, a} =
a’. (b) ∨ commutative (so is ∧).
(c) ∨ is associative (so is ∧).
5.1. LATTICES
82 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
82
′
(d) a ∧ (a ∨ b) = a = a ∨ (a ∧ b) [absorption] , i.e., ‘ glb{a, lub{a, b}} = a = lub{a, glb{a, b}} .
(e) a ≤ b ⇔ a ∨ b = b ⇔ a ∧ b = a.
(f ) b ≤ c ⇒ {a ∨ b ≤ a ∨ c, a ∧ b ≤ a ∧ c} [isotonicity]
. (f1) {a ≤ b, c ≤ d} ⇒ {a ∨ c ≤ b ∨ d, a ∧ c ≤ b ∧ d}.
Proof. We prove only a few parts. The rest are left for the reader.
(c) Let d = a ∨ (b ∨ c). Then, d is the lub of {a, b ∨ c}. Thus, d is an upper bound of both
{a, b} and {a, c}. So, d ≥ a ∨ b and d ≥ a ∨ c. Therefore, d ≥ a ∨ b and d ≥ c and hence
d an upper bound of {a ∨ b, c}. So, d is greater or equals to the lub of {a ∨ b, c},
i.e., d ≥ (a ∨ b) ∨ c. Thus, the first part of the result follows.
(e) Let a ≤ b. As b is an upper bound of {a, b}, we have a ∨ b = lub{a, b} ≤ b. Also, a ∨ b is
an upper bound of {a, b} and hence a ∨ b ≥ b. So, we get a ∨ b = b. Conversely, let a ∨ b
= b. As a ∨ b is an upper bound of {a, b}, we have a ≤ a ∨ b = b. Thus, the first part
of the result follows.
(f ) Let b ≤ c. Note that a ∨ c ≥ a and a ∨ c ≥ c ≥ b. So, a ∨ c is an upper bound for {a, b}.
Thus, a ∨ c ≥ lub{a, b} = a ∨ b and hence the prove of the first part is
over.
(f1) Using isotonicity, we have a ∨ c ≤ b ∨ c ≤ b ∨ d. Similarly, using isotonicity again, we have
a ∧ c ≤ b ∧ c ≤ b ∧ d.
Practice 5.1.6. Show that in a lattice one distributive equality implies the other.
Definition 5.1.7. If (Li , ≤i ), i = 1, 2 are lattices with ∨ := lub and ∧ := glb. Then, (L1 × L2 ,
≤) is a poset with a = (a1 , a2 ) ≤ (b1 , b2 ) = b if a1 ≤1 b1 and a2 ≤2 b2 , that is, if b
dominates a entrywise. In this case, we see that a ∨ b = (a1 ∨1 b1 , a2 ∨2 b2 ) and a ∧ b = (a1
∧1 b1 , a2 ∧2 b2 ). Thus (L1 × L2 , ≤) is a lattice, called the direct product of (Li , ≤i ), for i =
1, 2.
Example 5.1.8. 1. Consider L = {0, 1} with usual order. The set of all binary strings Ln
of length n is a poset with the order (a1 , . . . , an ) ≤ (b1 , . . . , bn ) if ai ≤ bi , ∀i. This is
the n-fold direct product of L. It is called the lattice of n-tuples of 0 and 1.
5.1. LATTICES
83 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
83
2. Consider the lattices [3] and [4] with usual orders. Hasse diagram of the direct product
[3] × [4] is given below.
5.1. LATTICES
84 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
84
(3, 4)
(1, 4)
(3, 1)
(1, 1)
Practice 5.1.9. Consider N with the usual order. The lattice order defined on N2 as a
direct
product is different from the lexicographic order on N2 . Draw pictures for all (a, b) ≤ (5, 6)
in
both the orders to see the
argument.
lattice. Proof. The direct product of two lattices is a lattice by definition. Note that
Thus, the map f must have one of the following forms. Draw pictures to understand this.
5.1. LATTICES
85 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
85
−1
(a) f (0) = N.
−1 −1
(b) f (0) = [k] and f (1) = {k + 1, . . .}.
−1 −1 −1
(c) f (0) = [k], f (1) = [r] \ [k] and f (2) = N \ [r + k].
5.1. LATTICES
86 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
86
(1, 0, 1)
(1, 1, 0) (0, 1, 1) 6 10 15 {a, b} {a, c} {b, c}
(0, 0, 0) 1 ∅
7. Fix n ∈ N and let p1 , p2 , . . . , pn be n distinct primes. Prove that the lattice D(N ), for
N = p1 p2 · · · pn is isomorphic to the lattice Ln (the lattice of n-tuples of 0 and 1) and
to the lattice P (S), where S = {1, 2, . . . , n}. The Hasse diagram for n = 3 is shown
above.
1
f
a b c
0 0
Complemented but NOT distributive Distributive but NOT complemented
5.1. LATTICES
87 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
87
Discussion 5.1.17. [The comparison table] Let (L, ≤) be a lattice and let a, b, c ∈ L. Then,
the following table lists the properties that hold (make sense) in the specified type of lattices.
Properties Lattice type
∨, ∧ are idempotent any
lattice
∨, ∧ are commutative any lattice
∨, ∧ are associative any lattice
[absorption] a ∧ (a ∨ b) = a = a ∨ (a ∧ b) any lattice
a ≤ b⇔ a ∧b= a ⇔ a ∨b= b any
lattice [isotonicity] b ≤ c ⇒ {a ∨ b ≤ a ∨ c, a ∧ b ≤ a ∧ c} any
lattice
a ∨ (b ∧ c) ≤ (a ∨ b) ∧ (a ∨ c)
[distributive inequalities] any lattice
a ∧ (b ∨ c) ≥ (a ∧ b) ∨ (a ∧ c)
[modular inequality] a ≤ c ⇔ a ∨ (b ∧ c) ≤ (a ∨ b) ∧ c any lattice
0 is unique; 1 is unique bounded lattice !!
if a is a complement of b, then b is also a complement of a bounded lattice !!
¬0 is unique and it is 1; ¬1 is unique and it is 0 bounded lattice !!
an element a has
n a unique complement o distributive complemented lattice !!
a ∨ c = b ∨ c, a ∨ ¬c = b ∨ ¬co ⇒ a = b
[cancelation] n distributive complemented lattice
a ∧ c = b∧ c, a ∧ ¬c = b∧ ¬c ⇒ a = b
¬(a ∨ b) = ¬a ∧ ¬b
[DeMorgan]
¬(a ∧ b) = ¬a ∨ ¬b distributive complemented lattice
a ∨ ¬b = 1 ⇔ a ∨ b =
a a ∧ ¬b = 0 ⇔ a ∧ b distributive complemented lattice
=a
Proof. We will only prove the properties that appear in the last three rows. The other
properties are left as an exercise for the reader. To prove the cancelation property, note that
and
(a ∨
b) ∧
(¬a
∧
¬b)
= (a
∧ ¬a
∧
¬b)
∨ (b
∧ ¬a
∧
¬b)
=0
∨0
= 0.
Hence, by Definition 5.1.15, we get ¬(a ∨ b) = ¬a ∧ ¬b. Similarly, note that (a ∧ b) ∨ (¬a ∨ ¬b) =
(a∨¬a∨¬b)∧(b∨¬a∨¬b) = 1∧1 = 1 and (a∧b)∧(¬a∨¬b) = (a∧b∧¬a)∨(a∧b∧¬b) = 0∧0 = 0.
5.2. BOOLEAN ALGEBRAS
85 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
85
Thus, by Definition 5.1.15, we again get ¬(a ∧ b) = (¬a ∨ ¬b). To prove the next assertion,
note
that if a ∨ ¬b = 1, then
a = a ∨ (b ∧ ¬b) = (a ∨ b) ∧ (a ∨ ¬b) = (a ∨ b) ∧ 1 = a ∨
b.
Proposition 5.2.2. Let S be a Boolean algebra. Then, the following statements are
true.
1. Elements 0 and 1 are unique.
5.2. BOOLEAN ALGEBRAS
86 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
86
Proof.
1. Let 01 and 02 be two such elements. Then, 01 ∨ x = x and x = x ∨ 02 , for all x ∈ S.
Hence, 01 = 01 ∨ 02 = 02 . Thus, the required result follows. A similar argument implies
that 1 is unique.
2. Suppose there exists t, r ∈ S such that s ∨ t = 1, s ∧ t = 0, s ∨ r = 1 and s ∧ r = 0. Then,
t = t ∧ 1 = t ∧ (s ∨ r) = (t ∧ s) ∨ (t ∧ r) = 0 ∨ (t ∧ r) = (s ∧ r) ∨ (t ∧ r) = (s ∨ t) ∧ r = 1 ∧
r = r.
of uncountable size.
30
2. Take S = {n ∈ N : n|30} with a ∨ b = lcm(a, b), a ∧ b = gcd(a, b), ¬a = a , 0 = 1 and
1 = 30. It is a Boolean algebra.
3. Let B = {T , F } with 0 = F , 1 = T and with usual ∨, ∧, ¬. It is a Boolean
algebra.
4. Let B be the set of all truth functions involving the variables p1 , . . . , pn , with usual ∨, ∧,
¬.
Take 0 = F and 1 = T. This is the free Boolean algebra on the generators p1 , . . . , pn .
5. The class of finite length formulae involving variables p1 , p2 , . . . is a countable
infinite
Boolean algebra with usual operations.
Observation.
The rules of Boolean algebra treat (∨, 0) and (∧, 1) equally. Notice that the second
part of the rules in Definition 5.2.1 can be obtained by replacing ∨ with ∧ and 0 with 1.
Thus, any statement that one can derive from these rules has a dual version which is
derivable
from the rules. This is called the principle of duality.
Theorem 5.2.4. [Rules] Let (S, ∨, ∧, ¬) be a Boolean algebra. Then, the following rules, as
well as their dual, hold true.
1. ¬0 = 1.
2. For each s ∈ S, s ∨ s = s [idempotence] .
3. For each s ∈ S, s ∨ 1 = 1.
4. For each s, t ∈ S, s ∨ (s ∧ t) = s [absorption] .
5. If s ∨ t = r ∨ t and s ∨ ¬t = r ∨ ¬t, then s = r [cancelation] .
6. (s ∨ t) ∨ r = s ∨ (t ∨ r) [associative] .
5.2. BOOLEAN ALGEBRAS
88 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
88
Proof. We give the proof of the first part of each item and that of its dual is left for the reader.
1. 1 = 0 ∨ (¬0) = ¬0.
2. s = s ∨ 0 = s ∨ (s ∧ ¬s) = (s ∨ s) ∧ (s ∨ ¬s) = (s ∨ s) ∧ 1 = (s ∨ s).
5.2. BOOLEAN ALGEBRAS
89 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
89
3. 1 = s ∨ ¬s = s ∨ (¬s ∧ 1) = (s ∨ ¬s) ∧ (s ∨ 1) = 1 ∧ (s ∨ 1) = s ∨ 1.
4. s ∨ (s ∧ t) = (s ∧ 1) ∨ (s ∧ t) = s ∧ (1 ∨ t) = s ∧ 1 = s.
5. s = s ∨ 0 = s ∨ (t ∧ ¬t) = (s ∨ t) ∧ (s ∨ ¬t) = (r ∨ t) ∧ (r ∨ ¬t) = r ∨ (t ∧ ¬t) = r ∨ 0 = r.
6. We will prove it using absorption and cancelation. Using absorption, (s ∨ t) ∧ s = s
and s ∨ (r ∧ s) = s. Thus, (s ∨ t) ∨ r ∧ s = (s ∨ t) ∧ s ∨ (r ∧ s) = s ∨ (r ∧ s) = s.
s ∨ (t ∨ r) ∧ s = (s ∨ t) ∨ r ∧ s.
s ∨ (t ∨ r) ∧ ¬s = (s ∨ t) ∨ r ∧ ¬s.
Example 5.2.5. Let (L, ≤) be a distributive complemented lattice. Then, by Definition 5.1.2,
L has two binary operations ∨ and ∧ and by Definition 5.1.15, the operation ¬x. It can
be easily verified that (L, ∨, ∧, ¬) is a indeed a Boolean algebra.
Now, let (B, ∨, ∧, ¬) be a Boolean algebra. Then, for any two elements a, b ∈ B, we
define a ≤ b if a ∧ b = a. The next result shows that ≤ is a partial order in B. This partial
order is generally called the induced partial order. Thus, we see that the Boolean algebra
B, with the induced partial order, is a distributive complemented lattice.
Thus, we observe that there is one-to-one correspondence between the set of Boolean
Algebras and the set of distributive complemented lattice.
Definition 5.2.7. [Atom] Let B be a Boolean algebra. If there exists a b ∈ B, b = 0 such that
b is a minimal element in B, then b is called an atom.
Example 5.2.8. 1. In the powerset Boolean algebra, singleton sets are the only atoms.
5.2. BOOLEAN ALGEBRAS
91 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
91
Proposition 5.2.13. Let B be a Boolean algebra and p, q be two distinct atoms. Then, p∧q =
0.
Proposition 5.2.14. Let B be a Boolean algebra with three distinct atoms p, q and r.
Then,
p ∨ q = p ∨ q ∨ r.
Example 5.2.15. Let B be a Boolean algebra having distinct atoms A = {p, q, r}. Then,
B
5.2. BOOLEAN ALGEBRAS
92 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
92
Theorem 5.2.16. Let B be a Boolean algebra having distinct atoms A = {p, q, r, s}. Let b ∈ B,
b = 0. Suppose that S = {atoms x : x ≤ b} = {p, q, r}. Then, b = p ∨ q ∨
Therefore, the above equality implies that [b ∧ ¬(p ∨ q ∨ r)] = 0. So, there is an atom, say
x, such that x ≤ b ∧ ¬(p ∨ q ∨ r). Thus, we have x ≤ b and x ≤ ¬(p ∨ q ∨ r).
Notice that if x ≤ (p ∨ q ∨ r), then x ≤ 0, which is not possible. So, x = p, q, r is an atom in
S, a contradiction.
Theorem 5.2.17. [Representation] Let B be a finite Boolean algebra. Then, there exists
a set X such that B is isomorphic to P (X ).
y = y ∧ b = y ∧ (x1 ∨ · · · ∨ xk ) = (y ∧ x1 ) ∨ · · · ∨ (y ∧
xk ).
Since y = 0, by Proposition 5.2.13, it follows that y ∧ xi0 = 0, for some i0 ∈ {1, 2, . . . , k}.
As xi0 and y are atoms, we have y = y ∧ xi = xi and hence y ∈ A. Thus, f is a surjection.
Preserving 0, 1: Clearly f (0) = ∅ and f (1) = X .
Preserving ∨, ∧: By definition,
x ∈ f (b1 ∧ b2 ) ⇔ x ≤ b1 ∧ b2 ⇔ x ≤ b1 and x ≤ b2
⇔ x ∈ f (b1 ) and x ∈ f (b2 ) ⇔ x ∈ f (b1 ) ∩ f (b2 ).
5.2. BOOLEAN ALGEBRAS
94 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
94
Now, let x ∈ f (b1 ∨ b2). Then, by definition, x = x ∧ (b1 ∨ b2) = (x ∧ b1) ∨ (x ∧ b2). So, there
exists i such that x ∧ bi = 0 (say, x ∧ b1 ). As, x is an atom, x ≤ b1 and hence x ∈ f (b1 ) ⊆ f
(b1 ) ∪ f (b2 ). Conversely, let x ∈ f (b1 ) ∪ f (b2 ). Without loss of generality, let x ∈ f (b1 ).
Thus, x ≤ b1 and hence x ≤ b1 ∨ b2 which in turn implies that x ∈ f (b1 ∨ b2 ).
As a direct corollary, we have the following result.
90 CHAPTER 5. LATTICES AND BOOLEAN ALGEBRA
Corollary 5.2.18. Let B be a finite Boolean algebra having exactly k atoms. Then, B
is isomorphic to P ({1, 2, . . . , k}) and hence has exactly 2k elements.
Exercise 5.2.19. 1. Determine the number of elements in a finite Boolean algebra.
2. Supply a Boolean homomorphism f from P (J4 ) to P (J3 ) such that the image of P (J4 ) has
4 elements.
3. Prove/Disprove: The number of Boolean homomorphisms from P (J4 ) to P (J3 ) is less
than the number of lattice homomorphisms from P (J4 ) to P (J3 ).
4. Show that a lattice homomorphism on a Boolean algebra which preserves 0 and 1 is a
Boolean homomorphism.
5. Consider the class of all functions f : R → {π, e}. Can we define some operations on
this class to make it a Boolean algebra?
6. Show that a finite Boolean algebra must have at least one atom. Is ‘finite’ necessary?
7. A positive integer is called squarefree if it is not divisible by the square of a prime. Let
Bn = {k ∈ N : k|n}. For a, b ∈ Bn take the operations a ∨ b = lcm(a, b), a ∧ b = gcd(a,
b) and ¬a = n/a. Show that Bn is a Boolean algebra if and only if n > 1 is squarefree.
8. Show that the set of subsets of N which are either finite or have a finite complement is a
countable infinite Boolean algebra. Find the atoms. Is it isomorphic to the Boolean
algebra of all finite length formulae involving variables p1 , p2 , · · · ?
9. Let B be a Boolean algebra and xi ∈ B, i = 1, 2, . . .. We know that, for each n ∈ N, the
W
n ∞W
expression ‘ xi ’ is meaningful in each Boolean algebra due to associativity. Is ‘ xi ’
i=1 i=1
necessarily a meaningful expression?
10. Prove/Disprove: Let f : B1 → B2 be a Boolean homomorphism and a ∈ B1 be an atom.
Then, f (a) is an atom of B2 .
11. Fill in the blank: The number of Boolean homomorphisms from P (J4 ) to P (J3 ) is .
12. Fill in the blank: The number of Boolean homomorphisms from P (J4 ) onto P (J3 ) is .
13. How many atoms does “divides 30030 Boolean algebra” has? How many elements does
it have?
14. If B1 and B2 are Boolean algebras of size k (k > 100), then they must be isomorphic
and there must be more than k isomorphisms between them.
15. Give examples of two countably infinite non-isomorphic Boolean algebras.
16. Give examples of two uncountably infinite non-isomorphic Boolean algebras.
Chapter 6
Counting
Discussion 6.0.1. In the previous chapters, we had learnt that two sets, say A and B,
have the same cardinality if there exists a one-one and onto function f : A → B. We also learnt
the following two rules of counting which play a basic role in the development of this subject.
1. [Multiplication rule] If a task has n compulsory parts, say A1 , A2 , . . . , An and the
ith part can be completed in mi = |Ai | ways, i = 1, . . . , n, then the task can be
completed in m1 m2 · · · mn ways. In mathematical terms,
Ans: The task has two alternative parts. Part 1: form a three digit number with distinct
numbers from {1, 3, 5, 7, 9} using the odd digits. Part 2: form a three digit number with
distinct numbers from {2, 4, 6, 8} using the even digits. Observe that Part 1 is a task
having three compulsory subparts. In view of 6.1.1, we see that Part 1 can be done in 60
ways. Part 2 is a task having three compulsory subparts. In view of 6.1.1, we see that Part 2
can be done in 24
ways. Since our task has alternative parts, addition rule applies. Ans:
84.
Proof. Here the task has r compulsory parts. Choose the first element of the sequence, the
second element and so on.
Exercise 6.1.5. 1. In how many ways can r distinguishable/distinct balls be put into n
distinguishable/distinct boxes?
2. How many distinct ways are there to make a 5 letter word using the ENGLISH alphabet
4. How many 5-letter words using only A’s, B’s, C’s, and D’s are there that do not
contain the word “CAD”?
6.1. PERMUTATIONS AND COMBINATIONS
93 CHAPTER 6. COUNTING
93
Example 6.1.7. How many one-one maps f : [4] → A = {A, B, . . . , Z } are there?
Ans: The task has 4 compulsory parts: select f (1), select f (2), select f (3) and select f
(4). Note that f (2) cannot be f (1), f (3) cannot be f (1) or f (2) and so on. Now apply the
multipli- cation rule. Ans: 26 · 25 · 22!
24 · 23 = 26!
.
Proof. Let us view an r-permutation as a one-one map from f : [r] → S. Here the task
has r compulsory tasks: select f (1), select f (2), . . ., select f (r) with the condition, for 2
≤ k ≤ r, f (k) 6∈ {f (1), f (2), . . . , f (k − 1)}. Multiplication rule applies. Hence, the
number of
r-permutations equals n(n − 1) · · ·(n r + 1) = (n−n!r)! .
−
Definition 6.1.9. By P (n, r), we denote the number of r-permutations of [n]. By
convention, P (n, 0) = 1. Some books use the notation n(r) and call it the falling factorial
of n. Thus, if r > n then P (n, r) = n(r) = 0 and if n = r then P (n, r) = n(r) = n!.
Exercise 6.1.10. 1. How many distinct ways are there to make 5 letter words using
the
ENGLISH alphabet if the letters must be different?
2. How many distinct ways are there to arrange the 5 letters of the word ROY AL?
3. Determine the number of ways to place 4 couples in a row if each couple seats
together.
4. How many distinct ways can 8 persons, including Ram and Shyam, sit in a row, with
Ram and Shyam sitting next to each other?
Proposition 6.1.11. [principle of disjoint pre-images of equal size] Let A, B be finite sets
−
and f : A → B be a function such that for each pair b1 , b2 ∈ B we have |f 1 (b1 )| = k = |f
−1 − −
(b2 )| (recall that f 1 (b1 ) ∩ f 1 (b2 ) = ∅). Then, |A| = k|B|.
Discussion 6.1.12. Consider the word AABAB. Give subscripts to the three As and the two
Bs and complete the following list. Notice that each of them will give us AABAB if we
erase the subscripts.
A1 A2 B1 A3 B2 A1 A2 B1 B2 A3 A1 A2 A3 B1 B2 A1 A2 A3 B2 B1 A1 A2
A1 A2 B2 A3 B1 ··· ··· ··· B
· ·2 B
· 1 A3
··· ··· ··· ··· ···
··· ··· ··· ··· ···
··· ··· ··· B2 A3 B1 A1 A2 B2 A3 B1 A2 A1
Example 6.1.13. How many words of size 5 are there which use three A’s and two B’s?
Ans: Put A = {arrangements of A1 , A2 , A3 , B1 , B2 } and B = {words of size 5 which use
three A’s and two B’s}. For each arrangement a ∈ A, define f (a) to be the word in B
obtained by erasing the subscripts. Then, the function f : A → B satisfies:
6.1. PERMUTATIONS AND COMBINATIONS
95 CHAPTER 6. COUNTING
95
−1 −1 −1 −1
‘for each b, c ∈ B, b = c, we have |f (b)| = |f (c)| = 3!2! and f (b) ∩ f (c) =
∅’.
| A|
Thus, by Proposition 6.1.11, |B| = = 5! .
3!2! 3!2!
6.1. PERMUTATIONS AND COMBINATIONS
96 CHAPTER 6. COUNTING
96
Remark 6.1.14. Let us fix n, k ∈ N with 0 ≤ k ≤ n and ask the question ‘how many words of
size n are there which uses k many A’s and (n − k) many B’s’ ?
Ans: Put A = {arrangements of A1 A2 . . . Ak B1 B2 . . . Bn−k } and B = {words of size n
which uses k many A’s and (n − k) many B’s} and proceed as above to get
|A| n!
|B| = =
−
k!(n k)! k!(n − k)!
n!
as the required answer. Observe that the above argument implies k!(n− ∈ Z. We denote this
k)!
number by P (n; k). Note that P (n; k) = P (n; n − k), Also, as per convention, P (n; k) = 0,
whenever k < 0 or n < k.
Definition 6.1.15. A multiset is a collection of objects where an object can appear more than
once. So, a set is a multiset. Note that {a, a, b, c, d} and {a, b, a, c, d} are the same 5-
multisets.
Theorem 6.1.17. [Allocation I: distinct locations; identical objects (ni of type i); at
most one per place] Fix a positive integer k and for 1 ≤ i ≤ k, let Gi ’s be boxes containing
ni ∈ N
P
k
identical objects. If the objects in distinct boxes are non-identical and n ≥ ni then, the number
i=1
of allocations of the objects in n distinct locations l1 , . . . , ln , each location receiving at most one
n! P
object, is n1 !···nk !(n− ni )!.
P
k
Proof. Consider a new group Gk+1 with nk+1 = n − ni objects of a new type. Notice that
1
an allocation of objects from G1 , . . . , Gk to n distinct places, where each location receives at
most one object, gives a unique arrangement of elements of G1 , . . . , Gk+1 .1 Thus, the number
6.1. PERMUTATIONS AND COMBINATIONS
97 CHAPTER 6. COUNTING
97
1
Take an allocation of objects from G1 , . . . , Gk to n distinct places, where each location receives at most
one object. There are nk+1 locations which are empty. Supply an object from Gk+1 to each of these
locations. We have created an arrangement of elements of G1 , . . . , Gk+1 . Conversely, take an arrangement of
elements of G1 , . . . , Gk+1 . View this as an allocation of elements of G1 , . . . , Gk+1 to n distinct places. Empty the
places which have received elements from Gk+1 . We have created an allocation of elements of G1 , . . . , Gk to n
distinct places, where each location receives at most one object.
6.1. PERMUTATIONS AND COMBINATIONS
98 CHAPTER 6. COUNTING
98
n! P
Definition 6.1.18. Let n, n1 , n2 , . . . , nk ∈ N. Then, the is de-
n1 ! · · · !(n − ni )!
number
nk
noted by P (n; n1 , . . . , nk ). Thus, P (6; 1, 1, 1) = P (6, 3). As a convention, P (n; n1 , . . . , nk )
=0
P
k
whenever either ni < 0; for some i, 1 ≤ i ≤ k, or ni > n. Many texts use C (n; n1 , · · · , nk )
to
i=1
mean P (n; n1 , · · · , nk ). We shall interchangeably use
them.
Example 6.1.21. In how many ways can you allocate 3 identical passes to 10 students so that
each student receives at most one? Ans: C (10, 3)
Experiment
Complete the following list by filling the left list with all 3-subsets of [5] and the right list
with 3-subsets of [4] as well as with 2-subsets of [4] as shownbelow.
{1,
2, 3} {1, 2, 3}
C (4, 3)
{2, 3, 4} {2, 3, 4}
{
1, 2, 5} {1, 2}
C (5, 3)
C (4, 2)
{3, 4, 5} {3, 4}
Theorem 6.1.23. [Alternate proof of Pascal’s Theorem 6.1.22] Here we supply a combi-
natorial proof, i.e., ‘by associating the numbers with objects’. Let S = [n + 1] and A be
6.1. PERMUTATIONS AND COMBINATIONS
99 CHAPTER 6. COUNTING
99
Also, n + 1 ∈/ A if and only if A is an (r + 1)-subset of [n]. So, a set A which does not contain
n + 1 can be formed in C (n, r + 1) ways. Hence, an (r + 1)-subset of S can be formed,
by definition, in C (n, r) + C (n, r + 1) ways. Thus, the required result follows.
Experiment
Here we consider subsets of [4]. Complete the following list by using 0’s, 1’s, x’s and
y’s, where x and y are commuting (xy = yx) symbols.
∅ 0000 yyyy = y4
{1} 1000 xyyy = xy3
{2} 0100 yxyy = xy3
{3} 0010 yyxy = xy3
{4} 0001 yyyx = xy3
{1, 2} 1100 xxyy = x2 y2
Remark 6.1.24. [Another alternate proof of Pascal’s Theorem 6.1.22] Here we supply
another combinatorial proof. An (r + 1) subset of [n + 1] may be viewed as a string
(word) of size n + 1 made of (n − r) many 0’s and (r + 1) many 1’s. The number of such
strings which end with a 1 is C (n, r). The number of such strings which end with a 0 is C (n,
r + 1). So, the required conclusion follows.
Practice 6.1.25. Give a combinatorial proof of C (n, r) = C (n, n − r), whenever n, r ∈ N
with
0 ≤ r ≤ n.
Proof. Task has k compulsory parts: select n1 for pocket p1 and so on. So, the answer
is
C (n, n1 )C (n − n1 , n2 ) · · · C (n − n1 − · · · − nk−1 , nk ) = P (n; n1 , . . . ,
nk ).
Alternate. Take an allocation of o1 , . . . , on into pockets p1 , . . . , pk so that the pocket pi
gets ni objects. This is an allocation of n1 copies of p1 , · · · , nk copies of pk into locations o1 ,
. . . , on where each location gets exactly one. Hence, the answer is P (n; n1 , . . . , nk ).
6.1.
10 PERMUTATIONS AND COMBINATIONS CHAPTER 6. COUNTING
10
1 1
Exercise 6.1.27. 1. In a class there are 17 girls and 20 boys. A committee of 5 students
is to be formed to represent the class.
(a) Determine the number of ways of forming the committee consisting of 5 students.
6.1.
10 PERMUTATIONS AND COMBINATIONS CHAPTER 6. COUNTING
10
2 2
(b) Suppose the committee also needs to choose two different people from among
them- selves, who will act as “spokesperson” and “treasurer”. In this case,
determine the number of ways of forming a committee consisting of 5 students. Note
that two com- mittees are different if
i. either the members are different, or
ii. even if the members are the same, they have different students as
spokesperson and/or treasurer.
(c) Due to certain restrictions, it was felt that the committee should have at least 3 girls.
In this case, determine the number of ways of forming the committee consisting of 5
students (no one is to be designated as spokesperson and/or treasurer).
5. How many anagrams of M I SSI SSI P P I are there so that no two S are adjacent?
6. How many rectangles are there in an n × n square? How many squares are there?
7. Show that a product of n consecutive natural numbers is always divisible by n!.
8. Show that (m!)n divides (mn)!.
9. If n points are placed on the circumference of a circle and all the lines connecting them are
joined, what is the largest number of points of intersection of these lines inside the
circle that can be obtained?
10. Prove that C (pn, pn − n) is a multiple of p in two ways. Hint: Newton’s identity.
11. How many ways are there to form the word MATHEMATICIAN starting from any
side and moving only in horizontal or vertical
M directions?
A M
M A T A M
M
M A T H T A M
M A T H E H T A M
M A T H E M E H T A M
M A T H E M A M E H T A M
M A T H E M A T A M E H T A M
M A T H E M A T I T A M E H T A M
M A T H E M A T I C I T A M E H T A M
M A T H E M A T I C I C I T A M E H T A M
M A T H E M A T I C I A I C I T A M E H T A M
M A T H E M A T I C I A N A I C I T A M E H T A M
6.1.
10 PERMUTATIONS AND COMBINATIONS CHAPTER 6. COUNTING
10
3 3
12. (a) In how many ways can one arrange n different books in m different boxes kept in
a row, if books inside the boxes are also kept in a row?
(b) What if no box can be empty?
13. Prove by induction that 2n |(n + 1) · · · (2n).
1 k
n1 , . . . , nk ≥ 0
n1 + · · · + nk =
n
1
Nonstandard notion
2
Nonstandard notion
6.2. CIRCULAR PERMUTATIONS
99 CHAPTER 6. COUNTING
99
Example 6.1.32. Form words of size 5 using letters from ‘MATHEMATICIAN’ (including
multiplicity, that is, you may use M at most twice). How many are there?
P
Ans: C (5; k1 , · · · , k8 ).
k1 +···+k8 =5
k1 ≤2,k2 ≤3,k3 ≤2,k4 ≤1,k5 ≤1,k6 ≤2,k7 ≤1,k8 ≤1
Exercise 6.1.33. 1. Show that |P ([n])| = 2n in the following ways.
(a) By using Binomial Theorem.
(b) By using ‘select a subset is a task with n compulsory parts’.
(c) By associating a subset with a 0-1 string of length n and evaluating their values in
base-2.
(d) Arguing in the line of ‘a subset of [n + 1] either contains n + 1 or not’ and
using induction.
2. Let S be a set of size n. Then, prove in two different ways that the number of subsets
of S of odd size is the same as the number of subsets of S of even size, or equivalently
P P −
C (n, 2k) = C (n, 2k + 1) = 2n 1 .
k ≥0 k ≥0
3. Prove the following identities on Binomial coefficients.
Pn −
(a) C (k, ℓ)C (n, k) = C (n, ℓ)2n ℓ .
k=ℓ
P
ℓ
(b) C (m + n, ℓ) C (m, k) C (n, ℓ − k).
= k=0
n
P
t P
(c) C (n, ℓ) = C (t, k) C (n − t, ℓ − k) C (t, k) C (n − t, ℓ − k), for any t, 0 ≤ t ≤ n.
= k=0
k=0
rP
(d) C (n + r + 1, r) = C (n + ℓ, ℓ).
ℓ=0
nP
(e) C (n + 1, r + 1) = C (ℓ, r).
ℓ=r
P
n P
n
4. Evaluate (2k + 1) C (n, 2k + 1) (5k + 3) C (n, 2k + 1), whenever n ≥ 3.
and k=0
k=0
5. [Generalized Pascal] Assume that k1 + · · · + km = n. Show that
C (n; k1 , . . . , km ) = C (n − 1; k1 − 1, . . . , km ) + · · · + C (n − 1; k1 , . . . , km − 1).
P
6. What is C (n; k1 , . . . , km )?
k1 +...+km =n
P
7. Put l = ⌊ 2m ⌋. What is (−1)k2 +k4 +···+k2l C (n; k1 , . . . , km )?
k1 +...+km =n
Example 6.2.2. Exactly two pictures in Figure 6.1 represent the same circular permutation.
A4 A3 A1 A5 A2 A3
A5 A2 A2 A4 A1 A4
A1 A3 A5
[A1 , A2 , A3 , A4 , A5 ,
A1 ] Figure 6.1: Circular permutations
Theorem 6.2.4. [circular permutations] The number of circular permutations of [n] is (n−1)!.
Proof. A proof may be obtained on the line of the previous example. Here we give an alternate
proof. Put A = {circular permutations of [5]}. Put B = {permutations of [4]}. Define f
: A → B as f ([5, x1 , x2 , x3 , x4 , 5]) = [x1 , x2 , x3 , x4 ]. Define g : B → A as g([x1 , x2 , x3 , x4
]) = [5, x1 , x2 , x3 , x4 , 5]. Then, g ◦ f (a) = a, for each a ∈ A and f ◦ g(b) = b, for each b ∈ B.
Hence,
by the bijection principle (see Theorem 2.3.8) f is a bijection.
1
Think of creating the circular permutation from a given permutation.
6.2. CIRCULAR PERMUTATIONS
101 CHAPTER 6. COUNTING
101
Example 6.2.7. 1. We have R1 (ABC ABC ABC ) = [BC ABC ABC A], R2 (ABC ABC ABC ) = [C
ABC ABC AB] and R3 (ABC ABC ABC ) = [ABC ABC ABC ]. Thus, orbit size of ABC ABC ABC
is 3.
9. If we take the set of all arrangements of a finite multiset and group them into orbits
(notice that each orbit gives us exactly one circular arrangement), then the number of
orbits is the number of circular arrangements.
Example 6.2.9. Suppose, we are given an arrangement [X1 , . . . , X10 ] of five A’s and five
B’s. Can it have an orbit size 3?
Ans: No. To see this assume that it’s orbit size is 3. Then,
6.2. CIRCULAR PERMUTATIONS
102 CHAPTER 6. COUNTING
102
[X1 , . . . , X10 ] = R3 (X1 , . . . , X10 ) = R6 (X1 , . . . , X10 ) = R9 (X1 , . . . , X10 ) = R2 (X1 , . . . , X10 ).
6.2. CIRCULAR PERMUTATIONS
103 CHAPTER 6. COUNTING
103
Since 3 was the least positive integer with R3 (X1 , . . . , X10 ) = [X1 , . . . , X10 ], we arrive at
a contradiction. Hence, the orbit size cannot be 3.
Proof. Suppose, the orbit size of [X1 , . . . , Xn ] is k and n = kp + r, for some r, 0 < r < k.
Then,
Proposition 6.2.11. Let S1 = {Pi1 , Pi2 , . . . , Pik } and S2 = {Pj1 , Pj2 , . . . , Pjl } be any two
orbits
of certain arrangements of an n-multiset. Then, either S1 ∩ S2 = ∅ or S1 = S2 .
Proof. If S1 ∩ S2 = ∅, then there is nothing to prove. So, let there exists an arrangement
Pt ∈ S1 ∩ S2 . Then, by definition, there exist rotations R1 and R2 such that R1 (Pi1 ) = Pt and
− − −
R2 (Pj1 ) = Pt . Thus, R2 1 (Pt ) = Pj1 and hence R2 1 (R1 (Pi1 )) = R2 1(Pt ) = Pj1 . Therefore, we
see that the arrangement Pj1 ∈ S1 and hence S2 ⊆ S1 . A similar argument implies that S1 ⊆ S2
and hence S1 = S2 .
6!
Example 6.2.13. Think of all arrangements P1 , . . . , Pn , n 3!3!
= , of three A’s and three
B’s. How many copies of [ABC ABC ] are there in [R0 + · · · + R5 ](P1 + · · · + Pn )?
Ans: Of course 6. To see this, note that R0 takes [ABC ABC ] to itself; R1 will take
[C ABC AB] to [ABC ABC ]; R2 will take [BC ABC A] to [ABC ABC ]; and so
on.
Example 6.2.14. Let P = [X1 , . . . , X12 ] be an arrangement of a 12-multiset with orbit size
3. Since, the orbit size of P is 3, the set S = {P, R1 (P ), R2 (P )} forms the orbit of P . Thus,
the rotations R0 , R3 , R6 and R9 fix each element of S, i.e., Ri (Rj (P )) = Rj (P ) for all i ∈ {0, 3,
6, 9} and j ∈ {0, 1, 2}. In other words, [R0 + · · · + R11 ](P ) accounts for 4 counts of the same
circular arrangement, where 4 is nothing but the number of rotations fixing P . Thus, we see
that
6.2. CIRCULAR PERMUTATIONS
104 CHAPTER 6. COUNTING
104
The proof of the next result is similar to the idea in the above example and hence is omitted.
Ans: In this case, R0 fixes all the 35 arrangements. The rotations R1 , R2 , R3 and R4
fixes the arrangements AAAAA, BBBBB and C C C C C . Hence, the required number is
15
35 + 4 · 3 = 51.
Verify that the answer will be 8 if we have just two alphabets A and B.
6.2. CIRCULAR PERMUTATIONS
107 CHAPTER 6. COUNTING
107
Exercise 6.2.19. 1. If there are n girls and n boys then what is the number of ways of
making them sit around a circular table in such a way that no two girls are adjacent
and no two boys are adjacent?
2. Persons P1 , . . . , P100 are seating on a circle facing the center and talking. If Pi talks
lie, then the
(a) person to his right talks truth. So, the minimum number of persons talking truth is
.
(b) second person to his right talks truth’ ? So, the minimum number of persons
talking truth is .
(c) next two persons to his right talk truth’ ? So, the minimum number of persons talking
truth is .
3. Let us assume that any two garlands are same if one can be obtained from the other
by rotation. Then, determine the number of distinct garlands that can be formed
using 6 flowers, if the flowers
(a) are of 2 colors, say ‘red’ and
‘blue’. (b) are of 3 different colors.
(c) are of k different colors, for some k ∈ N.
(d) of ‘red’ color are 2 and that of ‘blue’ color is 4.
6. 3 subsets of an 9-set.
Solution: Observe that all the problems correspond to forming strings using +’s (or |’s
or bars) and 1’s (or balls or dots) in place of A’a and B’s, respectively?
6.3. SOLUTIONS IN NON-NEGATIVE INTEGERS 105
BBABBBABA 11 + 111 + 1+ = 2 + 3 + 1 + • • | • • • | • |
ABBBBBAAB 0 | • • • • • || •
ABBBABABB +11111 + +1 = 0 + 5 + 0 + | • • • | • | • •
1
+111 + 1 + 11 = 0 + 3 + 1 +
2
Figure 6.2: Understanding the three problems
Note that the A’s are indistinguishable among themselves and the same holds for B’s.
Thus, we need to find 3 places, from the 9 = 3 + 6 places, for the A’s. Hence, the
answer is C (9, 3). The answer will remain the same as we just need to replace A’s with
+’s (or
|’s) and B’s with 1’s (or balls) in any string of 3 A’s and 6 B’s. See Figure 6.2 or note that
four numbers can be added using 3 +’s or four adjacent boxes can be created by putting
3 vertical lines or |’s.
Proof. Each solution (x1 , . . . , xr ) may be viewed as an arrangement of n dots and r − 1 bars.
‘Put x1 many dots; put a bar; put x2 many dots; put another bar; continue; and end by
putting xr many dots.’
For example, (0, 2, 1, 0, 0) is associated to | • •| • || and vice-versa. Thus, there are C (n + r
−
1, r − 1) arrangements of n dots and r − 1 bars.
1). Proof. Let A be an r-multiset. Let di be the number of copies of i in A. Then, any
solution of
d1 + · · · + dn = r in nonnegative integers gives A uniquely. Hence, the conclusion.
Alternate. Put A = {arrangements of n − 1 dots and r bars}. Put B = {r-multisets of [n]}.
For a ∈ A, define f (a) to be the multiset
f (a) = {d(i) + 1 | where d(i) is the number of dots to the left of the i-th bar}.
Example 6.3.6. 1. There are 5 kinds of ice-creams available in our market complex. In how
many ways can you buy 15 of them for a party?
Ans: Suppose you buy xi ice-creams of the i-th type. Then, the problem is the same as
finding the number of solutions of x1 + · · · + x5 = 15 in nonnegative integers.
2. How many solutions in N0 are there to x + y + z = 60 such that x ≥ 3, y ≥ 4, z ≥ 5?
Ans: (x, y, z) is such a solution if and only if (x−3, y −4, z −5) is a solution to x+y +z =
48 in N0 . So, answer is C (50, 2).
3. How many solutions in N0 are there to x + y + z = 60 such that 20 ≥ x ≥ 3, 30 ≥ y ≥
4, 40 ≥ z ≥ 5?
Ans: We are looking for solution in N0 of x + y + z = 48 such that x ≤ 17, y ≤ 26 and
z ≤ 35. Let A = {(x, y, z) ∈ N3 | x + y + z = 48}, Ax = {(x, y, z) ∈ N3 | x + y + z = 48, x
≥ 0 0
18}, Ay = {(x, y, z) ∈ N03 | x + y + z = 48, y ≥ 27} and Az = {(x, y, z) ∈ 0N3 | x + y + z =
48, z ≥ 36}. We know that |A| = C (50, 2). Our answer is then C (50, 2) − |Ax ∪ Ay ∪ Az
|. Very soon we will learn to find the value of |Ax ∪ Ay ∪ Az |.
Exercise 6.3.7. 1. Determine the number of solutions of x + y + z = 7 with x, y, z ∈ N?
2. Find the number of allocations of n identical objects to r distinct locations so that location
i gets at least pi ≥ 0 elements, i = 1, 2, · · · , r.
3. In how many ways can we pick integers x1 < x2 < x3 < x4 < x5 , from [20] so that
xi − xi−1 ≥ 3, i = 2, 3, 4, 5? Solve in three different ways.
4. Find the number of solutions in nonnegative integers of a + b + c + d + e < 11.
5. In a room, there are 2 distinct book racks with 5 shelves each. Each shelf is capable
of holding up to 10 books. In how many ways can we place 10 distinct books in two
racks?
6. How many 4-letter words (with repetition) are there with the letters in alphabetical order?
7. Determine the number of non-decreasing sequences of length r using the numbers 1, 2, . . . , n.
8. In how many ways can m indistinguishable balls be put into n distinguishable boxes
with the restriction that no box is empty.
9. How many 26-letter permutations of the ENGLISH alphabets have no 2 vowels together?
10. How many 26-letter permutations of the ENGLISH alphabets have at least two
consonants between any two vowels?
11. How many ways are there to select 10 integers from the set {1, 2, . . . , 100} such that
the positive difference between any two of the 10 integers is at least 3.
12. How many 10-element subsets of the ENGLISH alphabets do not have a pair of
consecutive letters?
6.4. SET PARTITIONS
107 CHAPTER 6. COUNTING
107
13. How many 10-element subsets of the ENGLISH alphabets have a pair of consecutive
let- ters?
6.4. SET PARTITIONS
108 CHAPTER 6. COUNTING
108
14. How many ways are there to distribute 50 balls to 5 persons if Ram and Shyam
together get no more than 30 and Mohawk gets at least 10?
15. How many arrangements of the letters of KAGARTHALAMNAGARTHALAM have no 2
vowels adjacent?
16. How many arrangements of the letters of RECURRENCERELATION have no 2
vowels adjacent?
17. How many ways are there to arrange the letters in ABRAC ADABARAARC ADA
such that the first
18. How many ways are there to arrange the letters in K AGART H ALAM N AGART H AT AM
such that the first
19. In how many ways can we pick 20 letters from 10 A’s, 15 B’s and 15 C ’s?
20. Determine the number of ways to sit 10 men and 7 women so that no 2 women sit next to
each other?
21. How many ways can 8 persons, including Ram and Shyam, sit in a row with Ram and
Shyam not sitting next to each other?
P
n P i1
Pi2 iP
k−1
22. Evaluate ·· 1.
·
i1 =1 i2 =1 i3 =1 ik =1
Example 6.4.2. (a) {1, 2}, {3}, {4, 5, 6} , {1, 3}, {2}, {4, 5, 6} and {1, 2, 3, 4}, {5}, {6}
are both partitions of [6] into 3 subsets.
−
(b) There are 2n 1 − 1 partitions of [n], n ≥ 2 into two subsets. To see this, observe that for
each nontrivial subset A ∈ P ([n]), the set {A, Ac } is a partition of [n] into two
6.4. SET PARTITIONS
109 CHAPTER 6. COUNTING
109
subsets. Since, the total number of nontrivial subsets of P ([n]) equals 2n − 2, the
required result follows.
(c) Number of allocations of 7 students into 7 different project groups so that each group has
one student, is 7! = C (7; 1, 1, 1, 1, 1, 1, 1) but the number of partitions of a set of 7
students into 7 subsets is 1.
6.4. SET PARTITIONS
110 CHAPTER 6. COUNTING
110
}
n
(d) In how many ways can I write o
1, 2}, {3, 4}, {5, 6}, {7, 8, 9}, {10, 11, 12 on a piece of
{
paper, with the condition that sets have to be written in a row in increasing size?
Ans: Let us write a few first.
o
n{1, 2}, {3, 4}, {5, 6}, {7, 8, 9}, {10, 11, correct
o
12} n{2, 1}, {3, 4}, {5, 6}, {7, 8, 9}, {10, correct
o
11, 12} n{5, 6}, {3, 4}, {1, 2}, {10, 11, correct
o
12}, {9, 7, 8} n{2, 3}, {1, 4}, {5, 6}, {7, 8, incorrect, not the same partition
o
9}, {10, 11, 12} n{2, 1}, {3, 4}, {7, 8, 9}, incorrect, not satisfying the condition
{5, 6}, {10, 11, 12}
There are 3!(2!)3 × 2!(3!)2 ways. Notice that from each written partition, if I remove
the brackets I get an arrangement of elements of [12].
(e) How many arrangements do I generate from a partition with pi subsets of size ni , n1 <
· · · < nk ?
kY
Ans: p1 !(n1 !)p1 · · · pk !(nk !)pk = [pi !(ni )pi ].
i=1
Theorem 6.4.3. [Set partition] The number of partitions of [n] with pi subsets of size ni ,
n1 < · · · < nk is
n!
.
!)p1 p 1 ! · · (nk !) k pk
·
(n1 p
!
Q
k
Proof. Note that each such partition generates [pi !(ni )pi ] arrangement of elements of [n].
i=1
Conversely, for each arrangement of elements of [n] we can easily construct a partition of the
above type which can generate this arrangement. Thus, the proof is complete.
Definition 6.4.4. Stirling numbers of the second kind, denoted S(n, r), is the number
of partitions of [n] into r-subsets (r-parts). By convention, S(n, r) = 1, if n = r and 0,
whenever either ‘n > 0 and r = 0’ or ‘n < r’.
Example 6.4.6. Determine the number of ways of putting n distinguishable/distinct balls into
r indistinguishable boxes with the restriction that no box is empty.
Ans: Let A be the set of n distinct balls and let the balls in i-th box be Bi , 1 ≤ i ≤ r.
6.4. SET PARTITIONS
111 CHAPTER 6. COUNTING
111
3. As the boxes are indistinguishable, we arrange the boxes in non-increasing order, i.e.,
|B1 | ≥ · · · ≥ |Br |.
Example 6.4.7. Let A = {a, b, c, d, e} and S = {1, 2, 3}. Define an onto function f : A → S
by
f (a) = f (b) = f (c) = 1, f (d) = 2 and f (e) = 3. Then, f gives a partition B1 = {a, b, c}, B2
=
{d} and B3 = {e} of A into 3-parts. Also, let A1 = {a, d}, A2 = {b, e} and A3 = {c} be
a partition of A into 3-parts. Then, this partition gives 3! onto functions from A into S, each
of them being a one-to-one function from {A1 , A2 , A3 } to S, namely,
Proof. ‘f is onto’ means ‘for all y ∈ [n] there exists x ∈ [r], such that f (x) = y’. Therefore,
the number of onto functions is 0, whenever r < n. So, we assume that r ≥ n. Then,
−1
1. for each i ∈ [n], f (i) = {x ∈ [r] | f (x) = i} is a non-empty set (f is onto).
−1 −1
2. f (i) ∩ f (j) = ∅, whenever 1 ≤ i = j ≤ n (f is a function).
S
n −1
3. f (i) = [r] (domain of f is [r]).
i=1
−
Therefore, f 1(i)’s give a partition of [r] into n-parts. Also, note that each such function
− −
f , gives a one-to-one function from {f 1 (1), . . . , f 1 (r)} to [n].
Conversely, for each partition A1 , A2 , . . . , An of [r] into n-parts, we get n! one-to-one
function from {A1 , A2 , . . . , An } to [n]. Hence,
{f : [r] → [n] | f is onto} = {g : {A1 , A2 , . . . , An } → [n] | g is one-to-
one}
X
nr = C (n, k)k!S(r, k). (6.1)
k=1
6.4. SET PARTITIONS
111 CHAPTER 6. COUNTING
111
2. The numbers S(r, k) can be recursively calculated using Equation (6.1). For example,
we show that S(m, 1) = 1, for all m ≥ 1.
P1
Ans: Take n ≥ 1 and r = 1 in Equation (6.1) to get n = n1 = k=1 C (n, k)k!S(1, k) =
C (n, 1)1!S(1, 1) = nS(1, 1). Thus, S(1, 1) = 1.
P1
Take n = 1 and r ≥ 2 in Equation (6.1) to get 1 = 1r = k=1 C (1, k)k!S(r, k) = S(r, 1).
3. As exercise, verify that S(5, 2) = 15, S(5, 3) = 25, ; S(5, 4) = 10, S(5, 5) = 1.
Exercise 6.4.11. 1. Determine the number of ways of
4, 3 + 1, 1 + 3, 2 + 2, 2 + 1 + 1, 1 + 1 + 2, 1 + 2 + 1, 1 + 1 + 1
+ 1.
Let Sk (n) denote the number of compositions of n into k parts. Then, S1 (4) = 1, S2 (4) =
P
3, S3 (4) = 3 and S4 (4) = 1. Determine Sk (n), for 1 ≤ k ≤ n and Sk (n).
k≥1
6.4. SET PARTITIONS
111 CHAPTER 6. COUNTING
111
rP
4. Let S = {f | f : [r] → [n]}. Compute |S| in two ways to prove (n + 1)r = C (r, k)nk .
k=0
5. Suppose 13 people get on the lift at level ◦. If all the people get down at some level, say
1, 2, 3, 4 and 5 then, calculate the number of ways of getting down if at least one
person gets down at each level.
Definition 6.4.12. [Partition of a number] Let n, k ∈ N. A partition of n into k parts
is a tuple (x1 , · · · , xk ) ∈ Nk written in non-increasing order such that x1 + · · · + xk = n. It
may be viewed as a k-multiset S ⊆ N with sum n. By πn (k), we denote the number of
partitions
of n into exactly k parts and by πn , the number of partitions of n. Conventionally π0 = 1
and
πn (k) = 0, whenever k >
n.
Remark 6.4.13. π7 (4) = 3 as the partitions of 7 into 4-parts are 4 + 1 + 1 + 1, 3 + 2 + 1 +
1
and 2 + 2 + 2 + 1. Verify that π7 (2) = 3 and π7 (3) =
4.
Example 6.4.14. Determine the number of ways of placing r indistinguishable balls into
n
indistinguishable boxes
1. with the restriction that no box is empty.
Ans: As the balls are indistinguishable, we need to count the number of balls in each box.
As the boxes are indistinguishable, arrange them so that the number of balls inside boxes
are in non-increasing order. Also, each box is non-empty and hence the answer is πr (n).
2. with no restriction.
Ans: Let us place one ball in each box. Now ‘placing r indistinguishable ball into n
indistinguishable boxes with no restriction’ is same as ‘placing r + n indistinguishable
balls into n indistinguishable boxes so that no box is empty.’ Therefore, the required
answer is πm+n (n).
Exercise 6.4.15. 1. Calculate π(n), for n = 1, 2, 3, . . . ,
8.
2. Prove that π2r (r) = π(r), for any r ∈ N.
3. For a fixed n ∈ N determine a recurrence relation for the numbers πn (r)’s for 1 ≤ r ≤
n. Definition 6.4.16. [Stirling number of first kind] The Stirling number of the first
kind, denoted s(n, k), is the coefficient of xk in xn, where xn is called the falling factorial and
equals
x(x − 1)(x − 2) · · · (x − n + 1). The rising factorialn is defined as x(x + 1)(x + 2) · · · (x + n − 1).
x
Exercise 6.4.17. Prove by induction that
− −
1. s(n, m)(−1)n m is the coefficient of xm in xn and |s(n, m)| = s(n, m)(−1)n m .
6.4. SET PARTITIONS
112 CHAPTER 6. COUNTING
112
2. Let a(n, k) denote the number of permutations of [n] which have k disjoint cycles. For
example, a(4, 2) = 11 as it corresponds to the permutations (12)(34), (13)(24), (14)(23),
(1)(234), (1)(243), (134)(2), (143)(2), (124)(3), (142)(3), (123)(4) and (132)(4). By con-
vention, a(0, 0) = 1 and a(n, 0) = 0 = a(0, n), whenever n ≥ 1. Determine prove that the
numbers a(n, k)’s satisfy
(8, 7)
U = UP
(2, 3)
R = RIGHT
(0, 0)
Example 6.5.1. 1. Determine the number of lattice paths from (0, 0) to (m, n).
Ans: As at each step, the unit increase is either R or U , we need to take n many R
steps and m many U steps to reach (m, n) from (0, 0). So, any arrangement of n many
R’s and m many U ’s will give such a path uniquely. Hence, the answer is C (m + n, m).
P
m
2. Use the method of lattice paths to prove C (n + ℓ, ℓ) = C (n + m + 1, m).
ℓ=0
Ans: Observe that C (n + m + 1, m) is the number of lattice paths from (0, 0) to (m, n +
1) and the left hand side is the number of lattice paths from (0, 0) to (ℓ, n), where 0 ≤ ℓ ≤
m. Fix ℓ, 0 ≤ ℓ ≤ m and let P be a lattice path from (0, 0) to (ℓ, n). Then, the path P
∪ Q, where Q = U RR · · · R with R appearing m − ℓ times, gives a lattice path from
(0, 0) to
(m, n + 1), namely
P Q
(0, 0) −→ (ℓ, n) → (ℓ, n + 1) (m, n + 1).
U −→
−
These lattice paths for 0 ≤ ℓ ≤ m are all distinct and hence the result follows.
6.4. SET PARTITIONS
114 CHAPTER 6. COUNTING
114
Discussion 6.5.3. As observed earlier, the number of lattice paths from (0, 0 to (n, n) is
C (2n, n). Suppose, we wish to take paths so that at no step the number of U ’s exceeds
the number of R’s. Then, what is the number of such paths?
Ans: Call an arrangement of n many U ’s and n many R’s a ‘bad path’ if the number of U
’s exceeds the number of R’s at least once. For example, the path RRU U U RRU is a ‘bad
path’. To each such arrangement, we correspond another arrangement of n + 1 many U ’s
and n − 1 many R’s in the following way: spot the first place where the number of U ’s
exceeds that of R’s in the ‘bad path’. Then, from the next letter onwards change R to U
and U to R. For example, the bad path RRU U U RRU corresponds to the path RRU U U U U
R. Notice that this
is a one-one correspondence. Thus, the number of bad paths is C (2n, n − 1). So, the answer
to
C (2n, n)
the question is C (2n, n) − C (2n, n − 1) .
= n+1
Definition 6.5.4. [Catalan number] The nth Catalan number, denoted Cn , is the number
of different representations of the product A1 · · · An+1 of n + 1 square matrices of the same
size using n pairs of brackets. By convention C0 = 1.
C (2n,n)
Theorem 6.5.5. [Catalan number] Prove that Cn = for all n ∈
n+1
N.
Proof. Claim: After the (n − k)-th ‘(’, there are at least k + 2 many A’s. To see this pick
the substring starting right from the (n − k)-th ‘(’ till we face (k + 1) many ‘)’s. This
substring represents a product of matrices. So, it must contain (k + 2) many Ai ’s.
Given one representation of the product, replace each Ai by A. Drop the right brackets to
have a sequence of n many ‘(’s and n + 1 many A’s. Thus, the number of A’s used till the n −
kth ‘(’ is at most n + 1 − (k + 2) = n − k − 1. So, the number of A’s never exceeds the
number of ‘(’. Conversely, given such an arrangement, we can put back the ‘)’s: find two
consecutive letters
from the last ‘(’; put a right bracket after them; treat (AA) as a letter; repeat the process. For
example,
4. Consider a regular polygon with vertices 1, 2, · · · , n. In how many ways can we divide the
polygon into triangles using (n − 3) noncrossing diagonals?
5. How many arrangements of n blue and n red balls are there such that at any position
in the arrangement the number of blue balls (till that position) is at most one more than
the number of red balls (till that position)?
6. We want to write a matrix of size 10 × 2 using numbers 1, . . . , 20 with each number
ap- pearing exactly once. Then, determine the number of such matrices in which the
numbers
Theorem 6.6.1. [Generalized binomial theorem] Let n be any real number. Then,
The above expression can also be obtained by using the Taylor series expansion of
f (x) = (1 + x)1/2 around x = 0. Recall that the Taylor series expansion of f (x)
(0) P f(k) (0) k
around x = 0 equals f (x) = f (0) + f ′ (0)x + ′′ x2 + x , where f (0) = 1,
f
2! k!
k≥3
f ′ (0) = 21 , f ′′ (0) = 2−1
2 and in general f (k) (0) =2 1 · 2( 1 − 1) · · 2· ( 1 − k + 1), for k ≥ 3.
(b) Let n = −r, where r ∈ N. Then, for k ≥ 1, Equation (6.2) gives C (−r, k) =
−r · (−r − 1) · · · (−r − k + 1)
=− ( 1)k C (r +−k 1, k). Thus,
k!
1 X
(1 + x)n = r = 1 − rx + C (r + 1, 2)x 2
+ C (r + k − 1, k)(−x)k .
(1 + x)
k≥3
2. Prove that there exists a bijection between any two of the following sets.
(a) The set of n letter words with distinct letters out of an alphabet consisting of m letters.
(b) The set of one-one functions from an n-set into an m-set.
(c) The set of distributions of n distinct objects into m distinct boxes, subject to ‘if an
object is put in a box, no other object can be put in the same box’.
(d) The set of n-tuples on m letters, without repetition.
(e) The set of permutations of m symbols taken n at a time.
3. Prove that there exists a bijection between any two of the following
(PHP1) If n + 1 pigeons stay in n holes then there is a hole with at least two pigeons.
(PHP2) If kn + 1 pigeons stay in n holes then there is a hole with at least k + 1 pigeons.
(PHP3) If p1 + · · · + pn + 1 pigeons stay in n holes then there is a hole i with at least pi +
1
pigeons.
Example 7.1.2. 1. Consider a tournament of n > 1 players, where each pair plays exactly
once and each player wins at least once. Then, there are two players with the same
number of wins.
Ans: Number of wins vary from 1 to n − 1 and there are n players.
2. A bag contains 5 red, 8 blue, 12 green and 7 yellow marbles. The least number of marbles
to be chosen to ensure that there are
(a) at least 4 marbles of the same color is 13,
(b) at least 7 marbles of the same color is 24,
(c) at least 4 red or at least 7 of any other color is 22.
3. In a group of 6 people, prove that there are three mutual friends or three mutual strangers.
Ans: Let a be a person in the group. Let F be the set of friends of a and S the set
of strangers to a. Clearly |S| + |F | = 5. By PHP either |F | ≥ 3 or |S| ≥ 3.
Case 1: |F | ≥ 3. If any two in F are friends then those two along with a are three mutual
friends. Else F is a set of mutual strangers of size at least 3.
Case 2: |S| ≥ 3. If any pair in S are strangers then those two along with a are
three mutual strangers. Else S becomes a set of mutual friends of size at least 3.
4. If 7 points are chosen inside or on the unit circle, then there is a pair of points which are
at a distance at most 1.
118 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
Ans: To see this divide the circle into 6 equal cone type parts creating an angle of
60o with the center. By PHP there is a part containing at least two points. The
distance between these two is at most 1.
5. If n + 1 integers are selected from [2n], then there is a pair which has the property
that one of them divides the other.
Ans: Each number has the form 2k O, where O is an odd number. There are n
odd numbers. If we select n + 1 numbers from S, by PHP some two of them (say, x, y)
have the same odd part, that is, x = 2i O and y = 2j O. If i ≤ j, then x|y, otherwise y|x.
6. (a) Let r1 , r2 , · · · , rmn+1 be a sequence of mn + 1 distinct real numbers. Then, prove that
there is a subsequence of m + 1 numbers which is increasing or there is a subsequence
of n + 1 numbers which is decreasing.
Ans: Define li to be the maximum length of an increasing subsequence starting at
ri . If some li ≥ m + 1 then we have nothing to prove. So, let 1 ≤ li ≤ m.
Since (li ) is a sequence of mn + 1 integers, by PHP, there is one number which
repeats at least n + 1 times. Let li1 = li2 = · · · = lin+1 = s, where i1 < i2 < · · · <
in+1 . Notice that ri1 > ri2 , because if ri1 ≤ ri2 , then ‘ri1 together with the
increasing sequence of length s starting with ri2 ’ gives an increasing sequence of
length s + 1. Similarly,
ri2 > ri3 > · · · > rin+1 and hence the required result
holds.
Alternate. Let S = {r1 , r2 , · · · , rmn+1 } and define a map f : S → Z × Z
by
f (ai ) = (s, t), for 1 ≤ i ≤ mn + 1, where s equals the length of the largest
increasing subsequence starting with ai and t equals the length of the largest
decreasing sub- sequence ending at ai . Now, if either s ≥ m + 1 or t ≥ n + 1, we
are done. If not, then note that 1 ≤ s ≤ m and 1 ≤ t ≤ n. So, the number of
tuples (s, t) is at most mn. Thus, the mn + 1 distinct numbers are being mapped
to mn tuples and hence
by PHP there are two numbers ai = aj such that f (ai ) = f (aj ). Now, proceed as
in the previous case to get the required result.
(b) Does the above statement hold for every collection of mn distinct numbers?
No.
Consider the sequence:
7. Given any 1010 integers, prove that there is a pair that either differ by, or sum to,
a multiple of 2017. Is this true if we replace 1010 by 1009?
Then, the tuple (p1 , q1 ) = (⌊ja⌋ − ⌊ia⌋, j − i) satisfies the required property. To
generate another tuple, find m2 such that
1 p
< |a − 1 |
m2 q1
and
1
proceed as before to get (p2 , q2 ) such that |q2 a − p2 | < ≤ 1
. Since |a − p2
|< 1
<
m2 q2 q2 m2
p1 p1 p2
|a − q1 |, we have q1 = q2 . Now use induction to get the required result.
9. Prove that there exist two powers of 3 whose difference is divisible by 2017.
Ans: Let S = {1 = 30 , 3, 32 , 33 , . . . , 32017 }. Then, |S| = 2018. As the remainders of
any integer when divided by 2017 is 0, 1, 2, . . . , 2016, by PHP, there is a pair which
has the same remainder. Hence, 2017 divides 3j − 3i for some i, j.
10. Prove that there exists a power of three that ends with 0001.
Ans: Let S = {1 = 30 , 3, 32 , 33 , . . .}. Now, divide each element of S by 104 . As |S| >
104 , by PHP, there exist i > j such that the remainders of 3i and 3j , when divided by
104 , are equal. But gcd(104 , 3) = 1 and thus, 104 divides 3ℓ − 1. That is, 3ℓ − 1 = s · 104
for some positive integer s. That is, 3ℓ = s · 104 + 1 and hence the result follows.
Exercise 7.1.3. 1. Consider the poset (X = P ([4]), ⊆). Write 6 maximal chains P1 , . . . P6
(need not be disjoint) such that ∪ Pi = X . Let A1 , . . . , A7 be 7 distinct subsets of [4].
i
Use
PHP, to prove that there exist i, j such that Ai , Aj ∈ Pk , for some k. That is, {A1 , . . . , A7
}
cannot be an anti-chain. Conclude that this holds as the width of the poset is
6.
9P
2. Let {x1 , . . . , x9 } ⊆ N with xi = 30. Then, there exist i, j, k ∈ [9] with xi + xj + xk ≥
12.
i=1
3. Pick any 6 integers from [10], then there exists a pair with odd sum.
4. Any 14-subset of [46] has four elements a, b, c, d such that a + b = c + d.
5. In a row of 12 chairs 9 are filled. Then, some 3 consecutive chairs are filled. Will 8 work?
6. Every n-sequence of integers has a consecutive subsequence with sum divisible by n.
13. Choose 5 points at random inside an equilateral triangle of side 1 unit, then there exists
a pair which have distance at most 0.5 units.
14. Prove that among any 55 integers 1 ≤ x1 < x2 < x3 < · · · < x55 ≤ 100, there is a pair
with difference 9, a pair with difference 10, a pair with difference 12 and a pair with
difference
13. Surprisingly, there need not be a pair with difference 11.
15. Let {x1 , x2 , . . . , xn } ⊆ Z. Prove that there exist 1 ≤ i < j ≤ n such that
(a) xi + xi+1 + · · · + xj −1 + xj is a multiple of 2017, whenever n ≥
2017. (b) xj + xi or xj − xi is a multiple of 2017, whenever n ≥ 1009.
16. Let A and B be two discs, each having 2n equal sectors. On disc A, n sectors are
colored red and n are colored blue. The sectors of disc B are colored arbitrarily with red
and blue colors. Show that there is a way of putting the two discs, one above the other,
so that at least n corresponding sectors have the same colors.
17. There are 7 distinct real numbers. Is it possible to select two of them, say x and y such
x−y
that 0 < 1+xy < √13 ?
Qn
18. If n is odd then for any permutation p of [n] the product i − p(i) is even.
i=1
19. Fix a positive α ∈ Qc . Then, S = {m + nα : m, n ∈ Z} is dense in R.
20. Take 25 points on a plane satisfying ‘among any three of them there is a pair at a
distance less than 1’. Then, some circle of unit radius contains at least 13 of the given
points.
21. Five points are chosen at the nodes of a square lattice (view Z × Z). Why is it certain that
a mid-point of some two of them is a lattice point?
22. Each of the given 9 lines cuts a given square into two quadrilaterals whose areas are in
the ratio 2 : 3. Prove that at least three of these lines pass through the same point.
23. If more than half of the subsets of [n] are selected, then some two of the selected
subsets have the property that one is a subset of the other.
24. Given any ten 4-subsets of [11], some two of them have at least 2 elements in common.
25. A person takes at least one aspirin a day for 30 days. If he takes 45 aspirin
altogether then prove that in some sequence of consecutive days he takes exactly 14
aspirins.
7.2. PRINCIPLE OF INCLUSION AND
121 CHAPTER
EXCLUSION 121
7. ADVANCED COUNTING PRINCIPLES
26. If 58 entries of a 14 × 14 matrix are 1, then there is a 2 × 2 submatrix whose all entries 1.
27. Let A and B be two finite non-empty sets with B = {b1 , b2 , . . . , bm }. Let f : A → B be
any function. Then, for any non-negative integers a1 , a2 , . . . , am if |A| = a1 +a2 +· · ·+am
−m+1
−
then prove that there exists an i, 1 ≤ i ≤ m such that |f 1 (bi )| ≥ ai .
7.2. PRINCIPLE OF INCLUSION AND
122 CHAPTER
EXCLUSION 121
7. ADVANCED COUNTING PRINCIPLES
Exercise 7.1.4. 1. If each point of a circle is colored either red or blue, then show that
there exists an isosceles triangle with vertices of the same color.
2. Each point of the plane is colored red or blue, then prove the following.
(a) There exist two points of the same color which are at a distance of 1
unit. (b) There is an equilateral triangle all of whose vertices have the same
color. (c) There is a rectangle all of whose vertices have the same color.
3. Let S ⊆ [100] be a 10-set. Then, some two disjoint subsets of S have equal sum.
4. For n ∈ N, prove that there exists a ℓ ∈ N such that n divides 2ℓ − 1.
5. Does there exist a multiple of 2017 that is formed using only the digits
(a) 2? Justify your answer.
(b) 2 and 3 and the number of 2’s and 3’s are equal? Justify your answer.
6. Each natural number has a multiple of the form 9 · · · 90 · · · 0, with at least one 9.
Example 7.2.1. How many natural numbers n ≤ 1000 are not divisible by any of 2, 3?
Ans: Let A2 = {n ∈ N | n ≤ 1000, 2|n} and A3 = {n ∈ N | n ≤ 1000, 3|n}. Then,
|A2 ∪ A3 | = |A2 | + |A3 | − |A2 ∩ A3 | = 500 + 333 − 166 = 667. So, the required answer is
1000 − 667 = 333.
n
X
n X
|U | − ∪ A i = |U | − (−1)k Ai1 ∩ · · · ∩ Ak i .
i=1
k=1 1≤i1 <···<ik ≤n
n
Proof. Let x ∪ Ai . Then, we show that inclusion of x in some Ai contributes (increases
i= 1
∈/
the value) 1 to both sides of Equation (7.1). So, assume that x is included only in the sets
A1 , · · · , Ar . Then, the contribution of x to |Ai1 ∩ · · · ∩ Aik | is 1 if and only if {i1 , . . . , ik } ⊆
[r].
P
Hence, the contribution of x to |Ai1 ∩ · · · ∩ Aik | is C (r, k). Thus, the contribution
1≤i1 <···<ik ≤n
of x to the right hand side of Equation (7.1) is
7.2. PRINCIPLE OF INCLUSION AND
123 CHAPTER
EXCLUSION 121
7. ADVANCED COUNTING PRINCIPLES
The element x clearly contributes 1 to the left hand side of Equation (7.1) and hence the required
result follows. The proof of the equivalent condition is left for the readers.
Example 7.2.3. How many integers between 1 and 10000 are divisible by none of 2, 3, 5, 7?
Ans: For i ∈ {2, 3, 5, 7}, let Ai = {n ∈ N | n ≤ 10000, i|n}. Therefore, the required answer
is
10000 − |A2 ∪ A3 ∪ A5 ∪ A7 | = 2285.
Definition 7.2.4. [Euler totient function] For a fixed n ∈ N, the Euler’s totient function
is defined as ϕ(n) = |{k ∈ N : k ≤ n, gcd(k, n) = 1}|.
Q
k
α
Theorem 7.2.5. Let n = pi i , be a factorization of n into distinct primes p1 , . . . , pk . Then,
i=1
1 1 1
ϕ(n) = n 1 − 1− · · · 1− .
p1 p2 pk
Proof. For 1 ≤ i ≤ k, let Ai = {m ∈ N : m ≤ n, pi |m}. Then,
h X k X i
1 1 1
ϕ(n) = n − | ∪ Ai | = 1 − + −···+ k
i pi
1≤i<j ≤k
p i p j (−1) p1 p2 · · · pk
n i=1
1 1
1 p p
= n 1− 1− · · · 1−
p1 2 k
n
as |Ai | = pi
, |Ai ∩ Aj | = p pn and so on. Thus, the required result follows.
i j
Proof. For each i, 1 ≤ i ≤ n, let Ai be the set of arrangements σ such that σ(i) = i. Then,
verify that |Ai | = (n − 1)!, |Ai ∩ Aj | = (n − 2)! and so on. Thus,
Xn
(−1)k−1
| ∪ Ai | = n.(n − 1)! − C (n, 2)(n − 2)! + · · · + C (n, n)0! = n! .
i
−1 k=1
k!
(−1)n
P
n
Dn 1
So, Dn = n! − ∪ Ai = n! (−1)k
k! . Furthermore, lim = .
i k=0 n→∞ n! e
Example 7.2.8. For n ∈ N, how many squarefree integers do not exceed n?
√
Ans: Let P = {p1 , · · · , ps } be the set of primes not exceeding n and for 1 ≤ i ≤ s, let Ai
be the set of integers between 1 and n that are multiples of pi2 . It is easy to see that
n n
7.2. PRINCIPLE OF INCLUSION AND
125 CHAPTER
EXCLUSION 121
7. ADVANCED COUNTING PRINCIPLES
|Ai | = ⌊ 2 ⌋, |Ai ∩ Aj | = ⌊ 2
⌋,
p
p2 i i pj
7.2. PRINCIPLE OF INCLUSION AND
123 CHAPTER
EXCLUSION
7. ADVANCED COUNTING PRINCIPLES
123
and so on. So, the number of squarefree integers not greater than n is
Xs X X
s n n n
n − | i=∪1 Ai | = n ⌊ 2⌋+ ⌊ 2 2⌋− ⌊ 2 2 2⌋+ · · ·
− p p p
i=1 i 1≤i<j ≤s i pj 1≤i<j <k≤s i pj pk
For n = 100, we have P = {2, 3, 5, 7}. So, the number of squarefree integers not exceeding 100
is
100 ⌋ − ⌊ 100 ⌋ − ⌊ 100 ⌋ − ⌊ 100 ⌋ ⌊ 100 ⌋ ⌊100 ⌋
100 − ⌊ + + = 61.
4 9 25 49 36 100
Exercise 7.2.9. 1. Let m, n ∈ N with gcd(m, n) = 1. Then, ϕ(mn) = ϕ(m)ϕ(n).
1 P r
2. Let n ∈ N. Then, use inclusion-exclusion to prove S(n, r) = (−1)i C (r, i)(r − i)
n .
r! i=0
3. In a school there are 12 students who take an art course A, 20 who take a biology
course B, 20 who take a chemistry course C and 8 who take a dance course D.
There are 5 students who take both A and B, 7 students who take both A and C , 4
students who take both A and D, 16 students who take both B and C , 4 students who
take both B and D and 3 students who take who take both C and D. There are 3 who
take A, B and C ; 2 who take A, B and D; 3 who take A, C and D; and 2 who take B, C
and D. Finally there are 2 in all four courses and further 71 students who have not taken
any of these courses. Find the total number of students.
4. Find the number of nonnegative integer solutions of a + b + c + d = 27, where 1 ≤ a ≤
5, 2 ≤ b ≤ 7, 3 ≤ c ≤ 9, 4 ≤ d ≤ 11.
5. Determine all integers n satisfying ϕ(n) = 13.
6. Determine all integers n satisfying ϕ(n) = 12.
P
7. For each fixed n ∈ N, use mathematical induction to prove that ϕ(d) = n.
d| n
12. Determine the number of 10-letter words using ENGLISH alphabets that does not
contain all the vowels.
7.2. PRINCIPLE OF INCLUSION AND
125 CHAPTER
EXCLUSION
7. ADVANCED COUNTING PRINCIPLES
125
14. Determine the number of ways to arrange 10 digits 0, 1, . . . , 9, so that the digit i is
never followed immediately by i + 1.
15. Determine the number of strings of length 15 consisting of the 10 digits, 0, 1, . . . , 9, so
that no string contains all the 10 digits.
16. Determine the number of ways of permuting the 26 letters of the ENGLISH alphabets so
that none of the patterns lazy, run, show and pet occurs.
17. Let x be a positive integer less than or equal to 9999999.
(a) Find the number of x’s for which the sum of the digits in x equals 30.
(b) How many of the solutions obtained in the first part consist of 7 digits?
Example 7.3.2. 1. How many words of size 8 can be formed with 6 copies of A and 6 copies
of B?
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
125 125
P
6
Ans: C (8, k), as we just need to choose k places for A, where 2 ≤ k ≤ 6.
k=2
Alternate. In any such word, we need m many A’s and n many B’s with m + n = 8,
8!
m ≤ 6 and n ≤ 6. Also, the number of words with m many A’s and n many B’s is .
m!n!
8!xm y n
We identify this number with and note that this is a term of degree 8 in
m!n!
h x2 x3 x4 x5 x6 ih y2 y3 y4 y5 y6 i
8! 1 + x + + + + + 1+ y+ + + + + .
2! 3! 4! 5! 6! 2! 3! 4! 5! 6!
If we replace y by x, then our answer is
h i
x2 x3 4 5 6 2 3 4 5 6
8!cf x8 , (1 + x + 2! + 3! + 4!x + 5!x + 6!x )(1 + x + 2!x + 3!x + 4!x + 5!x + 6!x )
h i
8 x2 x3 x4 x5 x6 x2 x3 x4 x5 x6
= 8!cf x , ( 2! + 3! + 4! + 5! + 6! )( 2! + 3! + 4! + 5! + 6! )
h i
2 3 2 3
= 8!cf x8 , ( 2!x + 3!x +· · ·)( x + x3! + · · ·)
2! 8
2 2
=
2 8!cf x8 , (ex − 1 − x)2 = e2x + 1 + x2 − 2xex − 2ex + 2x = 8! − − = 238.
8! 7! 8!
x4 x4 x2
as we need to have x, , and for the alphabets M, I , S and P , respectively.
4! 4! 2!
3. Prove that the number of nonnegative integer solutions of u + v + w + t = 10 equals
cf x10 , (1 + x + x2 + · · · )4 .
Ans: Note that u can take any value from 0 to 10 which corresponds to 1 + x + · · · +
x10 . Hence, using Theorem 6.6.1, the required answer is
−4 4· 5· · · ·
cf x10 , f = (1 + x + x2 + · · · )4 = (1 − x) = C (13, 10) = 10!
13
.
∞
Definition 7.3.3. [Generating functions] Let (br )0 be a sequence of integers. Then, the
1. ordinary generating function (ogf) is the formal power series
b0 + b1 x + b2 x2 + b3 x3 + · · · ,
and
x2 x3
b0 + b1 x + b2 + b3 + · · · .
2! 3!
If there exists an M ∈ N such that br = 0 for all r ≥ M , then the generating functions
have finitely many terms.
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
127 127
xn P P xn
Remark 7.3.5. 1. Let f (x) = , g(x) =
an bn ∈ P(x). Then, in case of egf,
n≥0 n! n≥0 n!
P xn Pn
n
their product equals dn , where dn = a b
k k n−k
, for n ≥ 0.
n≥0 n! k=0
ex −1
P yn ex −1
P (ex − 1)n
2. Note that e ∈ P(x) as e = y
implies that e = and
n≥0 n! n≥0 n!
x−
X (ex − 1)n X
m
(e x − 1)n
cf xm , ee 1 m
= cf x , = cf xm , . (7.2)
n! n!
n≥0 n=0
With the algebraic operations as defined in Definition 1.3, it can be checked that P(x) forms a
Commutative Ring with identity, where the identity element is given by the formal power series
P
f (x) = 1. In this ring, the element f (x) = an xn is said to have a reciprocal if there exists
P n≥0
another element g(x) = bn xn ∈ P(x) such that f (x) · g(x) = 1. So, the question arises, under
n≥0
what conditions on cf[xn , f ], can we find g(x) ∈ P(x) such that f (x)g(x) = 1. The answer to
this question is given in the following proposition.
as 1 = c0 − · (a b ) as 0 = c = 0 −
· (a2 b0 + a1 b1 )
1 0 1 a
= a0 b0 ; 0
b1 = a0 b1 + a1 b0 ; b2 = 1 a
as 0 = c2 = a0 b2 + a1 b1 + a2 b0 ; and in general, if we have computed bk , for k ≤ r, then using
1
0 = cr+1 = ar+1 b0 + ar b1 + · · · + a1 br + a0 br+1 , = · (ar+1 b0 + ar b1 + · · · + a1 br ).
br+1 −
a
0
Hence, the required result follows.
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
129 129
may not be defined (just to compute the constant term of the composition, one may have
to look at an infinite sum of rational numbers). For example, let f (x) = ex and g(x) = x + 1.
Note that g(0) = 1 = 0. Here, (f ◦ g)(x) = f (g(x)) = f (x + 1) = ex+1 . So, as function f ◦ g
is well
P
defined, but there is no formal procedure to write ex+1 as ak xk ∈ P(x) (i.e., with ak ∈ Q)
k ≥0
and hence ex+1 is not a formal power series over Q. The next result gives the condition under
which the composition (f ◦ g)(x) is well defined.
Proposition 7.3.7. Let f, g ∈ P(x). Then, the composition (f ◦ g)(x) ∈ P(x) if either f is
with cf x0 , g(x) = 0, such that (f ◦ g)(x) = x. Furthermore, (g ◦ f )(x) ∈ P(x) and (g ◦ f )(x)
= x.
P
Proof. As (f ◦ g)(x) ∈ P(x), let (f ◦ g)(x) = f (g(x)) = cn xn and suppose that either f is
a
n≥0
polynomial or cf x0 , g(x) = 0. Then, to compute ck = cf xk , (f ◦ g)(x) , for k ≥ 0, one just
P
k P
needs to consider the terms ak (g(x))n , whenever f (x) = an xn . Hence, each ck ∈ Q and
n=0 n≥ 0
thus, (f ◦ g)(x) ∈ P(x). This completes the proof of the first part. We leave the proof of the
other part for the reader.
Proposition 7.3.8. [Basic tricks] Recall the following statements from Binomial theorem and
Theorem 6.6.1.
−r
1. cf xn , (1 − x) = (1 + x + x2 + · · · )r = C (n + r − 1, n).
2. (1 − xm )n = 1 − C (n, 1)xm + C (n, 2)x2m − · · · + (−1)n xnm .
n
−1 n 1 − xm
3. (1 + x + x2 + · · · + xm ) = (1 − xm )n (1 + x + x2 + · · · )n .
= 1−x
We now define the formal differentiation in P(x) and give some important results. The
proof is left for the reader.
P
Definition 7.3.9. [Differentiation] Let f (x) = an xn ∈ P(x). Then, the formal differenti-
n ≥0
′
ation of f (x), denoted f (x), is defined by
′ −1
X
f (x) = a1 + 2a2 x + · · · + nan xn +···= nan
n− 1
x .
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
130 130
n≥1
Proposition 7.3.10. [ogf: tricks] Let g(x), h(x) be the ogf ’s for the sequences (ar 0)∞ , (br0)∞ ,
respectively. Then, the following are true.
∞
1. Ag(x) + Bh(x) is the ogf for (Aar + Bbr 0) .
2. (1 − x)g(x) is the ogf for the sequence a0 , a1 − a0 , a2 − a1 , · · · .
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
131 131
−1 ∞
3. (1 + x + x2 + · · · )g(x) = (1 − x) 0 r ) , where Mr = ar−1 + · · · + a0 .
g(x) is the ogf for (M
+ ar
∞
4. g(x)h(x) is the ogf for (cr )0 , where cr = a0 br + a1 br−1 + a2 br−2 + · · · + ar b0 .
′ ∞
5. xf (x) is the ogf for (rar )1 .
Proof. For example, to prove (3), note that if g(x) = a0 + a1 x + a2 x2 + · · · , then the
coefficient of x2 in (1 + x + x2 + · · · )(a0 + a1 x + a2 x2 + · · · ) is a2 + a1 + a0 .
∞
Example 7.3.11. 1. Let ar = 1 for all r ≥ 0. Then, the ogf of the sequence (ar )0 equals
−1
1 + x + x2 + · · · = (1 − x) = f (x). So, for r ≥ 0, the ogf for
′
(a) ar = r is xf (x) and
′ ′′
(b) ar = r 2 is x f (x) + xf (x) .
′ ′ ′′ −2 −3
(c) ar = 3r + 5r 2 is 3xf (x) + 5 xf (x) + x2 f (x) = 8x(1 − x) + 10x2 (1 − x) .
Alternate. We can think of the problem as follows: the above system can be interpreted
as coming from the monomial xr , where r = y1 + · · · + yn . That is, the problem
reduces to finding the coefficients of xyk of a formal power series, for yk ≥ 0. Now,
recall that
−
cf y xk , (1 − y) 1 = 1. Hence, the question reduces to computing
1 1
cf xr , = cf y r , = C (r + n − 1, r).
(1 − y)(1 − y) · · · (1 − (1 − y)n
y)
∞
P 1 −1 . Then, the required sum is 1 f ′ (1/2) = 2.
2k k. Put f (x) = (1 − x)
4. Evaluate 2
k=0
Alternately (rearranging terms of an absolutely convergent series) it is
1
2
+
1
4
+ 1
4
+
1
8
+ 1
8
+ 1
8
+
..
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
132 132
1 +21 + · · · =
2.
P
5. Determine a closed form expression for nxn ∈ P(x).
n≥0
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
133 133
!′
−1 P −2 −1 ′ P P
Ans: As (1 − x) = x , one has (1 − x)
n
= (1 − x) = xn = nxn
−1
.
n≥0 n ≥0 n≥0
x
Thus, the closed form expression is .
(1 − x)2
P
Alternate. Let S = nxn = x + 2x2 + 3x3 + · · · . Then, xS = x2 + 2x3 + 3x4 + · · · .
n ≥0
P k P k x x
Hence, (1 − x)S = x =x x = . Thus, S = .
k≥1 k≥0 −
1 x −
(1 x)2
6. Determine the sum of the first N positive integers.
− −
Ans: Using previous example, note that k = cf xk 1 , (1 − x) 2 . Therefore, by Propo-
P
N − − −
sition 7.3.10, one has k = cf xN 1 , (1 − x) 1 · (1 − x) 2 and hence
k=1
X
N
−1 −3 N (N + 1)
k = cf xN , (1 − x) = C (N + 1, N − 1) = .
2
k=1
X
N
1 1 1
k2 = xN , · x(1 + x) = cf xN −1 , −
xN 2 , − 4
1 − x (1 − x)3 (1 − x)4 + cf (1 x)
cf
k=1
N (N + 1)(2N + 1)
= C (N + 2, N − 1) + C (N + 1, N − 2) .
6
=
Exercise 7.3.12. 1. For n, r ∈ N, determine the number of solutions to x1 +2x2 +· · ·+nxn =
r with xi ∈ N0 , 1 ≤ i ≤ n.
P
∞
1
2. Determine 2k C (n + k − 1, k).
k=0
(a) 3 ≤ a ≤ 8,
(b) 3 ≤ a, b, c, d ≤ 8
(c) c is a multiple of 3 and e is a multiple of 4.
4. Determine the number of ways in which 100 voters can cast their 100 votes for 10
candi- dates such that no candidate gets more than 20 votes.
P
N
5. Determine a closed form expression for k3 .
k=1
P
6. Determine a closed form expression for
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
134 134
n≥0
n2 + n + 6
.
n!
7. Verify the following table of formal power series.
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
130 130
• • • • • → 9 : I -hook
••••• ••••••
••• •••• • • • • • → 7 : I I -hook
••• ••• • • • • → 3 : I I I -hook
•• •
• • • • •
• • •
(5, 3, 3, 2, 1, 1) (6, 4, 3, 1, 1) (5, 5, 4, 3, 2)
Figure 7.1: Ferrer’s diagram and it’s conjugate
Definition 7.3.15. [Self conjugate] A partition λ is said to be self conjugate if the Ferrer’s
′
diagram of λ and λ is the same.
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
131 131
Example 7.3.16. Find a one-one correspondence between self conjugate partitions and parti-
tions of n into distinct odd terms.
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
132 132
Ans: Let λ be a self conjugate partition with k diagonal dots. For 1 ≤ i ≤ k, define ni =
number of dots in the i-th ‘hook’ (dotted lines in Figure 7.1). Conversely, given any
partition, say (x1 , . . . , xk ) with odd terms, we can get a self conjugate partition by putting x1
dots in the first ‘hook’, x2 dots in the second ‘hook’ and so on. Since each xi is odd, the hook is
symmetric and xi ≤ xi−1 + 2 for 2 ≤ i ≤ k implies that the corresponding diagram of dots
is indeed a
Ferrer’s diagram and hence the result
follows.
Proof. Note that any partition λ of n has m1 copies of 1, m2 copies of 2 and so on till
mn n
P
copies of n, where mi ∈ N0 for 1 ≤ i ≤ n and mi = n. Hence, λ uniquely corresponds to
i=1
(x1 )m1 (x2 )m2 · · · (xn )mn in the word-expansion of
(1 + x + x2 + · · · )(1 + x2 + x4 + · · · ) · · · (1 + xn + x2n + · · · ).
Example 7.3.18. Let f (n) be the number of partitions of n in which no part is 1. Then, note
that the ogf for f (n) is (1 − x)ε(x). Hence, f (n) = πn − πn−1 .
Alternate. Let λ = (n1 , . . . , nk ) be a partition of n with nk = 1. Then, λ gives a
partition of n − 1, namely (n1 , . . . , nk−1 ). Conversely, if µ = (t1 , . . . , tk ) is a partition of
n − 1, then (t1 , . . . , tk , 1) is a partition of n with last part 1, Hence, the required result
follows.
The next result is the same idea as Theorem 7.3.17 and hence the proof is omitted.
Q
r
Theorem 7.3.19. The number of partitions of n with entries at most r is cf xn , 1
1−xi .
i=1
Theorem 7.3.20. [ogf of πn (r)] Fix n, r ∈ N. Then, the ogf for πn (r), the number of partitions
r
of n into r parts, is (1−x)(1−xx2 )···(1−xr ) .
′
Proof. Let λ be a partition of n into at most r parts. Then, λ corresponds to a partition of
n with entries at most r. Now, add a column of dots of height r on the left of the
′
Ferrer’s diagram of λ . Then, the new Ferrer’s diagram corresponds to a partition of n + r into
r parts.
Conversely, given a partition of n + r into r parts, the inverse map gives a partition of n into at
most r parts. Thus, by Theorem 7.3.19, we get
n−r xr
πn (r) = cf x ,
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
133 133
1 (1 − x)(1 − x2 ) · · · (1 − xr
. )
Hence, the ogf for πn (r) is .
(1 − x)(1 − x ) · · · (1 − x )
2 r
Exercise 7.3.21. 1. For n, r ∈ N, prove that πn (r) is the number of partitions of n + C (r, 2)
into r unequal parts.
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
134 134
2. Let P, M ⊆ N and f (n) be the number of partitions of n where parts are from P and
multiplicities are from M . Find the generating function for the numbers f (n).
1. If there is an unlimited supply of each object, then the egf of the number of r-
permutations is ekx .
2. If there are mi copies of i-th object, then the egf of the number of r-permutations is
x2 · · · m1 x2 xmk
1+ x+ + x · · 1+ x+ +· · · m ! .
2! 2! k
+ m1 ! · +
Proof. Part 1: Since there are unlimited supply of each object, the egf for each object corresponds
xn · · ·
to e = 1 + x + · · ·
x + . Hence, the required result follows.
+ n!
Part 2: Argument is similar to that of Part 1 and is omitted.
Part 3: Recall that n!S(r, n) is the number of surjections from [r] to S = {s1 , · · · , sn }.
Each surjection can be viewed as word of length r of elements of S, with each si appearing
at least
P
n
once. Thus, we need a selection of ki ∈ N copies of si , with ki = r. Also, by Theorem 6.1.26,
i=1
this number equals C (r; k1 , · · · , kn ). Hence,
x2 x3 n
n!S(r, n) = r!cf xr , x + + +·· = cf xr , (ex − 1)n .
·
2! 3! r!
Example 7.3.23. 1. In how many ways can you get Rs 2007 using denominations 1, 10, 100,
1000 only?
1
Ans: cf x2007 ,
(1 − x)(1 − x )(1 − x100 )(1 − x1000 ) .
10
3. Every natural number has a unique base-r representation (r ≥ 2). Note that Item (2)
corresponds to the case r =
10.
4. Consider n integers k1 < k2 < · · · < kn with gcd(k1 , . . . , kn ) = 1. Then, the number
of natural numbers not having a partition using {k1 , . . . , kn } is finite. Since gcd(k1 , . . . ,
kn ) =
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
135 135
P
1, there exist αi ∈ Z such that αi ki = 1. Let m = max{|α1 |, . . . , |αn |}, k = min{ki }
and
P
N = km(k1 +· · ·+kn ). Notice that N, N +k, N +2k, . . . can be represented as βi ki
where
P P
βi ≥ km. For 1 ≤ r < k, we have N + r = km(k1 + · · · + kn ) + r αi ki = (km −
rαi )ki .
Thus, each integer greater than N can be represented using k1 , . . . , kn . Determining
the largest such integer (Frobenius number) is the coin problem/ money
changing problem. The general problem is NP-hard. No closed form formula is known
for n > 3.
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
136 136
Notice!
Some times we have a way to obtain a recurrence relation from the generating
function. This is important and hence study the next example carefully.
1
Example 7.3.24. 1. Suppose F = = a0 + a1 x + · · · +
(1 − x)(1 − x10 )(1 − x100 )(1 − x1000 )
an xn + · · · . Then, taking log and differentiating, we get
′ 1 10x9 100x99 1000x999
F =F + + + .
1−x 1−x 10 1−x 100 1 − x1000
So,
10x9 100x99 X
n
1 1000x999
nan = cf x n−1
,F
′
= xn−1 , F + + + = an−k bk ,
1−x 1−x 10 1−x 100
1 − x1000 k=1
cf
where
1 if 10 ∤ k
1 10x 100x 9
1000x 99 999 11 if 10|k, 100 ∤ k
k−1
bk = cf x , + + + =
1−x 1−x 10
1 − x100 1 x1000
−
111 if 10|k, 100|k, 1000 ∤ k
1111 else.
P
n
1
P
n
1
2. We know that n→∞
lim k = ∞. What about lim pk , where pk is the k-th prime?
k=1 n→∞ k=1
P
n
1
Ans: For n > 1, let sn = k. Then, note that
k=1
1 1 1 1 1 1 Y
n
1
sn ≤ 1 + + + · · 1+ + + · · ·· 1+ +·· = (1 + ).
2 4 3 9 pn + pn2 pk − 1
· · · · k=1
Thus,
!
Y
n X
n X
n n−1
1 1 1 ≤ 1
log sn ≤ log (1 + ) ≤ log(1 + )≤ 1+ X .
k=1
pk − 1 pk − 1 pk − 1 p k
k=1 k=1 k=1
P
n
1
As sn → ∞, we see that lim pi = ∞ as n→∞
lim log sn = ∞.
n→∞ i
3. Let S be the set of natural numbers with only prime divisors 2, 3, 5, 7. Then,
X 1 1 1 1 1 1 2357
1+ = (1 + + + · · · )(1 + + + · · · ) · · · (1 + + · · · ) = .
1
+
n 2 4 3 9 7 49 1246
n ∈S
P nP
Exercise 7.3.25. 1. Let σ(n) = d, for n ∈ N. Then, prove that nπn = πn−k σ(k).
d|n k=1
2. A Durfee square is the largest square in a Ferrer’s diagram. Find the generating function
for the number of self conjugate partitions of n with a fixed size k of Durfee square. Hence,
X∞ k=1
3
show that (1 + x)(1 + x ) · · · = 1 +
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
137 137
x
k
2
.
(1 − x2 )(1 − x4 ) · · ·
(1 − x2k )
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
138 138
3. Show that the number of partitions of n into distinct terms ( each term is distinct) is the
same as the number of partitions of n into odd terms (each term is odd).
4. Find the number of r-digit binary numbers that can be formed using an even number of
0’s and an even number of 1’s.
5. Find the egf of the number of words of size r using A, B, C, D, E, if the word has
(a) all the letters and the letter A appears an even many times.
(b) all the letters and the first letter of the word appears an even number of times.
Hence, derive the relationship between the generating functions of (n!) and (cn ).
7. Let f (n, r) be the number of partitions of n where each part repeats less than r times.
Let g(n, r) be the number of partition of n where no part is divisible by r. Show that
f (n, r) = g(n, r).
8. Find the number of 9-sequences that can be formed using 0, 1, 2, 3 in each
case. (a) The sequence has an even number of 0’s.
(b) The sequence has an odd number of 1’s and an even number of 0’s.
(c) No digit appears exactly twice.
Definition 7.4.3. [Difference equation] For a sequence (an ), the first difference d(an ) is
an − an−1 . The k-th difference dk(an ) = dk−1(an ) − dk−1(an−1 ). A difference equation is
an equation involving an and its differences.
Example 7.4.4. 1. an − d2 (an ) = 5 is a difference equation. But, note that it doesn’t
give a recurrence relation as we don’t have any initial condition(s).
7.3. GENERATING FUNCTIONS CHAPTER 7. ADVANCED COUNTING PRINCIPLES
139 139
2. Every recurrence relation can be expressed as a difference equation. The difference equa-
tion corresponding to the recurrence relation an = 3 + 2an−1 is an = 3 + 2(an − d(an )).
If f = 0, then Equation (7.3) is homogeneous and is called the associated linear homogeneous
recurrence relation with constant coefficients (LHRRCC).
Theorem 7.4.8. For k ∈ N, let fi , 1 ≤ i ≤ k be known functions. Consider the k LNHRRCC
with the same set of initial conditions. If gi is a solution of the i-th recurrence then,
k
an = c1 an−1 + · · · + cr an−r + X αi fi (n) (7.5)
i=1
P
k
under the same set of initial conditions has αi gi (n) as it’s solution.
i=1
(7.6) Equation (7.6) is called the characteristic equation of the given LHRRCC. If x1 , . . . ,
xr are
P
r
the roots of Equation (7.6), then an = xin (and hence an = αi xi n for αi ∈ R) is a solution of
i=1
the given LHRRCC.
Proof. Let h(n) be any solution. Then, note that there exists α0 , . . . , αr−1 , such that
1 ···
h(0) α0
1
· · · xr−1
x0
.. = . ..
. . ,
h(r − 1) α r−1
x0 − · · · xr−1
r 1 r −1
P1
r−
as the r × r matrix is an invertible matrix. That is, for every αi ∈ R, h(n) = αi xi n , 0 ≤ n ≤
7.4. RECURRENCE RELATION
136 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
136
i=0
r − 1. Hence, we have proved the result for the first r values of h(n). So, let us assume that the
7.4. RECURRENCE RELATION
137 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
137
rP
−1
as for n = k, xki is a solution of Equation (7.6). Thus, by PMI, h(n) = αi xi n for all n. The
i=0
uniqueness is left as an exercise for the reader.
Example 7.4.11. 1. Solve an − 4an−2 = 0 for n ≥ 2 with a0 = 1 and a1 = 1.
Ans: Note that ±2 are the roots of the characteristic equation, x2 − 4 = 0. As the roots
are distinct, the general solution is an = α(−2)n + β2n for α, β ∈ R. The initial conditions
give α + β = 1 and 2β − 2α = 1. Hence, α = 1 , β = 3 . Thus, the unique solutions
is 4 4
−
an = 2n 2 3 + (−1)n .
2. Solve an = 3an−1 + 4an−2 for n ≥ 2 with a0 = 1 and a1 = c, a constant.
Ans: Note that −1 and 4 are the roots of the characteristic equation, x2 − 3x − 4 =
0. As the roots are distinct, the general solution is an = α(−1)n + β4n for α, β ∈ R.
−
Now, the initial conditions imply α = 4 c andβ = 1+c . Thus, the unique general solution
is 5 5
(4 − c)(−1)n (1 + c)4n
(a) an = + , if c = 4.
5 5
n
(b) an = 4 , if c = 4.
Theorem 7.4.12. [General solution: multiple roots] Let t is a root of Equation (7.6) of
−
multiplicity s. Then, u(n) = tn (α1 + nα2 + · · · + ns 1 αs ) is a solution (basic solution).
In
general, if ti is a root of Equation (7.6) with multiplicity si ), for i = 1, . . . , k, then every
solution is a sum of the k basic solutions.
−1
Proof. It is given that t is a zero of the polynomial F = xr − c1 xr − · · · − cr of multiplicity s.
n− r n−1 n−r
Put G0 = x n
F = x − c1 x − · · · − cr x and G1 = xG , G2 = xG′ , . . ., 1 = xG′s−2 .
′
Gs 0 1 −
Then, each of G0 , G1 , . . . , Gs−1 has a zero at t. That is, for i = 0, 1, . . . , s − 1, we have
−1 −r
Gi (t) = tn ni − c1 tn (n − 1)i − . . . − cr tn (n − r)i =
0.
s− 1
Now, take u(n) = tn P (n), where P (n) = 0 ≤ i ≤ s − 1. Then,
7.4. RECURRENCE RELATION
138 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
138
P
s−1 ni αi is a fixed polynomial, with αi ∈ R for
X i=0
−1 −r
αi Gi (t) = tn P (n) − c1 tn P (n − 1) − · · · − cr tn P (n − r) = 0.
i=0
7.4. RECURRENCE RELATION
139 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
139
Hence, for 0 ≤ i ≤ s − 1 and αi ∈ R, u(n) is a solution of the LHRRCC. The other part of the
proof is left for the reader.
Example 7.4.13. Suppose that a LHRRCC has roots 2, 2, 3, 3, 3. Then, the general solution
is given by 2n (α1 + nα2 ) + 3n (β1 + nβ2 + n2 β3 ).
Theorem 7.4.14. [LNHRRCC] Consider the LNHRRCC in Equation (7.3) and let un be a
general solution to the associated LHRRCC. If vn is a particular solution of the
LNHRRCC, then an = un + vn is a general solution of the LNHRRCC.
Notice!
No general algorithm are there to solve a LNHRRCC. If f (n) = an or nk or a
linear combination of these, then a particular solution can be obtained easily.
Ans: Observe that 1 and 2 are the characteristic roots of the associated LHRRCC (an =
3an−1 − 2a n−2 ). Thus, the general solution of the LHRRCC is un = α1n + β2n. Note that
5 is not a characteristic root and thus, vn = c5n is a particular solution of LNHRRCC
− −
if and only if c5n = 3c5n 1 − 2c5n 2 + 3(5)n . That is, if and only if c = 25/4. Hence,
the general solution of LNHRRCC equals an = α + β2n + (25/4)5n , where compute α
and β using the initial conditions.
7.4. RECURRENCE RELATION
140 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
140
3. In the above take f (n) = 3(2n ). Then, we see that with c(2)n as a choice for a
particular solution, we will have 4c = 6c − 2c + 12, an absurd statement. But, with the
choice cn(2)n , we have 4nc = 6(n − 1)c − 2(n − 2)c + 12, implying c = 6. Hence, the
general solution of LNHRRCC is an = α + β2n + 6n2n , where compute α and β using
the initial conditions.
7.4. RECURRENCE RELATION
141 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
141
Hence, F = 1 = 2
1−2x
− 1
1− x . Thus, an = cf[xn , F ] = 2n+1 − 1.
(1−x)(1−2x)
2. Find the ogf F for the Fibonacci recurrence relation an = an−1 + an−2 , a0 = 0, a1 = 1.
Ans: We have
∞
X ∞
X ∞
X ∞
X ∞
X
F = ai xi = x + i
2x + xi = x + x2 a xi + x a xi = x + (x2 + x)F.
ai −a i−1 i i
i=0 i=2 i=2 i=0 i=1
√ √
x −x −1 + 5 −1 − 5
Thus, F = = , where α = ,β= . So,
− −
1 x x 2
(x − α)(x − β) 2 X 2
∞
−x −1 α β 1 xi − xi
F = =√ − =√ .
(x − α)(x − β) 5 x−α x−β 5 αi β i
i=0
√ √
(−1)n n (1 + 5)n − (1 − 5)n
Hence, using α · β = −1, an = cf[xn , F ] √ (β − α ) =
n √ .
=
5 2n 5
The next result follows using a small calculation and hence the proof is left for the reader.
Theorem 7.5.2. [Obtaining generating function from recurrence relation] The generating
function of the r-th order LHRRCC an = c1 an−1 + · · · + cr an−r with initial conditions ai =
Ai , i = 0, 1, . . . , r − 1 is
−1
rP P
r−2 r −P
3 −1
Ai x i − c 1 x Ai xi − c2 x2 Ai xi − · · · − −1 xr A0
cr
i=0 i=0 i=0
.
1 − c 1 x − · · · − c r xr
Example 7.5.3. 1. Find the ogf for the Catalan numbers Cn ’s.
P C (2n,n)
Ans: Let g(x) = 1 + Cn xn , where Cn = n+1 with C0 = 1. Then,
n ≥1
∞
X 1 · 2n! n X 2(2n − 1)
n
X
g(x) − 1 = Cn x = x = Cn−1 xn
n + 1 n!n! n+1
n≥1 n≥1 n=1
X X Zx
∞ 4n + 4
n
∞ −6 n −6
= C x +
n−1 C n−1x = 4xg(x) + tg(t)dt.
n=1
n+1 n+1 x
n=1 0
Rx
So, [g(x) − 1 − 4xg(x)]x = −6 tg(t)dt. Now, we differentiate with respect to x to get
′ 0
g x(1 − 4x) + g(1 − 2x) = 1. To solve the ode, we first observe that
7.4. RECURRENCE RELATION
142 CHAPTER 7. ADVANCED COUNTING PRINCIPLES
142
Z Z
1 − 2x 1 2 x
= + = ln √ .
x(1 − 4x) x 1 − 4x 1 − 4x
7.5. GENERATING FUNCTION FROM
139 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
139
x
Thus, the integrating factor of the given ode is √ −
1 4x and hence the ode can be re-written
as
1 − 2x x
g(x) √ x 1 ⇔ d g(x) √ 1
′
+ g(x) = = .
1 − 4x (1 − 4x) 3/2 (1 − 4x)3/2 dx 1 − 4x (1 − 4x)3/2
That is, cf xn , xg(x)2 = Cn . Hence, g(x) = 1 + xg(x)2 . Solving for g(x), we get
r ! √
1 1 1 4 1 ± 1 − 4x.
g(x) = ± − =
2 x x2 x 2x
As the function g is continuous (being a power series in the domain of convergence) and
lim g(x) = C0 = 1, it follows that
x→0
√
1− 1 − 4x
g(x) = .
2x
n ≥ 1. Determine an .
P
Ans: Let g(x) = an xn . Then, note that C (n + r, r) = c(n + (r + 1) − 1, n). Hence,
n ≥0
7.5. GENERATING FUNCTION FROM
140 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
140
X !
g(x)2 = Xnak an−k X X 1
xn = C (n + r, r)xn = C (n + r, .
n
(1 − x)r+1
n)x =
n ≥0 k=0 n ≥0 n≥0
7.5. GENERATING FUNCTION FROM
141 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
141
1 i
Hence, a = cfhxn ,
n (1−x)(r+1)/2 . For example, for r = 2,
Now, using the initial conditions, F0 (x) = 1 and hence Fn (x) = (1 + x)n . Thus,
(
m n C (n, m) if 0 ≤ m ≤ n
f (n, m) = cf[x , (1 + x) ]
= 0 if m > n.
P
Alternate. Define Gm (y) = f (n, m)y n . Then, for m ≥ 1, Equation (7.9) gives
n ≥0
X X
Gm (y) = f (n, m)y n = (f (n − 1, m) + f (n − 1, m − 1)) y n
n≥0 n≥0
X X
= f (n − 1, m)y n + f (n − 1, m − 1)y n
n≥0 n≥0
= yGm (y) + yGm−1 (y).
y 1
Therefore, Gm (y) = Gm−1 (y). Using initial conditions, G0 (y) = . Hence,
1−y 1−y
m
y
Gm (y) = . Thus,
(1 − y)m+1
(
f (n, m) = cf y n , ym 1 C (n, m) if 0 ≤ m ≤ n
= cf y n−m , =
(1 − y) m+1 (1 − y) m+1
0 if m > n.
Therefore, Gm (y) = y G
m−1 (y). Using initial conditions, G0 (y) = 1 and hence
1 − my
ym Xm αk
Gm (y) = =m , (7.11)
(1 − y)(1 − 2y) · · · (1 − my) 1 − ky
y
k=1
where αk =
(−1)m−k k m
, for 1 ≤ k ≤ m. Thus,
k! (m − k)!
" #
X
m
αk X
m
αk
n m −m
S(n, m) = cf y , y = yn ,
1 − ky 1 − ky
k=1 cf
k=1
X
m Xm m−k n
n− m (−1) k
= αk k =
k=1 k=1
k! (m − k)!
1
Xm
− 1Xm
= (−1)m k k n C (m, k) = (−1)k (m − k)n C (m, k). (7.12)
m! k=1
m!
k=1
1 P m
Therefore, S(n, m) = (−1)k (m − k)n C (m, k).
m! k=1
This identity is generally known as the Stirling’s Identity.
Observation.
P
(a) Let us consider Hn (x) = S(n, m)xm . Then, verify that Hn (x) = (x + xD)n · 1
m≥0
as
H0 (x) = 1. Therefore, H1 (x) = x, H2 (x) = x + x2 , · · · . Thus, we don’t have a
single
expression for Hn (x) which gives the value of S(n, m)’s. But, it helps in showing that
S(n, m), for fixed n ∈ N, first increase and then decrease (commonly called unimodal).
The same holds for the sequence of binomial coefficients {C (n, m), m = 0, 1, . . . , n}.
(b) As there is no restriction on n.m ∈ N0 , Equation (7.12) is also valid for n < m. But,
we know that S(n, m) = 0, whenever n < m. Hence, we get the following identity,
Xm
(−1)m−k k n−1
= 0 whenever n < m.
k=1 (k − 1)! (m − k)!
5. Bell Numbers For n ∈ N, the n-th Bell number, denoted b(n), is the number of partitions
P
n
of [n]. Thus, b(n) = S(n, m), for n ≥ 1 and b(0) = 1. Hence, for n ≥ 1,
m=1
X
n X Xm (−1) m−k k n−1
b(n) = X S(n, m) = S(n, m) =
k≥1 k! (m − k)! e k! e k!
m≥k k ≥1 k ≥0
7.5. GENERATING FUNCTION FROM
143 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
143
kn
Thus, Equation (7.13) is valid even for n = 0. As b(n) has terms of the form , we
k!
P xn
compute its egf. Thus, if B(x) = b(n) then,
n≥0 n!
X n X X k xn
n
B(x) = 1+
x
b(n) = 1 + 1
n ≥1
n! n ≥1
e k≥1 k! n!
1X 1 X n 1 X 1 X (kx)n
= 1+ nx = 1+
e k≥1 k! k n! e k≥1 k! n≥1 n!
≥ n 1
1 X 1 kx 1X (ex )k
= 1+ e −1 = 1+ 1
e k≥1 k! e k≥1 k! −
k!
1 ex x−
= 1+ e − 1 − (e − 1) = ee 1 . (7.14)
e
Recall that ee −1 is a valid formal power series (see Remark 7.3.5).Taking logarithm of
x
′
Equation (7.14), we get log B(x) = ex − 1. Hence, B (x) = ex B(x), or equivalently
X b(n)xn−1 X xn X xm X xn
x = xex b(n) = x · b(n) .
n≥1 (n − 1)! n ≥0
n! m≥0 m! n≥0 n!
Thus,
b(n) X b(n)xn X xm X n
x
= cfxn , = cf xn−1 , b(n)
(n − 1)! −
(n 1)! ·
m! n≥0
n≥1 m≥0
n!
X
n−1 1
= · b(m) .
(n − 1 − m)! m!
m=0
P
n−1
Hence, we get b(n) = C (n − 1, m)b(m), for n ≥ 1, with b(0) = 1.
m=0
Exercise 7.5.4. 1. Find the number of binary words without having a subword 00 and 111.
Positive integer
N Y Y C (n − 1, r − 1)
solutions
Nonnegative
N Y N C (n + r − 1, r −
integer solutions 1)
N N Y r-partition of n πn (r)
h = i
n− r 1
cf x , (1−x)(1−x2 )···(1−xr )
N N N
Partitions of nT Pr
πn (i)
of length ≤ r i=1
3. Each of the 9 senior students said: ‘the number of junior students I want to help is exactly
one’. There were 4 junior students a, b, c, d, who wanted their help. The allocation
was done randomly. What is the probability that either a has exactly two seniors to help
him or b has exactly 3 seniors to help him or c has no seniors to help him?
4. In a particular semester 6 students took admission in our PhD programme. There were
9 professors who were willing to supervise these students. As a rule ‘a student can
have either one or two supervisors’. In how many ways can we allocate supervisors to
these students if all the ‘willing professors’ are to be allocated? What if we have an
additional condition that exactly one supervisor gets to supervise two students?
7.5. GENERATING FUNCTION FROM
145 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
145
5. How many lattice paths are there from (0, 0) to (9, 9) which does not cross the dotted line?
7.5. GENERATING FUNCTION FROM
146 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
146
(9, 9)
(0, 0)
12. We have an integer polynomial f (x). Fill in the blank with the smallest positive integer.
If f (x) = 2009 has many distinct integer roots, then f (x) = 9002 cannot have
an integer root.
13. In how many ways can one distribute
(a) 10 identical chocolates among 10 students?
(b) 10 distinct chocolates among 10 students?
(c) 10 distinct chocolates among 10 students so that each receives one?
7.5. GENERATING FUNCTION FROM
147 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
147
(d) 15 distinct chocolates among 10 students so that each receives at least one?
(e) 10 out of 15 distinct chocolates among 10 students so that each receives
one?
7.5. GENERATING FUNCTION FROM
148 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
148
15. What is the number of integer solutions of x + y + z = 10, with x ≥ −1, y ≥ −2 and
z ≥ −3?
1
16. Is the number of solutions of x+y +z = 10 in nonnegative multiples
2 of (x, y, z are
allowed to be 0, 1/2, 1, 3/2, . . . ) at most four times the number of nonnegative integer
solutions of x + y + z = 10?
17. How many words of length 8 can be formed using the English alphabets, where each
letter can appear at most twice? Give answer using generating function.
21. How many words of length 15 are there using the letters A,B,C,D,E such that each
letter must appear in the word and A appears an even number of times? Give your
answers using generating function.
7.5. GENERATING FUNCTION FROM
150 CHAPTER
RECURRENCE
7. ADVANCED
RELATION
COUNTING PRINCIPLES
150
22. The characteristic roots of a LHRRCC are 2, 2, 2, 3, 3. What is the form of the general
solution?
23. Consider the LNHRRCC an = c1 an− 1 + · · · +rc na−r + . Give a particular solution.
n
24. Obtain the ogf for an , where an = 2an−1 − an−2 + 5, an0 = 0, a1 = 1.
2
25. Solve the recurrence relation an = 2an−1 − an−2 + n + 5, a0 = 0, a1 = 1.
2
26. My class has n CSE, m MSC and r MC students. Suppose that t copies of the same
book are to be distributed so that each branch gets at least s. In how many ways can
this be done, if each student gets at most one? In how many ways can this be done,
without the previous restriction? Answer only using generating function.
Exercise 7.5.6. 1. My class has n CSE, m MSC and r MC students. Suppose that t distinct
books are to be distributed so that each branch gets at least s. In how many ways can
this be done, if each student gets at most one? In how many ways can this be done,
without the previous restriction? Answer only using generating function.
2. My class has N students. Assume that, to conduct an exam, we have M identical answer
scripts. In how many ways can we distribute the answer scripts so that each student gets
at least 2. Answer only using generating function.
3. My class has N students. Assume that, for an exam, we have M questions; each student
answers all the questions in an order decided by him/her (for example one can
follow
1, 2, · · · , M and another can follow M, M −1, · · · , 1). In how many ways can it happen that
some three or more students have followed the same order? Answer only using
generating function.
4. When ‘Freshers Welcome’ was organized 11 teachers went to attend. There were 4 types
of soft drinks available. In how many ways a total of 18 glasses of soft drinks can be
served to them, in general? Answer only using generating function.
Chapter 8
Graphs
Experiment
‘Start from a dot. Move through each line exactly once. Draw it.’ Which of the
following pictures can be drawn? What if we want the ‘starting dot to be the finishing
dot’ ?
Example 8.1.2. G = [4], {1, 1}, {1, 2}, {2, 2}, {3, 4}, {3, 4} is a pseudograph.
Example 8.1.4. A picture for the pseudograph in Example 8.1.2 is given in Figure 8.1.
1 2
3 4
Discussion 8.1.6. Note that a graph is an algebraic structure, namely, a pair of sets satisfying
some conditions. However, it is easy to describe and carry out the arguments with a pictorial
representation of a graph. Henceforth, the pictorial representations are used to describe graphs
and to provide our arguments, whenever required. There is no loss of generality in doing this.
Example 8.1.7. Consider the graph G in Figure 8.2. The vertex 12 is an isolated vertex. We
have N (1) = {2, 4, 7}, d(1) = 3. The set {9, 10, 11, 2, 4, 7} is an independent vertex set. The
set
{1, 2}, {8, 10}, {4, 5} is an independent edge set. The vertices 1 and 6 are not
adjacent.
Definition 8.1.8. [Complete graph, path graph, cycle graph and bipartite graph] Let G =
(V, E) be a graph on n vertices, say V = {v1 , . . . , vn }. Then, G is said to be a
8.1. BASIC CONCEPTS
149 CHAPTER 8. GRAPHS
149
1
A simple graph is a hypergraph, (V, E), if E is a collection of nonempty subsets of V .
8.1. BASIC CONCEPTS
150 CHAPTER 8. GRAPHS
150
4
5 13
8 6 3
10 12
2
7
11 9 1
The importance of the labels of the vertices depends on the context. At this point of
time, even if we interchange the labels of the vertices, we still call them a complete graph or
a path graph or a cycle or a complete bi-partite graph.
Quiz 8.1.9. What is the maximum number of edges possible in a simple graph of order n?1
P
Lemma 8.1.10. [Hand shaking lemma] In any graph G, d(v) = 2|E|. Thus, the number
v∈V
of vertices of odd degree is even.
P P
Proof. Each edge contributes 2 to the sum d(v). Hence, d(v) = 2|E|. Note that
v ∈V v ∈V
X X X
2|E| = d(v) = d(v) + d(v)
v∈V d(v) is odd d(v) is even
P
is even. So, d(v) is even. Hence, the number of vertices of odd degree is even.
d(v) is odd
Quiz 8.1.11. In a party of 27 persons, prove that someone must have an even number of friends
2
(friendship is mutual).
Proposition 8.1.12. In a graph G with n = |G| ≥ 2, there are two vertices of equal degree.
1
C (n, 2).
8.1. BASIC CONCEPTS
151 CHAPTER 8. GRAPHS
151
2
P
Otherwise d(v) is odd.
8.1. BASIC CONCEPTS
150 CHAPTER 8. GRAPHS
150
1 4 3 4 5
1 2 2 3 1 2 1 2 3
K1,1 K1,2 K2,2 K2,3
1 4 3 3
2
4
1 1 2 2 3 1 2 1
5
K1 K2 K3 K4 K5
1 4 3 3
2 2 4
4 5 1
2 3 1 2 1
5 3 6
C3 C4 C5 C6
1 4 3 2 1
1 1 2 2 3 1 2 3 4 5
P1 P2 P3 P4 P5
Proof. If G has two or more isolated vertices, we are done. So, suppose G has exactly one
isolated vertex. Then, the remaining n − 1 vertices have degree between 1 and n − 2 and
hence by PHP, the result follows. If G has no isolated vertex then G has n vertices whose degree
lie between 1 and n − 1. Now, again apply PHP to get the required result.
Example 8.1.13. The graph in Figure 8.5 is called the Petersen graph. We shall use it as
an example in many places.
3
2
8 7
9
4
6
10
1
5
Figure 8.5: Petersen graphs
also odd.
2. Let X = (V, E) be a graph having exactly two vertices, say u and v, of odd degree.
Then, prove that there is a path in X connecting u and v.
Definition 8.1.15. [Regular graph, cubic graph] The minimum degree of a vertex in G is
denoted δ(G) and the maximum degree of a vertex in G is denoted ∆(G). A graph G is called
k-regular if d(v) = k for all v ∈ V (G). A 3-regular graph is called cubic.
Example 8.1.16. 1. The graph Kn is regular.
2. The graph K4 is cubic.
3. The graph C4 is 2-regular.
4. The graph P4 is not regular.
5. The Petersen graph is cubic.
6. Consider the graph G in Figure 8.2. We have δ(G) = 0 and ∆(G) = 3.
Definition 8.1.18. [Subgraph, induced subgraph, spanning subgraph and k-factor] A graph
H is a subgraph of G if V (H ) ⊆ V (G) and E(H ) ⊆ E(G). If U ⊆ V (G), then the subgraph
induced by U is denoted by hU i = (U, E), where the edge set E = {uv ∈ E(G) | u, v ∈ U }.
A subgraph H of G is a spanning subgraph if V (G) = V (H ). A k-regular spanning subgraph
is
called a k-factor.
Example 8.1.19. 1. Consider the graph G in Figure 8.2.
(a) Let H1 be the graph with V (H1 ) = {6, 7, 8, 9, 10, 12} and E(H1 ) = {6, 7}, {9, 10} .
Then, H1 is not a subgraph of G.
(b) Let H2 be the graph with V (H2 ) = {6, 7, 8, 9, 10, 12} and E(H2 ) = {6, 7}, {8, 10} .
Then, H2 is a subgraph but not an induced subgraph of G.
(c) Let H3 be the induced subgraph of G on the vertex set {6, 7, 8, 9, 10, 12}. Then,
Quiz 8.1.20. Consider K8 on the vertex set [8]. How many 1-factors does it have?2
e ∈ E(G), then the graph G − e = (V, E(G) \ {e}). If u, v ∈ V (G) such that u ≁ v, then
G + uv = (V, E(G)
∪{uv}).
1
P
No, as d(v) = 15, not even.
2 4
8!/(2!) .
8.1. BASIC CONCEPTS
153 CHAPTER 8. GRAPHS
153
Example 8.1.22. Consider the graph G in Figure 8.2. Let H2 be the graph with V (H2 ) =
{6, 7, 8, 9, 10, 12} and E(H2 ) = {6, 7}, {8, 10} . Consider the edge e = {8, 9}. Then, H2 +
e is the induced subgraph h{6, 7, 8, 9, 10, 12}i and H2 − 8 = h{6, 7, 9, 10, 12}i.
4 3 4 3 3 3
2 2
4 4
1 2 1 2 1 1
5 5
C4 C4 C5 C5 = C5
Figure 8.6: Complement graphs
3. Show that a k-regular simple graph on n vertices exists if and only if kn is even and
n ≥ k + 1.
Definition 8.1.26. [Intersection, union and disjoint union] The intersection of two
graphs G and H , denoted G ∩ H , is defined as (V (G) ∩ V (H ), E(G) ∩ E(H )). The union of
two graphs G and H , denoted G ∪ H , is defined as (V (G) ∪ V (H ), E(G) ∪ E(H )). A disjoint
union of two graphs is the union while treating the vertex sets as disjoint sets.
Example 8.1.27. Two graphs G and H are shown below. The graphs G ∪ H and G ∩ H are
also shown below.
2 2 2 2
4 4
1 3 1 1 3 1
G H G∪H G∩H
2 b a 2
′
2 2
′
4
K2 c K3
′ ′
1 3 1 3
1 a 1 b
G1 K2 + K3 K2 + K2
Figure 8.7: Disjoint union and join of graphs
′ ′
Definition 8.1.28. [Join of two graphs] If V (G) ∩ V (G ) = ∅, then the join G + G is
′ ′ ′ ′
defined as G ∪ G + {vv : v ∈ V, v ∈ V }. The first ‘+’ means the join of two graphs and
the second
‘+’ means adding a set of edges to a given graph.
8.2 Connectedness
Definition 8.2.1. [Walk, trail, path, cycle, circuit, length and internal vertex] An u-v
walk in G is a finite sequence of vertices [u = v1 , v2 , · · · , vk = v] such that vi vi+1 ∈ E, for
all i = 1, · · · , k − 1. The length of a walk is the number of edges on it. A walk is called a
trail if edges on the walk are not repeated. A v-u walk is a called a path if the vertices
involved are all
distinct, except that v and u may be the same. A path can have length 0. A walk (trail, path)
8.2. CONNECTEDNESS
154 CHAPTER 8. GRAPHS
154
1
G+ H.
8.2. CONNECTEDNESS
155 CHAPTER 8. GRAPHS
155
Example 8.2.2.
(a) Take G = K5 with vertex set
[5].
• Then, [1, 2, 3, 2, 1, 2, 5, 4, 3] is a 8-walk in G and [1, 2, 2, 1] is not a
walk.
• The walk [1, 2, 3, 4, 5, 2, 4, 1] is a closed
trail.
• The walk [1, 2, 3, 5, 4, 1] is a closed path, that is, it is a 5-
cycle.
• The maximum length of a cycle in G is 5 and the minimum length of a cycle in G is 3.
•There are 10 = C (5, 3) many 3-cycles in
G.
• Verify that the number of 4-cycles in G is not C (5,
4). (b) Let G be the Petersen graph.
• There is a 9-cycle in G, namely, [6, 8, 10, 5, 4, 3, 2, 7, 9,
6].
• There are no 10-cycles in G. We shall see this when we discuss the Eulerian graphs.
Proof. If no vertex on W repeats, then W is itself a path. So, let ui = uj for some i < j. Now,
consider the walk W1 = [u1 , . . . , ui−1 , uj , uj +1 , . . . uk ]. This is also an u-v walk but of
shorter length. Thus, using induction on the length of the walk, the desired result follows.
Definition 8.2.4. [Distance, diameter, radius, center and girth] The distance d(u, v) of two
vertices in G is the shortest length of an u-v path in G. If no such path exists, the
distance is taken to be ∞. The greatest distance between any two vertices in a graph G is
called the
diameter of G. We shall use diam(G) to denote the diameter of G. Let distv = max d(v,
u).
u∈G
The radius is the min distv and the center consists of all vertices v for which distv is the radius.
v ∈G
The girth, denoted g(G), of a graph G is the minimum length of a cycle contained in G. If G
has no cycle, then we put g(G) = ∞.
Example 8.2.5. Let G be the Petersen graph. It has diameter 2. The radius is 2. Each vertex
is in the center. Its girth is 5.
8.2. CONNECTEDNESS
156 CHAPTER 8. GRAPHS
156
Practice 8.2.6. Determine the diameter, radius, center and girth of the following graphs: Pn
,
Cn , Kn and Kn,m = K n + K
m.
Exercise 8.2.7. Let G be a graph. Then, show that the distance function d(u, v) is a
metric on V (G). That is, it satisfies
1. d(u, v) ≥ 0 for all u, v ∈ V (G) and d(u, v) = 0 if and only if u = v,
2. d(u, v) = d(v, u) for all u, v ∈ V (G) and
3. d(u, v) ≤ d(u, w) + d(w, u) for all u, v, w ∈ V (G).
8.2. CONNECTEDNESS
157 CHAPTER 8. GRAPHS
157
Proposition 8.2.8 (Technique). Let G be a graph with kGk ≥ 1 and d(v) ≥ 2, for each
vertex
except one, say v1 . Then, G has a
cycle.
Proof. Consider a longest path [v1 , . . . , vk ] in G (as V (G) is finite, such a path exists).
As d(vk ) ≥ 2, it must be adjacent to some vertex from v2 , . . . , vk−2 , otherwise, we can extend
it to a longer path. Let i ≥ 2 be the smallest such that vi is adjacent to vk . Then, [vi , vi+1 , . . . ,
vk , vi ] is a cycle.
Proposition 8.2.9 (Technique). Let P and Q be two different u-v paths in G. Then, P ∪
Q
contains a cycle.
Proof. Imagine a signal was sent from u to v via P and was returned back from v to u via Q.
Call an edge ‘dead’ if signal has passed through it twice. Notice that each vertex receives
the signal as many times as it sends the signal.
Is E(P ) = E(Q)? No, otherwise both P and Q are the same graphs.
− −→
So, there are some ‘alive’ edges. Get an alive edge v 1 v2 . There must be an alive
edge
− −→ 1 − −→
v 2 v3 . Similarly get v 3 v4 and so on. Stop at the first instance of repetition of
a vertex: [v1 , v2 , · · · , vi , vi+1 · · · , vj = vi ]. Then, [vi , vi+1 · · · , vj = vi ] is a cycle.
Alternate. Consider the graph H = V (P ) ∪ V (Q), E(P )∆E(Q) , where ∆ is the symmetric
difference. Notice that E(H ) = ∅, otherwise P = Q. As the degree of each vertex in the
multigraph P ∪ Q is even and H is obtained after deleting pairs of multiple edges, each vertex
in H has even degree. Hence, by Proposition 8.2.8, H has a cycle.
Example 8.2.12. Complete graphs are chordal, so are the acyclic graphs. The Petersen graph
is not chordal.
Quiz 8.2.13. 1. How many acyclic graphs are there on the vertex set [3]?2
8.2. CONNECTEDNESS
158 CHAPTER 8. GRAPHS
158
2. How many chordal graphs are there on the vertex set [4]?3
1
Otherwise, v2 is incident to just one alive edge and some dead edges. This means v2 has received more signal
than it has sent.
2
7: 3 edges can be put in 23 ways. One of them is a cycle.
3
61: 6 edges can be put in 26 ways. There are three 4-cycles.
156 CHAPTER 8. GRAPHS
Notice!
The class of all graphs with that property is the POSET here. So, the maximality and
the minimality are defined naturally.
Proposition 8.2.17. If δ(G) ≥ 2, then G has a path of length δ(G) and a cycle of length at
least δ(G) + 1.
Hence, the cycle C = [vi , vi+1 , · · · , vk , vi ] has length at least δ(G) + 1 and the length of the
path
P = [vi , vi+1 , · · · , vk ] is at least
δ(G).
Definition 8.2.18. [Edge density] The edge density, denoted ε(G), is defined to be the
|E (G)|
number V (G) . Observe that ε(G) is also a graph invariant.
| |
Quiz 8.2.19. 1. When does ‘deletion of a vertex’ reduce edge density?
2
157 CHAPTER 8. GRAPHS
δ(G) 3
2. Is a lower bound for ε(G)?
2
1
2.
2 ε(G)n−d(v) ε(G)−d(v)
Put H = G − v. Then, kH k = ε(G)n − d(v), so that ε(H ) = n−1 = ε(G) + n−1 . So, we should
choose a vertex v with degree more that ε(G).
3
Yes.
8.3. ISOMORPHISM IN GRAPHS 157
3. Suppose that ε(G) ≥ δ(G). Should we have a vertex v with ε(G) ≥ d(v)?1
Proposition 8.2.20. Let G be a graph with kGk ≥ 1. Then, G has a subgraph H with δ(H ) >
ε(H ) ≥ ε(G).
Proof. If ε(G) < δ(G), then we take H = G. Otherwise, there is a vertex v with ε(G) ≥
d(v). Put G1 = G − v. Then, it can be easily verified that ε(G1 ) ≥ ε(G).
If ε(G1 ) < δ(G1 ), then we take H = G1 . Otherwise, there is a vertex v ∈ G1 with ε(G1 ) ≥
d(v). Put G2 = G1 − v. Then, we again have ε(G2 ) ≥ ε(G1 ) ≥ ε(G).
Continuing as above, we note that “Initially ε(G) > 0. At the i-th stage, we obtained the
subgraph Gi satisfying |V (Gi )| = |G| − i, ε(Gi ) ≥ ε(Gi−1 ). That is, we have been reducing
the number of vertices and the corresponding edge densities have been nondecreasing.” Hence,
this
process must stop before we reach a single vertex, as its edge density is 0.
So, let us assume that the process stops at H . Then, ‘ε(H ) < δ(H )’ must be true, or else,
the process would not stop at H and hence the required result follows.
Example 8.3.2. Consider the graphs in Figure 8.9. Then, note that
4
3 6 2 4
5 3
5 6
2 5
6 2
1 4 1 3
1
F G H
Figure 8.9: F is isomorphic to G but F is not isomorphic to H
Thus, f is an isomorphism.
Practice 8.3.4. Take the graphs F and G of Figure 8.9. Take the isomorphism f (1) = 1,
f (2) = 5, f (3) = 3, f (4) = 4, f (5) = 2 and f (6) = 6. Obtain the F ′ as described in Discussion
8.3.3. List V (F ′ ) and E(F ′ ). List V (G) and E(G). Notice that they are the same.
Definition 8.3.8. A graph invariant is a function which assigns the same value (output)
to isomorphic graphs.
Example 8.3.9. Observe that some of the graph invariants are: |G|, kGk, ∆(G), δ(G), the
multiset {d(v) : v ∈ V (G)}, ω(G) and α(G).
Exercise 8.3.10. How many graphs are there with vertex set {1, 2, . . . , n}? Do you find it
easy if we ask for nonisomorphic graphs (try for n = 4)?
Proposition 8.3.14. Let G be a graph and let Γ(G) denote the set of all automorphisms of G.
Then, Γ(G) forms a group under composition of functions.
8.4. TREES
159 CHAPTER 8. GRAPHS
159
8.4 Trees
Definition 8.4.1. [Tree and forest] A connected acyclic graph is called a tree. A forest is
a graph whose components are trees.
Proof. On the contrary, assume that there are two u-v-paths in T . Then, by Proposition
8.2.9,
T has a cycle, a contradiction.
Proposition 8.4.3. Let G be a graph with the property that ‘between each pair of vertices
there is a unique path’. Then, G is a tree.
Proposition 8.4.5. Let G be a connected graph with |G| ≥ 2. If v ∈ V (G) with d(v) = 1,
then
G − v is connected. That is, a vertex of degree 1 is never a cut
vertex.
Proposition 8.4.6 (Technique). Let G be a connected graph with |G| ≥ 2 and let v ∈ V (G).
If
G − v is connected, then either d(v) = 1 or v is on a cycle.
Proof. Assume that G − v is connected. If dG (v) = 1, then there is nothing to show. So,
assume that d(v) ≥ 2. We need to show that v is on a cycle in G.
Let u and w be two distinct neighbors of v in G. As G − v is connected there is a path, say
[u = u1 , . . . , uk = w], in G − v. Then, [u = u1 , . . . , uk = w, v, u] is a cycle in G containing
v.
Definition 8.4.8. [Cut edge] Let G be a graph. An edge e in G is called a cut edge or a
bridge if G − e has more connected components than that of G.
Proposition 8.4.9 (Technique). Let G be connected and e = [u, v] be a cut edge. Then, G −
e
has two components, one containing u and the other containing
v.
Proof. If G − e is not disconnected, then by definition, e cannot be a cut edge. So, G − e has
at least two components. Let Gu (respectively, Gv ) be the component containing the vertex
u (respectively, v). We claim that these are the only components.
Let w ∈ V (G). Then, G is a connected graph and hence there is a path, say P , from w to
u. Moreover, either P contains v as its internal vertex or P doesn’t contain v. In the first case,
w ∈ V (Gv ) and in the latter case, w ∈ V (Gu ). Thus, every vertex of G is either in V (Gv ) or in
V (Gu ) and hence the required result follows.
Proposition 8.4.10 (Technique). Let G be a graph and e be an edge. Then, e is a cut edge
if and only if e is not on a cycle.
Proof. Suppose that e = [u, v] is a cut edge of G. Let F be the component of G that contains
e. Then, by Proposition 8.4.9, F − e has two components, namely, Fu that contains u and
Fv that contains v.
Let if possible, C = [u, v = v1 , . . . , vk = u] be a cycle containing e = [u, v]. Then, [v
= v1 , . . . , vk = u] is an u-v path in F − e. Hence, F − e is still connected. A contradiction.
Hence, e cannot be on any cycle.
8.4. TREES
161 CHAPTER 8. GRAPHS
161
Conversely, let e = [u, v] be an edge which is not on any cycle. Now, suppose that F is
the component of G that contains e. We need to show that F − e is disconnected.
Let if possible, there is an u-v-path, say [u = u1 , . . . , uk = v], in F − e. Then, [v, u =
u1 , . . . , uk = v] is a cycle containing e. A contradiction to e not lying on any
cycle. Hence, e is a cut edge of F . Consequently, e is a cut edge of G.
1
Yes. Take G = ([4], {{1, 2}, {1, 3}, {1, 4}, {3, 4}}) and v = 1.
8.4. TREES
162 CHAPTER 8. GRAPHS
162
Proposition 8.4.11. The center of a tree always consists of a set of at most two vertices.
Proof. Let T be a tree of radius k. Since the center contains at least one vertex, let u be a vertex
in the center of T . Now, let v be another vertex in the center. We claim that u is adjacent to
v.
Suppose u ≁ v. Then, there exists a path from u to v, denoted P (u, v), with at least
one
internal vertex, say w. Let x be any pendant (d(x) = 1) vertex of T . Then, either v ∈ P (x, w)
or v ∈/ P (x, w). In the latter case, check that kP (x, w)k < kP (x, v)k ≤ k.
u w v u w v
x x
If v ∈ P (x, w), then u ∈/ P (x, w) and kP (x, w)k < kP (x, u)k ≤ k. That is, the distance from w
to any pendant vertex is less than k. Hence, k is not the radius, a contradiction. Thus, uv ∈ T
. We cannot have another vertex in the center, or else, we will have a C3 in T , a
contradiction.
Theorem 8.4.12. Let G be a graph with V (G) = [n]. Then, the following are
equivalent.
1. G is a tree.
2. G is a minimal connected graph on n vertices.
3. G is a maximal acyclic graph on n vertices.
Proof. (a)⇒(b). Suppose that G is a tree. If it is not a minimal connected graph on n vertices,
then there is an edge [u, v] such that G − [u, v] is connected. But then, by Theorem 8.4.10, [u,
v] is on a cycle in G. A contradiction.
(b)⇒(c). Suppose G is a minimal connected graph on n vertices. If G has a cycle, say Γ, then
select an edge e ∈ Γ. Thus, by Theorem 8.4.10, G − e is still connected graph on n vertices,
a contradiction to the fact that G is a minimal connected graph on n vertices. Hence, G is
acyclic.
Since G is connected, for any new edge e, the graph G + e contains a cycle and hence, G
is maximal acyclic graph.
(c)⇒(a). Suppose G is maximal acyclic graph on n vertices. If G is not connected, let G1 and
G2 be two components of G. Select v1 ∈ G1 and v2 ∈ G2 and note that G + [v1 , v2 ] is
acyclic graph on n vertices. This contradicts that G is a maximal acyclic graph on n vertices.
Thus, G is connected and acyclic and hence is a tree.
Exercise 8.4.13. 1. Show that a graph G is a tree if and only if between each pair of
vertices of G there is a unique path.
2. Draw a tree on 8 vertices. Label V (T ) as 1, . . . , 8 so that each vertex i ≥ 2 is adjacent
to exactly one element of [i − 1].
8.4. TREES
163 CHAPTER 8. GRAPHS
163
Proposition 8.4.14. Let T be a tree. Then, any graph G with δ(G) ≥ |T | − 1 has a
subgraph
H ∼=
T.
Let v ∈ V (T ) with d(v) = 1. Take u ∈ V (T ) such that uv ∈ E(T ). Now, consider the tree
T1 = T − v. Then, δ(G) ≥ |T | − 1 = n − 1 > n − 2. Hence, by induction hypothesis, G has a
subgraph H such that H ∼= T1 under a map, say φ. Let h ∈ V (H ) such that φ(h) = u.
Since δ(G) ≥ |T | − 1, h has a neighbor, say h1 , such that h1 is not a vertex in H but is a
vertex in G.
Now, map this vertex to v to get the required result.
Proof. We proceed by induction. Take a tree on n ≥ 2 vertices and delete an edge e. Then, we
get two subtrees T1 , T2 of order n1 , n2 , respectively, where n1 + n2 = n. So, E(T ) = E(T1 ) ∪
E(T2 ) ∪
{e}. By induction hypothesis kT k = kT1 k + kT2 k + 1 = n1 − 1 + n2 − 1 + 1 = n1 + n2 − 1 = n
− 1.
Proposition 8.4.16. Let G be a connected graph with n vertices and n − 1 edges. Then, G
is acyclic.
Proof. On the contrary, assume that G has a cycle, say Γ. Now, select an edge e ∈ Γ and
note that G − e is connected. We go on selecting edges from G that lie on cycles and keep
removing them, until we get an acyclic graph H . Since the edges that are being removed
lie on some cycle, the graph H is still connected. So, by definition, H is a tree on n
vertices. Thus, by Proposition 8.4.15, |E(H )| = n − 1. But, in the above argument, we have
deleted at least one
edge and hence, |E(G)| ≥ n. This gives a contradiction to |E(G)| = n − 1.
Proposition 8.4.17. Let G be an acyclic graph with n vertices and n − 1 edges. Then, G is
connected.
k ≥ 2. As G is
Proof. Let if possible, G be disconnected with components G1 , . . . , Gk ,P
acyclic, by definition, each Gi is a tree on, say ni ≥ 1 vertices, with i = 1k ni = n.
Thus, kGk =
Pk
(ni − 1) = n − k < n − 1 = kGk, as k ≥ 2. A
contradiction.
i=1
(a) G is a tree.
P
Proof. Let T be any tree on n vertices. Then, d(v) = 2kE(T )k = 2(n − 1) = 2n − 2.
v∈V (T )
Hence, by PHP, T has at least two vertices of degree 1.
Definition 8.4.21. Let T be a tree with vertices labeled by n integers, say [n]. The
Pru¨fer code PT of T is a sequence X of size n − 2 created in the following way.
1. Find the largest pendant vertex, say v1 . Let u1 be the neighbor of v1 . Put X (1) = u1 .
2. Let T1 = T − v1 and find X (2).
3. Repeat the procedure to obtain X (3), . . . , X (n − 2).
1 6 2 4
3
2 4 2 2,2
1 6 2
3 3 2 2,2,2
1 6
4 2 6 2,2,2,6
Exercise 8.4.23. In the above process, prove that uj = i, for some j, if and only if d(i) ≥ 2.
Example 8.4.24. Can I get back the original tree T from the sequence 2, 2, 2, 6? Ans:
Yes. The process of getting back the original tree is as follows.
1. Plot points 1, 2, . . . , 6.
2. Since ui is either 2 or 6, it implies that 2 and 6 are not the pendant vertices. Hence, the
pendant vertices in T must be {1, 3, 4, 5}. Thus, the algorithm implies that the
largest pendant 5 must be adjacent to (the first element of the sequence) 2.
3. At step 1, the vertex 5 was deleted. Hence, V (T1 ) = {1, 2, 3, 4, 6} with the given sequence
2, 2, 6. So, the pendants in T1 are {1, 3, 4} and the vertex 4 (largest pendant) is
adjacent to 2.
8.4. TREES
167 CHAPTER 8. GRAPHS
167
6. Lastly, V (T4 ) = {1, 6}. As the process ends with K2 and we have only two vertices
left, they must be adjacent.
The corresponding set of figures are as follows.
1 2 3 1 2 3 1 2 3 1 2 3
4 5 6 4 5 6 4 5 6 4 5 6
1 2 3 1 2 3
4 5 6 4 5 6
Proposition 8.4.25. Let T be a tree on the vertex set [n]. Then, d(v) ≥ 2 if and only if
v
appears in the Pru¨fer code PT . Thus, {v : v ∈/ PT } are precisely the pendant vertices in
T.
Proof. Let d(v) ≥ 2. Since the process ends with an edge, there is a stage, say i, where d(v)
decreases strictly. Thus, till at the (i − 1)-th stage, v was adjacent to a pendant vertex w
and at the i-th stage v was deleted and thus, v appears in the sequence.
Conversely, let v appear in the sequence at k-th stage for the first time. Then, the tree Tk had
a pendant vertex w of highest label that was adjacent to v. Note that Tk − w is a tree with at
least two vertices. Thus, d(v) ≥ dTk (v) ≥ 2.
Exercise 8.4.26. Prove that in the Pru¨fer code of T a vertex v appears exactly d(v) − 1
′
times. [Hint: If v is the largest pendant adjacent to w and T = T − v, then PT = w, PT ′ .]
′
Proposition 8.4.27. Let T and T be two trees on the same vertex set of integers. If PT = PT ′
′
, then T = T .
Proof. The statement is trivially true for |T | = 3. Assume that the statement holds for 3
<
′
|T | < n. Now, let T and T be two trees with vertex set [n] and PT = PT ′ . As PT = PT ′ ,
′
T and T have the same set of pendants. Further, the largest labeled pendant w is adjacent
to the vertex X (1) in both the trees. Thus, PT −w = PT ′ −w and hence, by induction
′ ′
hypothesis T − w = T − w. Thus, by PMI, T = T .
Proof. Verify the statement for |T | = 3. Now, let the statement hold for all trees T on n >
3 vertices and consider a set S of n + 1 integers and a sequence X of length (n − 1) of
elements of S.
8.4. TREES
169 CHAPTER 8. GRAPHS
169
′ ′
Let v = max{x ∈ S : x X }, S = S − v and X = X (2), . . . , X (n − 1). Note that as
∈/
′ ′ ′
v = X (i), for any i, X is a sequence of elements of S of length n − 2. As |S | = n, by
′ ′
induction hypothesis, there is a tree T with PT ′ = X .
′ ′
Let T be the tree obtained by adding a new pendant v at the vertex X (1) of T . In T ,
the vertices X (i), for i ≥ 2, were not available as pendants and now in T the vertex X (1) is
also
′ ′
not available as a pendant. (Here some X (i)’s may be the same). Let R = {x ∈ S : x ∈/ X
′
}
′ ′
be the pendants in T . Then, the set of pendants in T is (R ∪ {v}) \ {X (1)} which
equals
{x ∈ S : x ∈/ X }. Thus, v is the pendant of T of maximum label. Hence, PT =
X.
Theorem 8.4.29. [A. Cayley, 1889, Quart. J. Math] Let n ≥ 3. Then, there are
n−2
n
different trees with vertex set [n].
Proof. Let F be the class of trees on the vertex set [n] and let G be the class of n − 2-sequences
of [n]. Note that the function f : F → G defined as f (T ) = PT , the Pru¨fer code, is a one-
−
one and onto mapping. As |G| = nn 2 , the required result follows.
Exercise 8.4.30. 1. Find out all nonisomorphic trees of order 7 or
less.
2. Show that every automorphism of a tree fixes a vertex or an edge.
3. Give a class of trees T with |Γ(T )| = 6.
4. Let T be a tree, σ ∈ Γ(T ), u ∈ V (T ) such that σ 2 (u) = u. Can we have an edge [u, v] ∈ T
such that σ(u) = v?
5. Let T be a tree with center {u} and radius r. Let v satisfy d(u, v) = r. Show that r is
a pendant.
6. Let T be a tree with |T | > 2. Let T ′ be obtained from T by deleting the pendant vertices of
T . Show that the center of T is the same as the center of T ′ .
7. Let T be a tree with center {u} and σ ∈ Γ(T ). Show that σ(u) = u.
8. Is it possible to have a tree such that |Γ(T )| = 7?
9. Construct a tree T on vertices S = {1, 2, 3, 6, 7, 8, 9} for which PT = 6, 3, 7, 1, 2.
10. Practice with examples: get the Pru¨fer code from a tree; get the tree from a given code
and a vertex set.
11. How many trees of the following forms are there on the vertex set [100]?
. . . ···
8.4. TREES
170 CHAPTER 8. GRAPHS
170
12. Show that any tree has at least ∆(T ) leaves (pendant edges).
13. Let T be a tree and T1 , T2 , T3 be subtrees of T such that T1 ∩ T3 = ∅, T2 ∩ T3 = ∅ and
T1 ∩ T2 ∩ T3 = ∅. Show that T1 ∩ T2 = ∅.
8.4. TREES
171 CHAPTER 8. GRAPHS
171
14. Let T be a set of subtrees of a tree T . Assume that the trees in T have nonempty pairwise
intersection. Show that their overall intersection is nonempty. Is this true, if we replace
T by a graph G?
15. Recall that a connected graph G is said to be unicyclic if G has exactly one cycle as
it’s subgraph. Prove that if |G| = kGk, then G is a unicyclic graph.
8.5 Connectivity
Proposition 8.5.1. Let G be a connected graph on vertex set [n]. Then, its vertices can
be labeled in such a way that the induced subgraph on the set [i] is connected for 1 ≤ i ≤ n.
Proof. If n = 1, there is nothing to prove. Assume that the statement is true if n < k and let
G be a connected graph on the vertex set [k]. If G is a tree, pick any pendant vertex and label
it k. If G has a cycle, pick a vertex on a cycle and label it k. In both the case G − k is
connected. Now, use the induction hypothesis to get the required result.
Definition 8.5.2. [Separating set] Let G be a graph. Then, a set X ⊆ V (G) ∪ E(G) is
called
a separating set if G − X has more connected components than that of G.
Let X be a separating set of G. Then, ‘there exists u, v ∈ V (G) that lie in the same component
of G but lie in different components of G − X ’. If {u} ⊆ V (G) is a separating set of G, then u
is a cut vertex. If {e} ⊆ E(G) is a separating set of G, then it is a bridge/cut edge.
Example 8.5.3. 1. In a tree, each edge is a bridge and each non-pendant vertex is a
cut vertex. Is it true for a forest?
2. The graph K7 does not have a separating set of vertices. In K7 , a separating set of edges
must contain at least 6 edges.
Definition 8.5.6. [Edge connectivity] A graph G is called l-edge connected if |G| > 1
and G − F is connected for every F ⊆ E(G) with |F | < l. The greatest integer l such that
G is l-edge connected is the edge connectivity of G, denoted λ(G). Convention: λ(K1 ) = 0.
Example 8.5.7. 1. Note that λ(Pn ) = 1, λ(Cn ) = 2 and λ(Kn ) = n − 1, whenever n > 1.
2. Let T be a tree on n vertices. Then, λ(T ) = 1.
3. For the graph G in Figure 8.11, λ(G) = 3.
4. For the Petersen graph G, λ(G) = 3.
Exercise 8.5.8. Let |G| > 1. Show that κ(G) = |G| − 1 if and only if G = Kn . Can we
say the same for λ(G)?
Theorem 8.5.9. [H. Whitney, 1932] For any graph G, κ(G) ≤ λ(G) ≤ δ(G).
Proof. If G is disconnected or |G| = 1, then we have nothing to prove. So, let G be connected
graph and |G| ≥ 2. Then, there is a vertex v with d(v) = δ(G). If we delete all edges incident
on v, then the graph is disconnected. Thus, δ(G) ≥ λ(G).
Suppose that λ(G) = 1 and G − uv is disconnected with components Cu and Cv . If |Cu | =
|Cv | = 1, then G = K2 and κ(G) = 1. If |Cu | > 1, then we delete u to see that κ(G) = 1.
If λ(G) = k ≥ 2, then there is a set of edges, say e1 , . . . , ek , whose removal disconnects
G. Notice that G − {e1 , . . . , ek−1 } is a connected graph with a bridge, say ek = uv. For
each of e1 , . . . , ek−1 select an end vertex other than u or v. Deletion of these vertices from
G results in a graph H with uv as a bridge of a connected component. Note that κ(H ) ≤
1. Hence,
κ(G) ≤ λ(G).
Exercise 8.5.10. Give a lower bound on the number of edges of a graph G on n vertices
with vertex connectivity κ(G) = k.
Theorem 8.5.11. [Chartrand and Harary, 1968] For all integers a, b, c such that 0 < a ≤ b ≤
c, there exists a graph with κ(G) = a, λ(G) = b and δ(G) = c.
Theorem 8.5.12. [Mader, 1972] Every graph G of average degree at least 4k has a k-
connected subgraph.
We shall use induction to show that if G satisfies Equations (8.1) and (8.2), then G has a k-
(n+1) n(n−1)
connected subgraph. If n = 2k−1, then m ≥ (2k−3)(n−k+1)+1 = (n−2) 2 +1 = 2 . So,
n(n−1)
G is a graph on n vertices with at least 2 edges and hence G = Kn . Thus, Kk+1 ⊆ Kn = G.
Assume n ≥ 2k. If v is a vertex with d(v) ≤ 2k − 3, then we apply induction hypothesis
to
G − v to get the result. So, let d(v) ≥ 2k − 2, for each vertex v. If G is k-connected then, we
168 CHAPTER 8. GRAPHS
Theorem 8.5.13. [Menger] A graph is k-edge-connected if and only if there are k edge disjoint
paths between each pairs of vertices. A graph is k-connected if and only if there are k
internally vertex disjoint paths between each pairs of vertices.
Proof. Omitted.
Note that by definition, a disconnected graph is not Eulerian. In this section, the graphs can
have loops and multiple edges. The graphs that have a closed walk traversing each edge
exactly once have been named “Eulerian graphs” due to the solution of the famous
Ko¨nigsberg bridge problem by Euler in 1736. The problem is as follows: The city
Ko¨nigsberg (the present day Kaliningrad) is divided into 4 land masses by the river Pregel.
These land masses are joined by
7 bridges (see Figure 8.12). The question required one to answer “is there a way to start from
a land mass that passes through all the seven bridges in Figure 8.12 and return back to the
starting land mass”? Euler, rephrased the problem along the following lines: Let the four land
masses be denoted by the vertices A, B, C and D of a graph and let the 7 bridges correspond to
7 edges of the graph. Then, he asked “does this graph have a closed walk that traverses
each edge exactly once”? He gave a necessary and sufficient condition for a graph to have
such a closed walk and thus giving a negative answer to Ko¨nigsberg bridge problem.
One can also relate the above problem to the problem of “starting from a certain point, draw a
given figure with pencil such that neither the pencil is lifted from the paper nor a line is repeated
such that the drawing ends at the initial point”.
Theorem 8.6.2. [Euler, 1736] A connected graph G is Eulerian if and only if d(v) is even, for
each v ∈ V (G).
169 CHAPTER 8. GRAPHS
Proof. Let G have an Eulerian tour, say [v0 , v1 , . . . , vk , v0 ]. Then, d(v) = 2r, if v = v0 and
v appears r times in the tour. Also, d(v0 ) = 2(r − 1), if v0 appears r times in the tour.
Hence, d(v) is always even.
8.6. EULERIAN GRAPHS 169
B D
Conversely, let G be a connected graph with each vertex having even degree. Let W
= v0 v1 · · · vk be a longest walk in G without repeating any edge in it. As vk has an even
degree it follows that vk = v0 , otherwise W can be extended. If W is not an Eulerian tour
then there
′
exists an edge, say e = vi w, with w = vi−1 , vi+1 . In this case, wvi · · · vk (= v0 )v1 · · · vi−1 vi is
a
longer walk, a contradiction. Thus, there is no edge lying outside W and hence W is an Eulerian
tour.
Proposition 8.6.3. Let G be a connected graph with exactly two vertices of odd degree.
Then, there is an Eulerian walk starting at one of those vertices and ending at the other.
Proof. Let x and y be the two vertices of odd degree and let v be a symbol such that v ∈/ V
(G). Then, the graph H with V (H ) = V (G) ∪ {v} and E(H ) = E(G) ∪ {xv, yv} has each
vertex of even degree and hence by Theorem 8.6.2, H is Eulerian. Let Γ = [v, v1 = x, . . . , vk =
y, v] be an Eulerian tour. Then, Γ − v is an Eulerian walk with the required properties.
Exercise 8.6.4. Let G be a connected Eulerian graph and e be any edge. Show that G − e
is connected.
8 7 6 5
3 1 9
2 4 1 2 3 4
Theorem 8.6.6. [Finding Eulerian tour] The previous algorithm correctly gives an
Eulerian tour whenever, the given graph is Eulerian.
Proof. Let the algorithm start at a vertex, say v0 . Now, assume that we are at u with H as the
current graph and C as the only non trivial component of H . Thus, dH (u) > 0. Assume that
8.7. HAMILTONIAN GRAPHS
170 CHAPTER 8. GRAPHS
170
the deletion of the edge uv creates a non trivial component not containing v0 . Let Cu and
Cv
be the components of C − uv, containing u and v, respectively.
We first claim that u = v0 . In fact, if u = v0 , then H must have all vertices of even
degree and dH (v0 ) ≥ 2. So, C is Eulerian. Hence, C − uv cannot be disconnected, a
contradiction to C − uv having two components Cu and Cv . Thus, u = v0 . Moreover, note that
the only vertices of odd degree in C is u and v0 .
Now, we claim that Cu is a non trivial component. Suppose Cu is trivial. Then, v0 ∈ Cv ,
a contradiction to the assumption that the deletion of the edge uv creates a nontrivial
component not containing v0 . So, Cu is non trivial.
Finally, we claim that v0 ∈ Cv . If possible, let v0 ∈ Cu . Then, the only vertices in C − uv of
odd degree are v ∈ Cv and v0 ∈ Cu . Hence, C − uv + v0 v is a connected graph with each
vertex of even degree. So, by Theorem 8.6.2, the graph C − uv + v0 v is Eulerian. But, this
cannot be true as vv0 is a bridge. Thus, v0 ∈ Cv .
Hence, Cu is the newly created non trivial component not containing v0 . Also, each vertex of
Cu has even degree and hence by Theorem 8.6.2, Cu is Eulerian. This means, we can take an
′ ′
edge e incident on u and complete an Eulerian tour in Cu . So, at u if we take the edge e
in place of the edge e, then we will not create a non trivial component not containing v0 .
Thus, at each stage of the algorithm either u = v0 or there is a path from u to v0 .
Moreover, this is the only non trivial connected component. When the algorithm ends, we
must have u = v0 . Because, as seen above, the condition u = v0 gives the existence of an
edge that is incident on u and that can be traversed (as dH (u) is odd). Hence, if u = v0 ,
the algorithm
cannot stop. Thus, when algorithm stops u = v0 and all components are trivial.
Exercise 8.6.7. Apply the algorithm to graphs of Exercise 8.6.5. Also, create connected graphs
such that each of its vertex has even degree and apply the above algorithm.
Exercise 8.6.9. 1. Give a necessary and sufficient condition on m and n so that Km,n is
Eulerian.
2. Each of the 8 persons in a room has to shake hands with every other person as per
the following rules:
8.7. HAMILTONIAN GRAPHS
171 CHAPTER 8. GRAPHS
171
(b) Each handshake (except the first) should involve someone from the previous
hand- shake.
(c) No person should be involved in 3 consecutive handshakes.
Is there a way to sequence the handshakes so that these conditions are all met?
3. Let G be a connected graph. Then, G is an Eulerian graph if and only if the edge set of G
can be partitioned into cycles.
4 1
5 10
6 9
8.7. HAMILTONIAN GRAPHS
173 CHAPTER 8. GRAPHS
173
7 8
8.7. HAMILTONIAN GRAPHS
174 CHAPTER 8. GRAPHS
174
Since, g(G) = 5, the vertex 1 can only be adjacent to one of the vertices 5, 6 or 7.
Hence, if 1 is adjacent to 5, then the third vertex that is adjacent to 10 creates cycles of
length 3 or 4. Similarly, if 1 is adjacent to 7, then there is no choice for the third vertex
that can be adjacent to 2. So, let 1 be adjacent to 6. Then, 2 must be adjacent to 8. In this
case, note that there is no choice for the third vertex that can be adjacent to 3. Thus, the
Petersen graph is non-Hamiltonian.
Theorem 8.7.4. Let G be a Hamiltonian graph. Then, for S ⊆ V (G) with S = ∅, the
graph
G − S has at most |S| components.
Proof. Note that by removing k vertices from a cycle, one can create at most k
connected components. Hence, the required result follows.
Theorem 8.7.5. [Dirac, 1952] Let G be a graph with |G| = n ≥ 3 and d(v) ≥ n/2, for
each
v ∈ V (G). Then, G is Hamiltonian.
Theorem 8.7.6. [Ore, 1960] Let G be a graph on n ≥ 3 vertices such that d(u) + d(v) ≥ n,
for every pair of nonadjacent vertices u and v. Then, G is Hamiltonian.
Proof. Exercise.
Exercise 8.7.7. Let u and v be two vertices such that d(u) + d(v) ≥ |G|, whenever uv ∈/
E(G). Prove that G is Hamiltonian if and only if G + uv is Hamiltonian.
Theorem 8.7.11. Let d1 ≤ · · · ≤ dn be the vertex degrees of G. Suppose that, for each k <
n/2
with dk ≤ k, the condition dn−k ≥ n − k holds. Then, prove that G is Hamiltonian.
Proof. We show that under the above condition H = C (G) ∼= Kn . On the contrary,
assume that there exist a pair of vertices u, v ∈ V (G) such that uv ∈/ E(G) and dH (u) + dH (v)
≤ n − 1. Among the above pairs, choose a pair u, v ∈ V (G) such that uv ∈/ E(H ) and dH (u)
+ dH (v) is maximum. Assume that dH (v) ≥ dH (u) = k (say). Clearly, k < n/2.
Now, let Sv = {x ∈ V (H ) | xv ∈/ E(H ), x = v} and Su = {w ∈ V (H ) | wu ∈/ E(H ), w =
u}. Therefore, the assumption that dH (u) + dH (v) is the maximum among each pair of vertices
u, v with uv ∈/ E(H ) and dH (u) + dH (v) ≤ n − 1 implies that |Sv | = n − 1 − dH (v) ≥ dH
(u) = k and for each x ∈ Sv , dH (x) ≤ dH (u) = k. So, there are at least k vertices in H
(elements of Sv ) with degrees at most k.
Also, for any w ∈ Su , note that the choice of the pair u, v implies that dH (w) ≤ dH (v) ≤
n − 1 − dH (u) = n − 1 − k < n − k. Moreover, |Su | = n − 1 − k. Further, the condition
dH (u) + dH (v) ≤ n − 1, dH (v) ≥ dH (u) = k and u ∈/ Su implies that dH (u) ≤ n − 1 − dH (v)
≤ n − 1 − k < n − k. So, there are n − k vertices in H with degrees less than n − k.
′
Therefore, if d1 ≤ · · · ≤ dn are the vertex degrees of H , then we observe that there exists a
′
′
k < n/2 for which dk′ ≤ k and dn−k < n − k. As k < n/2 and di ≤ di′ , we get a contradiction.
Exercise 8.7.12. Complete an alternate proof of Theorem 8.7.11. Let R denote the property:
R : ‘If dk ≤ k then dn−k ≥ n − k, for each k < n/2’.
We know that G has this property.
1. Let e be an edge not in G. Show that G + e also has the property. What about the closure
H := C (G) of G?
2. Assume that max{d(u) + d(v) : u, v ∈ H are not adjacent} ≤ n − 2. Let e be an edge
not in H . Does H + e have property R? Is C (H + e) = H + e?
3. In view of the previous observations assume that G is an edge maximal graph with
property R which is not Hamiltonian. Do you have C (G) = G? Show that there are some
k vertices having degree at most k and some n − k vertices having degree less than n − k.
Does that contradict R?
8.7. HAMILTONIAN GRAPHS
177 CHAPTER 8. GRAPHS
177
Definition 8.7.13. [Line graph] The line graph H of a graph G is a graph with V (H ) = E(G)
and e1 , e2 ∈ V (H ) are adjacent in H if e1 and e2 share a common vertex/endpoint.
8.7. HAMILTONIAN GRAPHS
178 CHAPTER 8. GRAPHS
178
Theorem 8.7.16. A connected graph G is isomorphic to it’s line graph if and only if G = Cn
, for some n ≥ 3.
Proof. If G is isomorphic to its line graph, then |G| = kGk. Thus, G is a unicyclic graph.
Let [v1 , v2 , . . . , vk , vk+1 = v1 ] form the cycle in G. Then, the line graph of G contains a
cycle P = [v1 v2 , v2 v3 , . . . , vk v1 ]. We now claim that dG (vi ) = 2.
Suppose not and let dG (v1 ) ≥ 3. So, there exists a vertex u ∈/ {v2 , vk } such that u ∼ v1 .
In
that case, the line graph of G contains the triangle T = [v1 v2 , v1 vk , v1 u] and P = T . Thus,
the line graph is not unicyclic, a contradiction.
Exercise 8.7.17. 1. Determine the closure of G.
2. Show that H is not Hamiltonian.
G H
3. Give a necessary and sufficient condition on m, n ∈ N so that Km,n is Hamiltonian.
4. Show that any graph G with |G| ≥ 3 and kGk ≥ C (n − 1, 2) + 2 is Hamiltonian.
5. Show that for any n ≥ 3 there is a graph H with kGk = C (n − 1, 2) + 1 that is not
Hamil- tonian. But, prove that all such graphs H admit a Hamiltonian path (a path
containing all vertices of H ).
Lemma 8.8.2. Let P and Q be two v-w-paths in G such that length of P is odd and length of
8.7. HAMILTONIAN GRAPHS
179 CHAPTER 8. GRAPHS
179
Proof. Suppose P, Q have an inner vertex x (a vertex other than v, w) in common. Then,
one of P (v, x), P (x, w) has odd length and the other is even, say, P (v, x) is odd. If the
lengths of Q(v, x) and Q(x, w) are both odd then we consider the x-w-paths P (x, w) and Q(x,
w), otherwise we consider the paths P (v, x) and Q(v, x).
In view of the above argument, we may assume that P, Q have no inner vertex in common.
In that case it is clear that P ∪ Q is an odd cycle.
Theorem 8.8.3. Let G be a connected graph with at least two vertices. Then, the
following statements are equivalent.
1. G is 2 colorable.
2. G is bipartite.
3. G does not have an odd cycle.
Proof. Part 1 ⇒ Part 2. Let G be 2-colorable. Let V1 be the set of red vertices and V2 be the
set of blue vertices. Clearly, G is bipartite with partition V1 , V2 .
Part 2 ⇒ Part 1. Color the vertices in V1 with red color and that of V2 with blue color to get
the required 2 colorability of G.
Part 2 ⇒ Part 3. Let G be bipartite with partition V1 , V2 . Let v0 ∈ V1 and suppose Γ
= v0 v1 v2 · · · vk = v0 is a cycle. It follows that v1 , v3 , v5 · · · ∈ V2 . Since, vk ∈ V1 , we see
that k is even. Thus, Γ has an even length.
Part 3 ⇒ Part 2. Suppose that G does not have an odd cycle. Pick any vertex v.
Define V1 = {w | there is a path of even length from v to w} and V2 = {w | there is a path of odd
length from v to w}. Clearly, v ∈ V1 . Also, G does not have an odd cycle implies that V1 ∩ V2
= ∅. As G is connected each w is either in V1 or in V2 .
Let x ∈ V1 . Then, there is an even path P (v, x) from v to x. If xy ∈ E(G), then we have
a v-y-walk of odd length. Deleting all cycles from this walk, we have an odd v-y-path.
Thus,
y ∈ V2 . Similarly, if x ∈ V2 and xy ∈ E, then y ∈ V1 . Thus, G is bipartite with parts V1 ,
V2 .
Exercise 8.8.4. 1. There are 15 women and some men in a room. Each man shook
hands of exactly 6 women and each woman shook hands of exactly 8 men. How many
men are there in the room?
2. How do you test whether a graph is bipartite or not?
u1
u2 u7 u6
u3 u4 u5
is also a matching and it is maximum (why?). Can you give another maximum matching?
Example 8.9.7. Can we find a matching that saturates all vertices in the graph given below?
8.9. MATCHING IN GRAPHS
179 CHAPTER 8. GRAPHS
179
Ans: No. Let X be the given graph and take S = {1, 2, 3}. If there is such a matching then
|N (S)| should at least be |S|. But this is not the case with this graph.
Question: What if |N (S)| were at least |S|, for each S ⊆ X ?
Theorem 8.9.8. [Hall, 1935] Let G = (X ∪Y, E) be a bipartite graph. Then, there is a
matching that saturates all vertices in X if and only if for all S ⊆ X , |N (S)| ≥ |S|.
Proof. If there is such a matching, then obviously |S| ≤ |N (S)|, for each subset S of X
∗
. Conversely, suppose that |N (S)| ≥ |S|, for each S ⊆ X . Let if possible, M be a
maximum matching that does not saturate x ∈ X .
∗ ∗
As |N ({x})| ≥ |{x}|, there is a y ∈ Y such that xy ∈/ M . Since M cannot be extended,
y
must have been matched to some x1 ∈ X
.
Now consider N ({x, x1 }). It has a vertex y1 which is adjacent to either x or x1 or both by
∗ ∗
an edge not in M . Again the condition that M cannot be extended implies that y1 must
have
been matched to some x2 ∈ X . Continuing as above, we see that this process never stops
∗
and thus, G has infinitely many vertices, which is not true. Hence, M saturates each x ∈ X .
Corollary 8.9.9. Let G be a k-regular (k ≥ 1) bipartite graph. Then, G has a perfect matching.
Proof. Let X and Y be the two parts. Since G is k-regular |X | = |Y |. Let S ⊆ X and E be the
P
set of edges with an end vertex in S. Then k|S| = |E| ≤ d(v) = k|N (S)|. Hence, we see
v∈N (S)
that for each S ⊆ X, |S| ≤ |N (S)| and thus, by Hall’s theorem the required result follows.
Exercise 8.9.11. 1. Show that for any graph G the size of a minimum covering is n −
α(G).
8.9. MATCHING IN GRAPHS
180 CHAPTER 8. GRAPHS
180
Proof. By definition, the proof of the first statement is trivial. To prove the second statement,
∗
suppose that |M | = |K | and M is not a maximum matching. Let M be a matching of G
with
∗ ∗
|M | ≥ |M |. Then, using the first statement, we have |K | ≥ |M | > |M |. Thus, M is
maximum. As each covering must have at least |M | elements, we see that K is a minimum
covering.
Is the converse of Proposition 8.9.12 necessarily true? Can you guess the class of graphs
for which the converse of Proposition 8.9.12 is true?
∗
Theorem 8.9.14. [Konig, 1931] Let M be a maximum matching in a bipartite graph G
∗ ∗ ∗
and let K be a minimum covering. Then, |M | = |K |.
Exercise 8.9.15. How many perfect matchings are there in a labeled K2n
?
Definition 8.10.1. [Ramsey number] The Ramsey number r(m, n) is the smallest
natural number k such that any graph G on k vertices either has a Km or a K n as it’s
subgraph.
Example 8.10.2. As C5 does not have K3 or K 3 as it’s subgraph, r(3, 3) > 5. But,
using the first paragraph of this section, we get r(3, 3) ≤ 6 and hence, r(3, 3) = 6. It is
known that r(3, 4) = 9 (see the text by Harary for a table).
8.9. MATCHING IN GRAPHS
182 CHAPTER 8. GRAPHS
182
Case II. There is a vertex a with d(a) ≥ 6. If hN (a)i has a K 3 , we are done.
Otherwise, r(3, 3) = 6 implies that hN (a)i has a K3 with vertices, say, b, c, d. In that case a,
b, c, d induces the graph K4 .
P
Case III. Each vertex has degree 5. This case is not possible as d(v) should be
even.
Exercise 8.10.4. Can you draw a graph on 8 vertices which does not have K3 , K 4 in
it?
Theorem 8.10.5. [Erdos & Szekeres, 1935] Let m, n ∈ N. Then, r(m, n) ≤ r(m − 1, n)
+
r(m, n − 1).
Proof. Let p = r(m − 1, n) and q = r(m, n − 1). Now, take any graph G on p + q vertices
and take a vertex a. If d(a) ≥ p, then hN (a)i has either a subgraph Km−1 (and Km−1
together with a gives Km ) or a subgraph Kn . Otherwise, |N (a)c | ≥ q. In this case, hN (a)c i
has either a subgraph Km or a subgraph K n−1 (K n−1 together with a gives K n ).
Theorem 8.11.3. Fix n ≥ 1 and the natural numbers d1 ≤P· · · ≤ dn . Then, d = (d1 , . . . , dn )
is the degree sequence of a tree on n vertices if and only if di = 2n − 2.
P
Proof. If d = (d1 , . . . , dn ) is the degree sequence of a tree on n vertices then di = 2|E(T )|
=
2(n − 1) = 2n − 2.
P
Conversely, let d1 ≤ · · · ≤ dn be a sequence of natural numbers with di = 2n − 2.
We
use induction to show that d = (d1 , . . . , dn ) is the degree sequence of a tree on n vertices.
For
n = 1, 2, the result is trivial.
P Let the result be true Pfor all n < k and let d1 ≤ · · · ≤ dk , k > 2,
be natural numbers with di = 2k − 2. Since, di = 2k − 2, we must have d1 = 1 and dk
> 1.
′
Then, we note that d2′ = d2 , · · · , dk−
′
1 = dk−1 and dk = dk − 1 are natural numbers such that
P
di ′ = 2(k − 1) − 2. Hence, by induction hypothesis, there is a tree ′ on vertices 2, · · · , k − 1, k
T
with degrees d′i ’s. Now, introduce a new vertex 1 and add the edge {1, k} to get a tree T that
has the required degree sequence.
G − n is the required graph. So, let deg(k + 1) > deg(1). Then, k + 1 has a neighbor v = 1,
′
n with v 6∼ 1. Now, consider the graph G = G − {k + 1, v} + {n, k + 1} + {1, v} − {1, n}.
Then, G a also has d as it’s degree sequence with a better degree of neighbors.
′
3. If two graphs have the same degree sequence, are they necessarily isomorphic?
4. If two graphs are isomorphic, is it necessary that they have the same degree sequence?
Example 8.12.2. 1. A tree is embed-able on a plane and when it is embedded we have only
one face, the exterior face.
2. Any cycle Cn , n ≥ 3 is planar and any plane representation of Cn has two faces.
3. The planar embedding of K4 is given in Figure 8.15.
4. Draw a planar embedding of K2,3 .
5. Draw a planar embedding of the three dimensional cube.
8.12. PLANAR GRAPHS
181 CHAPTER 8. GRAPHS
181
9 f1 9 f1
14 13
f2 f2
8 11 8 11
10 f3 12 10 f3 12
15 f4
2 f4
1 2 3 4 5 1 3 4 5
f6 f5
7 6 7 6
Planar Graph X1 Planar Graph X2
Figure 8.16: Planar graphs with labeled faces to understand the Euler’s theorem
The faces of the planar graph X1 and their corresponding edges are listed below.
From the table, we observe that each edge of X1 appears in two faces. This can be easily
observed for the faces that don’t have pendant vertices (see the faces f2 and f3 ). In faces
f1 and f4 , there are a few edges which are incident with a pendant vertex. Observe that the
edges that are incident with a pendant vertex, e.g., the edges {2, 15}, {8, 9} and {1, 2} etc.,
appear twice when traversing a particular face. This observation leads to the proof of Euler’s
theorem
for planar graphs which is the next result.
Theorem 8.12.4. [Euler formula] Let G be a connected plane graph with f as the number
of faces. Then,
|G| − kGk + f = 2. (8.3)
Lemma 8.12.5. Let G be a plane bridgeless graph with kGk ≥ 2. Then, 2kGk ≥ 3f .
Further,
if G has no cycle of length 3 then, 2kGk ≥ 4f .
8.12. PLANAR GRAPHS
184 CHAPTER 8. GRAPHS
184
Proof. For each edge put two dots on either side of the edge. The total number of dots is 2kGk.
If G has a cycle then each face has at least three edges. So, the total number of dots is at least
3f . Further, if G does not have a cycle of length 3, then 2kGk ≥ 4f .
Theorem 8.12.6. The complete graph K5 and the complete bipartite graph K3,3 are not
planar. Proof. If K5 is planar, then consider a plane representation of it. By Equation (8.3),
f = 7.
But, by Lemma 8.12.5, one has 20 = 2kGk ≥ 3f = 21, a contradiction.
If K3,3 is planar, then consider a plane representation of it. Note that it does not have a C3 .
Also, by Euler’s formula, f = 5. Hence, by Lemma 8.12.5, one has 18 = 2kGk ≥ 4f = 20, a
contradiction.
For example, for each m, n ∈ N, the paths Pn and Pm are homeomorphic. Similarly, all the
cyclic graphs are homeomorphic to the cycle C3 if our study is over simple graphs. In general,
one can say that all cyclic graphs are homeomorphic to the graph G = (V, E), where V = {v}
and E = {e, e} (i.e., a graph having exactly one vertex and a loop). Also, note that if two
graphs are isomorphic then they are also homeomorphic. Figure 8.17 gives examples of
homeomorphic
graphs that are different from a path or a cycle.
Theorem 8.12.8. [Kuratowski, 1930] A graph is planar if and only if it has no subgraph
homeomorphic K5 or K3,3 .
Proof. Omitted.
We have the following observations that directly follow from Kuratowski theorem.
Definition 8.12.10. [Blocks of a graph] Let G be a graph. Define a relation on the edges of G
by e1 ∼ e2 if either e1 = e2 or there is a cycle containing both these edges. Note that this is an
8.12. PLANAR GRAPHS
186 CHAPTER 8. GRAPHS
186
equivalence relation. Let Ei be the equivalence class containing the edge ei . Also, let Vi denote
the endpoints of the edges in Ei . Then, the induced subgraphs hVi i are called the blocks of G.
Proposition 8.12.11. A graph G is planar if and only if each of its blocks are
Definition 8.12.12. [Maximal planar] A graph is called maximal planar if it is planar and
addition of any more edges results in a non-planar graph. A maximal plane graph is necessarily
connected.
Proposition 8.12.13. If G is a maximal planar graph with m edges and n ≥ 3 vertices, then
every face is a triangle and m = 3n − 6.
Proof. Suppose there is a face, say f , described by the cycle [u1 , . . . , uk , u1 ], k ≥ 4. Then,
we can take a curve joining the vertices u1 and u3 lying totally inside the region f , so that G +
u1 u3 is planar. This contradicts the fact that G is maximal planar. Thus, each face is a
triangle. It follows that 2m = 3f . As n − m + f = 2, we have 2m = 3f = 3(2 − n + m) or m
= 3n − 6.
Exercise 8.12.14. 1. Suppose that G is a plane graph with n vertices such that each face
is a 4-cycle. What is the number of edges in G?
3. Show that a plane graph on n ≥ 3 vertices can have at most 2n − 5 bounded faces.
4. Is it necessary that a plane graph G should contain a vertex of degree less than 5?
7. Show that any plane graph on n ≥ 4 vertices has at least four vertices of degree at
most five.
7 8
6 1
5 2
4 3
8.12. PLANAR GRAPHS
187 CHAPTER 8. GRAPHS
187
8.13 Vertex
Coloring
Proof. If |G| = 1, the statement is trivial. Assume that the result is true for |G| = n and let G
be a graph on n + 1 vertices. Let H = G − 1. As H is (∆(G) + 1)-colorable and d(1) ≤
∆(G), the vertex 1 can be given a color other than its neighbors.
Theorem 8.13.3. [Brooks, 1941] Every non complete graph which is not an odd cycle has
χ(G) ≤ ∆(G).
Proof. Let G be a minimal planar graph on n ≥ 6 vertices and m edges, such that G is
not
5-colorable. Then, by Proposition 8.12.13, m ≤ 3n − 6. So, nδ(G) ≤ 2m ≤ 6n − 12 and hence,
δ(G) ≤ 2m/n ≤ 5. Let v be a vertex of degree 5. Note that by the minimality of G, G − v
is
5-colorable. If neighbors of v use at most 4 colors, then v can be colored with the 5-th
color to get a 5-coloring of G. Else, take a planar embedding in which the neighbors v1 , . . . ,
v5 of v appear in clockwise order.
Let H = G[Vi ∪ Vj ] be the graph spanned by the vertices colored i or j. If vi and vj are
in
different connected components of H , then we can swap colors i and j in a component
that contains vi , so that the vertices v1 , . . . , v5 use only 4 colors. Thus, as above, in this
case the graph G is 5-colorable. Otherwise, there is a 1, 3-colored path between v1 and v3 and
similarly, a 2, 4-colored path between v2 and v4 . But this is not possible as the graph G is
planar. Hence,
every planar graph is 5-colorable.
Let H be the graph obtained by relabeling the vertices of G. Then, note that A(H ) =
−1 −
S A(G)S, for some permutation matrix S (recall that for a permutation matrix S t = S 1 ).
Hence, we talk of the adjacency matrix of a graph and do not worry about the labeling of the
vertices of G.
will give an adjacency matrix, say B. But, the
8.15. MORE EXERCISES 185
Example 8.14.2. The adjacency matrices of the 4-cycle C4 and the path P4 on 4 vertices are
given below.
0 1 0 1 0 1 0 0
1 0 1 0
A(C4 ) = , A(P ) = 1 0 1 0 .
4
0 1 0 1 0 1 0 1
1 0 1 0 0 0 1 0
Theorem 8.14.4. The (i, j) entry of B = A(G)k is the number of i-j-walks of length k.
Thus, bij = r if and only if we have r sequences i1 , . . . , ik−1 with aii1 = · · · = aik−1 ik = 1. That
is, bij = r if and only if we have r walks of length k between i and j.
5 3
6 2
1
Bibliography
[2] R. B. Bapat, Graphs and Matrices, Hindustan Book Agency, New Delhi, 2010.
[3] J. Cofman, “Catalan Numbers for the Classroom?”, Elem. Math., 52 (1997), 108 - 117.
[4] D. M. Cvetkovic, Michael Doob and Horst Sachs, Spectra of Graphs: theory and
applications, Academic Press, New York, 1980.
[5] D. I. A. Cohen, Basic Techniques of Combinatorial Theory, John Wiley and Sons, New
York, 1978.
[6] William Dunham, Euler: The Master of Us All, Published and Distributed by The Math-
ematical Association of America, 1999.
[10] J. Riordan, Introduction to Combinatorial Analysis, John Wiley and Sons, New York, 1958.