Logic 2024
Logic 2024
• 2+2=5
• Every integer is divisible by 12
• Microsoft is an excellent company (Not Statement)
• 1+101=110 (Universe of Discourse)
Introduction: Proposition
• Definition: The value of a proposition is called its truth value
denoted by
– T or 1 if it is true or
– F or 0 if it is false
• Truth table
Logical connectives
• Connectives are used to create a compound
proposition from two or more propositions
– Negation (denote ¬ or !)
– And logical conjunction (denoted ∧)
– Or logical disjunction (denoted ∨)
– XOR or exclusive or (denoted ⊕)
– Implication (denoted ⇒ or →)
– Biconditional (denoted ⇔ or ↔)
• If sin x = 0, then x = 0
False. x can be a multiple of π. If we let x=2π, then sin x=0 but x≠0.
The implication “if sin x = 0, then x = kπ, for some k” is true.
Converse, Inverse, Contrapositive
• Consider the proposition p → q
– Its converse is q → p
– Its inverse is ¬p → ¬q
– Its contrapositive is ¬q → ¬p Truth Table
Logical Connective: Biconditional
• The bi conditional p↔q is
the proposition that is true
when p and q have the same Truth table
truth values. It is false
otherwise.
• Note that it is equivalent to
(p→q)∧(q→p)
Example:
Let p :“You can take the flight,”
let q :“You buy a ticket.”
Then p ↔ q is “You can take the flight
if and only if you buy a ticket.
Logical Connective: Biconditional (2)
• The biconditional p↔q can be equivalently read
as
– p if and only if q
– p is a necessary and sufficient condition for q
– if p then q, and conversely
– p iff q
• Examples
– x>0 if and only if x2 is positive
– The alarm goes off iff a burglar breaks in
– You may have pudding iff you eat your meat
Which of the following biconditionals is true?
• x2 ≥ 0 if and only if x ≥ 0
False. The implication “if x ≥ 0 then x2 ≥ 0” holds.
However, the implication “if x2 ≥ 0 then x ≥ 0” is false.
Consider x=-1.
The hypothesis (-1)2=1 ≥ 0 but the conclusion fails.
Truth Tables
• A logical statement having n component statements
will have 2n rows in its truth table.
• For n = 2, 22 = 4 rows
Distinct Truth Tables
A logical statement having n variables must have its truth
table one of the 22(raise to n) possible truth tables,
Each of which having 2n rows.
• Alphabet
A well-formed formula (wff) in propositional logic is:
(1) An atom is a wff
(2) If P is a wff, then ~P is a wff.
(3) If P and Q are wffs then P∧Q, P∨Q, P→Q, P↔Q are wffs.
(4) The set of all wffs can be generated by repeatedly applying rules
(1)..(3).
• A and B are
logically
equivalent as A
<-> B Tautology
Logical Equivalences: Example
•Show that (p → q ) ∨ (q→p) is a tautology using Truth table
Logical Equivalences: Example
1. (p ∨(~ (p ∧ q)) 2. (p ∧ q) ∧ ~ (p ∨ q)
Expressing Connectives :
Some connectives can be expressed through others
Using Logical Equivalences: Example
• Logical equivalences can be used to construct additional logical
equivalences
• Example:
• Show that (p ∧ q) →q is a tautology using truth table(h. w.)
• Show that (p ∧ q) →q is a tautology without using truth table
0. (p ∧ q) →q
1. ≡ ¬(p ∧ q) ∨ q Implication Law on 0
2. ≡ (¬p ∨ ¬q) ∨ q De Morgan’s Law (1st) on 1
3. ≡ ¬p ∨ (¬q ∨ q) Associative Law on 2
4. ≡ ¬p ∨ T Negation Law on 3
5. ≡ T Domination Law on 4
Using Logical Equivalences: Example
• Example : Show that ¬(p ↔ q) ≡ (p ↔ ¬q)
• Sometimes it helps to start with the second proposition (p ↔ ¬q)
0. (p ↔ ¬q)
1. ≡ (p → ¬q) ∧ (¬q → p) Equivalence Law on 0
2. ≡ (¬p ∨ ¬q) ∧ (q ∨ p) Implication Law on 1
3. ≡ ¬(¬((¬p ∨ ¬q) ∧ (q ∨ p))) Double negation on 2
4. ≡ ¬(¬(¬p ∨ ¬q) ∨ ¬(q ∨ p)) De Morgan’s Law…
5. ≡ ¬((p ∧ q) ∨ (¬q ∧ ¬p)) De Morgan’s Law
6. ≡ ¬((p ∨ ¬q) ∧ (p ∨ ¬p) ∧ (q ∨ ¬q) ∧ (q ∨ ¬p))
Distribution Law
7. ≡ ¬((p ∨ ¬q) ∧ (q ∨ ¬p)) Identity Law
8. ≡ ¬((q → p ) ∧ (p → q)) Implication Law
9. ≡ ¬(p ↔ q) Equivalence Law
Using Logical Equivalences: Example
• Show that ¬(q → p) ∨ (p ∧ q) ≡ q
0. ¬(q → p) ∨ (p ∧ q)
1. ≡ ¬(¬q ∨ p) ∨ (p ∧ q) Implication Law
2. ≡ (q ∧ ¬p) ∨ (p ∧ q) De Morgan’s Double negation
3. ≡ (q ∧ ¬p) ∨ (q ∧ p) Commutative Law
4. ≡ q ∧ (¬p ∨ p) Distributive Law
5. ≡ q ∧ T Identity Law
≡q Identity Law
Examples
[(p→q) ∧ ~q] → ~p prove that it is tautology.
Answer:
[(p→q) ∧ ~q] → ~p
≡ [(~p∨q) ∧ ~q] → ~p Implication Law
≡[(~p ∧ ~q) ∨ (q ∧ ~q)] → ~p Distributive Law
≡ [(~p ∧ ~q) ∨ F] → ~p
≡ [~(p ∨ q)] → ~p Identity Law
≡ ~[~(p ∨ q)] ∨ ~p
≡ (p ∨ q) ∨ ~p
≡ (p ∨ ~p) ∨ q
≡T∨q
≡T
A tautology.
Simplifying Statement Forms
• Associative laws:
• Distributive laws:
• Absorption laws:
Logical Equivalences Involving Conditional and
Biconditional Statements
Duality Law
The dual statement obtained by interchanging OR (unions)
into AND (intersections) (and vice versa), interchanging
T(Universal set) into F(Null set )(and vice versa) .
EXAMPLE:
A A* are known as duels of each other.
The dual of ¬p ∧ ¬ (q ∨ p ) is ¬p ∨ ¬ (q ∧ p )
1. (p v q) ^ r dual is (p ^ q) v r
2. (p ^ q) v T dual is (p v q) ^ F
3. ¬ (p v q) ^ (p v ¬ (q ^ ¬s )) dual is ¬ (p ^ q) v (p ^ ¬ (q v ¬s ))
Thus The negation of a formula is equivalent to its dual in which every
variable is replaced by its negation.
1. The dual of (p ^ q) is (p v q)
And ¬ (p ^ q) ≈ (¬p v ¬ q)
Functionally Complete Sets of Logic Gates
AND , OR, NOT are all that’s needed to express any combinational
logic function as a switching algebra expression
operators are all that were originally defined
Thus the set {AND, NOT}, {OR, NOT} is said to be functionally
complete.
Example: ~(~(P ^ Q) v R) ≡ P ^ Q ^ ~R
Conjunctive and disjunctive normal forms
• CNF: a sentence that is a conjunction of one or more disjunctions
of one or more literals (and-of-ors-of-literals)
F1∧… ∧ Fn, Fi , i=1,n (Li1 ∨ … ∨Lim).
Example: (~A v C v D) ^ (A v ~C v E) ^ W
Elementary Sum
A sum of the two statement variables and their negations is called Elementary Sum. The
possible elementary sums are
𝑃,𝑄, ¬𝑃 ∨ 𝑄, ¬𝑄 ∨ 𝑃, 𝑃 ∨ ¬𝑃 ∨ 𝑄,𝑃 ∨ 𝑄
It is necessary and sufficient condition for an elementary sum to be identically True
that contain at least one pair of factor in which one is negation of other.
● Minterms ● Maxterms
𝑃 ∧ 𝑄, ¬𝑃 ∧ 𝑄, 𝑃 ∧ ¬ 𝑄, ¬ 𝑃 ∧ ¬ 𝑄 𝑃 ∨ 𝑄, ¬𝑃 ∨ 𝑄, 𝑃 ∨ ¬ 𝑄, ¬ 𝑃 ∨ ¬ 𝑄
Method to construct DNF/ PDNF
Construct a truth table for the proposition.
Use the rows of the truth table where the proposition is True to
construct minterms
If the variable is true, use the propositional variable in the minterm
If a variable is false, use the negation of the variable in the minterm
Connect the minterms with ∨’s.
Or use laws.
1. PDNF of ¬(p ∨ q) ↔ p ∧ q
p q r (p ∨ q) ¬r (p ∨ q)→¬r
● From the truth table we can
T T T T F F set up the PDNF
T T F T T T ● There are five sets of input
T F T T F F that make the statement
T F F T T T true.
F T T T F F
● Therefore there are five
minterms.
F T F T T T
F F T F F T
F F F F T T
T T T F T T T
T T F F T T T
T F T F T F F
T F F F T F F
F T T T T F F
F T F T F F F
F F T T T T T
F F F T F T F
T T T F T T T F F
T T F F T T T T T
T F T F T F F F T
T F F F T F F T T
F T T T T F F F T
F T F T F F F T T
F F T T T T T F F
F F F T F T F T T
p q r p→q (p→q ) →r
T T T T T
T T F T F
T F T F T
T F F F T
F T T T T
F T F T F
F F T T T
F F F T F
p→q
⇔ (p∧q) ∨ (¬p∧ q) ∨ (¬p∧ ¬q). From PDNF
⇔ ¬[¬(p∧q) ∧ ¬(¬p∧ q) ∧ ¬(¬p∧ ¬q)] NNF & DeMorgan
⇔¬[(¬p∨¬q) ∧ (¬¬p∨¬q) ∧ (¬¬p ∨ ¬¬q)] DeMorgan
⇔¬[(¬p∨¬q) ∧ (p∨¬q) ∧ (p∨q)] Doub. Neg.
⇔[¬(¬p∨¬q) ∨ ¬(p∨¬q) ∨ ¬(p∨q)] DeMorgan
Double Implication Law
Implication Law CNF
PDNF :
(¬p∧¬q∧ r) ∨
(p∧¬q∧¬r) ∨
(p∧q∧r)
PCNF :
(p ∨ q ∨ r) ∧
(p ∨ ¬ q ∨ r) ∧
(p ∨ ¬q ∨¬ r) ∧
(¬ p ∨ q ∨ r) ∧
(¬ p ∨ q ∨¬ r)
Distributive Laws, Normal Forms
• p∧(q∨r) ≡ (p∧q)∨(p∧r)
• p∨(q∧r) ≡ (p∨q)∧(p∨r)
• By applying these transformations, every formula
can be put in either
– Conjunctive normal form (and-of-ors-of-literals), or
– Disjunctive normal form (or-of-ands-of-literals)
• ¬p∨ (¬q∧¬r) is in DNF
• (¬p∨¬q)∧(¬p∨¬r) is an equivalent CNF
Quantifiers
Universe of Discourse, U: The domain of a variable in
a propositional function.
Universal Quantification ∀xP(x) of P(x) is the
proposition:“P(x) is true for all values of x in U.”
Example:
Let P(x) denote x2 ≥ x
If U is x such that 0 < x ≤ 1 then ∃xP(x) is true.
If U is x such that x < 1 then ∃xP(x) is true.
Example:
Example: Suppose P(x) indicates a predicate where "x is a
square" and Q(x) also indicates a predicate where "x is a
rectangle". Now we will find the universal quantifier of these
predicates.
Solution:
The statement must be:
∀x (x is a square ⇒ x is a rectangle), i.e., "all squares are
rectangles.'' The following syntax is used to describe this
statement:
∀xP(x) ⇒Q(x)
Negation (it is not the case)
¬∃xP(x) equivalent to ∀x¬P(x)
•True when P(x) is false for every x
•False if there is an x for which P(x) is true.
∃x∃yP(x,y) or ∃y∃xP(x,y)
True if there is a pair x,y for which P(x,y) is true.
False if P(x,y) is false for every pair x,y.
Quantification of Two Variables
∀x∃yP(x,y)
•True when for every x there is a y for which P(x,y) is true.
(in this case y can depend on x)
•False if there is an x such that P(x,y) is false for every y.
∃y∀xP(x,y)
•True if there is a y for which P(x,y) is true for every x.
(i.e., true for a particular y regardless (or independent) of x)
•False if for every y there is an x for which P(x,y) is false.
Let P (x), Q(x), and R(x) be the statements “x is a lion,” “x is fierce,” and “x drinks
coffee,” respectively.
Assuming that the domain consists of all creatures, express the statements in the
argument using quantifiers and P (x), Q(x), and R(x).
Horse(Harry)
Rabbit(Ralph)
∀y Greyhound(y) ⇒ Dog(y)
∀x ∀y ∀z Faster(x,y) ∧ Faster(y,z) ⇒ Faster(x,z)
TUTORIAL
• Which of these sentences are propositions? What are the truth values of those that are
propositions?
a) Boston is the capital of Massachusetts.
b) Miami is the capital of Florida.
c) 2 + 3 = 5. d) 5 + 7 = 10.
e) x + 2 = 11.
f) Answer this question.
• Let p and q be the propositions
p : It is below freezing.
q : It is snowing.
Write these propositions using p and q and logical connectives.
a) It is below freezing and snowing.
b) It is below freezing but not snowing.
c) It is not below freezing and it is not snowing.
d) It is either snowing or below freezing (or both).
e) If it is below freezing, it is also snowing.
I) It is either below freezing or it is snowing, but it is not snowing if it is below
freezing.
g) That it is below freezing is necessary and sufficient for it to be snowing.
TUTORIAL
• Let p, q, and r be the propositions
p : Grizzly bears have been seen in the area.
q : Hiking is safe on the trail.
r : Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives.
a) Berries are ripe along the trail, but grizzly bears have
not been seen in the area.
b) Grizzly bears have not been seen in the area and hiking
on the trail is safe, but berries are ripe along the trail.
c) If berries are ripe along the trail, hiking is safe if and
only if grizzly bears have not been seen in the area.
d) It is not safe to hike on the trail, but grizzly bears have
not been seen in the area and the berries along the trail are ripe.
• Use existential and universal quantifiers to express the statement "Everyone
has exactly two biological parents“ using the propositional function P(x, y),
which represents "x is the biological parent of y."
• Express this statement using quantifiers: "Every student in this class has taken
some course in every department in the school of mathematical sciences."
TUTORIAL