Post on 28-May-2018
Dept.of MCA,CREC Page 1
LECTURE NOTES
ON
MATHEMATICAL FOUNDATIONS OF COMPUTER SCIENCE
MCA I YEAR I SEMESTER (JNTUA-R09)
Mrs.B.Vijaya
Asst.Professor
DEPARTMENT OF MASTER OF COMPUTER APPLICATIONS
CHADALAWADA RAMANAMMA ENGINEERING COLLEGE CHADALAWADA NAGAR, RENIGUNTA ROAD, TIRUPATI (A.P) – 517506
Dept.of MCA,CREC Page 2
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY ANANTAPUR
MCA Semester-I T
4
(9F00104) MATHEMATICAL FOUNDATIONS OF COMPUTER SCIENCE
UNIT-I
Mathematical Logic: Statements and notations, Connectives, Well formed formulas, Truth
Tables, tautology, equivalence implication, Normal forms, Quantifiers, universal quantifiers
UNIT-II
Predicates: Predicative logic, Free & Bound variables, Rules of inference, Consistency, proof of
contradiction, Automatic Theorem Proving.
UNIT-III
Relations: Properties of Binary Relations, equivalence, transitive closure, compatibility and
partial ordering relations, Lattices, Hasse diagram. Functions: Inverse Function, Composition of
functions, recursive Functions, Lattice and its Properties,
UNIT-IV
Algebraic structures: Algebraic systems examples and general properties, Semi groups and
monads, groups, sub groups homomorphism, Isomorphism.
UNIT-V
Elementary Combinatorics: Basis of counting, Enumerating Combinations & Permutations,
with repetitions, Constrained repetitions, Binomial Coefficients, Binomial Multinomial
theorems, the principles of Inclusion – Exclusion. Pigeon hole principles and its application
Dept.of MCA,CREC Page 3
UNIT-VI
Recurrence Relation: Generating Functions & Sequences , Calculating Coefficient of
generating function, Recurrence relations, Solving Recurrence relation by substitution and
Generating functions. Characteristic roots, solution of Inhomogeneous Recurrence Relation.
UNIT-VII
Graph Theory: Representation of Graph, DFS, BFS, Spanning Trees, planar Graphs
UNIT-VIII
Graph Theory Applications: Basic Concepts Isomorphism and Sub graphs, Multi graphs and
Euler circuits, Hamiltonian graphs, Chromatic Numbers
REFERENCE:
1. Elements of Discrete Mathematics- A Computer Oriented Approach,C.L.Liu,
D.P. Mohapatra, 3/e,TMH.
2. Discrete Mathematics for Computer Scientists & Mathematicians, 2/e,
J.L.Mott, A. Kandel, T.P. Baker, PHI
3. Discrete Mathematical Structures with Application to Computer Science, Tremblay,
Manohar McGraw Hill Publication
4. Discrete and Combinatorial Mathematics- An Applied Introduction,Ralph.
P.Grimaldi, 5/e,Pearson Education.
5. Discrete Mathematics and its applications, 6th edition, K.H.Rosen, TMH.
6. Discrete Mathematical Structures, Mallik and Sen, Cengage Learning.
7. Discrete Mathematical Structures, Bernand Kolman, Robert C. Busby, Sharon Cutler
Ross, PHI/ Pearson Education.
8. Discrete Mathematics with Applications,Thomas Koshy,Elsevier.
9. Discrete Mathematics, Lovasz, Springer.
Dept.of MCA,CREC Page 4
UNIT-I
Mathematical Logics
Propositional Logic
The rules of mathematical logic specify methods of reasoning mathematical statements. Greek
philosopher, Aristotle, was the pioneer of logical reasoning. Logical reasoning provides the
theoretical base for many areas of mathematics and consequently computer science. It has many
practical applications in computer science like design of computing machines, artificial
intelligence, definition of data structures for programming languages etc.
Propositional Logic is concerned with statements to which the truth values, “true” and “false”,
can be assigned. The purpose is to analyze these statements either individually or in a composite
manner.
Propositional Logic – Definition
A proposition is a collection of declarative statements that has either a truth value "true” or a
truth value "false". A proposition consists of propositional variables and connectives. We denote
the propositional variables by capital letters (A, B, etc). The connectives connect the
propositional variables.
Some examples of Propositions are given below −
"Man is Mortal", it returns truth value “TRUE”
"12 + 9 = 3 − 2", it returns truth value “FALSE”
The following is not a Proposition −
"A is less than 2". It is because unless we give a specific value of A, we cannot say whether the
statement is true or false.
Connectives
In propositional logic generally we use five connectives which are − OR (∨), AND (∧),
Negation/ NOT (¬), Implication / if-then (→), If and only if (⇔).
OR (∨) − The OR operation of two propositions A and B (written as A ∨ B) is true if at least any
of the propositional variable A or B is true.
The truth table is as follows −
A B A ∨ B
True True True
Dept.of MCA,CREC Page 5
True False True
False True True
False False False
AND (∧)− The AND operation of two propositions A and B (written as A ∧ B) is true if both the
propositional variable A and B is true.
The truth table is as follows −
A B A ∧ B
True True True
True False False
False True False
False False False
Negation (¬) − The negation of a proposition A (written as ¬A) is false when A is true and is
true when A is false.
The truth table is as follows −
A ¬A
True False
False True
Implication / if-then (→) − An implication A→B is False if A is true and B is false. The rest
cases are true.
The truth table is as follows −
A B A → B
True True True
True False False
False True True
False False True
If and only if (⇔) − A⇔B is bi-conditional logical connective which is true when p and q are
both false or both are true.
The truth table is as follows −
Dept.of MCA,CREC Page 6
A B A ⇔ B
True True True
True False False
False True False
False False True
Tautologies
A Tautology is a formula which is always true for every value of its propositional variables.
Example − Prove [(A → B) ∧ A] → B is a tautology
The truth table is as follows −
A B A → B (A → B) ∧ A [(A → B) ∧ A] → B
True True True True True
True False False False True
False True True False True
False False True False True
As we can see every value of [(A → B) ∧ A] → B is “True”, it is a tautology.
Contradictions
A Contradiction is a formula which is always false for every value of its propositional variables.
Example − Prove (A ∨ B) ∧ [(¬A) ∧ (¬B)] is a contradiction
The truth table is as follows −
A B A ∨ B ¬A ¬B (¬A) ∧ (¬B) (A ∨ B) ∧ [(¬A) ∧ (¬B)]
True True True False False False False
True False True False True False False
False True True True False False False
False False False True True True False
As we can see every value of (A ∨ B) ∧ [(¬A) ∧ (¬B)] is “False”, it is a contradiction.
Contingency
Dept.of MCA,CREC Page 7
A Contingency is a formula which has both some true and some false values for every value of
its propositional variables.
Example − Prove (A ∨ B) ∧ (¬A) a contingency
The truth table is as follows −
A B A ∨ B ¬A (A ∨ B) ∧ (¬A)
True True True False False
True False True False False
False True True True True
False False False True False
As we can see every value of (A ∨ B) ∧ (¬A) has both “True” and “False”, it is a
contingency.
Well Formed Formula
Well Formed Formula (wff) is a predicate holding any of the following −
All propositional constants and propositional variables are wffs
If x is a variable and Y is a wff, ∀x Y and ∃x Y are also wff
Truth value and false values are wffs
Each atomic formula is a wff
All connectives connecting wffs are wffs
Propositional Equivalences
Two statements X and Y are logically equivalent if any of the following two conditions −
The truth tables of each statement have the same truth values.
The bi-conditional statement X ⇔ Y is a tautology.
Example − Prove ¬(A ∨ B) and [(¬A) ∧ (¬B)] are equivalent
Testing by 1st method (Matching truth table)
A B A ∨ B ¬ (A ∨ B) ¬A ¬B [(¬A) ∧ (¬B)]
True True True False False False False
True False True False False True False
False True True False True False False
False False False True True True True
Dept.of MCA,CREC Page 8
Here, we can see the truth values of ¬ (A ∨ B) and [(¬A) ∧ (¬B)] are same, hence the statements
are equivalent.
Testing by 2nd method (Bi-conditionality)
A B ¬ (A ∨ B) [(¬A) ∧ (¬B)] [¬ (A ∨ B)] ⇔ [(¬A) ∧ (¬B)]
True True False False True
True False False False True
False True False False True
False False True True True
As [¬ (A ∨ B)] ⇔ [(¬A) ∧ (¬B)] is a tautology, the statements are equivalent.
Inverse, Converse, and Contra-positive
A conditional statement has two parts − Hypothesis and Conclusion.
Example of Conditional Statement − “If you do your homework, you will not be punished.”
Here, "you do your homework" is the hypothesis and "you will not be punished" is the
conclusion.
Inverse − An inverse of the conditional statement is the negation of both the hypothesis and the
conclusion. If the statement is “If p, then q”, the inverse will be “If not p, then not q”. The
inverse of “If you do your homework, you will not be punished” is “If you do not do your
homework, you will be punished.”
Converse − The converse of the conditional statement is computed by interchanging the
hypothesis and the conclusion. If the statement is “If p, then q”, the inverse will be “If q, then p”.
The converse of "If you do your homework, you will not be punished" is "If you will not be
punished, you do not do your homework”.
Contra-positive − The contra-positive of the conditional is computed by interchanging the
hypothesis and the conclusion of the inverse statement. If the statement is “If p, then q”, the
inverse will be “If not q, then not p”. The Contra-positive of "If you do your homework, you will
not be punished” is "If you will be punished, you do your homework”.
Duality Principle
Duality principle set states that for any true statement, the dual statement obtained by
interchanging unions into intersections (and vice versa) and interchanging Universal set into Null
Dept.of MCA,CREC Page 9
set (and vice versa) is also true. If dual of any statement is the statement itself, it is said self-dual
statement.
Example − The dual of (A ∩ B) ∪ C is (A ∪ B) ∩ C
NAND Connective
A NAND is a logic connective that gives a False output only if all its inputs are True, otherwise
it gives True output.
NOR Connective
A B ~ (A.B)
F F T
F T T
T F T
F F F
A B ~(A+B)
0 0 1
0 1 0
1 0 0
Dept.of MCA,CREC Page 10
NOR is a logic Connective that gives True output if both the inputs are False, otherwise it gives
low output.
XOR (Exclusive OR) connective
An EX-NOR is a logic connective that gives True output if the inputs are same, otherwise it
gives False output.
X-
NOR (Exclusive NOR)
1 1 0
A B A⊕B
0 0 0
0 1 1
1 0 1
1 1 0
A B A X-NOR B
0 0 1
0 1 0
Dept.of MCA,CREC Page 11
An EX-NOR is a logic connective that gives True output if the inputs are same, otherwise it
gives False output.
Boolean algebra is algebra of logic. It deals with variables that can have two discrete values, 0
(False) and 1 (True); and operations that have logical significance. The earliest method of
manipulating symbolic logic was invented by George Boole and subsequently came to be
known as Boolean Algebra.
Boolean algebra has now become an indispensable tool in computer science for its wide
applicability in switching theory, building basic electronic circuits and design of digital
computers.
Boolean Functions
A Boolean function is a special kind of mathematical function f: Xn → X of degree n, where X
= {0, 1} is a Boolean domain and n is a non-negative integer. It describes the way how to derive
Boolean output from Boolean inputs.
Example − Let, F(A, B) = A’B’. This is a function of degree 2 from the set of ordered pairs of
Boolean variables to the set {0, 1} where F(0, 0) = 1, F(0, 1) = 0, F(1, 0) = 0 and F(1, 1) = 0
Boolean Expressions
A Boolean expression always produces a Boolean value. A Boolean expression is composed of
a combination of the Boolean constants (True or False), Boolean variables and logical
connectives. Each Boolean expression represents a Boolean function.
Example − AB’C is a Boolean expression
Boolean Identities
Double Complement Law
~(~A) = A
1 0 0
1 1 1
Dept.of MCA,CREC Page 12
Complement Law
A + ~A = 1 (OR Form)
A · ~A = 0 (AND Form)
Idempotent Law
A + A = A (OR Form)
A · A = A (AND Form)
Identity Law
A + 0 = A (OR Form)
A · 1 = A (AND Form)
Dominance Law
A + 1 = 1 (OR Form)
A · 0 = 0 (AND Form)
Commutative Law
A + B = B + A (OR Form)
A· B = B · A (AND Form)
Associative Law
A + (B + C) = (A + B) + C (OR Form)
A· (B · C) = (A · B) · C (AND Form)
Absorption Law
A· (A + B) = A
A + (A · B) = A
Simplification Law
A · (~A + B) = A · B
Dept.of MCA,CREC Page 13
A + (~A · B) = A + B
A · B + A · C + ~B · C = A · B + ~B ·C
Distributive Law
A + (B · C) = (A + B) · (A + C)
A · (B + C) = (A · B) + (A · C)
De-Morgan's Law
~(A · B) = ~A + ~B
~(A+ B) = ~A · ~B
Canonical Forms
For a Boolean expression there are two kinds of canonical forms −
The sum of minterms (SOM) form
The product of maxterms (POM) form
A B C Minterm
0 0 0 m0
0 0 1 m1
0 1 0 m2
0 1 1 m3
1 0 0 m4
Dept.of MCA,CREC Page 14
The Sum of Minterms (SOM) or Sum of Products (SOP) form
A minterm is a product of all variables taken either in their direct or complemented form. Any
Boolean function can be expressed as a sum of its 1-minterms and the inverse of the function
can be expressed as a sum of its 0-minterms. Hence,
F (list of variables) = ∑ (list of 1-minterm indices)
And F’ (list of variables) = ∑ (list of 0-minterm indices)
Example
Let, F(x, y, z) = x’ y’ z’ + x y’ z + x y z’ + x y z
Or, F(x, y, z) = m0 + m5 + m6 + m7
Hence,
F(x, y, z) = ∑ (0, 5, 6, 7)
Now we will find the complement of F(x, y, z)
F’ (x, y, z) = x’ y z + x’ y’ z + x’ y z’ + x y’ z’
Or, F’(x, y, z) = m3 + m1 + m2 + m4
Hence,
F’(x, y, z) = ∑ (3, 1, 2, 4) = ∑ (1, 2, 3, 4)
The Product of Maxterms (POM) or Product of Sums (POS) form
1 0 1 m5
1 1 0 m6
1 1 1 m7
Dept.of MCA,CREC Page 15
A maxterm is addition of all variables taken either in their direct or complemented form. Any
Boolean function can be expressed as a product of its 0-maxterms and the inverse of the
function can be expressed as a product of its 1-maxterms. Hence,
F (list of variables) = π (list of 0-maxterm indices)
and
F’(list of variables) = π (list of 1-maxterm indices).
Example
Let, F(x, y, z) = (x+y+z) • (x+y+z’) • (x+y’+z) • (x’+y+z)
Or, F(x, y, z) = M0 • M1 • M2 • M4
A B C Maxterm
0 0 0 M0
0 0 1 M1
0 1 0 M2
0 1 1 M3
1 0 0 M4
1 0 1 M5
1 1 0 M6
1 1 1 M7
Dept.of MCA,CREC Page 16
Hence,
F (x, y, z) = π(0, 1, 2, 4)
F’'(x, y, z) = (x+y’+z’) • (x’+y+z’) • (x’+y’+z) • (x’+y’+z’)
Or, F(x, y, z) = M3 • M5 • M6 • M7
Hence,
F ' (x, y, z) = π(3, 5, 6, 7)
Normal Forms
Let A(P1, P2, P3, …, Pn) be a statement formula where P1, P2, P3, …, Pn are the atomic variables.
If A has truth value T for all possible assignments of the truth values to the variables P1, P2, P3,
…, Pn , then A is said to be a tautology. If A has truth value F, then A is said to be identically
false or a contradiction.
Disjunctive Normal Forms
A product of the variables and their negations in a formula is called an elementary product. A
sum of the variables and their negations is called an elementary sum. That is, a sum of
elementary products is called a disjunctive normal form of the given formula.
Example:
The disjunctive normal form of
1. P (P Q) P ( P Q) (P P) (P Q).
2. (P Q) (P Q) ( (P Q) (P Q)) ((P Q) (P Q))
( P Q P Q) (P P) (Q P) (P Q) (Q Q).
Conjunctive Normal Forms
A formula which is equivalent to a given formula and which consists of a product of elementary
sums is called a conjunctive normal form of a given formula.
Example 1:
Dept.of MCA,CREC Page 17
The conjunctive normal form of
(a) P (P Q) P ( P Q).
(b) (P Q) P Q.
(c) (P⇔Q) ((P Q) (Q P))
(( P Q) ( Q P))
( P Q) ( Q P)
(P Q) (Q P)
(P Q) (Q Q) (P P) ( P Q).
(d) (P Q) (P Q) ( (P Q) (P Q)) ((P Q) (P Q))
((P Q) (P Q)) ( (P Q) ( P Q)
(P Q P) (P Q Q) ( P Q P) ( P Q Q).
Example 2:
(a) Show that the formula B ( A B) (A B) is a tautology.
B ( A B) (A B) B (( A A) B)
( B A A) ( B B)
T T
T.
Therefore, it is a tautology.
(b) Show that the formula ( B A) B is a contradiction.
( B A) B A (B B)
A F
F.
Therefore, it is a contradiction.
(c) Show that (Q P) ( P Q) is a contradiction.
(Q P) ( P Q) ( Q P) ( P Q)
( P Q Q) (P P Q)
F F
F.
Therefore, it is a contradiction.
Principal Disjunctive Normal Form (PDNF)
Let us assume A and B be two statement variables. All possible formulas by using conjunction
are given as follows. The total number of formulas for two variables A and B are 22 formulas.
Dept.of MCA,CREC Page 18
They are A B, A B,
A B and A B.
These are called minterms or Boolean conjunctions of A and B. The minterms (2n terms) are
denoted by M0, M1, … ,M2n-1.
A formula equivalent to a given formula consisting of the disjunction of minterms only is
called PDNF of the given formula.
Example 1:
Obtain the PDNF of ( P Q) (P⇔ Q)
P Q P Q P ⇔Q ( P Q) (P⇔ Q)
T T F F T
T F T T T
F T T T T
F F T F F
From the above table
( P Q) (P⇔ Q) (P Q) (P Q) ( P Q)
( P Q) (P Q) (P Q)
Example 2:
Obtain the PDNF of
P Q P Q
T T T
T F F
F T T
F F T
P Q (P Q) ( P Q) ( P Q)
( P Q) ( P Q) (P Q)
Dept.of MCA,CREC Page 19
Procedure for obtaining PDNF
Step1 : Get rid of ⇔, .
Step2 : Use De Morgan’s law.
Step3 : Use distributive law.
Step4 : Introduce missing factor in the disjunction.
Step5 : If there is elementary product of the form.
(P P) ( ) …… , delete P P.
For every truth value T in the truth table of the given formula, select minterm which also has the
value T for the same combination of the truth values of P and Q. The disjunction of these
minterms will be equivalent to the given formula.
To find a particular minterm Mi, the subscript i is expressed in the binary representation and
suitable number of 0’s are added to the left.
Example :
Obtain PDNF for P ((P Q ( Q P))).
Solution:
P ((P Q ( Q P))) P ((P Q (P Q)))
P ((P P Q))
P ( P (P Q))
P ( P (P Q))
P (P Q)
( P (Q Q)) (P Q)
( P Q) ( P Q) (P Q)
( P Q) ( P Q) (P Q)
.
1.2.4 Principal Conjunctive Normal Forms (PCNF)
The duals of minterms are called maxterms. For a given number of variables the maxterm
consists of disjunctions in which each variable or its negation, but not both, appears only once.
For a given formula, an equivalent formula consisting of conjunctions of maxterms only is
known as its principal conjunctive normal form. This is also called the product of
sums canonical form.
Dept.of MCA,CREC Page 20
Example 1:
Obtain the PCNF of ( P R) (Q⇆P).
Solution:
( P R) (Q⇆P) (P R) ((Q P) (P Q))
(P R) (( Q P) ( P Q))
(P R (Q Q)) ((P Q (R R)) ( P Q (R R))
(P Q R) (P Q R) (P Q R) ( P Q R) ( P Q R)
S (0,2,3,4,5).
S consisting of missing maxterms
M1 M6 M7
(P Q R) ( P Q R) ( P Q R).
Example2:
Obtain PCNF for A : ( P R) ((Q P) (P Q)).
Solution:
A (P R) (( Q P) ( P Q))
(P R (Q Q)) (P Q (R R)) ( P Q (R R))
(P Q R) (P Q R) (P Q R) (P Q R) ( P Q R) ( P Q R)
(P Q R) (P Q R) (P Q R) ( P Q R) ( P Q R)
(0,2,3,4,5).
Example 3:
From the given truth table formula S, determine its PDNF and PCNF
Table 1.2.4
A B C S
T T T T
T T F F
T F T F
T F F F
Dept.of MCA,CREC Page 21
F T T F
F T F F
F F T F
F F F T
By choosing the minterms corresponding to each T value of S,
the PDNF of S .
By choosing the maxterms corresponding to each F value of S,
the PCNF of
S ( A B C) ( A B C) ( A B C) (A B C) (A B C)
(A B C) .
Example 4:
Form the given truth table formula S, determine its PDNF and PCNF
A B C S
T T T F
T T F F
T F T T
T F F F
F T T T
F T F T
F F T F
F F F T
By choosing minterms corresponding to each T value of S,
the PDNF of S (A B C) ( A B C) ( A B C) ( A B C).
Dept.of MCA,CREC Page 22
By choosing maxterms corresponding to each F value of S,
the PCNF of S ( A B C) ( A B C) ( A B C) (A B C)
(1,4,6,7).
Example 5:
Obtain the product of sums canonical form of the formula A which is given by
(P Q R) ( P Q R) ( P Q R)
Solution:
A ( P Q R) (P Q R) (P Q R)
(0,3,7).
( A) consisting of missing maxterms
(1,2,4,5,6)
(P Q R) (P Q R) ( P Q R) ( P Q R) ( P Q R) .
Example 6:
Obtain the product-of-sums canonical form of the formula A, which is given by
( P Q R S) (P Q R S) (P Q R S) ( P Q R S) (P Q
R S).
Solution:
A (P Q R S) ( P Q R S) ( P Q R S) (P Q R S)
( P Q R S)
(P Q R S) (P Q R S) ( P Q R S) ( P Q R S)
( P Q R S)
(5, 6, 9, 10, 12).
( A) consisting of missing maxterms
(0,1,2,3,4,7,8,11,13,14,15)
M0 M1 M2 M3 M4 M7 M8 M11 M13 M14 M15
(P Q R S) (P Q R S) (P Q R S) (P Q R S) (P Q
R S)
(P Q R S) ( P Q R S) ( P Q R S) ( P Q R S)
( P Q R S) ( P Q R S).
Dept.of MCA,CREC Page 23
Example 7:
Obtain the product of sums canonical form of (P Q) ( P Q) (P Q).
Solution:
A ( P Q) (P Q) ( P Q)
(P Q) ( P Q) ( P Q)
(1,2,3).
( A) consisting of missing maxterms
(0)
M0
P Q.
QUANTIFIERS
The variable of predicates is quantified by quantifiers. There are two types of quantifier in
predicate logic − Universal Quantifier and Existential Quantifier.
Universal Quantifier
Universal quantifier states that the statements within its scope are true for every value of the
specific variable. It is denoted by the symbol ∀.
∀x P(x) is read as for every value of x, P(x) is true.
Example − "Man is mortal" can be transformed into the propositional form ∀x P(x) where P(x)
is the predicate which denotes x is mortal and the universe of discourse is all men.
Existential Quantifier
Existential quantifier states that the statements within its scope are true for some values of the
specific variable. It is denoted by the symbol ∃.
∃x P(x) is read as for some values of x, P(x) is true.
Example − "Some people are dishonest" can be transformed into the propositional form ∃x P(x)
where P(x) is the predicate which denotes x is dishonest and the universe of discourse is some
people.
Nested Quantifiers
If we use a quantifier that appears within the scope of another quantifier, it is called nested
quantifier.
Example
∀a ∃b P (x, y) where P (a, b) denotes a + b = 0