UNIT 1mathematical Logic
UNIT 1mathematical Logic
ON
MATHEMATICAL FOUNDATION OF
COMPUTER SCIENCE
(20BSX16)
II B. Tech I semester
(Common to CSE ,CSE(AI&ML),CSE (DS))
2021-22
M.G.VARA PRASAD
DEPARTMENT OF MATHEMATICS
Connectives
The words or phrases or symbols which are used to make a proposition by two or more
propositions are called logical connectives or simply connectives. There are five basic
connectives called negation, conjunction, disjunction, conditional and biconditional.
Negation
The negation of a statement is generally formed by writing the word ‘not’ at a proper
place in the statement (proposition) or by prefixing the statement with the phrase ‘It is not the
case that’. If p denotes a statement then the negation of p is written as p and read as ‘not p’. If the
truth value of p is T then the truth value of p is F. Also if the truth value of p is F then the truth
value of p is T. It is denoted by the symbol ¬ or ~.
Example 2: Consider the statement p: Kolkata is a city. Then ¬p: Kolkata is not a city.
Although the two statements ‘Kolkata is not a city’ and ‘It is not the case that Kolkata is a
city’ are not identical, we have translated both of them by p. The reason is that both these
statements have the same meaning.
p q p∧q
T T T
T F F
F T F
F F F
Note: Usually, in our everyday language the conjunction ‘and’ is used between two statements
which have some kind of relation. Thus a statement ‘It is raining today and 1 + 1 = 2’ sounds
odd, but in logic it is a perfectly acceptable statement formed from the statements ‘It is raining
today’ and ‘1 + 1 = 2’.
Disjunction
The disjunction of two statements p and q is the statement p ∨ q which is read as ‘p or q’.
The statement p ∨ q has the truth value F only when both p and q have the truth value F.
Otherwise it has truth value T.
p q p∨q
T T T
T F T
F T T
F F F
T T T
T F F
F T T
F F T
(i) You will get a speeding ticket if you drive over 70 km per hour.
(ii) Driving over 70 km per hour is sufficient for getting a speeding ticket.
(iii) If you do not drive over 70 km per hour then you will not get a speeding ticket.
(iv) Whenever you get a speeding ticket, you drive over 70 km per hour.
Solution: (i) p → q
(ii) p → q
(iii) ¬ p → ¬ q
(iv) q → p.
P Q ¬Q ¬P ¬Q → ¬P
T T F F T
T F T F F
F T F T T
F F T T T
Biconditional proposition
If p and q are any two statements (propositions), then the statement p↔ q which is read as ‘p if
and only if q’ and abbreviated as ‘p iff q’ is called a biconditional statement and the connective
is the biconditional connective.
It may be noted that p q is true only when both p and q are true or when both p and q are
false. Observe that p q is true when both the conditionals p → q and q → p are true, i.e., the
truth-values of (p → q) ∧ (q → p), given in Ex. 9, are identical to the truth-values of p q defined
here.
Tautology: A statement formula which is true regardless of the truth values of the statements
which replace the variables in it is called a universally valid formula or a logical truth or a
tautology.
Contradiction: A statement formula which is false regardless of the truth values of the
statements which replace the variables in it is said to be a contradiction.
Method I. Truth Table Method: One method to determine whether any two statement
formulas are equivalent is to construct their truth tables.
**Example: Show ((P ∨ Q) ∧ ¬(¬P ∧ (¬Q ∨ ¬R))) ∨ (¬P ∧ ¬Q) ∨ (¬P ∧ ¬R) is
tautology.
Solution: By De Morgan’s laws, we have
¬P ∧ ¬Q ⇔ ¬(P ∨ Q)
¬P ∨ ¬R ⇔ ¬(P ∧ R)
Therefore
(¬P ∧ ¬Q) ∨ (¬P ∧ ¬R) ⇔ ¬(P ∨ Q) ∨ ¬(P ∧ R)
⇔ ¬((P ∨ Q) ∧ (P ∨ R))
Also
¬(¬P ∧ (¬Q ∨ ¬R)) ⇔ ¬(¬P ∧ ¬(Q ∧ R))
⇔ P ∨ (Q ∧ R)
⇔ (P ∨ Q) ∧ (P ∨ R)
Hence ((P ∨ Q) ∧ ¬(¬P ∧ (¬Q ∨ ¬R))) ⇔ (P ∨ Q) ∧ (P ∨ Q) ∧ (P ∨ R)
⇔ (P ∨ Q) ∧ (P ∨ R)
Duality Law
Two formulas A and A∗ are said to be duals of each other if either one can be obtained from the
other by replacing ∧ by ∨ and ∨ by ∧. The connectives ∨ and ∧ are called duals of each other. If
the formula A contains the special variable T or F , then A∗, its dual is obtained by replacing T by
F and F by T in addition to the above mentioned interchanges.
Tautological Implications
A statement formula A is said to tautologically imply a statement B if and only
if A → B is a tautology.
In this case we write A ⇒ B, which is read as ’A implies B’.
Note: ⇒ is not a connective, A ⇒ B is not a statement formula.
A ⇒ B states that A → B is tautology.
Clearly A ⇒ B guarantees that B has a truth value T whenever A has the truth value T .
One can determine whether A ⇒ B by constructing the truth tables of A and B in the same
manner as was done in the determination of A ⇔ B.
P Q ¬P ¬Q P→Q ¬Q → ¬P (P → Q) → (¬Q → ¬P )
T T F F T T T
T F F T F F T
F T T F T T T
F F T T T T T
Since all the entries in the last column are true, (P → Q) → (¬Q → ¬P ) is a tautology.
Hence (P → Q) ⇒ (¬Q → ¬P ).
In order to show any of the given implications, it is sufficient to show that an assignment
of the truth value T to the antecedent of the corresponding conditional leads to the truth value T
for the consequent. This procedure guarantees that the conditional becomes tautology, thereby
proving the implication.
Normal Forms
If a given statement formula A(p1, p2, ...pn) involves n atomic variables, we have 2n possible
combinations of truth values of statements replacing the variables.
The formula A is a tautology if A has the truth value T for all possible assignments of the
truth values to the variables p1, p2, ...pn and A is called a contradiction if A has the truth value F
for all possible assignments of the truth values of the n variables. A is said to be satis able if A
has the truth value T for atleast one combination of truth values assigned to p1, p2, ...pn.
The problem of determining whether a given statement formula is a Tautology, or a
Contradiction is called a decision problem.
The construction of truth table involves a finite number of steps, but the construc-tion may
not be practical. We therefore reduce the given statement formula to normal form and find
whether a given statement formula is a Tautology or Contradiction or atleast satisfiable.
It will be convenient to use the word ”product” in place of ”conjunction” and ”sum” in place
of ”disjunction” in our current discussion.
A product of the variables and their negations in a formula is called an elementary product.
Similarly, a sum of the variables and their negations in a formula is called an elementary sum.
Let P and Q be any atomic variables. Then P , ¬P ∧Q, ¬Q∧P ¬P , P ¬P , and Q ∧ ¬P are
some examples of elementary products. On the other hand, P , ¬P ∨ Q, ¬Q ∨ P ∨ ¬P , P ∨ ¬P ,
and Q ∨ ¬P are some examples of elementary sums.
Any part of an elementary sum or product which is itself an elementary sum or
product is called a factor of the original elementary sum or product. Thus ¬Q,∧ ¬P , and ¬Q ∧ P
are some of the factors of ¬Q ∧ P ∧ ¬P .
A formula which is equivalent to a given formula and which consists of a sum of elementary
products is called a disjunctive normal form of the given formula.
(i) no two minterms are equivalent (ii). Each minterm has the truth value T for exactly
one combination of the truth values of the variables P and Q.
T T T P∧Q
T F F P ∧ ¬Q
F T T ¬P ∧ Q
F F T ¬P ∧ ¬Q
The PDNF of P → Q is (P ∧ Q) ∨ (¬P ∧ Q) ∨ (¬P ∧ ¬Q).
∴ P → Q ⇔ (P ∧ Q) ∨ (¬P ∧ Q) ∨ (¬P ∧ ¬Q).
T T T P∧Q∧R T F T T
T T F P ∧ Q ∧ ¬R T F F T
T F T P ∧ ¬Q ∧ R F F F F
T F F P ∧ ¬Q ∧ ¬R F F F F
F T T ¬P ∧ Q ∧ R F T T T
F T F ¬P ∧ Q ∧ ¬R F F F F
F F T ¬P ∧ ¬Q ∧ R F T F T
F F F ¬P ∧ ¬Q ∧ ¬R F F F F
In order to obtain the principal disjunctive normal form of a given formula is con-
structed as follows:
(1). First replace →, by their equivalent formula containing only ∧, ∨ and ¬.
(2). Next, negations are applied to the variables by De Morgan’s laws followed by the
application of distributive laws.
(3). Any elementarily product which is a contradiction is dropped. Minterms are ob-tained
in the disjunctions by introducing the missing factors. Identical minterms appearing in the
disjunctions are deleted.
P ∨ (P ∧ Q) ⇔ P
P ∨ (¬P ∧ Q) ⇔ P ∨ Q
Example: Write the principal disjunctive normal form of each formula and com-pare these
normal forms.
Now,
P ∨ Q ⇔ (P ∧ T ) ∨ (Q ∧ T )
⇔ (P ∧ (Q ∨ ¬Q)) ∨ (Q ∧ (P ∨ ¬P ))
⇔ (P ∧ Q) ∨ (P ∧ ¬Q) ∨ (Q ∧ P ) ∨ (Q ∧ ¬P )
⇔ (P ∧ Q) ∨ (P ∧ ¬Q) ∨ (¬P ∧ Q)
which is the required PDNF.
Hence, P ∨ (¬P ∧ Q) ⇔ P ∨ Q.
→ ((P → Q) ∧ ¬(¬Q ∨ ¬P )) ⇔
¬P ∨ ((¬P ∨ Q) ∧ (Q ∧ P ))
⇔ ¬P ∨ ((¬P ∧ Q ∧ P ) ∨ (Q ∧ Q ∧ P ))
⇔ ¬P ∨ F ∨ (P ∧ Q)
⇔ ¬P ∨ (P ∧ Q)
⇔ (¬P ∧ T ) ∨ (P ∧ Q)
⇔ (¬P ∧ (Q ∨ ¬Q)) ∨ (P ∧ Q)
For a given formula, an equivalent formula consisting of conjunctions of the max-terms only is
known as its principle conjunctive normal form. This normal form is also called the product-of-
sums canonical form.The method for obtaining the PCNF for a given formula is similar to the
one described previously for PDNF.
Example: Obtain the principal conjunctive normal form of the formula (¬P→R)∧(Q↔P)
Solution:
(¬P → R) ∧ (Q ↔ P )
⇔ [¬(¬P ) ∨ R] ∧ [(Q → P ) ∧ (P → Q)]
⇔ (P ∨ R) ∧ [(¬Q ∨ P ) ∧ (¬P ∨ Q)]
⇔ (P ∨ R ∨ F ) ∧ [(¬Q ∨ P ∨ F ) ∧ (¬P ∨ Q ∨ F )]
⇔ [(P ∨ R) ∨ (Q ∧ ¬Q)] ∧ [¬Q ∨ P ) ∨ (R ∧ ¬R)] ∧ [(¬P ∨ Q) ∨ (R ∧ ¬R)]
⇔ (P ∨ R ∨ Q) ∧ (P ∨ R ∨ ¬Q) ∧ (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)
which is required principal conjunctive normal form.
Note: If the principal disjunctive (conjunctive) normal form of a given formula A containing n
variables is known, then the principal disjunctive (conjunctive) normal form of ¬A will consist
of the disjunction (conjunction) of the remaining minterms (maxterms) which do not appear in
the principal disjunctive (conjunctive) normal form of A. From A ⇔ ¬¬A one can obtain the
principal conjunctive (disjunctive) normal form of A by repeated applications of De Morgan’s
laws to the principal disjunctive (conjunctive) normal form of ¬A.
Definition: If a conclusion is derived from a set of premises by using the accepted rules of
reasoning, then such a process of derivation is called a deduction or a formal proof and the
argument is called a valid argument or conclusion is called a valid conclusion.
Definition: Let A and B be two statement formulas. We say that ”B logically follows from A”
or ”B is a valid conclusion of the premise A” iff A → B is a tautology, that is A ⇒ B.
We say that from a set of premises {H1, H2, · · · , Hm}, a conclusion C follows logically iff
H1 ∧ H2 ∧ ... ∧ Hm ⇒ C-----(1)
Note: To determine whether the conclusion logically follows from the given premises, we use
the following methods:
1. Truth table method
2. Without constructing truth table method.
Example: Determine whether the conclusion C follows logically from the premises
H1 and H2.
(a) H1 : P → Q H2 : P C : Q
(b) H1 : P → Q H2 : ¬P C : Q
(c) H1 : P → Q H2 : ¬(P ∧ Q) C : ¬P
(d) H1 : ¬P H2 : P Q C : ¬(P ∧ Q)
(e) H1 : P → Q H2 : Q C : P
Solution: We first construct the appropriate truth table, as shown in table.
P Q P→Q ¬P ¬(P ∧ Q) P Q
T T T F F T
T F F F T F
F T T T T F
F F T T T T
(a) We observe that the first row is the only row in which both the premises have the value T .
The conclusion also has the value T in that row. Hence it is valid.
In (b) the third and fourth rows, the conclusion Q is true only in the third row, but not in the
fourth, and hence the conclusion is not valid.
Similarly, we can show that the conclusions are valid in (c) and (d) but not in (e).
Example: Show that R∨S follows logically from the premises C∨D, (C ∨D) → ¬H, ¬H → (A ∧
¬B), and (A ∧ ¬B) → (R ∨ S).
Solution:
{1} (1) (C ∨ D) → ¬H Rule P
{2} (2) ¬H → (A ∧ ¬B) Rule P
{1, 2} (3) (C ∨ D) → (A ∧ ¬B) Rule T, (1), (2), and I13
{4} (4) (A ∧ ¬B) → (R ∨ S) Rule P
{1, 2, 4} (5) (C ∨ D) → (R ∨ S) Rule T, (3), (4), and I13
{6} (6) C ∨ D Rule P
{1, 2, 4, 6} (7) R ∨ S Rule T, (5), (6), and I11
Hence the result.
(P ∧ R) → S ⇔ P → (R → S)
Let P denote the conjunction of the set of premises and let R be any formula. The above
equivalence states that if R is included as an additional premise and S is derived from P ∧ R, then
R → S can be derived from the premises P alone.
Rule CP is also called the deduction theorem and is generally used if the conclu-sion of
the form R → S. In such cases, R is taken as an additional premise and S is derived from the
given premises and R.
Example: ‘If there was a ball game, then traveling was difficult. If they arrived on time, then
traveling was not difficult. They arrived on time. Therefore, there was no ball game’. Show that
these statements constitute a valid argument. Solution: Let us indicate the statements as follows:
P : There was a ball game.
Q: Traveling was difficult.
R: They arrived on time.
Hence, the given premises are P → Q, R → ¬Q, and R. The conclusion is ¬P .
{1} (1) R → ¬Q Rule P
{2} (2) R Rule P
{1, 2} (3) ¬Q Rule T, (1), (2), and I11
{4} (4) P → Q Rule P
{4} (5) ¬Q → ¬P Rule T, (4), and P → Q ⇔ ¬Q → ¬P
{1, 2, 4} (6) ¬P Rule T, (3), (5), and I11
Example: Determine the validity of the following arguments using propositional logic:
”Smoking is healthy. If smoking is healthy, then cigarettes are prescribed by physicians.
Therefore, cigarettes are prescribed by physicians”.
Solution: Let us indicate the statements as follows:
P : Smoking is healthy.
Q: Cigarettes are prescribed by physicians.
Hence, the given premises are P , P → Q. The conclusion is Q.
Thus, the given set of premises leads to a contradiction and hence it is inconsistent.
Quantifiers
Quantifiers are words that are refer to quantities such as ’some’ or ’all’.
Universal Quantifier: The phrase ’forall’ (denoted by ∀) is called the universal quantifier.
For example, consider the sentence ”All human beings are mortal”.
Let P (x) denote ’x is a mortal’.
Then, the above sentence can be written as
(∀x ∈ S)P (x) or ∀xP (x)
where S denote the set of all human beings.
∀x represents each of the following phrases, since they have essentially the same for all x
For every x
For each x.
Existential Quantifier: The phrase ’there exists’ (denoted by ∃) is called the exis-tential
quantifier.
For example, consider the sentence
”There exists x such that x2 = 5.
This sentence can be written as
(∃x ∈ R)P (x) or (∃x)P (x),where P (x) : x2 = 5.
∃x represents each of the following phrases
There exists an x
There is an x
For some x
There is at least one x.
Example: Let P (x) denote the statement ”x is a professional athlete” and let Q(x) denote the
statement ”x plays soccer”. The domain is the set of all people.
(a). Write each of the following proposition in English.
(x)(P (x) → Q(x)
(∃x)(P (x) ∧ Q(x))
(x)(P (x) ∨ Q(x))
(b). Write the negation of each of the above propositions, both in symbols and in words.
Solution:
(a). (i). For all x, if x is an professional athlete then x plays soccer.
”All professional athletes plays soccer” or ”Every professional athlete plays
soccer”.
(ii). There exists an x such that x is a professional athlete and x plays soccer.
”Some professional athletes paly soccer”.
(iii). For all x, x is a professional athlete or x plays soccer.
”Every person is either professional athlete or plays soccer”.
Example: Establish the validity of the following argument:”All integers are ratio-nal numbers.
Some integers are powers of 2. Therefore, some rational numbers are powers of 2”.
Solution: Let P (x) : x is an integer
R(x) : x is rational number
S(x) : x is a power of 2
Hence, the given statements becomes (x)(P (x) → R(x)), (∃x)(P (x) ∧ S(x)) ⇒ (∃x)(R(x) ∧ S(x))
Solution:
Example: Show that from (∃x)[F (x) ∧S(x)] → (y)[M(y) → W (y)] and (∃y)[M(y) ∧ ¬W (y)] the
conclusion (x)[F (x) → ¬S(x)] follows.
Example: Using predicate logic, prove the validity of the following argument: ”Every husband
argues with his wife. x is a husband. Therefore, x argues with his wife”.