Lecture Notes
Lecture Notes
Lecture-1
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Propositions
A proposition is a declarative sentence (or an assertion) which is either true or false, but not
both.
Examples of propositions
3. 1 + 5 = 6 (true)
4. 6 divides 13 (false)
3. x + y = 7
4. a − b > 3
1
q : 1 + 9 = 10.
r : 6 divides 11.
Compound Propositions
The propositions which are framed from existing propositions using the following logical con-
nectives are called compound propositions.
Negation ¬ (NOT),
Conjunction ∧ (AND),
Disjunction ∨ (OR),
Implication =⇒ (if),
Biconditional ⇐⇒ (if and only if),
Exclusive or ⊕ (XOR)
Negation ¬ (NOT). It is a unary operator.
If p is a proposition, then the negation of p is denoted by ¬p. (Other notations are ∼ p or p̄.)
Truth table for ¬p
p ¬p
1 0
0 1
Example
p : 4 is a prime number.(0)
¬p : 4 is not a prime number.(1)
Conjunction ∧ (AND). It is a binary operator.
If p, q are propositions, then the conjunction of p, q is (denoted by p ∧ q) is “p and q”.
Example
p : 4 is a prime number.
q : 3 + 2 = 5.
p ∧ q : 4 is a prime number and 3 + 2 = 5.
Truth table for p ∧ q
p q p∧q
0 0 0
0 1 0
1 0 0
1 1 1
2
Disjunction ∨ (OR). It is a binary operator.
If p, q are propositions, then the disjunction of p, q is (denoted by p ∨ q) is “p or q”.
Example
p : 4 is a prime number.
q : 3 + 2 = 5.
p ∨ q : 4 is a prime number or 3 + 2 = 5.
Truth table for p ∨ q
p q p∨q
0 0 0
0 1 1
1 0 1
1 1 1
p q p⊕q
0 0 0
0 1 1
1 0 1
1 1 0
p q p −→ q
0 0 1
0 1 1
1 0 0
1 1 1
Example
If Warangal is capital of Telangana then NewDelhi is not capital of India. (1)
3
In p −→ q, p is hypothesis (antecedent or premise) and q is conclusion (or consequence).
Note. we can read p −→ q as any one of the following types.
if p, then q
p implies q
p only if q
p is sufficient condition for q
q is necessary condition for p.
q follows from p
q whenever p
q if p
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
4
Department of Mathematics, NIT Warangal
MA4201: Mathematical Foundations of Computer Science
MSc (M&SC), I Semester (AY 2022-23)
Quiz-1 (29-8-2022)
Duration: 15 mins Max. Marks: 5
Four of these eight statements are true and four are false. Assuming only one person
committed the murder, who did it?
Answer.
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-2
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
p q p ←→ q
0 0 1
0 1 0
1 0 0
1 1 1
1
(iv) (p −→ q) ∧ (¬p −→ r)
(v) (¬p ←→ ¬q) ←→ (q ←→ r)
( )
(vi) (p ∧ q) ∨ ¬r ←→ p
Precedence of Logical Operators
Operator Precedence
¬ 1
∧ 2
∨ 3
−→ 4
←→ 5
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-3
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-4
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
x
|{z} is greater than3
| {z }
variable/subject predicate
(i) One can create a proposition from P (x, y) by binding variables x and y by giving values
to them.
1
(ii) Binding variables using quantifiers
1. Universal quantifier (∀)
2. Existential quantifier (∃)
True False
∀x P (x) P (a) is true for every a ∈ U P (a) is false for some a ∈ U
Examples.
(1) Let U = Set of all integers.
P (x) : x + 1 > x,
Q(x) : x = 1,
R(x) : x = x + 1.
Then ∀x P (x) true, ∀x Q(x) False, ∀x R(x) False.
(2) Let U = {1, 2, 3, 4}
P (x) : x is even,
Q(x) : x ̸= 5,
Then ∀x P (x) false, ∀x Q(x) true.
2. The existential quantification of P (x) is the statement ∃x P (x).
We read it as :
There exists x such that P (x),
For some x P (x).
Truth Table for existential quantifier
True False
∃x P (x) P (a) is true for some a ∈ U P (a) is false for every a ∈ U
Examples.
(1) Let U = Set of all integers.
P (x) : x + 1 > x,
2
Q(x) : x = 1,
R(x) : x = x + 1.
Then ∃x P (x) true, ∃x Q(x) true, ∃x R(x) False.
(2) Let U = {1, 2, 3, 4}
P (x) : x > 5
Q(x) : x is even,
Then ∃x P (x) false, ∃x Q(x) true.
Terminology.
Scope of a quantifier
The part of a logical expression to which the quantifier is applied.
Example. (1) ∃x P (x)
The scope of ∃x is P (x).
( )
(2) ∃x P (x) ∧ Q(x) ∨ ∀x R(x)
The scope of ∃x is P (x) ∧ Q(x) and the scope of ∀x is R(x).
Note. The following are tautological implications corresponding to quantifiers.
(i) ∀x P (x) =⇒ P (c) where c is arbitrary element of U .
(ii) P (c) =⇒ ∃x P (x) for some c.
(iii) ∀x P (x) =⇒ ∃x P (x)
Expressing quantifiers using conjunctions and disjunctions
(1) If U = {a1 , a2 , · · · , an }. Then
∀x P (x) ≡ P (a1 ) ∧ P (a2 ) ∧ · · · ∧ P (an )
∃x P (x) ≡ P (a1 ) ∨ P (a2 ) ∨ · · · ∨ P (an )
(2) If U = {a1 , a2 , · · · }. Then
∀x P (x) ≡ P (a1 ) ∧ P (a2 ) ∧ · · ·
∃x P (x) ≡ P (a1 ) ∨ P (a2 ) ∨ · · ·
Note. ∀y P (x, z) ≡ ∃y P (x, z) ≡ P (x, z)
3
Example. Translate the following sentences into logical expression.
(1) All students are clever.
(2) Some students are clever.
Note. Let U = set of all real numbers. Then
(1) ∀x < 0(x2 > 0) ≡ ∀x(x < 0 −→ x2 > 0)
(2) ∀y ̸= 0(y 3 ̸= 0) ≡ ∀y(y ̸= 0 −→ y 3 ̸= 0)
(3) ∃z > 0(z 2 = 2) ≡ ∃z(z > 0 ∧ z 2 = 2)
Exercise. Translate the following sentences into logical expression.
(1) All prime integers are positive.
Answer. ∀x (P (x) → Q(x))
(2) Not all primes are odd.
Answer. ¬∀x (P (x) → R(x))
(3) Every integer is even or odd.
Answer. ∀x (E(x) ∨ R(x))
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
4
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-5
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
1
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-6
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Nested Quantifiers. Two quantifiers are said to be nested if one is within the scope of the
other.
Example. ∃x∀yP (x, y), here the scope of ∃x is ∀yP (x, y).
Note. 1. ∀x∀yP (x, y) ≡ ∀y∀xP (x, y)
2. ∃x∃yP (x, y) ≡ ∃y∃xP (x, y)
3. ∃x∀yP (x, y) ̸≡ ∀y∃xP (x, y)
Example. P (x, y) : x2 = y where Ux = {2, 3, 4} and Uy = {4, 9, 16}
Truth value of ∃x∀yP (x, y) is False. (check this!)
Truth value of ∀y∃xP (x, y) is True. (check this!)
Note. ∃x∀yP (x, y) =⇒ ∀y∃xP (x, y). (for some a, ∀yP (a, y) true =⇒ ∀y∃xP (x, y) true)
Example. Express the definition of a limit using quantifiers.
Example. Express the fact that limx→a f (x) does not exist, with the help of quantifiers and
predicates.
Example. Express the negation of the statement ∃x∀y∃z (x + y + z ≥ 10) so that no negation
precedes a quantifier.
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
1
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-7
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Rules of Inference
Argument form (in propositional logic). A sequence of compound propositions
H , H , · · · , Hn , C
|{z}
| 1 2{z }
premises conclusion
H1
H2
..
.
Hn
∴C
H1 ∧ H2 ∧ · · · ∧ Hn =⇒ C
i.e., H1 ∧ H2 ∧ · · · ∧ Hn −→ C is a tautology.
1
Rules of inferences (in propositional logic)
H1 : p
p ∧ (p → q) =⇒ q
1. H2 : p→q Modus ponens ( )
i.e., p ∧ (p → q) → q is a tautology
∴C : q
H1 : ¬q
2. H2 : p→q Modus tollens ¬q ∧ (p → q) =⇒ ¬p
∴C : ¬p
H1 : p→q
3. H2 : q→r Hypothetical syllogism (p → q) ∧ (q → r) =⇒ p → r
∴C : p→r
H1 : p∨q
4. H2 : ¬p Disjunctive syllogism (p ∨ q) ∧ ¬p =⇒ q
∴C : q
H1 : p
5. Addition p =⇒ p ∨ q
∴C : p∨q
H1 : p∧q
6. Simplification p ∧ q =⇒ p
∴C : p
H1 : p
7. H2 : q Conjunction (p) ∧ (q) =⇒ p ∧ q
∴C : p∧q
H1 : p∨q
8. H2 : ¬p ∨ r Resolution (p ∨ q) ∧ (¬p ∨ r) =⇒ q ∨ r
∴C : q∨r
Fallacies
Example
If you do every problem in this book, then you will learn Discrete Maths.
you learnt discrete maths.
————————————————————————————————-
Therefore, you did every problem in this book.
————————————————————————————————-
This is not a valid argument.
First Order Logic. The predicate logic in which the quantification takes place over variables
only.
Example. ∀x P (x), ∃x∀y P (x, y)
Second Order Logic. Which is the extension of first order logic obtained by introducing
quantification of predicates.
Example. ∀P ∃x P (x)
Exercise. Validate the following argument.
(1) If today is tuesday, I have a test in MFCS or Algebra.
(2) If my Algebra professor is sick, I will not have a test in Algebra.
(3) Today is tuesday and my Algebra professor is sick.
————————————————————————————
∴ I have a test in MFCS.
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
3
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-8
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
∀x P (x)
∴ P (c)
1. Universal instantiation
c is an arbitrary element in U .
∃x P (x)
3. ∴ P (c) for some c ∈ U Existential instantiation
1
Universal modus ponens
( )
∀x P (x) → Q(x)
P (a) (where a is a particular element of U )
——————————————————————–
∴ Q(a) .
Universal modus tollens
( )
∀x P (x) → Q(x)
¬Q(a) (where a is a particular element of U )
—————————————————————–
∴ ¬P (a)
Example.
( )
∀x P (x) ∨ Q(x) .
( )
∀x ¬Q(x) ∨ S(x) .
( )
∀x R(x) → ¬S(x)
∃x¬P (x)
———————————-
∴ ∃x¬R(x) .
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-9
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Resolution Principle
Literal. A variable or the negation of a variable.
Example. p, ¬p, q, ¬q, · · ·
Product. Conjunction of literals.
Sum. Disjunction of literals.
Clause. A disjunction of literals, e.g., p ∨ ¬q, ¬q ∨ r ∨ s, etc.
Note. (i) The complementary of a literal p is ¬p.
(ii) The complementary of a literal ¬p is p.
Resolvent of two clauses C1 and C2 (containing a pair of complementary literals)
C1 = p ∨ q ∨ r
C2 = ¬p ∨ ¬s ∨ t
∴ Resolvent of C1 and C2 , C = q ∨ r ∨ ¬s ∨ t
Note. We can apply Resolvent rule only when one clause has a complementary literal of some
literal existed in the other clause.
Theorem: Given two clauses C1 , C2 , a resolvent C of C1 and C2 is a logical consequence of C1
and C2 . (that is, if C1 and C2 are true, then C is true. C1 ∧ C2 =⇒ C)
The resolution principle: Given a set S of clauses, a (resolution) deduction of C from S is a
finite sequence C1 , C2 , · · · , Ck of clauses such that each Ci either is a clause in S or a resolvent
of clauses preceding C and Ck = C.
A deduction of (empty clause) is called a refutation or a proof of S.
Problem Solving Technique.
2. Try to derive (empty clause) from these sequence of clauses, using Resolution Principle.
Example. Show that the following argument is correct using the resolution principle.
If today is tuesday, I have a test in in MFCS or Algorithms.
If my Algorithms professor is sick, I will not have a test in Algorithms.
1
Today is tuesday and my Algorithms professor is sick.
Therefore, I have a test in MFCS.
Example.
(1) p → (q ∨ r)
(2) p ∧ ¬q
(3) r → s
————————-
∴s
————————-
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-10
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
(p ∧ q) ∨ r ≡ (p ∨ r) ∧ (q ∨ r)
≡ [(p ∨ r) ∧ q] ∨ [(p ∨ r) ∧ r]
≡ (p ∧ q) ∨ (r ∧ q) ∨ (p ∧ r) ∨ (r ∧ r)
1
(2). An elementary sum is identically true (a tautology) iff the sum contains at least one pair
of complementary literals.
Eg. (i) p ∨ q ∨ s ∨ ¬q ≡ 1
(ii) q ∨ · · · ∨ ¬q ∨ · · · ≡ 1
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-11
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Minterm. A conjunction in which each variable occurs once either in the negated form or
in the non-negated form.
Note. Minterms are binary representation of the numbers from 0 to 2n − 1, for n variables.
• Replace →, ↔ by using ∨, ∧, ¬
• Delete duplications
1
Principal CNF. Conjunction of maxterms. (Product of sums canonical form)
∏
Eg. p ↔ q ≡ (¬p ∨ q) ∧ (p ∨ ¬q) ≡ 1, 2
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-12
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
1
Problem solving procedure.
• Replace →, ↔ using ∨, ∧, ¬
• Use the above rules (1) to (6) to bring the quantifiers to the left
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-17
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Recall: For a finite set A, |A| is the cardinality of A that is the number of elements of A.
For a pair of sets A and B, A × B is their cartesian product:
A × B = {(a, b) | a ∈ A ∧ b ∈ B}
Product rule (in sets): If A and B are finite sets, then |A × B| = |A| · |B|.
If one event can occur in n1 ways and another event can occur in n2 ways, then there are
n1 × n2 ways in which these two events can occur.
General product rule: For any m ∈ N, if A1 , A2 , . . . , Am are finite sets, then
m · (m − 1) · (m − 2) · · · (m − n + 1)
Sum Rule: If A and B are finite sets that are disjoint (meaning A ∩ B = ∅), then
|A ∪ B| = |A| + |B|
If a task can be done either in one of |A| = m ways or in one of |B| = n ways, where none of
the set of m ways is the same as any of the set of n ways, then there are m + n ways to do the
task.
Example 5. Suppose variable names in a programming language can be either a single up-
percase letter or an uppercase letter followed by a digit. Find the number of possible variable
names.
1
Example 6. Each user on a computer system has a password which must be six to eight
characters long.
Each character is an uppercase letter or digit.
Each password must contain at least one digit.
How many possible passwords are there?
Principle of Inclusion-Exclusion for Two Sets (Subtraction Rule): For any two finite
sets A and B (not necessarily disjoint), |A ∪ B| = |A| + |B| − |A ∩ B|.
Example 7. How many bit strings of length 8 either start with a 1 bit or end with the two bits
00 ?
Theorem 1 (The Pigeonhole Principle). For any positive integer k, if k+1 objects (pigeons)
are placed in k boxes (pigeonholes), then at least one box contains two or more objects. The
Pigeonhole Principle (rephrased more formally): If a function f : A → B maps a finite
set A with |A| = k + 1 to a finite set B with |B| = k, then f is not injective.
Example 8. Among any group of 367 people, there must be at least two with the same birthday,
because there are only 366 possible birthdays.
Question 1. How many students must be in a class to guarantee that at least two students
receive the same score on the final exam, if the exam is graded on a scale from 0 to 100 points?
Application. Given a sequence of n integers a1 , a2 , . . . , an , there exist consecutive a’s in the
sequence whose sum is divisible by n,
i.e., ∃ i,j with 1 ≤ i ≤ j ≤ n such that ai+1 + ai+2 + · · · + aj is divisible by n.
Application. A man hiked for 10 hours and covered a total distance of 45kms. It is known
that he hiked 6kms in the first hour and only 3kms in the last hour. Show that he must have
hiked at least 9kms within a certain period of two consecutive hours.
Application. Show that among any n + 1 positive integers not exceeding 2n there must be an
integer that divides one of the other integers.
Application. Show that given any n + 2 integers there exist two of them whose sum or differ-
ence is divisible by 2n.
Generalized pigeonhole principle. If N objects are placed into k boxes, then there is at
least one box containing at least ⌈N/k⌉ objects.
Example 9. Assume 100 people. Can you tell something about the number of people born in
the same month?
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-18
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Theorem 1 (The Pigeonhole Principle). For any positive integer k, if k+1 objects (pigeons)
are placed in k boxes (pigeonholes), then at least one box contains two or more objects. The
Pigeonhole Principle (rephrased more formally): If a function f : A → B maps a finite
set A with |A| = k + 1 to a finite set B with |B| = k, then f is not injective.
Example 8. Among any group of 367 people, there must be at least two with the same birthday,
because there are only 366 possible birthdays.
Question 1. How many students must be in a class to guarantee that at least two students
receive the same score on the final exam, if the exam is graded on a scale from 0 to 100 points?
Application. Given a sequence of n integers a1 , a2 , . . . , an , there exist consecutive a’s in the
sequence whose sum is divisible by n,
i.e., ∃ i,j with 1 ≤ i ≤ j ≤ n such that ai+1 + ai+2 + · · · + aj is divisible by n.
Application. Show that among any n + 1 positive integers not exceeding 2n there must be an
integer that divides one of the other integers.
Application. Show that given any n+2 integers there exist two of them whose sum or difference
is divisible by 2n.
Generalized pigeonhole principle. If N objects are placed into k boxes, then there is at
least one box containing at least ⌈N/k⌉ objects.
Example 9. Assume 100 people. Can you tell something about the number of people born in
the same month?
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
1
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-19
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
1. Permutations
Definition 1. Let S be a set of distinct objects. Any ordered arrangement of the objects of
S is called a permutation. An ordered arrangement of r elements of S is called an r-permutation.
Example 10. Let S = {a, b, c}. The ordered arrangement b, a, c is a permutation of S. The
ordered arrangement c, b is a 2-permutation of S. The ordered arrangement c is a 1 permutation
of S.
Fact 1. Let n, r ∈ N such that r ≤ n. Then the number of r-pernutations of a set with n
elements is denoted by P (n, r) and is given by P (n, r) = n(n − 1)(n − 2) · · · (n − r + 1).
n!
Fact 2. P (n, r) =
(n − r)!
Note: Now, we can define P (n, r) for r = 0. P (n, 0) = 1. Also, note that P (n, n) = n!.
Example 11. Suppose that a salesman has to visit eight different cities. He must begin
his trip in a specified city, but he can visit the other seven cities in any order he wishes. How
many possible orders can the salesman use when visiting these cities?
2. Combinations
1
Example 13. Let S = {1, 2, 3, 4}. All possible 3-combinations of the elements of S are
{1, 2, 3}, {1, 2, 4}, {2, 3, 4} and {1, 3, 4}.
The following theorem will give you the relation between P (n, r) and C(n, r).
P (n, r) n!
C(n, r) = =
P (r, r) r!(n − r)!
Example 14. How many poker hands of five cards can be dealt from a standard deek of 52
cards? Also, how many ways are there to select 47 cards from a standard deck of 52 cards?
Theorem 3. Let n and r be two non-negative integers with r ≤ n. Then, C(n, r) = C(n, n − r).
Example 16. Suppose that there are 9 faculty members in the mathematics department and
11 in the computer science department. How many ways are there to select a committee to
develop a discrete mathematics course at a school if the committee is to consist of three faculty
members from the mathematics department and four from the computer science department?
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-20
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
A binomial expression is simply the sum of two terms, such as x + y. The binomial theorem
( )
gives the coefficients of the expansion of powers of binomial expressions. The number nr is
called a binomial coefficient because these numbers occur as coefficients in the expansion of
powers of binomial expressions such as (x + y)n .
Theorem 4 (The Binomial Theorem). Let x and y be variables, and let n be a nonneg-
ative integer. Then
( ) ( ) ( ) ( ) ( )
n n n n−1 n n−2 2 n n n
n
(x + y) = x + x y+ x y + ··· + xy n−1
+ y
0 1 2 n−1 n
∑n ( )
n n−r r
= x y
r
r=0
Corollaries
1. Let n be a non-negative integer. Then
n ( )
∑ n
= 2n
r
r=0
That is, ( ) ( ) ( ) ( ) ( ) ( )
n n n n n n
+ + + ··· = + + + ···
0 2 4 1 3 5
3. Let n be a non-negative integer. Then
∑
n ( )
r n
2 = 3n
r
r=0
1
Figure 1: Pascal’s Triangle.
Two different combinatorial proofs of the Pascal’s identity will be discussed in the class.
(n )
Exercise 1. Prove the Pascal’s identity by algebraic manipulation from the formula for r .
(n )
Remark 1. Pascal’s identity, together with the initial conditions r can be used to recur-
sively define binomial coefficients. This recursive definition is useful in the computation of
binomial coefficients because only addition (and not multiplication ) of integers is needed to use
this recursive definition.
Pascal’s identity is the basis for a geometric arrangement of the binomial coefficients in a
triangle, as shown in Figure 1. This triangle is known as Pascal’s triangle. The nth row in the
( )
triangle consists of the binomial coefficients nr , r = 0, 1, 2, . . ..
2
Theorem 7 (Vandermonde’s Identity). Let m, n, and r be non-negative integers with
r not exceeding either m or n. Then
( ) ∑r ( )( )
m+n m n
=
r r−k k
k=0
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
3
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-21
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Example (Pigeonhole Principle). During a month with 30 days, a baseball team plays at
least one game a day, but no more than 45 games. Show that there must be a period of some
number of consecutive days during which the team must play exactly 14 games.
In many counting problems, elements may be used repeatedly. For instance, a letter or digit
may be used more than once on a license plate. In this section, we will show how to solve
counting problems where elements may be used more than once.
Example. How many strings of length r can be formed from the uppercase letters of the
English alphabet?
Example. How many ways are there to select four fruits from a bowl containing apples,
oranges, and pears if the order in which the fruits are selected does not matter, only the type
of fruit matters, and there are at least four fruits of each type of fruit in the bowl?
Example. How many ways are there to select five coins from a cash box containing 1 ru-
pee coins, 2 rupee coins, 5 rupee coins, 10 rupee coins, 20 rupee coins, 50 rupee coins, and 100
rupee coins? Assume that the order in which the coins are chosen does not matter, that the
coins of each denomination are indistinguishable, and that there are at least five coins of each
type.
Example. Let x1 , x2 and x3 be three non-negative integers. How many solutions does the
equation x1 + x2 + x3 = 11 have?
1
Example. Let x1 , x2 and x3 be integers with x1 ≥ 1, x2 ≥ 2 and x3 ≥ 3. How many so-
lutions does the equation x1 + x2 + x3 = 11 have?
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-22
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Some elements may be indistinguishable (i.e., identical) in counting problems. When this is
the case, care must be taken to avoid counting things more than once.
Theorem 11 (Permutations with Identical Objects). There are n objects in which n1
indistinguishable objects of type-1, n2 indistinguishable objects of type-2, . . ., and nk indistin-
guishable objects of type-k such that n1 + n2 + · · · + nk = n. Then the number of different
n!
permutations of the n objects is .
n1 ! n2 ! · · · nk !
Example. How many different strings can be made by reordering the letters at the word
SUCCESS?
|A1 ∪ A2 ∪ · · · ∪ An |
∑n ∑ ∑
= |Ai | − |Ai ∩ Aj | + |Ai ∩ Aj ∩ Ak | − · · · + (−1)n−1 |A1 ∩ A2 ∩ · · · ∩ An |
i=1 1≤i<j≤n 1≤i<j<k≤n
Example. Find the number of positive integers n such that 1 ≤ n ≤ 100 and n is not divisible
by 2, 3, or 5.
x1 + x2 + x3 + x4 = 18
1
Exercise. Find the number of integer solutions of the equation
x1 + x2 + x3 = 20
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-23
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
1. Balls-to-Bins Problem
Many counting problems can be solved by enumerating the ways balls (a.k.a. objects) can be
placed into bins (where the order these balls are placed into the bins does not matter). The balls
can be either distinguishable (i.e., different from each other) or indistinguishable (i.e., identical).
Similarly, bins can be distinguishable, or indinguishable.
When you solve a counting problem using the model of distributing balls into bins, you need
to determine whether the balls are distinguishable and whether the bins are distinguishable.
We have four cases:
• The number of ways to distribute k distinguishable balls into n distinguishable bins (with-
out condition) = nk
Example 1. How many ways are there to distribute hands of 5 cards to each of four
players from the standard deck of 52 cards?
1
1.2. indistinguishable balls, distinguishable bins
• The number of ways to distribute k indistinguishable balls into n distinguishable bins (each
( )
bin receives at most 1 ball) = n Ck = nk .
Example 2. How many ways are there to put four different employees into three indistin-
guishable offices, when each office can contain any number of employees?
Note: The numbers S(n, j) are called Stirling numbers of the second kind.
Solution of Example 2: the number of ways to put 4 different employees into 3 indistinguishable
offices = S(4, 1) + S(4, 2) + S(4, 3) = 1 + 7 + 6 = 14.
2
Remark. Distributing n indistinguishable balls into k indistinguishable bins is the same as
writing n as the sum of at most k positive integers in non-increasing order.
If a1 + a2 + · · · + aj = n, where a1 , a2 , . . . , aj are positive integers with a1 ≥ a2 ≥ · · · ≥ aj ,
we say that ⟨a1 , a2 , . . . , aj ⟩ is a partition of the positive integer n into j positive integers.
Result. The number of ways to distribute n indistinguishable balls into k indistinguishable
∑
bins (without condition) = kj=1 P (n, j)
where P (n, j) = the number of partitions of n into exactly j parts/integers.
Note. But no simple closed formula exists for this number.
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
3
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-24
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
2. How many ways are there to distribute 5 balls into 3 boxes if each box must have at least one
ball in it if
a) both the balls and boxes are distinguishable?
b) the balls are indistinguishable, but the boxes are distinguishable?
c) the balls are distinguishable, but the boxes are indistinguishable?
d) both the balls and boxes are indistinguishable?
1
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture 25
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Balls-to-Bins Problem
In how many ways can we distribute 𝒌 balls in to 𝒏 bins?
Condition on the number of balls received
𝒌 balls 𝒏 bins No condition Each bin receives Each bin receives at Each bin receives
at most 1 ball least 1 ball exactly 1 ball
different different 𝑛𝑘 , 𝑛𝑃𝑘 if 𝑘 ≤ 𝑛, 𝑛! ∙ 𝑆(𝑘, 𝑛) if 𝑘 ≥ 𝑛, 𝑛! if 𝑘 = 𝑛,
for any 𝑛, 𝑘 0 if 𝑘 > 𝑛 0 if 𝑘 < 𝑛 0 if 𝑘 ≠ 𝑛
𝑛
same different (𝑛−1+𝑘), (𝑘 ) if 𝑘 ≤ 𝑛, 𝑘−1
(𝑛−1) if 𝑘 ≥ 𝑛, 1 if 𝑘 = 𝑛,
𝑘
for any 𝑛, 𝑘 0 if 𝑘 > 𝑛 0 if 𝑘 < 𝑛 0 if 𝑘 ≠ 𝑛
different same ∑𝑛𝑗=1 𝑆(𝑘, 𝑗) 1 if 𝑘 ≤ 𝑛, 𝑆(𝑘, 𝑛) if 𝑘 ≥ 𝑛, 1 if 𝑘 = 𝑛,
for any 𝑛, 𝑘 0 if 𝑘 > 𝑛 0 if 𝑘 < 𝑛 0 if 𝑘 ≠ 𝑛
same same ∑𝑛𝑗=1 𝑃(𝑘, 𝑗) 1 if 𝑘 ≤ 𝑛, 𝑃(𝑘, 𝑛) if 𝑘 ≥ 𝑛, 1 if 𝑘 = 𝑛,
for any 𝑛, 𝑘 0 if 𝑘 > 𝑛 0 if 𝑘 < 𝑛 0 if 𝑘 ≠ 𝑛
𝑆(𝑘, 𝑛) is the number of partitions of the set {1, 2, … , 𝑘} into exactly 𝑛 parts,
𝑃(𝑘, 𝑗 ) is the number of partitions of 𝑘 into 𝑗 parts.
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-26
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Recurrence Relations
Recurrence relations play an important role in many aspects of the study of algorithms and
their complexity. You will see in your Design and analysis of algorithms course how recurrence
relations can be used to analyze the complexity of divide-and-conquer algorithms, such as the
merge sort algorithm.
First, we see how we can use recurrence relations to model certain problems. Consider the
following famous puzzle.
The Tower of Hanoi Puzzle: A popular puzzle of the late nineteenth century invented
by the French mathematician Édouard Lucas, called the Tower of Hanoi, consists of three pegs
mounted on a board together with disks of different sizes. Initially these disks are placed on the
first peg in order of size, with the largest on the bottom (as shown in the following Figure 1).
The rules of the puzzle allow disks to be moved one at a time from one peg to another as long
as a disk is never placed on top of a smaller disk. The goal of the puzzle is to have all the disks
on the second peg in order of size, with the largest on the bottom.
Question. How many moves does it take to transfer n disks from peg 1 to peg 2 , following the
rules of the Tower of Hanoi puzzle?
1
Exercise. A young pair of rabbits (one of each sex) is placed on an island. A pair of rabbits
does not breed until they are 2 months old. After they are 2 months old, each pair of rabbits
produces another pair each month. Find the number of pairs of rabbits on the island after 10
months, assuming that no rabbits ever die.
2
Recurrence relation Is linear? Is homogeneous? Degree
an = 3.5an−1 X X 1
fn = fn−1 + fn−2 X X 2
an = an−3 + an−6 X X 6
2
an = an−1 + an−2 × − −
hn = 2hn−1 + 1 X × 1
Remark. More than one sequence can be a solution for the same recurrence relation. For
instance,
an = 2an−1 − an−2
together with the initial conditions a0 = d0 , a1 = d1 , . . . , ak−1 = dk−1 uniquely determine the
sequence.
In the above example, the initial conditions a0 = 0, a1 = 3 represent the first sequence and
a0 = 5, a1 = 5 represent the second sequence.
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
3
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-27
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
The explicit formula for the solution sequence {an }: Let r1 and r2 be two roots. We have
three cases:
Example A. Find an explicit formula for the Fibonacci numbers. The corresponding recurrence
relation is
fn = fn−1 + fn−2 , f0 = 0, f1 = 1.
1
1. an + an−1 − 6an−2 = 0 and a0 = −1, a1 = 8
Exercise The Lucas numbers satisfy the recurrence relation Ln = Ln−1 + Ln−2 and L0 =
2, L1 = 1.
2. Roots are r1 , r1 , r2 (one pair of equal roots), then an = (α1 + α2 n)r1n + α3 r2n
4. Roots are r1 = α + iβ, r2 = α − iβ and r3 , α, β are real (one pair of complex roots), then
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
3
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-28
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
where c1 , c2 , . . . , ck are real numbers and g(n) is a function not identically zero, depending only
on n.
• The recurrence relation an = c1 an−1 +c2 an−2 +· · ·+ck an−k is called the associated homogeneous
recurrence relation.
Examples
1. an = 3an−1 + 2n
2. an = 5an−1 − 6an−2 + 7n
4. an = −11an−1 − 6an−2 + n2 2n
nℓ (b0 + b1 n + b2 n2 + · · · + bt nt )sn
2. g(n) = n6n ?
3. g(n) = 1?
4. g(n) = n4 ?
(ii) Find the solution of the above recurrence relation with initial conditions a0 = 3000, a1 =
3300.
Exercise. (i) Find all solutions of the recurrence relation an + 5an−1 + 6an−2 = 42 · 4n .
(ii) Find the solution of this recurrence relation with a1 = 56 and a2 = 278.
Exercise. Find the solution of the recurrence relation an = 4an−1 − 3an−2 + 2n + n + 3 with
a0 = 1 and a1 = 4.
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-29
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
a0 = 1
a1 = 2
an+2 = (an+1 )(an ), ∀n ≥ 0
a0 = 1
an = 3a2n−1 , ∀n > 0
where n is a power of 2.
Example. (using domain transformation)
Solve the recurrence relation T (n) = nT 2 (n/2) with initial condition T (1) = 6 when n = 2k .
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
1
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-30
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
∞
∑
G(x) = a0 + a1 x + a2 x2 + · · · + an xn + · · · = an xn
n=0
∑
Example (i) For the sequence 1, 2, 4, 8, 16, . . ., the generating function is ∞ n n
n=0 2 x .
∑∞
(ii) For the sequence an = n + 1, ∀n ≥ 0, the generating function is n=0 (n + 1)xn .
Remark We can define generating functions for finite sequences of real numbers by extending
a finite sequence a0 , a1 , a2 , . . . , an into an infinite sequence by setting an+1 = 0, an+2 = 0, . . ..
The generating function G(x) of this infinite sequence {an }∞
n=0 = {an } is a polynomial of degree
n as
G(x) = a0 + a1 x + a2 x2 + · · · + an xn
1. If f (x) is a generating function for the sequence {an } and g(x) is a generating function for
the sequence {bn }, then pf (x)+rg(x) is a generating function for the sequence {pan + rbn },
where p and r are any two real numbers.
2. If f (x) is a generating function for the sequence {an }, then xf ′ (x) is a generating function
for the sequence {nan }.
1
Sequence Generating function
1 ∑
{1n } = 1, 1, 1, . . . = ∞ n=0 x = 1 + x + x + · · ·
n 2
1−x
1 ∑
{(−1)n } = 1, −1, 1, −1, . . . = ∞n=0 (−1) x = 1 − x + x − x + · · ·
n n 2 3
1+x
1 ∑
{cn } = ∞n=0 c x = 1 + cx + c x + · · ·
n n 2 2
1 − cx
1 ∑
{n + 1} = 1, 2, 3, 4, . . . = ∞
n=0 (n + 1)x = 1 + 2x + 3x + 4x + · · ·
n 2 3
(1 − x) 2
x ∑
{n} = 0, 1, 2, 3, . . . = ∞
n=0 nx = 0 + 1x + 2x + 3x + · · ·
n 2 3
(1 − x) 2
{ } 1+x ∑
(n + 1)2 = 12 , 22 , 32 , 42 , . . . = ∞
n=0 (n + 1) x = 1 + 2 x + 3 x + 4 x + · · ·
2 n 2 2 2 2 2 3
(1 − x) 3
{ } x(1 + x) ∑∞ 2 n
n2 = 02 , 12 , 22 , 32 , 42 , . . . = n=0 n x = 02 + 12 x + 22 x2 + 32 x3 + · · ·
(1 − x)3
(m+n−1) 1 ∑∞ (m+n−1) n
{ } = x
n (1 − x)m n=0 n
a0 = 6
a1 = 30,
an = 5an−1 − 6an−2 , ∀n ≥ 2
Ans: an = −12 · 2n + 18 · 3n , ∀n ≥ 0
Exercise Solve the following recurrence relation using generating functions.
a0 = 1
a1 = 9
an = 8an−1 + 10n−1 , ∀n ≥ 2
Ans: an = 1
2 (8n + 10n ) , ∀n ≥ 0
2
Example Use generating functions to solve the recurrence relation
an+1 − an = n2 , a0 = 1 (n ≥ 0)
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
3
MA4201: Mathematical Foundation of Computer Science MSc (M&SC),I Sem
re LECTURE – 32
Department of Mathematics NIT Warangal
Example:- let A = {1,2,3} and B = {2,3} then A × B = { (1,2), (1,3), (2,2), (2,3), (3,2), (3,3) }.
Define a relation R such that aRb when a<b then R = { (1,2), (1,3), (2,3)}.
Let A is a non-empty set then a relation from A to A is a subset of A × A.
A × A = {(a, b) | a ∈ A , b ∈ A}
If |A| = n then no. of relations on A = 2n*n.
Representation of a relation
MR = ( mij) 1 ≤ i ≤ n, 1 ≤ j ≤ m
where,
1, if (𝑎𝑖 , 𝑏𝒋 ) ∈ 𝑅
𝑚𝑖𝑗 = {
0, if (𝑎𝑖 , 𝑏𝒋 ) ∉ 𝑅
(a,b) = ab, here ab is called as edge(directed edge) and represented as arrow and
a
Let A = {1,2,3,4}, R = {(1,1), (3,1), (3,2), (4,4)}
(A,R) = ( {1,2,3,4}, {(1,1), (3,1), (3,2), (4,4)} )
Example: A={1,2,3,4} and relation is R ≤ R={(1,2),(1,3),(1,4)(2,3),(2,4),(3,4),(4,4)}
Digraph representation:
1 2
4 3
1 2
Reference :-
1. Kenneth H Rosen. Discrete Mathematics and It’s Applications with Combinatoies and
Graph Theory, 7th edition, Tata McGraw Hill,2017
2 . Lecture Notes - Dr. Y. Sreenivasa Rao
MA4201: Mathematical Foundations of Computer Science MSc(M&SC), 1st Sem
Lecture-33
Department of Mathematics, NIT Warangal
Types of Relation
Let R be a relation on A.
1. Reflexive relation
A relation R is reflexive if for all y ∈ A, (y, y) ∈ R.
All the diagonal entries in MR are 1.
Every node in DR has a loop.
∀ a ∈ A, a R a
∀ a ∈ A, (a, a) ∈ 𝑅
2. Irreflexive Relation
A relation on a set A is irreflexive if no element is related to itself, in other words.
All the diagonal entries in MR are 0.
Every node in DR should not have any loop.
∀ a ∈ A, a ℟ a
∀ a ∈ A, (a, a) ∉ 𝑅
Note: Irreflexive ≠ Not reflexive
3
3. Symmetric Relation
A relation on a set A is symmetric relation if the first element is related to the second
element, then the second element is also related to the first element.
(a, b) ∈ 𝑅 (b, a) ∈ 𝑅
∀ a ∀ b (a R b b R a)
(I)
1 2
aa = (a, a)
ab = (a, b)
ba = (b, a)
4. Antisymmetric Relation
A relation on a set A is said to be antisymmetric if for all a, b in A if a related to b and
b is related to a, then a=b.
∀ a ∀ b (a R b ʌ b R a a=b)
∀ a, b ∈ A, (a, b) ∈ 𝑅 & (b, a) ∈ R a=b
(a, b) ∈ 𝑅, a ≠ 𝑏 (b, a) ∉ R
a b
mij , i ≠ 𝑗
5. Asymmetric Relation
A relation is said to be asymmetric if for all a, b in A if a is related to b, then b does not
related to a.
∀ a ∀ b (a R b b ℟ a)
∀ a, b ∈ A, (a, b) ∈ 𝑅 (b, a) ∉ 𝑅
(a, a) ∈ 𝑅 (a, a) ∉ 𝑅 (Not have any loop)
a b
MR = (mij)ij , where, i ≠ j
mij = 1 ʌ mji = 0
(Or) mij = 0 ʌ mji = 1
(Or) mij = 0 ʌ mji = 0
(Or) mij = 0 , i = j
6. Transitive Relation
A relation is said to be transitive if for all a, b, c in A, if a is related to b and b is related to
c, then a is related c.
∀ a, b, c ∈ A, (a, b), (b, c) ∈ R (a, c) ∈ R
∀ a ∀ b ∀ c, (a R b ʌ b R c a R c)
a c
Combining Relations
Let R1, R2 be two relations on A.
Union
R1 U R2= {(a, b) | (a, b) R1 V (a, b) R2}
𝑀R1 U R2 = MR1 V MR2 = (aij V bij)
Example
1 0 V 1 1 = 1 1
0 0 0 1 0 1
Mʀ¯1 = MʀT
Composition of Relation
In the mathematics of binary relations, the formation of a new binary relation R∘S
from two given binary relations R and S is known as the composition of relations.
𝑅1 = 𝑅
𝑅 2 = 𝑅𝑜𝑅
𝑅 3 = 𝑅 2 𝑜𝑅
𝑅 4=𝑅 3oR
:
:
𝑅 𝑛+1 = 𝑅 𝑛 𝑜𝑅
MA4201: Mathematical Foundation of Computer Science MSc (M&SC),I Sem
LECTURE – 34
Department of Mathematics NIT Warangal
Composition
Let A,B,C be sets and let R1 and R2 be two relations such that R1 ⊆ A × B and R2 ⊆
B × C. Then R1 and R2 given rise to a relation from A to C indicated by R2oR1 and defined by
(a,c) ∈ R2oR1 , iff ヨ b ∈ B such that (a,b) ∈ R1 & (b,c) ∈ R2 .
Example:- A = {a,b,c}
B = {1,2,3,4}
C = { x,y,z}
R1={(a,2),(a,3),(b,3),(b,4),(c,2),(c,4)}
R2={(1,x),(1,z),(2,y),(3,y),(3,z),(4,y)}
R2oR1={(a,y),(a,z),(b,z),(b,y),(c,y)}
i.e R ⊆A×A & it is defined as , (a,c) ∈ RoR iff ヨ b∈ A such that (a,b) , (b,c) ∈ R
Example:- A = {1,2,3,4}
R={(1,1),(2,1),(3,2),(4,3)}
RoR={(1,1),(2,1),(3,1),(4,2)}
• The Boolean Product represented by A⊙B is quite different from the above two
operations. Let A be a Boolean matrix of order a1 × a2 and B a Boolean matrix of order
b1 × b2. A⊙B is defined only if a2 = b1. So let A have an order of m×p and B have an
order of p×n Let E = A⊙B = [eij ]. E is then said to be the Boolean Product of A and B.
E is an m × n Matrix.
For eij we select the ith row of A and jth column of B. If even one of the corresponding
entries are both 1, the result is 1, else the result is 0(as illustrated in the figure below).
Example:-
M1 =
M2 =
M1 ⊙ M2 =
Reference :-
1. Kenneth H Rosen. Discrete Mathematics and It’s Applications with Combinatorics
andGraph Theory, 7th edition, Tata McGraw Hill,2017
Fact:
Suppose R be a relation on A. Then R is Transitive relation if and only if Rn ⊆ R
Proof:
Part 1:
Suppose R is Transitive relation on A.
let us prove by Mathematical Induction
For n = 1, Clearly, R1 ⊆ R
Assume that, Rk ⊆ R
claim: Rk+1 ⊆ R
We know that (a, b) ∈ Rk+1 = Rk ◦ R
∃ c ∈ A such that (a, c) ∈ Rk and (c, b) ∈ Rk
since Rk ⊆ R =⇒ (a, c) ∈ R
∴ ∃ c ∈ A such that (a, c) ∈ R and (c, b) ∈ R
∴ (a, b) ∈ R
Hence, Rk+1 ⊆ R
By Mathematical Induction, Rn ⊆ R
Part 2:
Suppose Rn ⊆ R ,∀n = 1, 2, ...
To prove that R is Transitive
(i.e. To prove that (a, c) ∈ R and (c, b) ∈ R =⇒ (a, b) ∈ R)
Let (a, c) ∈ R and (c, b) ∈ R
(a, c) ∈ R2 = R ◦ R = R2
But R2 ⊆ R
∴ (a, c) ∈ R
Hence, R is Transitive
1
Paths in Diagraphs (Directed Graphs)
Def:- A path from u to v in a diagraph D = (V,E) is a sequence of edges (x0 , x1 ) (x1 , x2 ) ...
(xn−1 , xn ) where n ≥ 0 and n ∈ Z satisfying the terminal node of an edge equal to initial node in
the next edge in the sequence
NOTATIONS:
NOTE:
Theorem:
If there is a path of length 2 from u to v in DR if and only if (u, v) ∈ R2
Proof:
Part 1:
Let R be a relation on A
Suppose There is a path of length 2 from u to v in DR
Then ∃ a node a ∈ A such that (u, a), (a, v) are edges in DR i.e.(u, a), (a, v) ∈ R
∴ (u, v) ∈ R ◦ R
Hence, (u, v) ∈ R2
Part 2:
Suppose (u, v) ∈ R2
Then ∃ c ∈ A such that (u, c) ∈ R and (c, v) ∈ R
=⇒ (u, c), (c, v) ∈ R
=⇒ u, c, v is a path of length 2 in DR between u and v
Hence, There exists a path of length 2 in DR between u and v
2
e.g. A = { 1, 2, 3, 4 }
R = { (1, 1), (2, 1), (3, 2), (4, 3) }
R2 = { (1, 1), (2, 1), (3, 1), (4, 2) }
R3 = { (1, 1), (2, 1), (3, 1), (4, 1) }
Closure of Relations
Reflexive closure: Let R be a relation on A which is not reflexive. Now the smallest reflexive
relation containing R is called the Reflexive closure of R.
Observation:
T
1. S = Ri , R ⊆ Ri where each Ri is reflexive
i
2. R is not reflexive Then S = R ∪ ∆
3. MS = MR∪∆ = MR ∨ M∆ = MR ∨ I
Symmetric closure: Let R be a relation on A which is not symmetric. Now the smallest sym-
metric relation containing R is called the symmetric closure of R.
3
Observation:
T
1. S = Ri , R ⊆ Ri where each Ri is symmetric
i
2. R is not symmetric Then S = R ∪ R−1
3. MS = MR∪R−1 = MR ∨ MR−1 = MR ∨ MRT
[1]
References
4
MA4201: Mathematical Foundation of Computer Science MSc (M&SC),I Sem
LECTURE – 36
Transitive closure -
Definition -
*
Let R be a relation on a set A. The connectivity relation 𝑅 consists of the
pairs (a,b) such that there is a path of length at least one from a to b in R.
Proof –
Suppose R is not transitive
*
Claim - 𝑅 is “smallest “ “transitive” relation “containing R”
(I) “containing R “
∞
𝑛 *
R = R’ ⊆ ⋃ 𝑅 = 𝑅
𝑛=1
(II) “transitive”
∞
𝑛
(a,b) , (b,c) ∈ R* = ⋃ 𝑅
𝑛=1
𝑛1 𝑛2
⇒ (a,b) ∈ 𝑅 𝑎𝑛𝑑 (𝑏, 𝑐) ∈ 𝑅
∞
𝑛2 𝑛1 𝑛2+𝑛1 𝑛 *
⇒ (a, c) ∈ 𝑅 ◦𝑅 =𝑅 ⊆ ⋃ 𝑅 = 𝑅
𝑛=1
∴ R* is transitive
(III) “smallest “
Claim : – R* ⊆ S
𝑛
Since S is transitive 𝑆 ⊆ S ∀ n = 1, 2 ….
∞
𝑛
⋃ 𝑆 ⊆S
𝑛=1
2 2 3 3
since R ⊆ S , 𝑅 ⊆ 𝑆 ,𝑅 ⊆ 𝑆 …
∞ ∞
* 𝑛 𝑛
𝑅 = ⋃ 𝑅 ⊆ ⋃ 𝑆 ⊆S
𝑛=1 𝑛=1
so, R* ⊆ S
∞
𝑛 1 2 𝑛
R* = ⋃ 𝑅 = 𝑅 ∪ 𝑅 …… ∪ 𝑅
𝑛=1
R=
1 2 𝑛
• Trcl(R) = 𝑅 ∪ 𝑅 … . ∪ 𝑅 if R is a relation on A with n elements
= 𝑀𝑅 ⋁ 𝑀 2⋁ ..... ⋁ 𝑀 𝑛
𝑅 𝑅
(1) (2) (𝑛)
= 𝑀𝑅 ∨ 𝑀𝑅 ∨ 𝑀𝑅 ……… ∨ 𝑀𝑅
Algorithm :
1. Write MR
2. Initialize : A=MR
B=A
3. For i =1 to n-1
A = A ⊙ MR
B=B⋁A
*
4. Write R for B
*
5. Return R
Complexity :
O(n3) · n
O(n4)
Example:
A = { (a, a), (b,b), (a,c), (c, a), (c,b) }
WARSHALL’S ALGORITHM
Warshall’s algorithm, named after Stephen Warshall, who described this algorithm I 1960
is an efficient method for computing the transitive closure of a relation. Algorithm 1 can find the
transitive closure of a relation on a set with n elements using 2n3(n-1) bit operations. However,
the transitive closure can be found by Warshall’s algorithm using only 2n 3 bit operations.
Warshall’s algorithm is sometimes called the Roy-Warshall algorithm, because Bernard
Roy described this algorithm in 1959.
Suppose that R is a relation on a set with n elements. Let v1,v2,………..vn be an arbitrary
listing of these n elements. The concept of the interior vertices of a path is used in Warshall’s
algorithm. If a, x1, x2, …., xm-1, b is a path, its interior vertices are x1, x2,……, xm-1, that is, all the
vertices of the path that occur somewhere other than as the first and last vertices in the path.
For instance, the interior vertices of a path a, c, d, f, g, h, b, j in a directed graph are c, d, f, g, h
and b. The interior vertices of a, c, d, a, f, b are c, d, a, and f. (Note that the first vertex in the
path is not an interior vertex unless it is visited again by the path, except as the last vertex.
Similarly, the last vertex in the path is not an interior vertex unless it was visited previously by
the path, except as the first vertex).
EXPLANATION
Let R be the relation with directed graph shown in figure 3. Let a, b, c, d be a listing of the
elements of the set. Find the matrices W0, W1, W2, W3 and W4. The matrix W4 the transitive
closure of R.
1
[LECTURE 37] 2022
0 0 0 1
1 0 1 0
W 0= [ ]
1 0 0 1
0 0 1 0
W1 has 1 as it (i, j)th entry if there is a path from vi to vj that has only
v1 = an interior vertex. Note that all paths of length one can still be used since they have interior
vertices. Also, there is now an allowable path from b to d namely, b, a, d. Hence,
0 0 0 1
1 0 1 1
W1= [ ]
1 0 0 1
0 0 1 0
W2 has 1 as its (i, j)th entry if there is a path from vi to vj that has only v1 = a and v2 = b as an
interior vertices, if any. Since there are no edges that have b as a terminating vertex, no new
paths are obtained when we permit b to be an interior vertex. Hence, W2 = W1
W3 has 1 as its (i, j)th entry if there is a path from vi to vj that has only v1 = a and v2 = b and /or v3
= c as its interior vertices, if any. We now have paths from d to a namely, d, c, a, and from d to d,
namely, d, c, d. Hence,
0 0 0 1
1 0 1 1
W3=[ ]
1 0 0 1
1 0 1 1
Finally, W4 has 1 as its (i, j)th entry if there is a path from vi to vj that has v1 = a, v2 = b, v3 = c
and/or v4 = d as interior vertices, if any. Since there are all the vertices of the graph, this entry is
1 if and only if there is path from vi and vj. Hence,
1 0 1 1
1 0 1 1
W4 = [ ]
1 0 1 1
1 0 1 1
2
[LECTURE 37] 2022
with no vertices other than v1, v2, …, vk as interior vertices if and only if either there is a path
from vi to vj with its interior vertices among the first k-1 vertices in the list, or there are paths
from vi to vk and from vk to vi have interior vertices only among the first k-1 vertices in the list
that is, either as path from vi to vj already existed before vk was permitted as an interior vertex,
or allow vk as an interior vertex produces a path that goes from vi and v k and then from vk to v k-1.
These two cases are shown in Figure 4.
Case 1 Case 2
(𝑘−1)
The first type of path exists if and only if 𝑤𝑖𝑗 = 1, and the second type of path exists if
(𝑘−1) (𝑘−1) (𝑘−1) (𝑘−1)
and only if both 𝑤𝑖𝑘 and 𝑤𝑘𝑗 are 1. Hence 𝑤𝑖𝑗 is 1 if and only if either 𝑤𝑖𝑗 is 1
(𝑘−1) (𝑘−1)
or both 𝑤𝑖𝑘 and 𝑤𝑘𝑗 are 1 . This gives us Lemma 2.
(𝑘)
LEMMA2 Let 𝑊𝑘 = [𝑤𝑖𝑗 ] be the zero -one matrix that has a 1 in its (𝑖, 𝑗)th position if and
only if there is a path from 𝑣𝑖 to 𝑣𝑗 with interior vertices from the set{𝑣1 , 𝑣2 , … , 𝑣𝑘 }. Then
(𝑘) (𝑘) (𝑘−1) (𝑘−1)
𝑤𝑖𝑗 = 𝑤𝑖𝑗 ⋁(𝑤𝑖𝑘 ⋀𝑤𝑘𝑗 )
Lemma 2 gives us the means to efficiently the matrices 𝑊𝑘 , 𝑘 = 1,2, … , 𝑛. We display the
psedocode for Warshall`s algorithm, using Lemma 2, as Algorithm 2.
3
[LECTURE 37] 2022
ALGORITHM-2:Warshall Algorithm.
procedure Warshall (MR : n × n zero- one matrix)
W := MR
for k := 1 to n
begin
for i := 1 to n
begin
for i := 1 to n
wij := wij V (wik ˄ wkj)
end
end{ W = [wij] is MR*}
Example: By using Warshall’s algorithm, find the transitive closure of the relation
>>In step 1, we will consider 1st column and 1st row of the above matrix i.e., C1 and R1.
4
[LECTURE 37] 2022
0 0 0 0
1 0 1 1
New matrix = [ ]
1 0 0 1
1 0 1 1
>>In step 4, we will consider 4th column and 4th row of the above matrix.
C4 R4
{2, 3, 4} {1, 3, 4}
C4×C4 = {(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)}
0 0 0 0
1 0 1 1
New matrix [Rt*] = [ ]
1 0 1 1
1 0 1 1
Rt* = {(2,1),(2,3),(2,4),(3,1),(3,3),(3,4),(4,1),(4,3),(4,4)}
Rt* is the transitive closure of relation R.
REFERENCE:
Lecture on 21.11.2022 - Dr. Y. Sreenivasa Rao
ICS 241 Discrete Mathematics II (Spring 2015) by Edsger W. Dijkstra
*****
5
MA4201:
Mr Mathematical Foundation of Computer Science MSc (M&SC),I Sem
LECTURE – 38
Department of Mathematics NIT Warangal By – Manish Dharmani, Neeraj Patnayak, Mainak Banerjee
LEMMA: Let Wk = [wij[k]] be the zero-one matrix that has a 1 in its (I,j)th position if and only if there is a path
from vi to vj with interior vertices from the set {v1,v2,………,vn}. Then
wij[k]= wij [k-1] ˅(wik[k-1] ˄ wkj[k-1])
whenever i, j, and k are positive integers not exceeding n.
Counting of relations:
1.Reflexive Relation and Irreflexive Relation:
A reflexive relation on set A must contain the n elements (a,a) for every a∈A. The remaining number of pairs
is n2−n. So we can choose only among n2−n elements to build reflexive relations. Hence, there are
2 −𝑛
2𝑛 = 2𝑛(𝑛−1)
reflexive relations on a set with cardinality n.
An irreflexive relation is the opposite of a reflexive relation. It contains no identity elements (a,a) for
all a∈A. It is clear that the total number of irreflexive relations is given by the same formula as for reflexive
relations.
2.Symmetric relation:
We can determine the number of symmetric relations on a set A. A relation R defined on a set A with n
elements has ordered pairs of the form of (a, b). Now, we know that element 'a' can be chosen in n ways
and similarly, element 'b' can be chosen in n ways. This implies we have n2 ordered pairs (a, b) in R. Also, if
(a, b) is in R, then for a symmetric relation, (b, a) is forced to be in R. Therefore, we have 2 n(n-1)/2 such ordered
pairs. For a reflexive relation, we have ordered pairs of the form (a, a) which are also symmetric. We have
2n such ordered pairs. Hence, the number of symmetric relations is 2n. 2n(n-1)/2 = 2n(n+1)/2.
Antisymmetric relation and Asymmetric relation:
Consider an antisymmetric relation R on set A, say a, b ∈A with a≠b, then relation R must not contain
both (a, b) and (b, a). it may contain one of the ordered pairs or neither of them. Thus, there
are three possible choices for pairs. Therefore, the count of all combinations of these
𝑛(𝑛−1)
choices is equal to 3 2 . The number of subsets of pairs of the form (a, a) is equal to 2𝑛 .
𝑛(𝑛−1)
Therefore, total number of possible antisymmetric relations is equal to 2𝑛 ⋅ 3 2 .
For asymmetric relation almost everything is same as antisymmetric relation only the pairs
of the form (a, a) are not allowed. Thus, total number of possible asymmetric relation is
𝑛(𝑛−1)
equal to 3 2 .
**There is no particular counting technique for Transitive Relation**
Question:
1.how many possible relations are there on a set s={1,2,3,……,n} which are both reflexive and symmetric?
2.how many possible relations are there on a set s={1,2,3,……,n} which are both symmetric and
antisymmetric?
1. Kenneth H Rosen. Discrete Mathematics and It’s Applications with Combinatoies and Graph Theory, 7th edition,
Tata McGraw Hill,2017
2 .Lecture Notes - Dr. Y. Sreenivasa Rao
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-39
Department of Mathematics, NIT Warangal Date: 26.11.2022
Department
Definition of Mathematics,
(Equivalence NIT Warangal Scribe: Dr. Y. Sreenivasa RaoMA4201: Mathematical
Relation):
Foundations of Computer Science MSc (M&SC), I Sem
A relation 𝑅 on 𝐴 is called Equivalence Relation if 𝑅 satisfied the following condition:
1. 𝑅 is Reflexive (that is ∀𝑎 ∈ 𝐴 ⟹ 𝑎𝑅𝑎)
Lecture-5
2. 𝑅 is Symmetric (that is ∀𝑎∀𝑏(𝑎𝑅𝑏 ⟹ 𝑏𝑅𝑎))
3. 𝑅 is Transitive (that is ∀𝑎∀𝑏∀𝑐(𝑎𝑅𝑏 ∧ 𝑏𝑅𝑐 ⟹ 𝑎𝑅𝑐))
Definition
Department(Partition of a set):
of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
The class sets {𝐵𝑖 }𝑖∈𝐼 forms a partition for the set 𝐴 if
1. 𝐵𝑖 ≠ ∅
Lecture-5
2. 𝐵𝑖 ∩ 𝐵𝑗 = ∅, ∀𝑖 ≠ 𝑗
3. ⋃𝑖∈𝐼 𝐵𝑖 = 𝐴
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Therefore ⋃[𝑎]∈𝐴/~[𝑎] = 𝐴.
That follows for the equivalence relation ∼ forms the partition 𝐴/∼ for 𝐴.
1
(i) Let 𝑎 ∈ 𝐴. Then 𝑎 ∈ 𝐴
⟹ 𝑎 ∈ 𝐵1 ∪ 𝐵2 ∪ … ∪ 𝐵𝑛
⟹ 𝑎 ∈ 𝐵𝑖 , 𝑓or some 𝑖
⟹ 𝑎, 𝑎 ∈ 𝐵𝑖
⟹ 𝑎~𝑎. That follows 𝐴 is Reflexive.
(ii) Let 𝑎, 𝑏 ∈ 𝐴 and 𝑎~𝑏. Then 𝑎~𝑏 ⟹ 𝑎, 𝑏 ∈ 𝐵𝑖 , for some 𝑖
⟹ 𝑏, 𝑎 ∈ 𝐵𝑖
⟹ 𝑏~𝑎. That follows 𝐴 is Symmetric.
(iii) Let 𝑎, 𝑏, 𝑐 ∈ 𝐴 and 𝑎~𝑏, 𝑏~𝑐. Then 𝑎, 𝑏 ∈ 𝐵𝑖 and 𝑏, 𝑐 ∈ 𝐵𝑗 for some 𝑖, 𝑗. That
follows 𝑏 ∈ 𝐵𝑖 ∩ 𝐵𝑗 . But either 𝐵𝑖 ∩ 𝐵𝑗 = ∅ or 𝐵𝑖 = 𝐵𝑗 . Now 𝐵𝑖 ∩ 𝐵𝑗 ≠ ∅ that
follows 𝐵𝑖 = 𝐵𝑗 . Therefore 𝑎, 𝑐 ∈ 𝐵𝑖 = 𝐵𝑗 implies that 𝑎~𝑐. That show 𝐴 is
Transitive.
Hence ~ is an equivalence relation on 𝐴.
Note:
(i) The number of different equivalence relation on 𝐴 with |𝐴| = 𝑛
=The number of different partitions for 𝐴 with |𝐴| = 𝑛
= ∑𝑛𝑘=1 𝑆(𝑛, 𝑘) = 𝐵𝑛 (Bell Number)
(ii) If 𝑎 ∈ 𝐴 and 𝑎 ∈ 𝐵𝑖 for some 𝑖, then [𝑎] = 𝐵𝑖 .
Let any 𝑥 ∈ [𝑎]. Then 𝑥 ∈ [𝑎] ⟹ 𝑥~𝑎
⟹ 𝑥, 𝑎 ∈ 𝐵𝑖
⟹ 𝑥 ∈ 𝐵𝑖 .
That follows [𝑎] ⊆ 𝐵𝑖 .
Let any 𝑦 ∈ 𝐵𝑖 . Then 𝑦 ∈ 𝐵𝑖 ⟹ 𝑦, 𝑎 ∈ 𝐵𝑖
⟹ 𝑦~𝑎
⟹ 𝑦 ∈ [𝑎].
That follows 𝐵𝑖 ⊆ [𝑎]. Therefore [𝑎] = 𝐵𝑖 .
Example: Let 𝐴 = {1,2,3,4,5,6} and 𝐵1 = {1,2,3}, 𝐵2 = {4,5}, 𝐵3 = {6} are the partition for
A. Find the equivalence relation induces from {𝐵1 , 𝐵2 , 𝐵3 }.
The partition includes 3 subsets correspond to 3 equivalence classes of the relation
𝑅(say). We can denote these classes by 𝐸1 , 𝐸2 , 𝐸3 . They contain the following points:
𝐸1 = {(1,1), (2,2), (3,3), (1,2), (2,1), (1,3), (3,1), (2,3), (3,2)}
𝐸2 = {(4,4), (5,5), (4,5), (5,4)}
𝐸3 = {(6,6)}
Therefore, the relation 𝑅 roster form is given by
𝑅 = 𝐸1 ∪ 𝐸2 ∪ 𝐸3
= {(1,1), (2,2), (3,3), (4,4), (5,5), (6,6), (1,2), (2,1), (1,3), (3,1), (2,3), (3,2)(4,5), (5,4)}
2
Note:
From the above example, we noticed that 𝐸1 is nothing but 𝐵1 × 𝐵1. In the similar
way 𝐸2 = 𝐵2 × 𝐵2 and 𝐸3 = 𝐵3 × 𝐵3. Therefore, the equivalence relation 𝑅 on 𝐴 is
𝐸1 ∪ 𝐸2 ∪ 𝐸3 = (𝐵1 × 𝐵1 ) ∪ (𝐵2 × 𝐵2 ) ∪ (𝐵3 × 𝐵3 ).
Conclusion:
If {𝐵1 , 𝐵2 , … , 𝐵𝑛 } is a partition for 𝐴. Then the equivalence relation corresponding
to the partition is (𝐵1 × 𝐵1 ) ∪ (𝐵2 × 𝐵2 ) ∪ … ∪ (𝐵𝑛 × 𝐵𝑛 ).
Reference
1. Kenneth H Rosen. Discrete Mathematics and Its Applications with Combinatorics and
Graph Theory, 7th Edition, Tata McGraw Hill, 2017.
2. Lecture Notes: Dr. Y. Sreenivasa Rao
3
MA4201: Mathematical Foundations of Computer Science MSc (M&SC), I Sem
Lecture-40
Department of Mathematics, NIT Warangal Scribe: Dr. Y. Sreenivasa Rao
Equivalent Relation: -
Let R be a relation on A that satisfies –
Reflexive Property
Symmetric Property
Transitive Property
is called equivalence relation.
E.g., 1 A=ℤ, m € ℤ+, R= ‘/ ‘
aRb m/(a-b)
1) REFLEXIVE –
aRa m/(a-a) = m/0
⇒ (a, a) € R, for all a € ℤ
2) SYMMETRIC-
(a, b) € R
aRb m/(a-b)
m/(b-a)
(b-a) € R
3) TRANSITIVE
(a, b) € R and (b, c) € R
m/(a-b) and m/(b-c)
Then m/(a-b)-(b-c)
⇒ m/(a-c)
Hence R is an equivalence relation
A=ℤ, m € ℤ+ (a, b) € R m/(a-b) a ≡ b (mod m)
aRb a/b
This is reflexive, transitive but not symmetric that’s why it is not equivalence relation.
= [5]5
The set of all equivalent classes
𝑍 ≡ 5 = {[0]5 , [1]5 , [2]5 , [3]5 , [4]5 }
Partition Let S be a non-empty set. Let {𝐵𝑖 }𝑘𝑖=1 be a family of subsets of S, and satisfies the following
conditions
(i) 𝐵𝑖 ≠ 𝜙,∀𝑖
(iv) 𝐵𝑖 ∩ 𝐵𝑗 = 𝜙
(ii) ∪𝑛𝑖=1 𝐵𝑖 = 𝑆
R1 1 2
3
R2
1 2 3
1 2 3
R1∪R2
R1 and R2 are equivalence relation but R1∪R2 is not
• Antisymmetric
• Transitive
Definition. If 𝐴 is a set and 𝑅 is a partial order on A, then the pair (𝐴, 𝑅)is called a partially ordered set
or poset
4
3
2
1
a≼b ,that is a and b are comparable
a a a
b b b
if a and b are not comparable then ,
a b
Example:
let A={1,2,4,5,10,20}, ≼=| or (D20,|),i.e divisor of 20 with ≼=|
Hasse Diagram:
20
4 10
2 5
1
Ex: a
x o y
C p q z
S t
In 1 no. picture maximal elements are b and a ,minimal element is c.
In 2 no. picture minimal elements are o , z and maximal element are x,o,y.
In 3 no. picture minmal elements are s,t and maximal elements are p,q.
Topological Sorting:
Motivation. Suppose that a project is made up of 100 different tasks. Some tasks can be
completed only after others have been finished. How can an order be found for these tasks?
To model this problem we setup a partial order on the set of tasks as follows:
𝑥 ≼ 𝑦 iff 𝑦 cannot be started until 𝑥 has been completed
Find a topological sorting.
Definition. Constructing a (compatible) total ordering from a given partial ordering is called
topological sorting (or linearization of a partial order)
Lemma. Every non-empty finite poset has at least one minimal element.
Topological Sorting Algorithm
Let (𝐴, ≼) be a non-empty finite poset.
• Choose a minimal element 𝑎 from (𝐴, ≼)
• Remove 𝑎 from 𝐴
Consider (𝐴 − {𝑎 }, ≼) which is a non-empty finite poset
• Choose a minimal element 𝑎 from (𝐴 − {𝑎 }, ≼)
Write 𝑎 ≺ 𝑎
• Remove 𝑎 from A
Consider (𝐴 − {𝑎 , 𝑎 }, ≼) which is a non-empty finite poset
• Choose a minimal element 𝑎 from (𝐴 − {𝑎 , 𝑎 }, ≼)
Write 𝑎 ≺ 𝑎 ≺ 𝑎
• Continue this process until no elements remain, i.e., 𝐴 is empty
𝑎 ≺ 𝑎 ≺ 𝑎 ≺ ⋯ ≺ 𝑎 is the required total ordering
Example :
A is non empty, |A| = n
A1
A2
A3
A4
6 7
4 5
2 3
1
Hasse Diagram
Exercise. Find a compatible total ordering for the poset ( {1, 2, 4, 5, 12, 20} , | ) .
Theorem. Least and greatest elements are unique (if they exist).
4 5
2 3 4
1 2
a) b) 4 10
9 12
3 2 5
Lattices
Definition. A poset is a lattice if every pair of elements has a lub and glb
Notation. 𝑙𝑢𝑏(𝑎, 𝑏) = 𝑎 ∨ 𝑏 (read 𝑎 join b)
𝑔𝑙𝑏(𝑎, 𝑏) = 𝑎 ∧ 𝑏 (read 𝑎 meet b)
c
a wee d
b
a ( c۷d ) = a۸e = a --------①
( a۸c ) ۷( a۸d ) = b۷b = b -------②
① and ② are not equal, therefore not a distributive class
Definition. A lattice is said to be bounded lattice if it has the greatest element 1 and a least
element 0.
0≤x≤1
Definition. Let (𝐿, ≼, 0,1) be a bounded lattice.
For any 𝑎 ∈ 𝐿, there exists 𝑏 ∈ 𝐿 such that
𝑎 ∧ 𝑏 = 0, 𝑎 ∨ 𝑏 = 1
𝑏 is called a complement of 𝑎, denoted by 𝑎 or 𝑎
1
a b
a b
Question. Give an example of a finite lattice where at least one element has more than
one complement.
a ccc b
0
Question. Give an example of a finite lattice where at least one element has
NO complement.
Boolean Algebra
Example : The set of propositions of n varaibles with the ۷ and ۸ operators, F and T,