0% found this document useful (0 votes)
31 views90 pages

Discrete Mathematics

The document outlines the syllabus for a course on Discrete Mathematics, focusing on binary relations, sets, and operations on sets. It defines key concepts such as sets, subsets, operations like union and intersection, and introduces multisets and binary relations. Additionally, it covers properties of sets, including De Morgan's laws and the uniqueness of the empty set.

Uploaded by

bandimohan200507
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views90 pages

Discrete Mathematics

The document outlines the syllabus for a course on Discrete Mathematics, focusing on binary relations, sets, and operations on sets. It defines key concepts such as sets, subsets, operations like union and intersection, and introduces multisets and binary relations. Additionally, it covers properties of sets, including De Morgan's laws and the uniqueness of the empty set.

Uploaded by

bandimohan200507
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 90

MALLA REDDY

UNIVERSITY

Discrete Mathematics
(MR23-1BS0801)
UNIT-I: Binary Relations on Sets

Syllabus
Binary Relations, Equivalence Relations, Partial Order Sets, Total Order Sets, Lattices,
Hasse Diagrams, Functions, Binary and n-ary Operations.

Self-study: Transitive Closure, Fundamental theorem of Arithmetic.

--
Sets
Definition: “A set is a well-defined collection of objects.” These objects are called elements
or members of the set.
So, we can say that it is the collection of all such type of elements or objects which satisfy
some rule and it is possible to say whether a particular object belongs to the collection or not.
We write a  A to denote that “ a is an element of the set A”. Similarly, a  A is used to
denote that “ a is not an element of the set A”. It is common for sets to be denoted by using
uppercase letters. Lowercase letters are usually used to denote elements of sets.
Examples: 1. The set V of all vowels in the English alphabet can be written as
V  {a, e, i, o, u} .
2. The set O of odd positive integers less than 10 can be expressed by O  {1,3,5,7,9} .
3. Although sets are usually used to group together elements with common properties, there is
nothing that prevents a set from having seemingly unrelated elements. For instance,
{a, 2, Fred, New Jersey} is the set containing the four elements a, 2, Fred, and New Jersey.
4. The set of positive integers less than 100 can be denoted by {1, 2,3, . . . ,99}.

Remark: Sets can have other sets as members. For example, the set {N, Z, Q, R} is a set
containing four elements, each of which is a set. The four elements of this set are N, the set of
natural numbers; Z, the set of integers; Q, the set of rational numbers; and R, the set of real
numbers.

Remark: Note that the concept of a datatype, or type, in computer science is built upon the
concept of a set. In particular, a datatype or type is the name of a set, together with a set of
operations that can be performed on objects from that set. For example, boolean is the name
of the set {0,1} together with operators on one or more elements of this set, such as AND,
OR, and NOT.

Notations: There are five ways used to describe a set.


1. Describe a set by describing the properties of the members of the set (Set builder
notation).
2. Describe a set by listing its elements (Roster method).
3. Describe a set A by its characteristic function, defined as
1 if x  A
A  x  
0 if x  A
for all x in U where U is the universal set, sometimes called the “universe of discourse” or
just the “universe” which is a fixed specified set describing the context for the duration of the
discussion.
4. Describe a set by a recursive formula. This is to give one or more elements of the set and a
rule by which the rest of the elements of the set may be generated.
5. Describe a set by an operation (such as union, intersection, complement, etc.) on some
other sets.

Problem: Describe the set containing all the nonnegative integers less than or equal to 5.
Solution: Let A denote the set. Then the set A can be described in the following ways:

--
1. A = {x | x is a nonnegative integer less than or equal to 5}.
2. A = {0,1,2,3,4,5}.
1 for x  0,1, 2,3, 4,5
3.  A  x   
0 otherwise
4. A =  xi 1  xi  1, i  0,1, 2,3, 4, where x0  0 .

Remark: Sometimes in roster method, a set is described without listing all its members.
Some members of the set are listed, and then ellipses (. . .) are used when the general pattern
of the elements is obvious.

Subset: Let A and B be two sets. Then A is said to be a subset of B if every element of A is an
element of B.
If A is a subset of B, we say A is contained in B. Symbolically, we write A  B .

Proper Subset: A is said to be a proper subset of B if A is a subset of B and there is at least


one element of B which is not in A.
If A is a proper subset of B, then we say A is strictly contained in B. Symbolically, we
write A  B .

Properties: Let A, B, and C are sets. Then we have


1. A  A .
2. If A  B and B  C then A  C .
3. If A  B and B  C then A  C .
4. If A  B and A  C then B  C .

Equal Sets: Two sets A and B are equal iff A  B and B  A . We write A  B .

Result: To show that two sets A and B are equal, we must show that each element of A is also
an element of B, and conversely.

Null Set or Empty Set: A set containing no elements is called the empty set or null set,
denoted by  .
For example, given the universal set U of all positive numbers, the set of all positive numbers
x in U satisfying the equation x  1  0 is an empty set since there are no positive numbers
which can satisfy this equation.

Note: The empty set is a subset of every set.

Note: It is important to note that the sets  and   are very different sets. The former has
no elements, whereas the latter has the unique element  .

Singleton: A set containing a single element is called a singleton.

--
Operations on Sets

There are several operations on set. A few important ones are discussed in this section.
Consider U as the universal set and now we define the following operations.

Absolute Complement: Let A be any subset of U. The absolute complement of A is defined


as A   x : x  A .

Relative Complement: If A and B are sets, the relative complement of A with respect to B is
given as B  A   x : x  B and x  A .

Note:   U , U   and the complement of the complement of A is equal to A i.e. A  A .

Union: Let A and B be two sets. The union of A and B is given as


A  B   x : x  A or x  B or both .
More generally, if A1 , A2 ,..., An are sets, then their union is the set of all objects which belong
to at least one of them, and is denoted by
n
A1  A2  ...  An or  Aj .
j 1

Intersection: Let A and B be two sets. The intersection of A and B is given as


A  B   x : x  A and x  B  .
More generally, if A1 , A2 ,..., An are sets, then their intersection is the set of all objects which
belong to every one of them, and is denoted by
n
A1  A2  ...  An or  Aj .
j 1

Basic Properties Union Intersection


Idempotent A A  A A A  A
Commutative A B  B  A A B  B  A
Associative A   B  C    A  B  C A   B  C    A  B  C

Remark: It should be noted that, in general,


 A  B  C  A   B  C .
Symmetrical Difference or Boolean Sum: The symmetrical difference of two sets A and
B is given as
A  B   x : x  A, or x  B, but not both .

Disjoint Sets: Two sets A and B are said to be disjoint if they do not have a member in
common.
Mathematically, A B   .

--
Distributive Laws: Let A, B and C are three sets. Then,
C   A  B    C  A  C  B  ,
C   A  B    C  A  C  B  .

Power Set: Let A be a given set. The power set of A, denoted by P(A), is the family of sets
such that X  A iff X  P  A  .
Symbolically,
P  A    X : X  A .
Example: Let A  a, b, c . Then the power set of A is
P  A    , a , b , c , a, b , b, c , c, a , a, b, c .

Venn Diagram

It is often helpful to use Venn diagram [after JohnVenn (1834-1883)], to visualize the various
properties of the set operations. The main points of Venn Diagram are:
 The universal set is represented by a large rectangular area.
 Subsets within this universe are represented by circular areas.

A summary of set operations and their Venn diagrams is given below:

--
De Morgan’s Laws: Let A and B be two sets. Then,
 A  B  A  B
 A  B  A  B
Note: The proof of the above laws can be given with the help of Venn diagram.

Problem: Prove that empty set is unique.


Proof: Let there are two empty sets, 1 and 2 .
Since 1 and 2 are included in every set.
Therefore, 1  2 and 2  1
 1  2 . Hence Proved.

Problem: Let U  1, 2,3, 4,5 , A  1,5 , B  1, 2,3, 4 . Find the following sets.
(a) A  B
(b) A  B
Solution: (a) A  B = 1,5  U  B 
= 1,5  5
= 5
(b) A  B = U  A   U  B 
= 2,3, 4  5
= 2,3, 4,5

Multiset

In mathematics, a multiset (or bag, or mset) is a modification of the concept of a set that,
unlike a set, allows for multiple instances for each of its elements.

The number of instances given for each element is called the multiplicity of that
element in the multiset.

As a consequence, an infinite number of multisets exist which contain only elements a


and b, but vary in the multiplicities of their elements:
 The set {a, b} contains only elements a and b, each having multiplicity 1
when {a, b} is seen as a multiset.
 In the multiset {a, a, b}, the element a has multiplicity 2, and b has
multiplicity 1.
 In the multiset {a, a, a, b, b, b}, a and b both have multiplicity 3.

These objects are all different, when viewed as multisets, although they are the same
set, since they all consist of the same elements. As with sets, and in contrast to tuples, order

--
does not matter in discriminating multisets, so {a, a, b} and {a, b, a} denote the same
multiset.

Note: To distinguish between sets and multisets, a notation that incorporates square brackets
is sometimes used: the multiset {a, a, b} can be denoted as [a, a, b].

Remark: The cardinality of a multiset is constructed by summing up the multiplicities of all


its elements. For example, in the multiset {a, a, b, b, b, c} the multiplicities of the members
a, b, and c are respectively 2, 3, and 1, and therefore the cardinality of this multiset is 6.

Example: One of the simplest and most natural examples is the multiset of prime factors of a
natural number n. Here the underlying set of elements is the set of prime factors of n. We
know that 120 = 23 31 51 which gives the multiset {2, 2, 2, 3, 5}.

Notation: We can write a ∈n A if element a occurs in the multiset A at least n times.


For example: 1∈3{1,2,3,1,1}, 4∈0{1,2,3,1,1}.

Applications: Multiset Concept is useful in following areas:


 fundamental in combinatorics
 an important tool in the theory of relational databases
 used to implement relations in database systems
 SQL operates on multisets and return identical records

Relations
Ordered Pair: In ordered pair, each set is specified by two objects in a prescribed order. The
ordered pair of a and b, with first coordinate a and second coordinate b, is the set  a, b  .

Note:  a, b    c, d  iff a  c and b  d .

Cartesian Product: Let A and B are two sets. The Cartesian product of A and B is defined as
A  B   a, b  : a  A and b  B .

More generally, the Cartesian product of n sets A1 , A2 ,..., An is defined as


A1  A2  ...  An   a1 , a2 ,..., an  : ai  Ai , i  1, 2,..., n .

The expression  a1 , a2 ,..., an  is called an ordered n-tuple.

Example: Let A  0,1, 2 and B  a, b Then,


A  B   0, a  ,  0, b  , 1, a  , 1, b  ,  2, a  ,  2, b  .

Note: From the definition of the Cartesian product we have seen that any element  a, b  in a
Cartesian product A  B is just an ordered pair.

--
Binary Relation: A binary relation R from A to B is a subset of Cartesian product A  B .

n-ary Relation: An n-ary relation is a subset of a Cartesian product of n sets A1 , A2 ,..., An .


In case n  1 , a subset R of A is called a unary relation on A.

Example: Let all the points inside a unit circle whose centre is at the origin. Then the set
R   x, y  : x and y are real numbers and x 2  y 2  1
is a relation on the set of real numbers.

Domain of R: Let R be a relation from A to B. The domain of R denoted by dom R, is


defined as
dom R   x : x  A and ( x, y )  R for some y  B .

Range of R: Let R be a relation from A to B. The range of R denoted by ran R, is defined as


ran R   y : y  B and ( x, y )  R for some x  A .

Note: 1- Here, dom R  A and ran R  B . Moreover, the domain of R is the set of first
coordinates in R and the range of R is the set of second coordinates in R.

Note: 2- We sometimes write  x, y   R as x R y which reads “x relates to y”.

Properties of Binary Relations

1 Transitivity  x, y, z if x R y and y R z, then x R z;


2 Reflexivity x x R x;
3 Irreflexivity x x R x;
4 Symmetry  x, y if x R y , then y R x;
5 Antisymmetry  x, y if x R y and y R x, then x  y;
6 Asymmetry  x, y if x R y , then y R x;

Equivalence Relation

Definition: Let R be a relation on A. R will be an equivalence relation on A if the following


conditions are satisfied:
1. If xRx  x  A (R is reflexive).
2. If xRy , then yRx  x, y  A (R is symmetric).
3. If xRy and yRz , then xRz  x, y, z  A (R is transitive).

Example: Let N  1, 2,3,  be the set of natural numbers. Define a relation R in N as
follows:
R   x, y  ; x, y  N and x  y is even .

--
R is an equivalence relation in N because the first two conditions are clearly satisfied and to
prove the third condition, if x  y and y  z are divisible by 2, then x   y  y   z is
divisible by 2. Therefore, x  z is divisible by 2. Hence Proved.

Note: In this equivalence relation all the odd numbers are equivalent and so are all the even
numbers.

Partition: Let A be a given set. A partition of A is a collection P of disjoint subsets whose


union is A.
Mathematically,
1. For any B  P, B  A;
2. For any B, C  P, B  C   , or B  C; and
3. For any x  A,  B  P such that x  B.

Equivalence Class: Let A be a given set and R is an equivalence relation on A, the


equivalence class  x  of each element x of A is defined as
 x   y  A : xRy .

Note: We can have  x    y  even if x  y provided xRy .

Remark: Let A be a given set and R is an equivalence relation on A, then S   x  : x  A is


a partition of A into disjoint nonempty subsets. Conversely, if P is a partition of A into
nonempty disjoint subsets, then P is the set of equivalence classes for the equivalence relation
E defined on A by aEb iff a and b belong to the same subset of P.

Congruence modulo ‘m’: Let ‘m’ be any positive integer then the relation congruence
modulo ‘m’    mod m   is defined by x  y  mod m  iff x  y  a.m for some integer a.

Theorem: For any positive integer m, the relation   mod m  is an equivalence relation on
the integers, and partitions the integers into „m‟ distinct equivalence classes: [0], [1],…,[m-1].

Proof: We have a  b  mod m  which implies a  b  m.k .

First, we prove R is an equivalence relation. For this,

1. Reflexivity: a  a  m.0
 a  a  mod m 
 aRa .

2. Symmetry: If a  b  mod m  then a  b  m.k


   a  b    m.k
 b  a  m.(k )  m.k  where k   k
 b  a  mod m 

--
 bRa .

3. Transitivity: If a  b  mod m  and b  c  mod m 


then a  b  m.k1 and b  c  m.k2
Adding these, we get
 a  b  b  c  m.k1  m.k2
 a  c  m.k3 where k3  k1  k2
 a  c  mod m  .

Therefore, it is an equivalence relation.

Now, if x is any integer, then by division algorithm

x  mq  r
where q and r are integers and 0  r  m .

Thus, x  r  mod m  and  x    r  .

So, each equivalence class for this relation is one of the classes [0],[1],…,[m-1].

Moreover, if  x    y  where 0  x  y  m -1,

Then y  ma  x for some integer a.

Therefore, 0  y  x  m.a  m implies a  0 and x  y.

Ordering Relations

In this topic, we need to understand the following concepts.

Order Theory: It studies various kinds of binary relations that capture the intuitive notion of
ordering expressed usually using phrases "less than" or "precedes".

Partial Order: A relation R on a set A is called a partial order on A when R is reflexive,


antisymmetric, and transitive, and then the set A is called a partially ordered set or a poset.

Notation:  A; R  is used to denote that A is partially ordered by the relation R.

Note: The relation  on the set of real numbers is the prototype of a partial order, so it is
common to write  to represent an arbitrary partial order on A.

Characteristic Properties of a Partial Order

1. Reflexivity i.e.  a  A, a  a

--
2. Antisymmetry i.e.  a,b∈ A, if a  b and b  a then a=b
3. Transitivity i.e.  a,b,c∈ A, if a  b and b  c then a c

Comparable: Two elements a and b in a set A are said to be comparable under  if either
A  b or b a; otherwise, they are incomparable.

Totally Ordered Set: If every pair of elements of a set A are comparable, then we say that
[A; ] is totally ordered or that A is a totally ordered set or a chain.

In this case,  the relation is called a total order.

Examples: 1. If Z is the set of integers and  is the usual ordering on Z, then [Z;  ]is
partially ordered and totally ordered.

2. The relation < on Z is not a partial order because it is not reflexive.

Lattices
.
A lattice is a partially ordered set (L, ≤) in which every pair of elements a, b ∈ L has a greatest
lower bound and a least upper bound.

Example: Let Z+ denote the set of all positive integers and let R denote the relation ‘division‘ in
Z+, such that for any two elements a, b ∈ Z+, aRb, if a divides b. Then (Z+, R) is a lattice in
which the join of a and b is the least common multiple of a and b, i.e.
a ∨ b = a ⊕ b = LCM of a and b,
and the meet of a and b, i.e. a ∗ b is the greatest common divisor (GCD) of a and b i.e.,
a ∧ b = a ∗ b = GCD of a and b.
We can also write a+b = a∨b = a⊕b=LCM of a and b and a.b = a∧b = a∗b=GCD of a and b.

Example: Let n be a positive integer and Sn be the set of all divisors of n If n = 30, S30 = {1, 2,
3, 5, 6, 10, 15, 30}. Let R denote the relation division as defined in Example 1. Then (S30, R) is
a Lattice see Fig:

--
Example: Let A be any set and P (A) be its power set. The poset (P (A), ⊆) is a lattice in which
the meet and join are the same as the operations ∩ and ∪ on sets respectively.
S = {a}, P (A) = {ϕ, {a}}

S = {a, b}, P (A) = {ϕ, {a}, {a}, S}.

Some Properties of Lattice


Let (L, ≤) be a lattice and ∗ and ⊕ denote the two binary operation meet and join on (L, ≤).
Then for any a, b, c ∈ L, we have

(L1): a∗a = a, (L1)′ : a⊕a = a (Idempotent laws)


(L2): b∗a = b∗a, (L2)′: a ⊕b = b + a (Commutative laws)
(L3) : (a∗b)∗c = a∗(b∗c), (L3)′: (a⊕b)⊕c = a⊕(b + c) (Associative laws)
(L4) : a∗(a + b) = a, (L4)′: a⊕(a∗b) = a (Absorption laws).

The above properties (L1) to (L4) can be proved easily by using definitions of meet and
join. We can apply the principle of duality and obtain (L1)′ to (L4)′.

Complemented lattice:

A complemented lattice is a bounded lattice (with least element 0 and greatest element 1), in
which every element a has a complement, i.e. an element b satisfying a ∨ b = 1 and a ∧ b = 0.
Complements need not be unique.

--
Example: Lattices shown in Fig (a), (b) and (c) are complemented lattices.

Sol.
For the lattice (a) GLB(a, b) = 0 and LUB(x, y) = 1. So, the complement a is b and vise versa.
Hence, a complement lattice.

For the lattice (b) GLB(a, b) = 0 and GLB(c, b) = 0 and LUB(a, b) = 1 and LUB(c, b) = 1; so
both a and c are complement of b.
Hence, a complement lattice.

In the lattice (c) GLB(a, c) = 0 and LUB(a, c) = 1; GLB(a, b) = 0 and LUB(a, b) = 1. So,
complement of a are b and c.
Similarly complement of c are a and b also a and c are complement of b.
Hence lattice is a complement lattice.

Hasse Diagrams
A partial order ≤ on a set P can be represented by means of a diagram known as Hasse diagram
of (P, ≤). In such a diagram,
(i). Each element is represented by a small circle or dot.
(ii). The circle for x ∈ P is drawn below the circle for y ∈ P if x < y, and a line is drawn
between x and y if y covers x.
(iii). If x < y but y does not cover x, then x and y are not connected directly by a single line.

Note: For totally ordered set (P, ≤), the Hasse diagram consists of circles one below the other.
The poset is called a chain.

Example: Let P = {1, 2, 3, 4, 5} and ≤ be the relation “less than or equal to” then the Hasse
diagram is:

Is not a total order set


--
Example: Draw the Hasse diagram for the relation R on A = {1, 2, 3, 4, 5} whose relation matrix
1 0 1 1 1
0 1 1 1 1
given as: MR = 0 0 1 1 1
0 0 0 1 0
[0 0 0 0 1]

Sol: R= {(1, 1), (1, 3), (1, 4), (1, 5), (2, 2), (2, 3), (2, 4), (2, 5), (3, 3), (3, 4), (3, 5), (4, 4), (5.5)}.
Hasse diagram for MR is

Example: A partial order R on the set A = {1, 2, 3, 4} is represented by the following digraph.
Draw the Hasse diagram for R.

Sol: By examining the given digraph , we find that


R= {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.
We check that R is reflexive, transitive and antisymmetric. Therefore, R is partial order relation
on A.
The hasse diagram of R is shown below:

--
Example: Draw the Hasse diagram for the partial ordering ⊆ on the power set P (S) where
S = {a,b, c}.

Sol: S = {a, b, c}.


P (S) = {ϕ, {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c}}.
Hasse diagram for the partial ordered set is shown in fig:

Minimal and Maximal elements(members):


Let (P, ≤) denote a partially ordered set. An element y ∈ P is called a minimal member of P
relative to ≤ if for no x ∈ P , is x < y. Similarly an element y ∈ P is called a maximal member of
P relative to the partial ordering ≤ if for no x ∈ P , is y < x.

Note:
(i). The minimal and maximal members of a partially ordered set need not unique.
(ii). Maximal and minimal elements are easily calculated from the Hasse diagram.
They are the 'top' and 'bottom' elements in the diagram.

Example:

In the Hasse diagram, there are two maximal elements and two minimal elements.
The elements 3, 5 are maximal and the elements 1 and 6 are minimal.

--
Upper and Lower Bounds: Let (P, ≤) be a partially ordered set and let A ⊆ P . Any element
x ∈ P is called an upper bound for A if for all a ∈ A, a ≤ x. Similarly, any element x ∈ P is called
a lower bound for A if for all a ∈ A, x ≤ a.

Example: Find the great lower bound and the least upper bound of {b, d, g}, if they exist in the
poset shown in fig:

Solution: The upper bounds of {b, d, g} are g and h. Since g < h, g is the least upper bound. The
lower bounds of {b, d, g} are a and b. Since a < b, b is the greatest lower bound.

Functions

A function is a rule which maps a number or entity to another unique number or entity.
Let A and B be two non-empty sets. A function f from A to B is a relation from A to B such that:
(i) dom f = A i.e. f is defined at each a  A.
(ii) if ( x, y  f ) and ( x ,z f ) then y= z i.e. no element of A is related to two elements of B.
Note: 1. The words mapping, transformation, correspondence, and operator are used as
synonyms of function.
2. If f is a function from A to B, we write f: A→B.

One-One Function or Injective Function: A function f A B : → is said to be one-to-one


if f(x1)= f(x2)  x1= x2.
Thus, f is one-one iff for each b ran f , b has precisely one pre-image.

Onto Function or Surjective Function: A function f: A→ B is said to be onto iff ran f = B.


In other words, f is onto if each bB has some pre-image in A.

Bijective Function: If a function is both one-to-one and onto then it is called a bijective
function.

--
Remark: A one-to-one, onto function f : A  B is usually called a one-to-one
correspondence between A and B.

Note: 1. If a function f : A  B is not one-to-one, we call it a many-to-one function.

2. If f : A  B is not necessarily onto B, then it is said to be into B.

3. Since a function is a set, two functions f and g from A to B are equal if they are
equal as sets. In other words, f  g iff f  a   g  a  for each a  A .

Constant Function: A function f : X  X is said to be a constant function if


f  x  k  x X where k is fixed.

Identity Function: A function f : X  X is said to be an identity function if


f  x  x  x X .

Example: Let A  r , s, t , B  1, 2,3 and C  r , s, t , u .


Now, R   r ,1 ,  r , 2  ,  t , 2  is a relation from A to B but R is not a function since
image of r is not unique.
The set f   r ,1 ,  s, 2  ,  t , 2  is a function from A to B but f is not one-to-one
since 2 has two pre-images.. Likewise, f is not onto B since 3 has no pre-image.
The function g   r ,1 ,  s, 2  ,  t ,3 is both a one-to-one and an onto function from
A to B.
On the other hand, the function h : C  B defined as h   r ,1 ,  s,1 ,  t , 2  ,  u ,3
is onto, but not one-to-one since 1 has two pre-images.

Composition of Functions

The composition of a function is an operation where two functions say f and g generate a
new function say h in such a way that h  x   g  f  x   .

It means here function g is applied to the function of x . So, basically, a function is applied
to the result of another function.
Definition: Let f : A  B and g : B  C be two functions. Then the composition of f and
g , denoted by g f , is defined as the function g f : A  C given by g f  x   g  f  x   ,
 x  A.

--
The below figure shows the representation of composite functions.

Note: The order of function is an important thing while dealing with the composition of
functions since f g  x  is not always equal to g f  x  .

Symbol: It is also denoted as g f  x  , where ∘ is a small circle symbol. We cannot replace


∘ with a dot (.), because it will show as the product of two functions, such as  g . f  x  .

Domain in Composition Function: f  g  x   is read as f of g of x . In the composition of


f g  x  the domain of function f becomes g  x  . The domain is a set of all values which
go into the function.

Example: If f  x   3x  1 and g  x   x , then f of g of x , f  g  x    f  x 2   3x 2  1.


2

If we reverse the function operation, such as g of f of x , g  f  x    g  3x  1   3x  1 .


2

Properties of Function Compositions

1. Associative Property: If there are three functions f , g and h , then they are said to
be associative if and only if
f  g h   f g h

2. Commutative Property: Two functions f and g are said to be commute with each
other, if and only if
f gg f

3. The function composition of one-to-one function is always one to one.


4. The function composition of two onto function is always onto.
5. The inverse of the composition of two functions f and g is equal to the composition of
the inverse of both the functions, such as  f g   g 1 f 1 .
1

--
Example: If f  x   3 x , then f f  x   f  f  x    f  3x 2   3.9 x 4  27 x 4 .
2

Inverse Function
Definition: An inverse function or an anti-function is defined as a function, which can
reverse into another function. In simple words, if any function f takes x to y then, the
inverse of f will take y to x.

If the function is denoted by f or F , then the inverse function is denoted by f 1 or F 1 .


One should not confuse (-1) with exponent or reciprocal here.

Note: If f and g are inverse functions, then f  x   y iff g  y   x.

Example: If f  x   2 x  5 then what will be the inverse of f ?

y 5
Let f  x   2 x  5  y  x   g  y
2
x 5
Then, f 1  x   .
2
Remark: In trigonometry, the inverse sine function is used to find the measure of angle for
which sine function generated the value.
For example, sin-1(1) = sin-1(sin 90) = 90 degrees. Hence, sin 90 degrees is equal to 1.
Note: A function that consists of its inverse fetches the original value.
Types of Inverse Function: There are various types of inverse functions like the inverse of
trigonometric functions, rational functions, hyperbolic functions and log functions. The
inverses of some of the most common functions are given below.

Function Inverse of the Function Comment

+ –

× / Don‟t divide by 0

1/x 1/y x and y not equal to 0

x2 √y x and y ≥ 0

xn y1/n n is not equal to 0

ex ln(y) y>0

ax log a(y) y and a > 0

Sin (x) Sin-1 (y) – π/2 to + π/2

--
Function Inverse of the Function Comment

Cos (x) Cos-1 (y) 0 to π

Tan (x) Tan-1 (y) – π/2 to + π/2

Operations
We can classify the operations into following main categories:
Unary Operation: A unary operation is an operation with only one operand, i.e. a single
input.
Examples: The function f : A  A , (where A is a set) is a unary operation on A. The
trigonometric functions are unary operations.
Notations: Common notations are prefix notation (e.g. +, −, ¬), postfix notation
(e.g. factorial n!), functional notation (e.g. sin x or sin(x)), and superscripts (e.g.
transpose AT).
Binary Operation: A binary operation or dyadic operation is a calculation that combines two
elements (called operands) to produce another element.
Examples: The familiar arithmetic operations of addition, subtraction, and multiplication.
Other examples are readily found in different areas of mathematics, such as vector addition
and matrix multiplication.

Remark: More precisely, a binary operation on a set S is a mapping of the elements of


the Cartesian product S × S to S i.e. f : S  S  S.
Note: Because the result of performing the operation on a pair of elements of S is again an
element of S, the operation is called a closed (or internal) binary operation on S (or
sometimes expressed as having the property of closure).
n-ary Operation: An operation that takes n arguments for its input is an n-ary operation.
Example: Adding a bunch of numbers together would be a simple n-ary operation, i.e.
n
Sum  x1 , x2 ,..., xn    xi
i 1

Also, picking out a maximum, minimum, mean, medium, the first object in a list and so on
are also its examples.

Remark: In general, a function takes an object from space X and maps it to space Y. If the
objects in X are tuples (an ordered collection of sub-objects) then the function is an n-ary
operation.
f : X Y
X  X1  X 2  ...  X n
then f is an n-ary operation.

--
SOLVED PROBLEMS

Example 1. Which of these sets are equal: {x, y, z}, {z, y, z, x}, {y, x, y, z}, {y, z, x, y}?
Solution: They are all equal. Order and repetition do not change a set.

Example 2. List the elements of each set where N = {1, 2, 3, …}.


(a) A = {x ∈ N| 3 < x < 9}
(b) B = {x ∈ N| x is even, x < 11}
(c) C = {x ∈ N| 4 + x = 3}
Solution: (a) A consists of the positive integers between 3 and 9; hence A = {4, 5, 6, 7, 8}.
(b) B consists of the even positive integers less than 11; hence B = {2, 4, 6, 8, 10}.
(c) No positive integer satisfies 4 + x = 3; hence C = ∅, the empty set.

Example 3. In a survey of 120 people, it was found that:


65 read Newsweek magazine, 20 read both Newsweek and Time,
45 read Time, 25 read both Newsweek and Fortune,
42 read Fortune, 15 read both Time and Fortune,
8 read all three magazines.
(a) Find the number of people who read at least one of the three magazines.
(b) Draw its Venn diagram.
(c) Find the number of people who read exactly one magazine.
Solution: (a) We want to find n(N ∪ T ∪ F).
Using Inclusion–Exclusion Principle, we can write
n(N ∪ T ∪ F)= n(N) + n(T ) + n(F ) − n(N ∩ T ) − n(N ∩ F) − n(T ∩ F) + n(N ∩ T ∩ F)
= 65 + 45 + 42 − 20 − 25 − 15 + 8 = 100
(b) To draw the required Venn diagram, we need to obtain the following:
8 read all three magazines,
20 − 8 = 12 read Newsweek and Time but not all three magazines,
25 − 8 = 17 read Newsweek and Fortune but not all three magazines,
15 − 8 = 7 read Time and Fortune but not all three magazines,
65 − 12 − 8 − 17 = 28 read only Newsweek,
45 − 12 − 8 − 7 = 18 read only Time,
42 − 17 − 8 − 7 = 10 read only Fortune,
120 − 100 = 20 read no magazine at all.
Hence, it can be drawn as following

--
(c) From Venn diagram, we can clearly see that 28+ 18 + 10 = 56 read exactly one of the
magazines.

Example 4. Given: A = {1, 2},B = {x, y, z}, and C = {3, 4}. Find: A × B × C.
Solution: A × B × C consists of all ordered triplets (a, b, c) where a ∈ A, b ∈ B, c ∈ C. These
elements of A × B × C can be systematically obtained by a so-called tree diagram as shown
below. The elements of A×B ×C are precisely the 12 ordered triplets to the right of the tree
diagram.

Observe that n(A) = 2, n(B) = 3, and n(C) = 2 and, as expected,


n(A × B × C) = 12 = n(A) ・ n(B) ・ n(C).

Example 5. Find x and y given (2x, x + y) = (6, 2).


Solution: Two ordered pairs are equal if and only if the corresponding components are equal.
Hence we obtain the equations
2x = 6 and x + y = 2
from which we derive the answers x = 3 and y = −1.

Example 6. If A = {1, 2, 3, 4} and B = {x, y, z}. Let R be the following relation from A to B:
R = {(1, y), (1, z), (3, y), (4, x), (4, z)}
(a) Determine the matrix of the relation.
(b) Draw the arrow diagram of R.
(c) Find the inverse relation R−1 of R.

--
(d) Determine the domain and range of R.
Solution:

(c) Reverse the ordered pairs of R to obtain R−1:


R−1 = {(y, 1), (z, 1), (y, 3), (x, 4), (z, 4)}
Observe that by reversing the arrows in above figure, we obtain the arrow diagram of R−1.

(d) The domain of R, Dom(R), consists of the first elements of the ordered pairs of R, and the
range of R, Ran(R), consists of the second elements. Thus,
Dom(R) = {1, 3, 4} and Ran(R) = {x, y, z}

Example 7. Let X = {1, 2, 3, 4}. Determine whether each relation on X is a function from X
into X.
(a) f = {(2, 3), (1, 4), (2, 1), (3.2), (4, 4)}
(b) g = {(3, 1), (4, 2), (1, 1)}
(c) h = {(2, 1), (3, 4), (1, 4), (2, 1), (4, 4)}
Solution: Recall that a subset f of X×X is a function f: X → X if and only if each a ∈ X
appears as the first coordinate in exactly one ordered pair in f.
(a) No. Two different ordered pairs (2, 3) and (2, 1) in f have the same number 2 as their first
coordinate.
(b) No. The element 2 ∈ X does not appear as the first coordinate in any ordered pair in g.
(c) Yes. Although 2 ∈ X appears as the first coordinate in two ordered pairs in h, these two
ordered pairs are equal.

Example 8. Let A = {a, b, c}, B = {x, y, z},C = {r, s, t}. Let f: A → B and g: B → C be
defined by:
f = {(a, y), (b, x), (c, y)} and g = {(x, s), (y, t ), (z, r)}.
Find: (a) composition function g◦f: A → C; (b) Im(f ), Im(g), Im(g◦f ).
Solution: (a) Use the definition of the composition function to compute:
(g◦f )(a) = g(f (a)) = g(y) = t
(g◦f )(b) = g(f (b)) = g(x) = s
(g◦f )(c) = g(f (c)) = g(y) = t

--
That is g◦f = {(a, t ), (b, s), (c, t)}.
(b) Find the image points (or second coordinates):
Im(f ) = {x, y}, Im(g) = {r, s, t}, Im(g◦f ) = {s, t}.

Example 9. Let the functions f : A → B, g : B → C, h : C → D be defined as in the following


figure: Determine if each function is: (a) onto, (b) one-to-one, (c) invertible.

Solution: (a) The function f : A → B is not onto since 3 ∈ B is not the image of any element
in A.
The function g : B → C is not onto since z ∈ C is not the image of any element in B.
The function h : C → D is onto since each element in D is the image of some element of C.
(b) The function f : A → B is not one-to-one since a and c have the same image 2.
The function g : B → C is one-to-one since 1, 2 and 3 have distinct images.
The function h : C → D is not one-to-one since x and z have the same image 4.
(c) No function is one-to-one and onto; hence no function is invertible.

--
UNIT-II: Mathematical Logic

Syllabus

Statements and Notation, Connectives, Quantified Propositions, Logical Inferences,


Methods of Proof of an Implication, First Order Logic and other Methods of Proof, Rules
of Inference for Quantified Propositions

Self-study: Nested quantifiers, Strong Mathematical Induction


1 Mathematical Logic : Statements and Notation
The rules of logic specify the meaning of mathematical statements. For instance, these
rules help us understand and reason with statements such as “There exists an integer that
is not the sum of two squares” and “For every positive integer n, the sum of the positive
integers not exceeding n is n(n + 1)/2.” Logic is the basis of all mathematical reasoning,
and of all automated reasoning. It has practical applications to the design of computing
machines, to the specification of systems, to artificial intelligence, to computer programming,
to programming languages, and to other areas of computer science, as well as to many other
fields of study.
Usually sentences are classified in to four types.

• Declarative • Interrogative

• Exclamatory • Imperative

In logics, we pay our attention to those declarative sentences to which it is meaningful


to assign one and only one of the truth values TRUE or FALSE. Such declarative sentences
are called P ropositions or Statements. For definiteness the following assumptions are made
about propositions.

Assumption 1 :The Law of Excluded Middle


For every proposition p, either p is true or p is false
Assumption 2 :The Law of Contradiction
For every proposition p, it is not the case that p is both true and false

2 Connectives
Propostions are combined by means of connectives to form new propositions or statements.
They are

(i) not (ii) and (iii) or (iv) if .. then (v) If and only if

2.1 Negation (not)


If p is a Proposition, then “p is not true” is also a proposition. This we represent as “ ∼ p”
and it is referred as “not p” or “negation of p” or “denial of p”. The proposition “ not p” is
true when p is false and false when p is true.
Example : p : Ramanujan is genius
∼ p : It is not the case that Ramanujan is genius
or ∼ p : It is false that Ramanujan is genius
or ∼ p : Ramanujan is not genius
The truth table for negation is as given below.

p ∼p
T F
F T
2.2 Conjunction (and)
If p and q are propositions, then “p and q” is also a proposition, which we represent as “p∧q”
and is called “Conjunction”. The conjunction “p ∧ q” is true only when p is true and q is
true. In all other cases it is false.

Example : p : 2 is an irrational number
q : 7 is a prime number

p ∧ q : 2 is an irrational number and 7 is a prime number

The truth table for conjunction is as given below.

p q p∧q
T T T
T F F
F T F
F F F

2.3 Disjunction (or)


It is divided into two parts:

2.3.1 Inclusive Disjunction


If p and q are propositions, then “p or q” is also a proposition, represented by “p ∨ q” and is
called “Inclusive Disjunction”. This disjunction “p ∨ q” is true whenever at least one of the
two propositions is true. In other words, this disjunction is false only when p is false and q
is false. In all other cases, it is true.
Example : “Students who have taken calculus or computer science can take this
class.”
Here, we mean that students who have taken both calculus and computer science can
take the class, as well as the students who have taken only one of the two subjects.

The truth table for inclusive disjunction is as given below.

p q p∨q
T T T
T F T
F T T
F F F

2.3.2 Exclusive Disjunction


If p and q are propositions, then “p or q” is also a proposition, represented by “p∨q” and
is called “Exclusive Disjunction”. This disjunction “p∨q” is true whenever one of the two
propositions is true. In other words, this disjunction is false when p and q are both false or
both true.
Example : “Students who have taken calculus or computer science, but not both,
can enroll in this class.” Here, we mean that students who have taken both calculus and
computer science course cannot take the class. Only those who have taken exactly one of
the two courses can take the class.
Similarly, when a menu at a restaurant states, “Soup or salad comes with an entrée,”
the restaurant almost always means that customers can have either soup or salad, but not
both.
Hence, this is an exclusive, rather than an inclusive, or. The truth table for exclusive
disjunction is given below.
p q p∨q
T T F
T F T
F T T
F F F

2.4 Conditional (if p then q)


If p and q are propositions, then the proposition “p implies q” or “if p then q” is represented
as “p → q” and is called an “Implication” or a “Conditional”. In this case, p is called
premise, hypothesis or antecedent of implication and q is called the conclusion or consequent
of the implication. The conditional “p → q” is false only when p is true and q is false, in all
other cases it is true.

The statement “p → q” is called a conditional statement because “p → q” asserts


that q is true on the condition that p holds. Note that the statement “p → q” is true when
both (i) p and q are true and (ii) p is false (no matter what truth value q has). Because
conditional statements play such an essential role in mathematical reasoning, a variety of
terminology is used to express “p → q”. In general, the following ways are used to express
this conditional statement:
“if p, then q” “p implies q”
“if p, q” “q follows from p”
“p is sufficient for q” “a sufficient condition for q is p”
“q if p” “q whenever p”
“q when p”

Example: A useful way to understand the truth value of a conditional statement is


to think of an obligation or a contract. For example, the pledge many politicians make when
running for office is
“If I am elected, then I will lower taxes.”

If the politician is elected, voters would expect this politician to lower taxes. Fur-
thermore, if the politician is not elected, then voters will not have any expectation that this
person will lower taxes, although the person may have sufficient influence to cause those
in power to lower taxes. It is only when the politician is elected but does not lower taxes
that voters can say that the politician has broken the campaign pledge. This last scenario
corresponds to the case when p is true but q is false in “p → q”.

Similarly, consider a statement that a professor might make:


“If you get 100% on the final, then you will get an A.”
If you manage to get a 100% on the final, then you would expect to receive an A. If
you do not get 100% you may or may not receive an A depending on other factors. However,
if you do get 100%, but the professor does not give you an A, you will feel cheated.

The truth table for conditional is as given below.


p q p→q
T T T
T F F
F T T
F F T

Converse, Contrapositive and Inverse: We can form some new conditional state-
ments starting with a conditional statement “p → q”. In particular, there are three related
conditional statements that occur so often that they have special names.

(i) The proposition “q → p” is called the converse of “p → q”.

(ii) The contrapositive of “p → q” is the proposition “¬q → ¬p”.

(iii) The proposition “¬p → ¬q” is called the inverse of “p → q”.

Example: What are the contrapositive, the converse, and the inverse of the condi-
tional statement “The home team wins whenever it is raining“?

Solution: Since “q whenever p” is one of the ways to express the conditional state-
ment “p → q”, the original statement can be rewritten as

“If it is raining, then the home team wins.”

So, we can write as following:

Contrapositive: “If the home team does not win, then it is not raining.”

Converse: “If the home team wins, then it is raining.”

Inverse: “If it is not raining, then the home team does not win.”

Note: Out of these three conditional statements formed from “p → q”, only the
contrapositive always has the same truth value as “p → q”.

2.5 Biconditional
If p and q are propositions, then the conjunction of conditionals p → q and q → p is called
“Biconditional” of p and q and is denoted by p ↔ q. Thus p ↔ q is same as (p → q)∧(q → p)
and is read as “p if and only if q”.

Example: “You can take the flight if and only if you buy a ticket.”
This statement is true if p and q are either both true or both false, that is, if you buy a
ticket and can take the flight or if you do not buy a ticket and you cannot take the flight. It
is false when p and q have opposite truth values, that is, when you do not buy a ticket, but
you can take the flight (such as when you get a free trip) and when you buy a ticket but you
cannot take the flight (such as when the airline bumps you).

The truth table for biconditional is as given below.


p q p→q q→p p↔q
T T T T T
T F F T F
F T T F F
F F T T T

Combined Truth Table: The combined truth table is as follows:

p q ∼p p∧q p∨q p∨q p→q p↔q


T T F T T F T T
T F F F T T F F
F T T F T T T F
F F T F F F T T

3 Definitions
Compound Propositions: The new propositions obtained by using connectives are
called molecular or compound propositions.

Simple Propositions: Propositions which don’t contain any logical connectives are
called simple propositions.

Propositional Function: A propositional function is a function whose variables are


propositions.

Remark: While representing a statement (proposition) involving connectives in sym-


bolic form, care has to be taken to ensure that the symbolic representation conveys the
intended meaning of the statement without any ambiguity. Appropriate parenthesis are to
be used at appropriate places to achieve this objective.

Well-formed Formulae: Statements represented in symbolic forms which cannot


be interpreted in more than one way are called well-formed formulae.

Logically Equivalent or Equivalent: Two propositional functions p and q are


logically equivalent or equivalent, if they have same truth values or truth tables. Then we
write p ≡ q.
Problem 1 Construct the truth table for the following:
(i) p ∧ ∼ q (ii) ∼ p ∨ q (iii) ∼ p ∨ ∼ q (iv) p → ∼ q
Solution :

p q ∼p ∼q p∧∼q ∼p∨q ∼p∨∼q p→∼q


T T F F F T F F
T F F T T F T T
F T T F F T T T
F F T T F T F T

Problem 2 Construct the truth tables of the following compound propositions:


(i) ( p ∨ q ) ∧ r (ii) p ∨ ( q ∧ r )
Solution :

p q r p∨q (p∨q)∧r q∧r p∨(q∧r)


T T T T T T T
T T F T F F T
T F T T T F T
T F F T F F T
F T T T T T T
F T F T F F F
F F T F F F F
F F F F F F F

Problem 3 Construct the truth tables of the following compound propositions:


(i) ( p ∧ q ) → r (ii) q ∧ ( ∼ r → p )
Solution : Do it yourself.

Tautology: A compound proposition function which is true for all possible truth
values of its components is called “tautology”.

Contradiction: A compound proposition function which is false for all possible


truth values of its components is called “contradiction” or an “absurdity”

Contingency: A compund proposition which is neither a tautology nor a contra-


diction is called a “contingency”.

Example :
p ∼p p∨∼p p∧∼p
T F T F
F T T F

Here, p∨∼p is a tautology, and p∧∼p is a contradiction.


Problem 4 Show that
(i) ( p ∨ q ) ∨ ( p ↔ q ) is a tautology,
(ii) ( p ∨ q ) ∧ ( p ↔ q ) is a contradiction,
(iii) ( p ∨ q ) ∧ ( p → q ) is a contingency.
Solution :
p q p∨q p→q p↔q (p∨q)∨(p↔q) (p∨q)∧(p↔q) (p∨q)∧(p→q)
T T F T T T F F
T F T F F T F F
F T T T F T F T
F F F T T T F F

Problem 5 Prove that [ ( p → q ) ∧ ( q → r ) ] → ( p → r ) is a tautology.


Solution :
p q r p→q q→r (p→q)∧(q→r) p→r [( p → q ) ∧ ( q → r )] → ( p → r )
T T T T T T T T
T T F T F F F T
T F T F T F T T
T F F F T F F T
F T T T T T T T
F T F T F F T T
F F T T T T T T
F F F T T T T T

Hence, [ ( p → q ) ∧ ( q → r ) ] → ( p → r ) is a Tautology.

Problem 6 For any two Propositions p, q prove that ( p → q) ⇔ ( ∼ p ∨ q).


Solution :

p q p→q ∼p ∼p∨q
T T T F T
T F F F F
F T T T T
F F T T T

We observe that p → q and ∼ p ∨ q have identical truth values for all possible truth values
of p and q.
∴ ( p → q) ⇔ ( ∼ p ∨ q) i.e., p → q and ∼ p ∨ q are logically equivalent.

Logical Implication: A proposition p logically implies a proposition q, and q is a


logical consequence of p, if the implication (p → q) is true for all possible assignments of the
truth values of p and q, that is, if (p → q) is a tautology.

Note: Much care must be taken not to confuse implication (or conditional) with
logical implication. The conditional is only a way of connecting the two propositions p and
q, whereasif p logically implies q then p and q are related to the extent that whenever p
has the truth value T then so does q. We do note that every logical implication is an
implication (conditional), but not all implications are logical implications.

Valid and Faulty Inferences: We say that an inference is valid if the implication
is a tautology, that is, if the implication is a logical implication otherwise, we say that the
inference is faulty or invalid.

4 The Laws of Logic


The following results are known as Laws of Logic obtained based on the definition of logical
equivalence.

1. Law of double negation : For any Proposition p, ∼ (∼ p) ⇔ p

2. Idempotent Laws : For any Proposition p, (a) p ∨ p ⇔ p (b) p ∧ p ⇔ p

3. Identity Laws : For any Proposition p, (a) p ∨ F0 ⇔ p (b) p ∧ T0 ⇔ p


Where F0 is a Contradiction and T0 is a Tautology.

4. Inverse Laws : For any Proposition p, (a) p ∨ ∼ p ⇔ T0 (b) p ∧ ∼ p ⇔ F0

5. Domination Laws : For any Proposition p, (a) p ∨ T0 ⇔ T0 (b) p ∧ F0 ⇔ F0

6. Commutative Laws : For any two Proposition p and q,


(a) (p ∨ q) ⇔ (q ∨ p) (b) (p ∧ q) ⇔ (q ∧ p)

7. Absorption Laws : For any two Proposition p and q,


(a) [p ∨ (p ∧ q)] ⇔ p (b) [p ∧ (p ∨ q)] ⇔ p

8. De Morgan Laws : For any two Proposition p and q,


(a) ∼(p ∨ q) ⇔ ∼ p ∧ ∼ q (b) ∼(p ∧ q) ⇔ ∼ p ∨ ∼ q

9. Associative Laws : For any three Proposition p, q and r


(a) p ∨ (q ∨ r) ⇔ (p ∨ q) ∨ r (b) p ∧ (q ∧ r) ⇔ (p ∧ q) ∧ r

10. Distributive Laws : For any three Proposition p, q and r


(a) p ∨ (q ∧ r) ⇔ (p ∨ q) ∧ (p ∨ r) (b) p ∧ (q ∨ r) ⇔ (p ∧ q) ∨ (p ∧ r)

Problem 7 Obtain the truth table for p ∨ (q ∧ r) and (p ∧ q) ∨ (p ∧ r) for all possible
truth values of p, q, r.
Solution : Do it yourself.
5 Fallacies
These are the statements which appear to be true but they are not. There are three forms
of faulty inferences.
1. Fallacy of affirming the Consequent :
p→q
q
∴ p is a Fallacy
since [(p → q) ∧ q] → p is not a tautology.
2. Fallacy of denying the antecedent :
p→q
∼p
∴ ∼q is a Fallacy
since [(p → q) ∧ (∼ p)] → (∼ q) is not a tautology.
3. Non sequitur fallacy (Non sequitur means it doesn’t follow) :
p
∴ q is a Fallacy
since p → q is not a tautology.

Problem 8 Simplify the following Compound propositions using laws of logic.


(i) (p ∨ q)∧ ∼(∼ p ∨ q)
(ii) ∼ [∼ [( p ∨ q ) ∧ r] ∨ ∼ q ]
Solution : The solution can be written as following:
(i) (p ∨ q)∧ ∼(∼ p ∨ q) ≡ (p ∨ q) ∧ (p ∧ ∼ q) DeMorgan and Double Negation Laws
≡ [(p ∨ q) ∧ p ] ∧ ∼ q Associative Law
≡ [ p ∧ (p ∨ q) ] ∧ ∼ q Commutative Law
≡ p∧∼q Absorption Law

(ii) ∼ [∼ [( p ∨ q ) ∧ r] ∨ ∼ q ] ≡ ∼ [∼ [( p ∨ q ) ∧ r]] ∧ ∼ [∼ q ] De Morgan


Law
≡ [( p ∨ q ) ∧ r] ∧ q Law of double negation
≡ ( p ∨ q ) ∧ (r ∧ q) Associative Law
≡ ( p ∨ q ) ∧ (q ∧ r) Commutative Law
≡ (( p ∨ q ) ∧ q) ∧ r Associative Law
≡ q∧r Absorption Law

Remark : Logically equivalent propositions are treated as equivalent propositions.


Some of the useful logically equivalent propositions are here under.
(i) ∼ (p ∨ q) ≡ ∼ p ∧ ∼ q (ii) ∼ (p ∧ q) ≡ ∼ p ∨ ∼ q
(iii) ∼ (p → q) ≡ p ∧ ∼ q
(iv) (p → q) ≡ ∼ (∼(p → q)) ≡ ∼ (p ∧ ∼ q) ≡ ∼ p ∨ ∼∼ q ≡ ∼ p ∨ q
Proposition Negation
∼p p
p∧q ∼p∨∼q
p∨q ∼p∧∼q
p→q p∧∼q
∼ ( p → q) ∼p∨q

Problem 9 Show that ( p → q ) ∧ [ ∼ q ∧ (r ∨ ∼ q)] ⇔ ∼(q ∨ p).

Solution : This can be done by using truth tables of both LHS and RHS or obtain RHS
from LHS by simplifying LHS.
( p → q ) ∧ [ ∼ q ∧ (r ∨ ∼ q)] ≡ ( p → q ) ∧ [ ∼ q ∧ (∼ q ∨ r)] Commutative Law
≡ (p→q )∧∼q Absorption Law
≡ ∼[(p→q )→q ] {∵∼(p→q )≡p∧∼q }
≡ ∼[∼(p→q )∨q ] {∵(p→q )≡∼p∨q }
≡ ∼[(p∧∼q )∨q ] {∵∼(p→q )≡p∧∼q }
≡ ∼ [ q ∨ ( p ∧ ∼ q ) ] Commutative Law
≡ ∼ [ (q ∨ p) ∧ ( q ∨ ∼ q ) ] Distributive Law
≡ ∼ [ (q ∨ p) ∧ T0 ] { ∵ q ∨ ∼ q is a Tautology }
≡ ∼ (q ∨ p) Identity Law

Problem 10 Show that [( p ∨ q ) ∧ ∼ { ∼ p ∧ (∼ q ∨ ∼ r)}] ∨ (∼ p ∧ ∼ q) ∨ (∼ p ∧ ∼ r)


is a Tautology.

Solution : Let w = u ∨ v

where u = ( p ∨ q ) ∧ ∼ { ∼ p ∧ (∼ q ∨ ∼ r)} and


v = (∼ p ∧ ∼ q) ∨ (∼ p ∧ ∼ r)
Now
u ≡ ( p ∨ q ) ∧ ∼ { ∼ p ∧ (∼ q ∨ ∼ r)}
≡ ( p ∨ q ) ∧ ∼ { ∼ p ∧ ∼ (q ∧ r)}
≡ ( p ∨ q ) ∧ ∼ { ∼ (p ∨ (q ∧ r))}
≡ ( p ∨ q ) ∧ { p ∨ (q ∧ r)}
≡ p ∨ {q ∧ (q ∧ r)}
≡ p ∨ (q ∧ r)
Now
v ≡ (∼ p ∧ ∼ q) ∨ (∼ p ∧ ∼ r)
≡ ∼(p∨q )∨∼(p∨r)
≡ ∼ {( p ∨ q ) ∧ ( p ∨ r )}
≡ ∼ {p ∨ ( q ∧ r )} ≡ ∼ u

∴ w ≡ u ∨ v ≡ u ∨ ∼ u , which is always true.


∴ The given compound proposition is a Tautology.
6 Rules of Inference
To construct proofs, we need a means of drawing conclusions or deriving new assertions from
old ones; this is done using rules of inference. Rules of inference specify which conclusions
may be inferred legitimately from assertions known, assumed, or previously established.

1. Modus Ponens or Rule of detachment : If the statement p is assumed as true,


and also the statement p → q is accepted as true, then in these circumstances, we must
accept q as true. Symbolically we write it as
p
p→q
∴ q
or p ∧ (p→q) → q is a tautology.

Example : It is 11.00 o’clock at Hyderabad.


If it is 11.00 o’clock at Hyderabad, then it is 9.30 o’clock at Newyork.
Then by rule of detachment, we can conclude that
It is 9.30 o’clock at Newyork.

2. Law of hypothetical syllogism or Transitive rule : Whenever the two implica-


tions p → q and q → r are accepted as true, we must accept the implication p → r as
true. Symbolically we write it as
p→q
q→r
∴ p→r
This is because of the implication (p → q) ∧ (q → r) → (p → r) is a tautology.
This can be extended to a larger number of variables, for example
p→q
q→r
r→s
∴ p→s

3. Law of contrapositive : Symbolically it can be written as


(p → q) ⇐⇒ ∼ q →∼ p

4. Demorgan Laws : Symbolically these laws can be written as


∼ (p ∨ q) ⇐⇒ ∼ p ∧ ∼ q
∼ (p ∧ q) ⇐⇒ ∼ p ∨ ∼ q

7 Methods of Proof of an Implication


The propositions that commonly appear in Mathematical discussions are conditionals of
the form p → q, where p and q are simple or compound propositions which may involve
quantifiers. Given such a conditional, the process of establishing that the conditional is true
by using the laws of logic (rules) and other known facts is called a proof of conditional. The
process of establishing that a proposition is a false is called disproof.
1. Trivial Proof : If it is possible to establish that q is true, then regardless of the truth
values of p, p → q is true.

2. Vacuous Proof : If p is shown to be false, then p → q is true for any proposition q.

3. Direct Proof : The direct proof begins by assuming p is true and then, from available
information, from the frame of reference, the conclusion q is shown to be true by valid
inference.

4. Indirect Proof : The implication p → q is equivalent to the implication ∼ q → ∼ p.


Hence we can establish the truth of p → q by prooving ∼ q → ∼ p, which is called
indirect proof. Hence, in the indirect proof
(a) assume q is false
(b) prove on the basis of available information, p is false.

5. Proof by Contradiction : We know the fact that p → q is true if and only if p


∧ ∼ q is false. This is derived from DeMorgan laws and the fact p → q ≡ ∼ p ∨ q.
Hence, in the proof by contradiction
(a) assume p ∧ ∼ q is true
(b) Discover some conclusion that is false or violates the existing / established
rules.
(c) Then based on the contradiction obtained in (b), we can say p ∧ ∼ q is
false and hence p → q is true.

6. Proof by Cases : If Proposition p is in the form p1 ∨ p2 ∨ p3 ∨ ...... ∨ pn then ( p1


∨ p2 ∨ p3 ∨ ...... ∨ pn ) → q can be established by proving separately p1 → q, p2 →
q, p3 → q, .... pn → q.

7. Proof by Elimination of Cases : This method of proof is nothing more than the
law of disjunctive syllogism, given by [ ( p ∨ q ) ∧ ∼ p ] → q. This can be extended to
any finite number of cases.
{ [ ( p1 ∨ p2 ∨ p3 ∨ p4 ....∨ pn ) ∨ q ] ∧ ∼ p1 ∧ ∼ p2 ∧ ∼ p3 ∧ ∼ p4 ...∧ ∼ pn } → q

8. Conditional Proof : We know that p → (q → r) ≡ (p ∧ q) → r. Hence the proof


of conditional p → (q → r) is as follows.
(a) combine the two antecedents p and q
(b) Then prove r on the basis of available information.

9. Proof by Equivalence : To prove p ↔ q, we break it into two parts i.e., p → q and


q → p and prove them separately. To prove these parts we can choose any one of the
previous methods.
8 First Order Logic and Other Methods of Proof
Everyone enrolled in MRUH has lived in a hostel.
Sahithya has never lived in a hostel.
————————————————–
∴ Sahithya has never enrolled in MRUH.

Our target is to determine whether the aforementioned argument is correct or not. All
three are statements and are independent as no implication is there. Propositional logic
is not enough to handle these kinds of arguments therefore we’ll move to first-order logic.
We’ll identify the validity of such arguments using first-order logic or predicate logic. So
we’ll understand Predicates and Quantifiers.

Predicates: Predicates are statements involving variables which are neither True nor
False untill or unless the values of variables are specified.
Example:

1. x is an animal.

2. x is greater than 4.

3. x is less than 5

4. x + y = 7.

All the above statements are neither True nor False. They are not propositions because we
can’t identify thruth values for the argument.
In Predicate logic, a statement is devided into two parts: subject and predicate. Usually we
denote such statements with shorthand notation; G(x).

G(x) : x is greater than 3,


where G() denotes the predicate “is greater than 3” and x denotes the subject or variable.
After assigning the values of a variable x, the statement G(x) becomes proposition and has
a truth value (either True or False)

G(5) : 5 is greater than 3, (True)

G(3) : 3 is greater than 3, (False)

Quantifiers: Quantifiers are words that refer to quantities such as “some” or “all”. It tells
for howmany elements a given Predicate is True. In English, Quantifiers are used to express
the quantities without giving an exact number.
Ex. all. some, many, none, few etc.
Sentence like: —

1. “Jack has many friends”

2. “Can I have some water?”


Types of quantifiers are:

1. Universal quantifier: The Universal Quantifiers of P (x) is the statement P (x)


is true for all values of x in the domain.
Example: Let P (x) be a statement x + 1 > x

P (1) = 1 + 1 > 1 = 2 > 1 True


P (2) = 2 + 1 > 1 = 3 > 1 True
P (x) is “True” for all natural numbers. Mathematically, we write: (∀x ∈ N), P (x)
Symbolically, we can write this as ∀x, P (x), here “∀” is a universal quantifier.

2. Existential quantifier The Existential Quantifiers of Q(x) is the statement


Q(x)P is True for some values of x in the domain.
Example: Let Q(x) be a statement x < 2

Q(1) = 1 < 2 True


Q(2) = 2 < 2 False
Q(3) = 3 < 2 False
There exists some(x = 1) in natural numbers for which Q(x) is “True”.
Symbolically, we can write this as ∃x, Q(x), here “∃” is an existential quantifier.

Remark: If we use a quantifier that appears within the scope of another quantifier, then
it is called nested quantifier.
Example :

1. O(x): x is an odd number; P (x): x is a Prime number.

2. B(x) : x is a Bird.

3. F (x) : x can Fly.

Then “all birds can fly” can be written as


∀x, B(x) → F (x)
and “not all birds can fly” can be written as
∼ [ ∀x, B(x) → F (x) ] or ∃x, B(x) ∧ ∼ F (x)
4. There is a student who likes Mathematics but not Physics
M (x) : x likes Mathematics
P (x) : x likes Physics
S(x) : x is a student,
then the above statement can be written as ∃x, [ S(x) ∧ M (x) ∧ ∼ P (x) ]
The following table gives us the abbreviated meaning of the quantified statements.

No. Sentence Abbreviated Meaning


1 ∀x, F (x) all True
2 ∃x, F (x) at least one true
3 ∼ [ ∃x, F (x) ] none true
4 ∀x, [∼ F (x) ] all false
5 ∃x, [∼ F (x) ] at least one false
6 ∼ [ ∃x, [∼ F (x) ] ] none false
7 ∼ [ ∀x, F (x) ] not all true
8 ∼ [ ∀x, [∼ F (x) ] ] not all false

These can be further reduced to four, by listing the following equivalences.


No. Sentence Reference Numbers
1 ∀x, F (x) ≡ ∼ [ ∃x, [∼ F (x) ] ] 1&6
2 ∃x, F (x) ≡ ∼ [ ∀x, [∼ F (x) ] ] 2&8
3 ∼ [ ∃x, F (x) ] ≡ ∀x, [∼ F (x) ] 3&4
4 ∃x, [∼ F (x) ] ≡ ∼ [ ∀x, F (x) ] 5&7

Remark: The variable present in a quantified statement is called bound variable.

Other Methods of Proof: We can write a few more proof techniques as:

1. Proof by example: To show ∃x, F (x) is true, it is sufficient to show F (c) is true
for some c in the universe. This type is the only situation where an example proves
anything.

2. Proof by exhaustion: A statement of the form ∀x, [∼ F (x)] that F (x) is false for all
x (all false) or, equivalently, that there are no values of x for which F (x) is true (none
true) will have been proven after all the objects in the universe have been examined
and none found with property F (x).

3. Proof by counterexample: To show that ∀x, F (x) is false, it is sufficient to exhibit


a specific example c in the universe such that F (c) is false. This one value c is called a
counterexample to the assertion ∀x, F (x). In actual fact, a counterexample disproves
the statement ∀x, F (x).

9 Rules of Inference (Contd..)


5 Universal Specification : If a statement of the form ∀x, P (x) is assumed to be true,
then the Universal quantifier can be dropped to obtain P (c) is true for an arbitrary
object c in the Universe. This can be represented as
∀x, P (x)
∴ P (c) for all c
6 Universal Generalization : If a statement P (c) is true for each element c of the
Universe, then the Universal quantifier may be prefixed to obtain ∀x, P (x). This can
be represented as
P (c) for all c
∴ ∀x, P (x)

7 Existential Specification : If ∃x, P (x) is assumed to be true, then there is an ele-


ment c in the universe such that P (c) is true. This can be represented as
∃x, P (x)
∴ P (c) for some c

8 Existential Generalization : If P (c) is true for some element c in the Universe,


then ∃X, p(X) is true. This can be represented as
P (c) for some c
∴ ∃x, P (x)

Example : 1. All Men are fallible


All Kings are Men
Therefore, all Kings are fallible
Let, M (x) : x is a Men
F (x) : x is fallible
K(x) : x is a King
The above argument is symbolized as
∀x, M (x) → F (x)
∀x, K(x) → M (x)
∴ ∀x, K(x) → F (x)
The proof of this can be written as follows.

Assertion Reason

1. ∀x, M (x) → F (x) Premise 1


2. M (c) → F (c) Step 1 and Rule 5
3. ∀x, K(x) → M (x) Premise 2
4. K(c) → M (c) Step 3 and Rule 5
5. K(c) → F (c) Step 2, 4 and Rule 2
6. ∀x, K(x) → F (x) Step 5 and Rule 6

Example : 2. Lions are dangerous animals


There are Lions
Therefore, there are dangerous animals
Let, L(x) : x is a Lion
D(x) : x is dangerous
∴ The above argument is symbolized as
∀x, L(x) → D(x)
∃x, L(x)
∴ ∃x, D(x)
The proof of this can be written as follows.

Assertion Reason

1. ∃x, L(x) Premise 2


2. L(c) Step 1 and Rule 7
3. ∀x, L(x) → D(x) Premise 1
4. L(c) → D(c) Step 3 and Rule 5
5. D(c) Step 2, 4 and Rule 1
6. ∃x, D(x) Step 5 and Rule 8

10 Proof by Mathematical Induction


Let P (n) be a statemment which may be either true or false for each integer n. To prove
P (n) is true for all integers n ≥ 1, the following conditions are required:

(i) P (1) is true.

(ii) For all k ≥ 1, P (k) implies P (k + 1).

If we generalise this process, then there are 3 steps to a proof using the principle of
mathematical induction:

1. Basis of Induction : Show P (n0 ) is true where n0 is starting point.

2. Inductive hypothesis : Assume P (k) is true for k ≥ n0 .

3. Inductive step : Show that P (k + 1) is true on the basis of the inductive hypothesis.
n(n + 1)
Example: Prove the formula for the sum of the first n positive integer.
2
Proof: Let S(n) = 1 + 2 + 3 + ... + n. The proof consists of following steps:

1. Basis of Induction : Since S(1) = 1 = 1(1 + 1)/2, the formula is true for n = 1.

2. Inductive hypothesis : Assume the statement S(n) is true for n = k, that is,
k(k + 1)
S(k) = 1 + 2 + 3 + ... + k = .
2
3. Inductive step : Now, show that the formula is true for n = k + 1, that is, S(k + 1) =
(k + 1)(k + 2)
follows from the inductive hypothesis.
2
To do this, we have S(k + 1) = 1 + 2 + 3 + ... + k + (k + 1) = S(k) + (k + 1)
k(k + 1)
Now, using inductive hypothesis S(k) = in above, we can write
2
k(k + 1) k
S(k + 1) = S(k) + (k + 1) = + (k + 1) = (k + 1)( + 1)
2 2
(k + 1)(k + 2)
S(k + 1) =
2
Hence the formula holds for (k + 1) and the proof is complete by the principle of
mathematical induction.

Strong Mathematical Induction: Let P (n) be a statemment which may be


either true or false for each integer n. Then P (n) is true for all positive integers if there is
an integer q ≥ 1 such that

1. P (1), P (2),...,P (q) are all true.

2. When k ≥ q, the assumption that P (i) is true for all integers 1 ≤ i ≤ k implies that
P (k + 1) is true.

As in the case of the principle of mathematical induction, this form can be modified
to apply to statements in which the starting value is an integer different from 1.

Thus, just as before, there are 3 steps to proof by strong mathematical induction:

1. Basis of Induction : Show P (1), P (2),...,P (q) are all true.

2. Strong Inductive hypothesis : Assume P (i) is true for all integers i such that
1 ≤ i ≤ k where k ≥ q.

3. Inductive step : Show that P (k + 1) is true on the basis of the strong inductive
hypothesis.

Remark: In a proof using the principle of mathematical induction we are allowed


to assume P (k) in order to establish P (k + 1). But in using strong mathematical induc-
tion we assume not only P (k) but also P (k−1), P (k−2),...,P (1) as well, to establish P (k+1).

Example: Prove that the function b(n) = 2(3)n − 5 is the unique function defined
by

(1) b(0) = −3, b(1) = 1, and

(2) b(n) = 4b(n − 1) − 3b(n − 2) for n ≥ 2.

Solution: First it is easy to check that b(n) = 2(3)n − 5 satisfies the given relations.

Next, we claim that if a(n) is any other function satisfying relations (1) and (2), then
a(n) = b(n) for all n.

Let P (n) be the statement: a(n) = b(n).

We prove P (n) is a true statement for all non-negative integers n by strong induction.

1. Basis of Induction : Since we know b(0) = −3 and b(1) = 1 and we are assuming
a(0) = −3 and a(1) = 1. Thus, a(0) = b(0) and a(1) = b(1). Therefore, P (0) and P (1)
are true.
2. Strong Inductive hypothesis : Assume P (i) is true for all integers i such that
0 ≤ i ≤ k where k ≥ 1. In other words, assume a(i) = b(i) for all integers 0 ≤ i ≤ k
where k ≥ 1.

3. Inductive step : Now, show that P (k + 1) is true or a(k + 1) = b(k + 1).

From (2), we can write a(k) = 4a(k − 1) − 3a(k − 2)


or, a(k + 1) = 4a(k) − 3a(k − 1)

But, by strong inductive hypothesis,


a(k) = b(k) and a(k − 1) = b(k − 1) since k ≥ 1 and k − 1 ≥ 0.

Thus, a(k + 1) = 4(2(3k ) − 5) − 3(2(3k−1 ) − 5)

= (8)(3k ) − (6)(3k−1 ) − 5

= (8)(3k ) − 2(3k ) − 5

= (6)(3k ) − 5

= (2.3)(3k ) − 5

= (2)(3k+1 ) − 5

= b(k + 1)

and the result is proved by induction.


UNIT-III: Elementary Combinatorics

Syllabus
Basics of Counting, Combinations and Permutations, Enumeration of Combinations and
Permutations, Enumerating Combinations and Permutations with Repetitions, Enumerating
Permutations with Constrained Repetitions, Binomial Coefficients, The Binomial and
Multinomial Theorems
Self-study Pascal’s Identity, Extended Binomial theorem
1 Introduction
For most applications of computers to problems,one normally needs to know, at least approx-
imately, how much storage will be required and about how many operations are necessary. A
major component of estimating the storage needed may be determining the number of items
of a particular type that have to be stored. Similarly, a knowledge of how many operations
the computation involves will help in assessing the length of program execution time, and
thereby aid in determining the potential cost of the computation. Being able to answer
such questions of the form “How many?”, is important if one attempts to compare differ-
ent methods of computation or even to decide whether or not a given computation is feasible.

Combinatorics is concerned with:

• Arrangements of elements in a set into patterns satisfying specifc rules, generally re-
ferred to as discrete structures. Here discrete (as opposed to continuous) typically also
means finite, although we will consider some infnite structures as well.

• The existence, enumeration, analysis and optimization of discrete structures.

• Interconnections, generalizations- and specialization-relations between several discrete


structures.

2 Basics of Counting
If X is a set, let us use |X| to denote the number of elements in X.

2.1 Two Basic Counting Principles


The following two elementary principles act as “building blocks” for all counting problems:

2.1.1 Sum Rule: The principle of disjunctive counting


If a set X is the union of disjoint nonempty subsets S1 , S2 , ... ,Sn then

|X|=|S1 |+|S2 |+...+|Sn |.

Note: It is important to note that the subsets S1 , S2 , ... ,Sn must have no elements
in common. Moreover, since X = S1 ∪ S2 ∪ ... ∪ Sn , each element of X is in exactly one of
the subsets Si . In other words, S1 , S2 , ... ,Sn is a partition of X.

Example: In how many ways can we draw a heart or a spade from an ordinary deck
of playing cards? A heart or an ace? An ace or a king? A card numbered 2 through 10? A
numbered card or a king?

Solution: Since there are 13 hearts and 13 spades, we may draw a heart or a spade
in 13 + 13 = 26 ways.
We may draw a heart or an ace in 13 + 3 = 16 ways since there are only 3 aces that
are not hearts.
We may draw an ace or a king in 4 + 4 = 8 ways.


There are 9 cards numbered 2 through 10 in each of 4 suits, clubs, diamonds, hearts,
or spades, so we may choose a numbered card in 36 ways. (Note: we are counting aces as
distinct from numbered cards.)
Thus, we may choose a numbered card or a king in 36 + 4 = 40 ways.

2.1.2 Product Rule: The principle of sequential counting


If S1 , S2 , ... ,Sn are nonempty sets, then the number of elements in the Cartesian product
S1 × S2 × ... × Sn is the product Πni=1 |Si |. That is,

|S1 × S2 × ... × Sn | = Πni=1 |Si |.

Example: Suppose that the license plates of a certain state require 3 English letters
followed by 4 digits, (a) How many different plates can be manufactured if repetition of
letters and digits are allowed? (b) How many plates are possible if only the letters can be
repeated? (c) How many are possible if only the digits can be repeated? (d) How many are
possible if no repetitions are allowed at all?

Solution: (a) 263 · 104 since there are 26 possibilities for each of the 3 letters and 10
possibilities for each of the 4 digits.
(b) 263 · 10 · 9 · 8 · 7.
(c) 26 · 25 · 24 · 104 .
(d) 26 · 25 · 24 · 10 · 9 · 8 · 7.

2.2 Indirect Counting


It is sometimes beneficial to solve some combinatorial problems by counting indirectly, that
is, by counting the complement of a set.

Example: Determine, by counting indirectly, the number of nonnegative integers


less than 109 that contain the digit 1.

Solution: First, determine the integers less than 109 that do not contain the digit 1.
We are considering 1-digit, or 2-digit, ... , up to 9-digit numbers. (Of course, a representation
like 000002578 is actually a 4-digit number so we can consider 9 positions to be filled with
any of the digits 0, 2, 3, 4, 5, 6, 7, 8, or 9. There are 99 such integers that do not contain
the digit 1.
Thus, there are 109 − 99 = 612, 579, 511 integers less than 109 that do contain the
digit 1.

2.3 One-to-One Correspondence


In this counting technique the problem at hand is replaced by another problem where it is
observed that there are exactly the same number of objects of the first type as there are of
the second type. In other words, a one-to-one correspondence is set up between the objects
of the first type with those of the second. (A one-to-one correspondence between 2 sets A
and B is just a one-to-one function from A onto B.) Of course, we would hope that in the
new context we can see how to count the objects of the second type more readily than those


of the first type.

Example: Suppose that there are 101 players entered in a single elimination tennis
tournament where any player who loses a match must drop out, and every match ends in
a victory for some player, that is, there are no ties. In each round of the tournament, the
players remaining are matched into as many pairs as possible, but if there is an odd number
of players left someone receives a bye (which means an automatic victory for this player in
this round). Enough rounds are played until a single player remains who wins the tourna-
ment. How many matches must be played in total?

Solution: Approach 1 - The 50 winners and bye will go into the second round and
pair into 25 matches and a bye. After this the 25 winners and the bye will go into the third
round where there will be exactly 13 matches. The fourth round will have six matches and
a bye; the fifth round, 3 matches and a bye; the sixth, 2 matches; the seventh will have 1
match and the winner of the seventh round wins the entire tournament. In total, there must
be 50 + 25 + 13 + 6 + 2 + 1 = 100 matches.

Approach 2 - Observe that there is a one-to-one correspondence between the number


of matches and the number of losers. Each match has one and only one loser and each loser
was eliminated in one and only one match. Therefore, the total number of matches is the
same as the total number of losers. At the start there are 101 players and at the end there
is only one undefeated player. Consequently, there must have been 100 losers and hence 100
matches are required to determine a winner.

Remark: One of the nice features of the second approach is that the problem and
its solution can be generalized. Any single elimination tournament similar to the one above
that starts with n contestants will require n − 1 matches in order to determine a winner.

2.4 Factorials
Definition: For each positive integer we define n! = (n − 1).(n − 2)...3.2.1 = the product
of all integers from 1 to n.

Also define 0! = 1. Note that 1! = 1.


Thus, 6! = 6 · 5 · 4 · 3 · 2 · 1

We read n! as “n factorial.”

3 Combinations and Permutations


Definition : Combinations - A combination of n objects taken r at a time (called
a r-combination of n objects) is an unordered selection of r of the objects.

Definition : Permutations - A permutation of n objects taken r at a time (called


a r-permutation of n objects) is an ordered selection or arrangement of r of the objects.

Remark: We are simply defining the terms r-combinations and r-permutations here
and have not mentioned anything about the properties of the n objects. For example, these


definitions say nothing about whether or not a given element may appear more than once
in the list of n objects.

Example: Suppose that the 5 objects from which selections are to be made are:
a, a, a, b, c.

Then, the 3-combinations of these 5 objects are: aaa, aab, aac, abc.

The 3-permutations are: aaa, aab, aba, baa, aac, aca, caa, abc, acb, bac, bca, cab, cba.

Remark: We will use expressions like {3·a, 2·b, 5·c} to indicate either (1) that
we have 3 + 2 + 5 = 10 objects including 3a0 s, 2b0 s and 5c0 s, or (2) that we have 3 objects
a, b, c where selections are constrained by the conditions that a can be selected at most three
times, b can be selected at most twice, and c can be chosen up to five times. The numbers
3, 2, and 5 in this example will be called repetition numbers.

Note: If there is no limit on the number of times an object can be repeated in a


selection (except that imposed by the size of the selection) We use the symbol ∞ as a repe-
tition number to mean that an object can occur an infinite number of times.

Example: The 3-combinations of {∞·a, 2·b, ∞·c} are

aaa, aab, aac, abb, abc, ccc, ccb, cca, cbb.

Definition : If we are considering selections where each object has ∞ as its repeti-
tion number then we designate such selections as selections with unlimited repetitions.
In particular, a selection of r objects in this case will be called r-combinations with
unlimited repetitions and any ordered arrangement of these r objects will be a r-permutation
with unlimited repetitions.

Example: The 3-combinationos of a, b, c, d with unlimited repetitions are the 3-


combinations of {∞·a, ∞·b, ∞·c, ∞·d}.
There are 20 such 3-combinations, namely:

aaa, aab, aac, aad, bbb, bba, bbc, bbd, ccc, cca, ccb, ccd, ddd, dda, ddb, ddc, abc, abd, acd, bcd

Moreover, there are 43 = 64 of 3-permutations with unlimited repetitions since the


first position can be filled in 4 ways (with a, b, c, or d), the second position can be filled in
4 ways, and likewise for the third position.

4 Enumeration of Combinations and Permutations


In this topic, we will only list formulas for combinations and permutations without repe-
titions. We will wait until later to use generating functions to give general techniques for
enumerating combinations where other rules govern the selections.

Let P (n, r) denotes the number of r-permutations of n elements without repetitions.


4.1 Theorem: Enumerating r-permutations without repetitions
n!
P (n, r) = n(n − 1)(n − 2)...(n − r + 1) =
(n − r)!
Proof: Since there are n distinct objects, the first position of a r-permutation may be
filled in n ways. Next, the second position can be filled in (n − 1) ways since no repetitions
are allowed and there are (n − 1) objects left to choose from. The third can be filled in
(n − 2) ways and soon until the rth position is filled in (n − r + 1) ways.

By applying the product rule, we conclude that

P (n, r) = n(n − 1)(n − 2)...(n − r + 1)

Using factorial definition, we can write


n!
P (n, r) =
(n − r)!
Note: When r = n, the above formula becomes
n!
P (n, n) = = n!.
0!
When explicit reference to r is not made, we assume that all the objects are to be arranged;
thus when we talk about the permutations of n objects we mean the case r = n.

Example: In how many ways can 7 women and 3 men be arranged in a row if the
3 men must always stand next to each other?

Solution: There are 3! ways of arranging the 3 men. Since the 3 men always
stand next to each other, we treat them as a single entity, which we denote by X. Then if
W1 , W2 , ..., W7 represents the women, we next are interested in the number of ways of arrang-
ing X, W1 , W2 , ..., W7 . There are 8! permutations of these 8 objects. Hence there are (3!)(8!)
permutations altogether (of course, if there has to be a prescribed order of an arrangement
on the 3 men then there are only 8! total permutations).

Example: In how many ways can the letters of the English alphabet be arranged
so that there are exactly 5 letters between the letters a and b?

Solution: There are P (24, 5) ways to arrange the 5 letters between a and b ,2 ways
to place a and b, and then 20! ways to arrange any 7-letter word treated as one unit along
with the remaining 19 letters. The total is P (24, 5)(20!)(2).

Linear and Circular Permutations: If the objects are being arranged in a line
then the permutations are called linear permutations and if we arrange those in a circle then
the permutations are called circular permutations.
In circular permutations, the number of permutations decreases.

Example: In how many ways can 5 children arrange themselves in a ring?


Solution: Here, the 5 children are not assigned to particular places but are only
arranged relative to oneanother. Thus, the arrangements are considered the same if the
children are in the same order clockwise. Hence, the position of child C1 is immaterial and
it is only the position of the 4 other children relative to C1 that counts. Therefore, keeping
C1 fixed in position, there are 4! arrangements of the remaining children.

Notation: Let C(n, r) denotes the number of r-combinations of n distinct objects


where 1 is the repetition number for each element. Thus, if S is a set with n elements,
C(n, r) is the number of subsets of S with exactly r elements. Or in the terminology of the
previous section, C(n, r) is the number of r-combinations of n elements without repetitions.
We read C(n, r) as “n choose r ” to emphasize that selections are being made. Fre-
quently, the terms C(n, r) are called binomial coefficients because of their role in the expan-
sion of (x + y)n .

4.2 Theorem: Enumerating r-combinations without repetitions


P (n, r) n!
C(n, r) = =
r! r!(n − r)!
Example: In how many ways can a hand of 5 cards be selected from a deck of 52
cards?

Solution: Each hand is essentially a 5-combination of 52 cards. Thus there are


52!
C(52, 5) = such hands.
5!47!
Example: How many 5-card hands consist of cards from a single suit?

Solution: For each of the 4 suits, spades, hearts, diamonds, or clubs, there are
C(13, 5) 5-card hands. Hence, there are a total of 4C(13, 5) such hands.

Example: In how many ways can a committee of 5 be chosen from 9 people?

Solution: C(9, 5) ways.

Example: How many committees of 5 or more can be chosen from 9 people?

Solution: C(9, 5) + C(9, 6) + C(9, 7) + C(9, 8) + C(9, 9).

Example: There are 21 consonants and 5 vowels in the English alphabet. Consider
only 8-letter words with 3 different vowels and 5 different consonants, how many such words
can be formed?

Solution: Choose the vowels, choose the consonants, and then arrange the 8 letters.
Therefore, C(5, 3)C(21, 5)8! such words can be formed.

Example: There are 30 females and 35 males in the junior class while there are
25 females and 20 males in the senior class. In how many ways can a committee of 10 be
chosen so that there are exactly 5 females and 3 juniors on the committee?


Solution: Let us construct the following table:

Junior, Female Junior, Male Senior, Female Senior, Male No. of Ways of Selection
0 3 5 2 C(30,0)C(35,3)C(25,5)C(20,2)
1 2 4 3 C(30,1)C(35,2)C(25,4)C(20,3)
2 1 3 4 C(30,2)C(35,1)C(25,3)C(20,4)
3 0 2 5 C(30,3)C(35,0)C(25,2)C(20,5)

Thus, the total number of ways is the sum of the terms in the last column:
C(30, 0)C(35, 3)C(25, 5)C(20, 2) + C(30, 1)C(35, 2)C(25, 4)C(20, 3)+
C(30, 2)C(35, 1)C(25, 3)C(20, 4) + C(30, 3)C(35, 0)C(25, 2)C(20, 5).

5 Enumerating Combinations and Permutations with


Repetitions
Let U (n, r) denote the number of r-permutations of n objects with unlimited repetitions
and let V (n, r) denote the number of r-combinations of n objects with unlimited repetitions.
That is, if a1 , a2 , ..., an are the n objects, we are counting r-combinations and r-permutations
of {∞ · a1 , ∞ · a2 , ..., ∞ · an }.

Permutations

Theorem: Enumerating r-permutations with unlimited repetitions: U (n, r) = nr .

Proof: Each of the r positions can be filled in n ways and so by the product rule,
U (n, r) = nr .

Example: There are 25 true or false questions on an examination. How many


different ways can a student do the examination if he or she can also choose to leave the
answer blank?

Solution: 325 .

Example: The results of 50 football games (win, lose or, tie) are to be predicted.
How many different forecasts can contain exactly 28 correct results?

Solution: Choose 28 correct results C(50, 28) ways. Each of the remaining 22
games has 2 wrong forecasts. Thus, there are C(50, 28) · 222 forecasts with exactly 28 correct
predictions.

Combinations

Let a1 , a2 , ..., an be the distinct objects so that selections are made from {∞ · a1 , ∞ ·
a2 , ..., ∞ · an }. Any r-combination will be of the form {x1 · a1 , x2 · a2 , ..., xn · an } where
x1 , x2 , ..., xn are the repetition numbers, each xi is nonnegative, and x1 + x2 + ... + xn = r.
Conversely, any sequence of nonnegative integers x1 , x2 , ..., xn where x1 + x2 + ... + xn = r
corresponds to an r-combination {x1 · a1 , x2 · a2 , ..., xn · an }.

First Observation: The number of r-combinations of {∞ · a1 , ∞ · a2 , ..., ∞ · an }


equals the number of solutions of x1 + x2 + ... + xn = r in nonnegative integers.

Second Observation: The number of nonnegative integral solutions of x1 + x2 +


... + xn = r is equal to the number of ways of placing r indistinguishable balls in n numbered
boxes.

Third Observation: The numberof ways of placing r indistinguishable balls in n


numbered boxes is equal to the number of binary numbers with (n − 1) 10 s and r 00 s.
If there are x1 balls in box number 1, x2 balls in box number 2, ..., xn balls in box
number n, then in a corresponding binary number let there be x1 00 s to the left of the first
1, x2 00 s between the first and second 1, x3 00 s between the second and third,..., and finally
xn 00 s to the right of the last 1.(Two consecutive 10 s mean that there were no balls in that
box.)
Example: Suppose r = 7 and n = 10 in the above, that is, we are interested in
7-combinations of {∞ · a1 , ∞ · a2 , ..., ∞ · a10 }. To the 7-combination a1 a1 a1 a4 a4 a8 a8 we as-
sociate the solution (3, 0, 0, 2, 0, 0, 0, 2, 0, 0) of x1 + x2 + ... + x10 = 7. Then to the solution
(3, 0, 0, 2, 0, 0, 0, 2, 0, 0) we associate the distribution of 3 balls in box 1, 0 balls in boxes 2,
3, 5, 6, 7, 9, and 10, 2 balls in box 4, and 2 balls in box 8. Then to this distribution of balls
associate the binary number 0001110011110011.

Fourth Observation: The number of binary numbers with n − 1 10 s and r 00 s is


C(n − 1 + r, r).
We have n−1+r positions and we need only choose which r positions will be occupied
by a 0, and then the remaining n − 1 positions are filled by 10 s.

We summarize:

Theorem: Enumerating r-combinations with unlimited repetitions:

V (n, r) =The number of r-combinations of n distinct objects with unlimited repetitions.


=the number of nonnegative integral solutions to x1 + x2 + ... + xn = r.
=the number of ways of distributing r similar balls into n numbered boxes
=the number of binary numbers with n − 1 one’s and r zeros.
=C(n − 1 + r, r) = C(n − 1 + r, n − 1)
(n − 1 + r)!
=
r! (n − 1)!
Remark: The number of r-combinations of {∞ · a1 , ∞ · a2 , ..., ∞ · an } is the same as
the number of r-combinations of {r · a1 , r · a2 , ..., r · an }.

Example: The number of 4-combinations of {∞ · a1 , ∞ · a2 , ∞ · a3 , ∞ · a4 , ∞ · a5 } is


C(5 − 1 + 4 , 4) = C(8, 4) = 70.

Example: How many different outcomes are possible by tossing 10 similar coins?


Solution: This is the same as placing 10 similar balls into two boxes labeled “heads”
and “tails”. Therefore, possible outcomes = C(2 − 1 + 10 , 10) = C(11, 10) = 11.

Example: Enumerate the number of ways of placing 20 indistinguishable balls into


5 boxes where each box is nonempty.

Solution: First, place one ball in each of the 5 boxes. Then we must count the
number of ways of distributing the 15 remaining balls into 5 boxes with unlimited repetitions.
Using previous theorem, we can do this in C(5 − 1 + 15, 15) = C(19, 15) ways.
Another Approach: We can also model this problem as a solution-of-an-equation
problem. If xi represents the number of balls in the ith box, then we are asked to enumerate
the number of integral solutions to x1 + x2 + x3 + x4 + x5 = 20. where each xi > 0 . After
distributing 1 ball into each of the 5 boxes, we then are to enumerate the number of integral
solutions of y1 + y2 + +y3 + y4 + y5 = 15 where each yi ≥ 0.

6 Enumerating Permutations with Constrained Repe-


titions
There are, of course, intermediate cases between selections with no repetitions and selections
with unlimited repetition of the objects. Suppose that we are given a particular selection of
r objects where there are some repetitions. What we desire is a formula for the number of
permutations on this given selection of r objects.

Theorem: Enumerating n-permutations with constrained repetitions:

Let q1 , q2 , ..., qt are nonnegative integers such that n = q1 + q2 + ... + qt . Also, let us
consider that a1 , a2 , ..., at are t distinct objects. Let P (n; q1 , q2 , ..., qt ) denotes the number of
n-permutations of the n-combination {q1 · a1 , q2 · a2 , ..., qt · at }, then
n!
P (n; q1 , q2 , ..., qt ) =
q1 ! q2 ! ... qt !
Example: Find the number of arrangements of letters in the word TALLAHASSEE.

Solution: Since this equals the number of permutations of {3 · A, 2 · E, 2 · L, 2 · S, 1 ·


H, 1 · T }. Therefore, the required number of arrangements are
11!
P (11; 3, 2, 2, 2, 1, 1, ) =
3!2!2!2!1!1!
Example: In how many ways can 23 different books be given to 5 students so that
2 of the students will have 4 books each and the other 3 will have 5 books each?

Solution: Choose the 2 students to receive 4 books each in C(5, 2) ways. Then to
23!
each such choice the 23 books can be distributed in P (23; 4, 4, 5, 5, 5) = ways.
4!4!5!5!5!
23!
Thus there are C(5, 2) · total distributions.
4!4!5!5!5!
7 Binomial Coefficients
In mathematics, the binomial coefficients are the positive integrs that occur as coefficients
in the binomial theorem.
In formulas arising from the analysis of algorithms in computer science, the binomial
coefficients occur over and over again, so that a facility for manipulating them is a necessity.
Moreover, different approaches to problems often give rise to formulas that are different in
appearance yet identities of binomial coefficients reveal that they are, in fact, the same ex-
pressions.

Some Examples of Combinatorial Identities

7.1 Representation by factorials


n!
C(n, r) =
r!(n − r)!
for every pair of integers n and r where n ≥ r ≥ 0.

7.2 Symmetry property


C(n, r) = C(n, n − r)

7.3 Newton’s Identity


C(n, r)C(r, k) = C(n, k)C(n − k, r − k) for integers n ≥ r ≥ k ≥ 0

A special case of this identity is C(n, r)r = nC(n − 1, r − 1)

Another special case of this identity is C(n, r + 1)(r + 1) = (n − r)C(n, r)

Remark: It might be instructive at this point to list some formulas for r-permutations
along with a combinatorial interpretation.

P (n, r) = nP (n − 1, r − 1)

P (n, r) = P (n, r − 1)(n − r + 1)

7.4 Pascal’s Identity


C(n, r) = C(n − 1, r) + C(n − 1, r − 1)

Pascal’s Identity in Permutations: P (n, r) = rP (n − 1, r − 1) + P (n − 1, r)

7.5 Boundary Conditions


C(n, 0) = 1 = C(n, n)


7.6 Secondary Conditions
C(n, 1) = n = C(n, n − 1)

7.7 Diagonal Summation


C(n, 0) + C(n + 1, 1) + C(n + 2, 2) + ... + C(n + r, r) = C(n + r + 1, r)

7.8 Row Summation


C(n, 0) + C(n, 1) + ... + C(n, r) + ... + C(n, n) = 2n

7.9 Row Square Summation


C(n, 0)2 + C(n, 1)2 + ... + C(n, r)2 + ... + C(n, n)2 = C(2n, n) for each positive
integers n.

A special case of this identity is

C(m, 0)C(n, 0) + C(m, 1)C(n, 1) + ... + C(m, m)C(n, n) = C(m + n, n) for


integers m ≥ n ≥ 0.

7.10 Column Summation


C(r, r) + C(r + 1, r) + ... + C(n, r) = C(n + 1, r + 1)

for any positive integer n ≥ r.

8 The Binomial and Multinomial Theorems


Any sum of two unlike symbols, such as x + y, is called a binomial. The binomial
theorem is a formula for the powers of a binomial.

In general, the sum of t unlike things, x1 + x2 + ... + xt is called a multinomial.

8.1 The Binomial Theorem


Let n be a positive integer. Then for all x and y,

(x+y)n = C(n, 0)xn +C(n, 1)xn−1 y+C(n, 2)xn−2 y 2 +...+C(n, r)xn−r y r +...+C(n, n)y n
n n n n n
 n   n−2 2  
(x + y)n = 0
x + 1
xn−1 y + 2
x y + ... + r
xn−r y r + ... + n
yn
Pn
(x + y)n = r=0 C(n, r)xn−r y r


n

Note: The binomial coefficients C(n, r) = r
receive their name from their appear-
ance in the expansion of powers of a binomial.

Example: (x + y)8 = C(8, 0)x8 + C(8, 1)x7 y + C(8, 2)x6 y 2 + C(8, 3)x5 y 3

+C(8, 4)x4 y 4 +C(8, 5)x3 y 5 +C(8, 6)x2 y 6 +C(8, 7)xy 7 +C(8, 8)y 8

= x8 + 8x7 y + 28x6 y 2 + 56x5 y 3 + 70x4 y 4 + 56x3 y 5 + 28x2 y 6

+8xy 7 + y 8 .

Corollary: Let n be a positive integer. Then for all x


Pn Pn Pn
(x + 1)n = r=0 C(n, r)xn−r = r=0 C(n, n − r)xn−r = r=0 C(n, r)xr

Replacing x by −x, we have


Pn Pn
(1 − x)n = r=0 C(n, r)(−x)r = r=0 C(n, r)(−1)r xr

8.2 The Multinomial Theorem


Let n be a positive integer. Then for all x1 , x2 , ..., xt , we have (x1 + x2 + ... + xt )n =
P (n; q1 , q2 , ..., qt ) xq11 xq22 , ..., xqt t where the summation extends over all sets of nonnegative
P
integers q1 , q2 , ..., qt where q1 + q2 + ... + qt = n.

There are C(n + t − 1, n) terms in the expansion of (x1 + x2 + ... + xt )n .

Example: Find the coefficient of x21 x3 x34 x45 in (x1 + x2 + x3 + x4 + x5 )10 .

Solution: There are C(10 + 5 − 1, 10) = C(14, 10) = 1001 terms in the expansion
(x1 + x2 + x3 + x4 + x5 )10 .
10!
The required coefficient is P (10; 2, 0, 1, 3, 4) = = 12600.
2!0!1!3!4!


UNIT-IV: Advanced Counting
Techniques

Syllabus

Recurrence Relations, Solving Linear Recurrence Relations, Divide-and-Conquer Algorithms


and Recurrence Relations, Generating Functions, Inclusion-Exclusion, Applications of
Inclusion- Exclusion.

Self-study: Euclidean algorithm and prime factorization.


1 Recurrence Relation
A recurrence relation is an equation that defines a sequence based on a rule that gives the
next term as a function of the previous term(s).

The simplest form of a recurrence relation is the case where the next term depends
only on the immediately previous term. If we denote the nth term in the sequence by xn , such
a recurrence relation is of the form xn+1 = f (xn ) for some function f . One such example is
xn+1 = 2 − xn /2.

A recurrence relation can also be of higher order, where the term xn+1 could depend
not only on the previous term xn but also on earlier terms such as xn−1 , xn−2 etc. A second
order recurrence relation depends just on xn and xn−1 and is of the form xn+1 = f (xn , xn−1 )
for some function f with two inputs. For example, the recurrence relation xn+1 = xn + xn−1
can generate the Fibonacci numbers.

To generate sequence based on a recurrence relation, one must start with some initial
values. For a first order recursion xn+1 = f (xn ), one just needs to start with an initial value
x0 and can generate all remaining terms using the recurrence relation. For a second order
recursion xn+1 = f (xn , xn−1 ), one needs to begin with two values x0 and x1 . Higher order
recurrence relations require correspondingly more initial values.

Note: A recurrence relation can be viewed as determining a discrete dynamical


system.

2 Solving Linear Recurrence Relations


A wide variety of recurrence relations occur in models. Some of these recurrence relations
can be solved using iteration or some other ad hoc technique. However, one important class
of recurrence relations can be explicitly solved in a systematic way. These are recurrence
relations that express the terms of a sequence as linear combinations of previous terms.

2.1 Linear Homogeneous Recurrence Relation with Constant Co-


efficients
A linear homogeneous recurrence relation of degree k with constant coefficients is a recurrence
relation of the form an = c1 an−1 + c2 an−2 + + ck an−k , where c1 , c2 , ..., ck are real numbers,
and ck 6= 0.
The recurrence relation in the definition is linear because the right-hand side is a sum
of previous terms of the sequence each multiplied by a function of n. The recurrence relation
is homogeneous because no terms occur that are not multiples of the aj s. The coefficients
of the terms of the sequence are all constants, rather than functions that depend on n. The
degree is k because an is expressed in terms of the previous k terms of the sequence.
A consequence of the second principle of mathematical induction is that a sequence
satisfying the recurrence relation in the definition is uniquely determined by this recurrence
relation and the k initial conditions a0 = C0 , a1 = C1 , ..., ak−1 = Ck−1 .
Example: The recurrence relation fn = fn−1 + fn−2 is a linear homogeneous recur-
rence relation of degree two. The recurrence relation an = an−5 is a linear homogeneous
recurrence relation of degree five.

Example: The recurrence relation an = an−1 + a2n−2 is not linear. The recurrence
relation Hn = 2Hn−1 + 1 is not homogeneous. The recurrence relation Bn = nBn−1 does not
have constant coefficients.

Note: Linear homogeneous recurrence relations are studied for two reasons. First,
they often occur in modeling of problems. Second, they can be systematically solved.

Example: What is the solution of the recurrence relation an = an−1 + 2an−2 with
a0 = 2 and a1 = 7?
Solution: The characteristic equation of the recurrence relation is r2 − r − 2 = 0. Its
roots are r = 2 and r = −1. Hence, the sequence an is a solution to the recurrence relation if
and only if an = α1 2n + α2 (−1)n , for some constants α1 and α2 . From the initial conditions,
it follows that a0 = 2 = α1 + α2 , a1 = 7 = α1 · 2 + α2 · (−1).
Solving these two equations shows that α1 = 3 and α2 = −1. Hence, the solution to
the recurrence relation and initial conditions is the sequence an with an = 3 · 2n − (−1)n .

Example: Find an explicit formula for the Fibonacci numbers.


Solution: Recall that the sequence of Fibonacci numbers satisfies the recurrence re-
lation fn = fn−1 + fn−2 and also satisfies the initial conditions f0 = 0 and f1 = 1.

The√roots of the characteristic equation r2 − r − 1 = 0 are r1 = (1 + 5)/2 and
r2 = (1 − 5)/2.
Therefore, the Fibonacci numbers are given by
√ !n √ !n
1+ 5 1− 5
fn = α1 + α2
2 2
for some constants α1 and α2 . The initial conditions f0 = 0 and f1 = 1 can be used
to find these constants. We have
f0 = α1 + α2 = 0,!
√ √ !
1+ 5 1− 5
f1 = α1 + α2 = 1.
2 2
The solution to these simultaneous equations for α1 and α2 is

α1 = √1 , α2 = − √15 .
5

Consequently, the Fibonacci numbers !


are given by
√ !n √ n
1 1+ 5 1 1− 5
fn = √ −√ .
5 2 5 2
Note: If there is one characteristic root of multiplicity two, then an = nr0n is another
solution of the recurrence relation when r0 is a root of multiplicity two of the characteristic
equation.

Example: What is the solution of the recurrence relation an = 6an−1 − 9an−2 with
initial conditions a0 = 1 and a1 = 6?
Solution: Do it yourself. Answer - an = 3n + n3n .

Example: Find the solution to the recurrence relation an = −3an−1 − 3an−2 − an−3
with initial conditions a0 = 1, a1 = −2, and a2 = −1.
Solution: Do it yourself. Answer - an = (1 + 3n − 2n2 )(−1)n .

2.2 Linear Nonhomogeneous Recurrence Relation with Constant


Coefficients
A recurrence relation of the form an = c1 an−1 + c2 an−2 + + ck an−k + F (n), where c1 , c2 , ..., ck
are real numbers and F (n) is a function not identically zero depending only on n, is called
a linear nonhomogeneous recurrence relation with constant coefficients. The recurrence re-
lation an = c1 an−1 + c2 an−2 + + ck an−k , is called the associated homogeneous recurrence
relation. It plays an important role in the solution of the nonhomogeneous recurrence rela-
tion.

Example: The recurrence relation an = 3an−1 + 2n is an example of a linear nonho-


mogeneous recurrence relation with constant coefficients.
Example: Each of the recurrence relations an = an−1 +2n , an = an−1 +an−2 +n2 +n+
1, an = 3an−1 + n3n , and an = an−1 + an−2 + an−3 + n! is a linear nonhomogeneous recurrence
relation with constant coefficients. The associated linear homogeneous recurrence relations
are an = an−1 , an = an−1 + an−2 , an = 3an−1 , and an = an−1 + an−2 + an−3 , respectively.

Note: The key fact about linear nonhomogeneous recurrence relations with constant
coefficients is that every solution is the sum of a particular solution and a solution of the
associated linear homogeneous recurrence relation.

Example: Find all solutions of the recurrence relation an = 3an−1 + 2n. What is the
solution with a1 = 3?
Solution: The associated linear homogeneous equation is an = 3an−1 . Its solutions
(h)
are an = α 3n , where α is a constant.
We now find a particular solution. Because F (n) = 2n is a polynomial in n of degree
one, a reasonable trial solution is a linear function in n, say, pn = cn + d, where c and d are
constants.
To determine whether there are any solutions of this form, suppose that pn = cn + d
is such a solution. Then the equation an = 3an−1 + 2n becomes cn + d = 3(c(n − 1) + d) + 2n.
Simplifying and combining like terms gives (2 + 2c)n + (2d − 3c) = 0. It follows that
cn + d is a solution if and only if 2 + 2c = 0 and 2d − 3c = 0.
This shows that cn+d is a solution if and only if c = −1 and d = −3/2. Consequently,
(p)
an = −n − 3/2 is a particular solution.
(p) (h) 3
Therefore, the final solutions can be written as an = an + an = −n − + α · 3n ,
2
where α is a constant.

To find the solution with a1 = 3, let n = 1 in the formula we obtained for the general
3
solution. We find that 3 = −1 − + 3α, which implies that α = 11/6. So, the solution we
2
3 11 n
seek is an = −n − + 3 .
2 6
Example: Find all solutions of the recurrence relation an = 5an−1 − 6an−2 + 7n .
49
Solution: Do it yourself. Answer - an = α1 · 3n + α2 · 2n + 7n .
20

3 Divide-and-Conquer Algorithms and Recurrence Re-


lations
Many recursive algorithms take a problem with a given input and divide it into one or more
smaller problems. This reduction is successively applied until the solutions of the smaller
problems can be found quickly. These procedures follow an important algorithmic paradigm
known as divide-and-conquer, and are called divide-and-conquer algorithms, because they
divide a problem into one or more instances of the same problem of smaller size and they
conquer the problem by using the solutions of the smaller problems to find a solution of the
original problem, perhaps with some additional work.

Divide-and-Conquer Recurrence Relations: Suppose that a recursive algorithm


divides a problem of size n into subproblems, where each subproblem is of size n/b (for
simplicity, assume that n is a multiple of b; in reality, the smaller problems are often of
size equal to the nearest integers either less than or equal to, or greater than or equal to,
n/b). Also, suppose that a total of g(n) extra operations are required in the conquer step
of the algorithm to combine the solutions of the subproblems into a solution of the original
problem. Then, if f (n) represents the number of operations required to solve the problem
of size n, it follows that f satisfies the recurrence relation f (n) = af (n/b) + g(n).
This is called a divide-and-conquer recurrence relation.

Example - Binary Search The binary search algorithm reduces the search for an
element in a search sequence of size n to the binary search for this element in a search
sequence of size n/2, when n is even. (Hence, the problem of size n has been reduced to
one problem of size n/2.) Two comparisons are needed to implement this reduction (one to
determine which half of the list to use and the other to determine whether any terms of the
list remain). Hence, if f (n) is the number of comparisons required to search for an element
in a search sequence of size n, then f (n) = f (n/2) + 2 when n is even.

Example - Finding the Maximum and Minimum of a Sequence Consider


the following algorithm for locating the maximum and minimum elements of a sequence
a1 , a2 , ..., an . If n = 1, then a1 is the maximum and the minimum. If n > 1, split the
sequence into two sequences, either where both have the same number of elements or where
one of the sequences has one more element than the other. The problem is reduced to
finding the maximum and minimum of each of the two smaller sequences. The solution to
the original problem results from the comparison of the separate maxima and minima of
the two smaller sequences to obtain the overall maximum and minimum. Let f (n) be the
total number of comparisons needed to find the maximum and minimum elements of the
sequence with n elements. We have shown that a problem of size n can be reduced into two
problems of size n/2, when n is even, using two comparisons, one to compare the maxima
of the two sequences and the other to compare the minima of the two sequences. This gives
the recurrence relation f (n) = 2f (n/2) + 2 when n is even.
Example - Merge Sort The merge sort algorithm splits a list to be sorted with
n items, where n is even, into two lists with n/2 elements each, and uses fewer than n
comparisons to merge the two sorted lists of n/2 items each into one sorted list. Consequently,
the number of comparisons used by the merge sort to sort a list of n elements is less than
M (n), where the function M (n) satisfies the divide-and-conquer recurrence relation M (n) =
2M (n/2) + n.

4 Generating Function
Generating functions are used to represent sequences efficiently by coding the terms of a
sequence as coefficients of powers of a variable x in a formal power series. Generating func-
tions can be used to solve many types of counting problems, such as the number of ways
to select or distribute objects of different kinds, subject to a variety of constraints, and the
number of ways to make change for a dollar using coins of different denominations. Gener-
ating functions can be used to solve recurrence relations by translating a recurrence relation
for the terms of a sequence into an equation involving a generating function. This equation
can then be solved to find a closed form for the generating function. From this closed form,
the coefficients of the power series for the generating function can be found, solving the
original recurrence relation. Generating functions can also be used to prove combinatorial
identities by taking advantage of relatively simple relationships between functions that can
be translated into identities involving the terms of sequences. Generating functions are a
helpful tool for studying many properties of sequences besides those described in this section,
such as their use for establishing asymptotic formulae for the terms of a sequence.

Definition: The generating function for the sequence


P∞ a0 , ak1 , ..., ak , ... of real numbers
k
is the infinite series G(x) = a0 + a1 x + + ak x + · · · = k=0 ak x .

Remark: The generating function for ak given in above definition is sometimes called
the ordinary generating function of ak to distinguish it from other types of generating func-
tions for this sequence.

Example:P The generating functions Pfor the sequences ak with ak = 3, ak = k + 1,


and ak = 2k are ∞ k
P∞ k ∞ k k
k=0 3x , k=0 (k + 1)x , k=0 2 x , respectively.

Example: What is the generating function for the sequence 1, 1, 1, 1, 1, 1?


Solution: The generating function of 1, 1, 1, 1, 1, 1 is 1 + x + x2 + x3 + x4 + x5 .
(x6 − 1)
We know that = 1 + x + x2 + x3 + x4 + x5 when x 6= 1. Consequently,
(x − 1)
(x6 − 1)
G(x) = is the generating function of the sequence 1, 1, 1, 1, 1, 1. [Because the
(x − 1)
powers of x are only place holders for the terms of the sequence in a generating function, we
do not need to worry that G(1) is undefined.]
1
Example: The function f (x) = is the generating function of the sequence
(1 − ax)
1
1, a, a2 , a3 , ... because = 1 + ax + a2 x2 + · · · when |ax| < 1, or equivalently, for
(1 − ax)
|x| < 1/|a| for a 6= 0.
4.1 Counting Problems and Generating Functions
We know a few techniques to count the r-combinations from a set with n elements when
repetition is allowed and additional constraints may exist. Such problems are equivalent to
counting the solutions to equations of the form e1 + e2 + · · · + en = C, where C is a constant
and each ei is a nonnegative integer that may be subject to a specified constraint.

Example: Find the number of solutions of e1 + e2 + e3 = 17, where e1 , e2 , and e3


are nonnegative integers with 2 ≤ e1 ≤ 5, 3 ≤ e2 ≤ 6, and 4 ≤ e3 ≤ 7.
Solution: The number of solutions with the indicated constraints is the coefficient
17
of x in the expansion of
(x2 + x3 + x4 + x5 )(x3 + x4 + x5 + x6 )(x4 + x5 + x6 + x7 ).
This follows because we obtain a term equal to x17 in the product by picking a term
in the first sum xe1 , a term in the second sum xe2 , and a term in the third sum xe3 , where
the exponents e1 , e2 , and e3 satisfy the equation e1 + e2 + e3 = 17 and the given constraints.
It is not hard to see that the coefficient of x17 in this product is 3. Hence, there are
three solutions.

4.2 Solution of Recurrence Relations Using Generating Functions


We can find the solution to a recurrence relation and its initial conditions by finding an
explicit formula for the associated generating function.

Example: Solve the recurrence relation ak = 3ak−1 for k = 1, 2, 3, ... and initial
condition a0 = 2.
Solution: Let G(x) is generating function for the sequence ak , i.e. G(x) = ∞ k
P
k=0 ak x .

First note that


P∞ P∞
xG(x) = k=0 ak xk+1 = k=1 ak−1 xk .

Using the recurrence relation, we see that


P∞ P∞
G(x) − 3xG(x) = k=0 ak x k − 3 k=1 ak−1 xk
P∞
G(x) − 3xG(x) = a0 + k=1 (ak − 3 ak−1 )xk = 2,

because a0 = 2 and ak = 3ak−1 .

Thus, G(x) − 3xG(x) = (1 − 3x)G(x) = 2.

Solving for G(x) shows that G(x) = 2/(1 − 3x).


P∞
We know that the identity 1/(1 − ax) = k=0 ak xk . Therefore, we can write
P∞ P∞
G(x) = 2 k=0 3k xk = k=0 2 · 3k xk .

Consequently, ak = 2 · 3k .
4.3 Proving Identities via Generating Functions
Combinatorial identities can be established using combinatorial proofs and generating func-
tions.
Pn
Example: Use generating functions to show that k=0 C(n, k)2 = C(2n, n) when-
ever n is a positive integer.

Solution: First note that by the binomial theorem C(2n, n) is the coefficient of xn
in (1 + x)2n .

However, we also have

(1 + x)2n = [(1 + x)n ]2 = [C(n, 0) + C(n, 1)x + C(n, 2)x2 + ... + C(n, n)xn ]2 .

The coefficient of xn in this expression is

C(n, 0)C(n, n) + C(n, 1)C(n, n − 1) + C(n, 2)C(n, n − 2) + + C(n, n)C(n, 0).


Pn 2
This
Pn equals k=0 C(n, k) , since C(n, n − k) = C(n, k). It is because both C(2n, n)
and k=0 C(n, k)2 represent the coefficient of xn in (1 + x)2n , they must be equal.

5 Inclusion-Exclusion
5.1 The Principle of Inclusion-Exclusion
The number of elements in the union of the two sets A and B is the sum of the numbers of
elements in the sets minus the number of elements in their intersection.
Mathematically, |A ∪ B| = |A| + |B| − |A ∩ B|.

Example: Suppose that there are 1807 freshmen at your school. Of these, 453
are taking a course in computer science, 567 are taking a course in mathematics, and 299
are taking courses in both computer science and mathematics. How many are not taking a
course either in computer science or in mathematics?
Solution: To find the number of freshmen who are not taking a course in either
mathematics or computer science, subtract the number that are taking a course in either of
these subjects from the total number of freshmen. Let A be the set of all freshmen taking a
course in computer science, and let B be the set of all freshmen taking a course in mathe-
matics. It follows that |A| = 453, |B| = 567, and |A ∩ B| = 299. The number of freshmen
taking a course in either computer science or mathematics is

|A ∪ B| = |A| + |B| − |A ∩ B| = 453 + 567 − 299 = 721.

Consequently, there are 1807 - 721 = 1086 freshmen who are not taking a course in
computer science or mathematics.

Example: A total of 1232 students have taken a course in Spanish, 879 have taken
a course in French, and 114 have taken a course in Russian. Further, 103 have taken courses
in both Spanish and French, 23 have taken courses in both Spanish and Russian, and 14
have taken courses in both French and Russian. If 2092 students have taken at least one of
Spanish, French, and Russian, how many students have taken a course in all three languages?
Solution: Do it yourself. Answer - 7.

Remark: General Form of the Principle of Inclusion-Exclusion - Let


A1 , A2 , ..., An be finite sets. Then
X X X
|A1 ∪ A2 ∪ ... ∪ An | = |Ai | − |Ai ∩ Aj | + |Ai ∩ Aj ∩ Ak | − ...
1≤i≤n 1≤i<j≤n 1≤i<j<k≤n
n+1
+ (−1) |A1 ∩ A2 ∩ ... ∩ An |.

5.2 Applications of Inclusion-Exclusion


Many counting problems can be solved using the principle of inclusion-exclusion. For in-
stance, we can use this principle to find the number of primes less than a positive integer.
Many problems can be solved by counting the number of onto functions from one finite set to
another. The inclusion-exclusion principle can be used to find the number of such functions.

5.2.1 The Number of Onto Functions


The principle of inclusionexclusion can also be used to determine the number of onto func-
tions from a set with m elements to a set with n elements.

Result: Let m and n be positive integers with m ≥ n. Then, there are

nm − C(n, 1)(n − 1)m + C(n, 2)(n − 2)m − ... + (−1)n−1 C(n, n − 1) · 1m

onto functions from a set with m elements to a set with n elements.

Example: How many onto functions are there from a set with six elements to a set
with three elements?
Solution: The required number is 36 − C(3, 1)26 + C(3, 2)16 = 729 − 192 + 3 = 540.

5.2.2 Derangements
A derangement is a permutation of objects that leaves no object in its original position. The
principle of inclusion-exclusion can be used to count the permutations of n objects that leave
no objects in their original positions.

Example: The permutation 21453 is a derangement of 12345 because no number


is left in its original position. However, 21543 is not a derangement of 12345, because this
permutation leaves 4 fixed.

Result: The number of derangements of a set with n elements is


 
1 1 1 n 1
Dn = n! 1 − + − + ... + (−1) .
1! 2! 3! n!
UNIT-V: Graph Theory

Syllabus

Graphs and Graph Models, Graph Terminology and Special Types of Graphs,
Representing Graphs and Graph Isomorphism, Connectivity, Euler and Hamilton Paths,
Shortest-Path Problems, Planar Graphs, Graph Colouring.

Self-study: Minimal spanning tree


1 Graphs
Definition: A graph G = (V, E) consists of V , a nonempty set of vertices (or nodes) and
E, a set of edges. Each edge has either one or two vertices associated with it, called its
endpoints. An edge is said to connect its endpoints.

Remarks: 1. The set of vertices V of a graph G may be infinite. A graph with


an infinite vertex set or an infinite number of edges is called an infinite graph, and in
comparison, a graph with a finite vertex set and a finite edge set is called a finite graph.
In this course we will usually consider only finite graphs.

2. A graph in which each edge connects two different vertices and where no two edges
connect the same pair of vertices is called a simple graph.

3. Graphs that may have multiple edges connecting the same vertices are called
multigraphs. When there are m different edges associated to the same unordered pair of
vertices u, v, we also say that u, v is an edge of multiplicity m.

4. When edges connect a vertex to itself, then such edges are called loops, and
sometimes we may even have more than one loop at a vertex.

5. Graphs that may include loops, and possibly multiple edges connecting the same
pair of vertices or a vertex to itself, are sometimes called pseudographs.

Definition: A directed graph (or digraph) (V, E) consists of a nonempty set of ver-
tices V and a set of directed edges (or arcs) E. Each directed edge is associated with an
ordered pair of vertices. The directed edge associated with the ordered pair (u, v) is said to
start at u and end at v.

Remarks: 1. When a directed graph has no loops and has no multiple directed
edges, it is called a simple directed graph.

2. Directed graphs that may have multiple directed edges from a vertex to a second
(possibly the same) vertex are called directed multigraphs. When there are m directed
edges, each associated to an ordered pair of vertices (u, v), we say that (u, v) is an edge of
multiplicity m.

Note: A graph with both directed and undirected edges is called a mixed graph.
For example, a mixed graph might be used to model a computer network containing links
that operate in both directions and other links that operate only in one direction.

Remark: This terminology for the various types of graphs is given in Table 1. We
will sometimes use the term graph as a general term to describe graphs with directed or undi-
rected edges (or both), with or without loops, and with or without multiple edges. At other
times, when the context is clear, we will use the term graph to refer only to undirected graphs.
2 Graph Models
Graphs are used in a wide variety of models as following:

2.1 Social Networks


Graphs are extensively used to model social structures based on different kinds of relation-
ships between people or groups of people. These social structures, and the graphs that
represent them, are known as social networks. In these graph models, individuals or orga-
nizations are represented by vertices; relationships between individuals or organizations are
represented by edges.
Example: Acquaintanceship and Friendship Graphs We can use a simple
graph to represent whether two people know each other, that is, whether they are acquainted,
or whether they are friends (either in the real world in the virtual world via a social net-
working site such as Facebook). Each person in a particular group of people is represented
by a vertex. An undirected edge is used to connect two people when these people know
each other, when we are concerned only with acquaintanceship, or whether they are friends.
No multiple edges and usually no loops are used. (If we want to include the notion of self-
knowledge, we would include loops.) The acquaintanceship graph of all people in the world
has more than six billion vertices and probably more than one trillion edges!

2.2 Communication Networks


We can model different communications networks using vertices to represent devices and
edges to represent the particular type of communications links of interest.
Example: Call Graphs Graphs can be used to model telephone calls made in
a network, such as a long distance telephone network. In particular, a directed multigraph
can be used to model calls where each telephone number is represented by a vertex and each
telephone call is represented by a directed edge. The edge representing a call starts at the
telephone number from which the call was made and ends at the telephone number to which
the call was made.We need directed edges because the direction in which the call is made
matters.We need multiple directed edges because we want to represent each call made from
a particular telephone number to a second number.
2.3 Information Networks
Graphs can be used to model various networks that link particular types of information.
Here, we will describe how to model the World Wide Web using a graph.
Example: The Web Graph The World Wide Web can be modeled as a directed
graph where each Web page is represented by a vertex and where an edge starts at the Web
page a and ends at the Web page b if there is a link on a pointing to b. Because new Web
pages are created and others removed somewhere on the Web almost every second, the Web
graph changes on an almost continual basis. Many people are studying the properties of the
Web graph to better understand the nature of the Web.

2.4 Software Design Applications


Graph models are useful tools in the design of software.
Example: Module Dependency Graphs One of the most important tasks in
designing software is how to structure a program into different parts, or modules. Under-
standing how the different modules of a program interact is essential not only for program
design, but also for testing and maintenance of the resulting software.A module dependency
graph provides a useful tool for understanding how different modules of a program interact.
In a program dependency graph, each module is represented by a vertex. There is a directed
edge from a module to a second module if the second module depends on the first.

2.5 Transportation Networks


We can use graphs to model many different types of transportation networks, including road,
air, and rail networks, as well shipping networks.
Example: Airline Routes We can model airline networks by representing each
airport by a vertex. In particular, we can model all the flights by a particular airline each
day using a directed edge to represent each flight, going from the vertex representing the
departure airport to the vertex representing the destination airport. The resulting graph
will generally be a directed multigraph, as there may be multiple flights from one airport to
some other airport during the same day.

2.6 Biological Networks


Many aspects of the biological sciences can be modeled using graphs.
Example: Niche Overlap Graphs in Ecology Graphs are used in many models
involving the interaction of different species of animals. For instance, the competition be-
tween species in an ecosystem can be modeled using a niche overlap graph. Each species is
represented by a vertex. An undirected edge connects two vertices if the two species repre-
sented by these vertices compete (that is, some of the food resources they use are the same).
A niche overlap graph is a simple graph because no loops or multiple edges are needed in
this model.

2.7 Tournaments
Graphs can also be used to model different kinds of tournaments.
Example: Single-Elimination Tournaments A tournament where each con-
testant is eliminated after one loss is called a single-elimination tournament. We can model
such a tournament using a vertex to represent each game and a directed edge to connect a
game to the next game the winner of this game played in.

3 Graph Terminology
There are some terminology that describes the vertices and edges of undirected graphs.

Definition: Two vertices u and v in an undirected graph G are called adjacent


(or neighbors) in G if u and v are endpoints of an edge e of G. Such an edge e is called
incident with the vertices u and v and e is said to connect u and v.

Definition: The set of all neighbors of a vertex v of G = (V, E), denoted by N (v),
is called the neighborhood of v.

Definition: The degree of a vertex in an undirected graph is the number of edges


incident with it, except that a loop at a vertex contributes twice to the degree of that
vertex. The degree of the vertex v is denoted by deg(v).

Definition: A vertex of degree zero is called isolated. It follows that an isolated


vertex is not adjacent to any vertex. A vertex is pendant if and only if it has degree one.
Consequently, a pendant vertex is adjacent to exactly one other vertex.

Theorem: The Handshaking Theorem Let G = (V, E) be an undirected graph


with m edges. Then P
2m = ν∈V deg(ν).

Note: This applies even if multiple edges and loops are present.

Result: An undirected graph has an even number of vertices of odd degree.

4 Special Types of Graphs


There are several classes of simple graphs. These graphs are often used as examples and
arise in many applications.

4.1 Complete Graphs


A complete graph on n vertices, denoted by Kn , is a simple graph that contains exactly
one edge between each pair of distinct vertices. The graphs Kn , for n = 1, 2, 3, 4, 5, 6, are
displayed in the following figure.
A simple graph for which there is at least one pair of distinct vertex not connected
by an edge is called noncomplete.

4.2 Cycles
A cycle Cn , n ≥ 3, consists of n vertices v1 , v2 , ..., vn and edges v1 , v2 , v2 , v3 , ..., vn−1 , vn , and
vn , v1 . The cycles C3 , C4 , C5 , and C6 are displayed in the following figure.

4.3 Wheels
We obtain a wheel Wn when we add an additional vertex to a cycle Cn , for n ≥ 3, and
connect this new vertex to each of the n vertices in Cn , by new edges. The wheels W3 , W4 ,
W5 , and W6 are displayed in the following figure.

4.4 n-Cubes
An n-dimensional hypercube, or n-cube, denoted by Qn , is a graph that has vertices repre-
senting the 2n bit strings of length n. Two vertices are adjacent if and only if the bit strings
that they represent differ in exactly one bit position. We display Q1 , Q2 , and Q3 in the
following figure.
4.5 Bipartite Graphs
Definition: A simple graph G is called bipartite if its vertex set V can be partitioned into
two disjoint sets V1 and V2 such that every edge in the graph connects a vertex in V1 and a
vertex in V2 (so that no edge in G connects either two vertices in V1 or two vertices in V2 ).
When this condition holds, we call the pair (V1 , V2 ) a bipartition of the vertex set V
of G.

Example: C6 is bipartite, as shown in the following figure, because its vertex set
can be partitioned into the two sets V1 = v1 , v3 , v5 and V2 = v2 , v4 , v6 , and every edge of C6
connects a vertex in V1 and a vertex in V2 .

Result: A simple graph is bipartite if and only if it is possible to assign one of two
different colors to each vertex of the graph so that no two adjacent vertices are assigned the
same color.

Definition: A complete bipartite graph Km,n is a graph that has its vertex set partitioned
into two subsets of m and n vertices, respectively with an edge between two vertices if and
only if one vertex is in the first subset and the other vertex is in the second subset.
The complete bipartite graphs K2,3 , K3,3 , K3,5 , and K2,6 are displayed in the following figure.
Applications of Special Types of Graphs

• Local Area Networks

• Interconnection Networks for Parallel Computation

Definition: A subgraph of a graph G = (V, E) is a graph H = (W, F ), where W is a


subset of V and F is a subset of E.. A subgraph H of G is a proper subgraph of G if H = G.

Definition: Let G = (V, E) be a simple graph. The subgraph induced by a subset W


of the vertex set V is the graph (W, F ), where the edge set F contains an edge in E if and
only if both end points of this edge are in W .

5 Representing Graphs and Graph Isomorphism


There are many useful ways to represent graphs. One way to represent a graph without
multiple edges is to list all the edges of this graph. Another way to represent a graph with
no multiple edges is to use adjacency lists, which specify the vertices that are adjacent to
each vertex of the graph.

Example: Use adjacency lists to describe the simple graph given in following figure:

Solution: Table 1 lists those vertices adjacent to each of the vertices of the graph.
Carrying out graph algorithms using the representation of graphs by lists of edges, or by
adjacency lists, can be cumbersome if there are many edges in the graph. To simplify
computation, graphs can be represented using matrices. Two types of matrices commonly
used to represent graphs will be presented here. One is based on the adjacency of vertices,
and the other is based on incidence of vertices and edges.

5.1 Adjacency Matrices


Suppose that G = (V, E) is a simple graph where |V | = n. Let the vertices of G are
listed arbitrarily as v1 , v2 , ..., vn . The adjacency matrix A (or AG ) of G, with respect to this
listing of the vertices, is the nxn zero-one matrix with 1 as its (i, j)th entry when vi and vj
are adjacent, and 0 as its (i, j)th entry when they are not adjacent. In other words, if its
adjacency matrix is A = [aij ], then

Example: Use an adjacency matrix to represent the graph shown below:

Solution: We order the vertices as a, b, c, d. The matrix representing this graph is


Example: Use an adjacency matrix to represent the pseudograph shown on the
next page:

Solution: The adjacency matrix using the ordering of vertices a, b, c, d is

5.2 Incidence Matrices


Let G = (V, E) be an undirected graph. Suppose that v1 , v2 , ..., vm are the vertices and
e1 , e2 , ..., en are the edges of G. Then the incidence matrix with respect to this ordering of
V and E is the m × n matrix M = [mij ]m×n , where

Example: Represent the graph shown on the next page with an incidence matrix.

Solution: The incidence matrix is


5.3 Isomorphism
Two graphs G1 and G2 are isomorphic if there is a one-to-one correspondence between their
vertex sets that preserve edges.

Other definition: Two graphs G1 and G2 are isomorphic if


• Number of vertices are same.

• Number of edges are same.

• An equal number of vertices with given degree.

• Vertex correspondence and edge correspondence is valid.

6 Connectivity
Many problems can be modeled with paths formed by traveling along the edges of graphs.

Path: A path is a sequence of edges that begins at a vertex of a graph and travels
from vertex to vertex along edges of the graph. As the path travels along its edges, it visits
the vertices along this path, that is, the endpoints of these edges.

Circuit: A path of length n ≥ 1 that begins and ends at the same vertex is called
circuit.
Connectedness in Undirected Graphs: An undirected graph is called connected
if there is a path between every pair of distinct vertices of the graph. An undirected graph
that is not connected is called disconnected. We say that we disconnect a graph when we
remove vertices or edges, or both, to produce a disconnected subgraph.

Connectedness in Directed Graphs: There are two notions of connectedness in


directed graphs, depending on whether the directions of the edges are considered.

Strongly Connected: A directed graph is strongly connected if there is a path


from a to b and from b to a whenever a and b are vertices in the graph.

Weakly Connected: A directed graph is weakly connected if there is a path


between every two vertices in the underlying undirected graph.

7 Euler and Hamilton Paths


7.1 Euler Path and Euler Circuit
A path in a graph G is said to be Eulerian path if it traverses each edge in the graph G
exactly once.
A circuit in a graph G is said to be Eulerian circuit if it traverses each edge in the graph
G exactly once.

Applications of Euler Paths and Circuits: Euler paths and circuits can be used to
solve many practical problems. For example, many applications ask for a path or circuit
that traverses each street in a neighborhood, each road in a transportation network, each
connection in a utility grid, or each link in a communications network exactly once. Find-
ing an Euler path or circuit in the appropriate graph model can solve such problems. For
example, if a postman can find an Euler path in the graph that represents the streets the
postman needs to cover, this path produces a route that traverses each street of the route
exactly once. If no Euler path exists, some streets will have to be traversed more than once.
7.2 Hamilton Path and Hamilton Circuit
A path which contains every vertex of graph G exactly once is called Hamiltonian graph.

A circuit that passes through each of the vertex in graph G exactly once except start-
ing vertex and ending vertex is called Hamiltonian circuit.

Applications of Hamilton Paths and Circuits: Hamilton paths and circuits can be
used to solve practical problems. For example, many applications ask for a path or circuit
that visits each road intersection in a city, each place pipelines intersect in a utility grid, or
each node in a communications network exactly once. Finding a Hamilton path or circuit
in the appropriate graph model can solve such problems. The famous traveling salesperson
problem or TSP asks for the shortest route a traveling salesperson should take to visit a set
of cities. This problem reduces to finding a Hamilton circuit in a complete graph such that
the total weight of its edges is as small as possible.

Question: Show that the following graph has Eulerian circuit but it does not have Hamil-
tonian circuit.

8 Shortest-Path Problems
Many problems can be modeled using graphs with weights assigned to their edges.
Weighted Graphs: Graphs that have a number assigned to each edge are called
weighted graphs.

Example: What is the length of a shortest path between a and z in the weighted
graph shown below?

Solution: Dijkstra Algorithm:


a b c d e z comments
0 ∞ ∞ ∞ ∞ ∞ start with vertex a to b and d
0 4 ∞ 2 ∞ ∞ min{4, 2}, satrt with vertex d to e
0 4 ∞ 2 5 ∞ min{4, 5}, satrt with vertex b to c and e
0 4 7 2 5 ∞ min{7, 5}, satrting vertex e to z
0 4 7 2 5 6 reached z
Shortest distance between a to z is 6 and the path is {a, d, e, z}.

We will solve this problem by finding the length of a shortest path from a to successive
vertices, until z is reached. The only paths starting at a that contain no vertex other than a
are formed by adding an edge that has a as one endpoint. These paths have only one edge.
They are a, b of length 4 and a, d of length 2. It follows that d is the closest vertex to a,
and the shortest path from a to d has length 2.
We can find the second closest vertex by examining all paths that begin with the
shortest path from a to a vertex in the set {a, d}, followed by an edge that has one endpoint
in {a, d} and its other endpoint not in this set. There are two such paths to consider, a, d, e
of length 5 and a, b of length 4. Hence, the second closest vertex to a is b and the shortest
path from a to b has length 4.
To find the third closest vertex to a, we need to examine only the paths that begin
with the shortest path from a to a vertex in the set {a, d, b}, followed by an edge that has
one endpoint in the set {a, d, b} and its other endpoint not in this set. There are three such
paths, a, b, c of length 7, a, b, e of length 7, and a, d, e of length 5. Because the shortest of
these paths is a, d, e, the third closest vertex to a is e and the length of the shortest path
from a to e is 5.
To find the fourth closest vertex to a, we need to examine only the paths that begin
with the shortest path from a to a vertex in the set {a, d, b, e}, followed by an edge that
has one endpoint in the set {a, d, b, e} and its other endpoint not in this set. There are two
such paths, a, b, c of length 7 and a, d, e, z of length 6. Because the shorter of these paths is
a, d, e, z, the fourth closest vertex to a is z and the length of the shortest path from a to z
is 6.
9 Planar Graphs
A graph is called planar if it can be drawn in the plane without any edges crossing (where
a crossing of edges is the intersection of the lines or arcs representing them at a point other
than their common endpoint). Such a drawing is called a planar representation of the graph.

Note: A graph may be planar even if it is usually drawn with crossings, because it
may be possible to draw it in a different way without crossings.

Example: K4 and Q3 are planar shown in the following figure:

Applications of Planar Graphs: Planarity of graphs plays an important role


in the design of electronic circuits. We can model a circuit with a graph by representing
components of the circuit by vertices and connections between them by edges.
The planarity of graphs is also useful in the design of road networks. Suppose we
want to connect a group of cities by roads. We can model a road network connecting these
cities using a simple graph with vertices representing the cities and edges representing the
highways connecting them.

Euler’s Formula: Let G be a connected planar simple graph with e edges and v
vertices. Let r be the number of regions in a planar representation of G. Then
r = e − v + 2.

Example: Suppose that a connected planar simple graph has 20 vertices, each of
degree 3. Into how many regions does a representation of this planar graph split the plane?
Solution: This graph has 20 vertices, each of degree 3, so v = 20. Because the sum
of the degrees of the vertices, 3v = 3 ∗ 20 = 60, is equal to twice the number of edges, 2e,
we have 2e = 60, or e = 30.
Consequently, from Euler’s formula, the number of regions is
r = e − v + 2 = 30 − 20 + 2 = 12.

10 Graph Colouring
A coloring of a simple graph is the assignment of a color to each vertex of the graph so that
no two adjacent vertices are assigned the same color.

Chromatic Number: The chromatic number of a graph is the least number of


colors needed for a coloring of this graph. The chromatic number of a graph G is denoted
by χ(G). (Here χ is the Greek letter chi.)
Result: The chromatic number of a planar graph is no greater than four.

Example: What is the chromatic number of Kn ?


Solution: A coloring of Kn can be constructed using n colors by assigning a different
color to each vertex. No two vertices can be assigned the same color, because every two
vertices of this graph are adjacent. Hence, the chromatic number of Kn is n.

Applications of Graph Colorings : Graph coloring has a variety of applications


to problems involving scheduling and assignments.

11 Trees: Introduction to Trees


Trees are particularly useful in computer science, where they are employed in a wide range
of algorithms. For instance, trees are used to construct efficient algorithms for locating items
in a list. They can be used in algorithms, such as Huffman coding, that construct efficient
codes saving costs in data transmission and storage. Trees can be used to study games such
as checkers and chess and can help determine winning strategies for playing these games.
Trees can be used to model procedures carried out using a sequence of decisions. Construct-
ing these models can help determine the computational complexity of algorithms based on
a sequence of decisions, such as sorting algorithms.

Definition: A connected graph that contains no simple circuits is called a tree.

Example: Which of the graphs shown in the following figure are trees?

Solution: G1 and G2 are trees, because both are connected graphs with no simple
circuits. G3 is not a tree because e, b, a, d, e is a simple circuit in this graph. Finally, G4 is
not a tree because it is not connected.

Result: An undirected graph is a tree if and only if there is a unique simple path
between any two of its vertices.

Rooted Tree: A rooted tree is a tree in which one vertex has been designated as
the root and every edge is directed away from the root.
Binary Tree: A binary tree is defined as a tree in which there is exactly one vertex of
degree two, and each of remaining vertices is of degree one or three. The vertex of degree
two serves as a root.

Pendant Vertex in Tree: A vertex of degree one is called pendant vertex of tree. In
the following graph vertices 1, 1 and 5 are pendants.

Path Lenghth of Tree: A path length of a tree is defined as the sum of edges from
the root of all pendant vertices.
Path lenght of the following tree is:

2+2+2=6

Result: A tree with n vertices has n − 1 edges.

12 Applications of Trees
• Storing hierarchical data

• Binary Search Tree

• Game Tree and many more


Example: Form a binary search tree for the words mathematics, physics, geogra-
phy, zoology, meteorology, geology, psychology, and chemistry (using alphabetical order).

Solution: Figure 1 displays the steps to construct this binary search tree. The
word mathematics is the key of the root. Because physics comes after mathematics (in
alphabetical order), add a right child of the root with key physics. Because geography comes
before mathematics, add a left child of the root with key geography. Next, add a right child
of the vertex with key physics, and assign it the key zoology, because zoology comes after
mathematics and after physics. Similarly, add a left child of the vertex with key physics
and assign this new vertex the key meteorology. Add a right child of the vertex with key
geography and assign this new vertex the key geology.Add a left child of the vertex with key
zoology and assign it the key psychology. Add a left child of the vertex with key geography
and assign it the key chemistry.
13 Tree Traversal
Traversal Algorithms: Procedures for systematically visiting every vertex of an ordered
rooted tree are called traversal algorithms.

We will describe three of the most commonly used such algorithms, preorder traversal,
inorder traversal, and postorder traversal. Each of these algorithms can be defined recur-
sively.

Preorder Traversal: Let T be an ordered rooted tree with root r. If T consists


only of r, then r is the preorder traversal of T . Otherwise, suppose that T1 , T2 , ..., Tn are
the subtrees at r from left to right in T . The preorder traversal begins by visiting r. It
continues by traversing T1 in preorder, then T2 in preorder, and so on, until Tn is traversed
in preorder.

Inorder Traversal: Let T be an ordered rooted tree with root r. If T consists


only of r, then r is the inorder traversal of T . Otherwise, suppose that T1 , T2 , ..., Tn are the
subtrees at r from left to right. The inorder traversal begins by traversing T1 in inorder,
then visiting r. It continues by traversing T2 in inorder, then T3 in inorder, . . . , and finally
Tn in inorder.

Postorder Traversal: Let T be an ordered rooted tree with root r. If T consists


only of r, then r is the postorder traversal of T . Otherwise, suppose that T1 , T2 , ..., Tn
are the subtrees at r from left to right. The postorder traversal begins by traversing T1 in
postorder, then T2 in postorder, . . . , then Tn in postorder, and ends by visiting r.

Infix notation: The form of an expression (including a full set of parentheses)


obtained from an inorder traversal of the binary tree representing this expression.

Prefix (or Polish) notation: The form of an expression obtained from a preorder
traversal of the tree representing this expression.

Postfix (or reverse Polish) notation: The form of an expression obtained from
a postorder traversal of the tree representing this expression.

14 Spanning Trees
Definition: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a
tree containing every vertex of G.

Example: Find a spanning tree of the simple graph G shown below:


Solution: The graph G is connected, but it is not a tree because it contains simple
circuits. Remove the edge {a, e}. This eliminates one simple circuit, and the resulting
subgraph is still connected and still contains every vertex of G. Next remove the edge {e, f }
to eliminate a second simple circuit. Finally, remove edge {c, g} to produce a simple graph
with no simple circuits. This subgraph is a spanning tree, because it is a tree that contains
every vertex of G. The sequence of edge removals used to produce the spanning tree is
illustrated in the figure below.

Note: Spanning tree is not unique.

Result: A simple graph is connected if and only if it has a spanning tree.

BFS and DFS - Algorithms to produce a spanning tree

Breadth-first search: A procedure for constructing a spanning tree that succes-


sively adds all edges incident to the last set of edges added, unless a simple circuit is formed.

Working Rule:

• QUEUE − first in first out: Visit any vertex.

• Start exploring all adjacent vertices connected through the selected vertex.

• Take vertices in any order and continue exploration untill all vertices are included.
Depth-first search, or backtracking: A procedure for constructing a spanning
tree by adding edges that form a path until this is not possible, and then moving back up
the path until a vertex is found where a new path can be formed.

Working Rule:

• STACK − last in first out: Visit any vertex.

• Like pre-order traverse, once we go to new vertex, we will suspend this vertex and start
exploring new verex .

• Continue untill all vertices are included.

15 Minimum Spanning Trees


Definition: A minimum spanning tree in a connected weighted graph is a spanning tree
that has the smallest possible sum of weights of its edges.
The spanning tree having weight 8 is minimal spanning tree.
Finding all spaaning tree of spanning tree is not that easy. To find minimal spanning tree
we have following algorithm.

Kruskal’s algorithm: A procedure for producing a minimum spanning tree in a


weighted graph that successively adds edges of least weight that are not already in the tree
such that no edge produces a simple circuit when it is added.

Working Rule:

• Choose an edge of minimum weight.

• At each step, choose the edge whose inclusion will not create a circuit.

• If G has n vertices, then stop after n − 1 edges.

Example: In the following graph, the green colour one is minimal spanning tree (MST) by
Kruskal’s algorithm.

Prim’s algorithm: A procedure for producing a minimum spanning tree in a


weighted graph that successively adds edges with minimal weight among all edges incident
to a vertex already in the tree so that no edge produces a simple circuit when it is added.

Working Rule:
• Select any vertex, choose an edge and smallest weight from G.

• At each stage, choose the edge of smallest weight joining a vertex already included to
vertex not yet included.

• Continue untill all vertices are included.

You might also like