Ch1 The Foundations of Logic Part1
Ch1 The Foundations of Logic Part1
(HUE)
Faculty of Artificial
Intelligence and Information
CS 104 Discrete Structure
Level 1
The Foundations: Logic and Proofs
Text Book:
Kenneth H. Rosen, “Discrete mathematics and its
applications”, 8th_ed (2019)
Chapter1 The Foundations: Logic and Proofs
Topics
Logic
Proposition logic
1.1 - Propositional Logic
What is logic?
The branch of philosophy concerned with
analysing the patterns of reasoning by
which a conclusion is drawn from a set of
premises, without reference to meaning or
context
(Collins English Dictionary)
Digital Logic
Propositional logic
• Simple types of statements, called
propositions, are treated as atomic
building blocks for more complex
statements
1) Alexandria is a port or a holiday resort.
2) Alexandria is not a port.
Therefore, Alexandria is a holiday resort
Basic connectives and truth tables
2+3=5.
not statements:
What a beautiful morning!
Get up and do your exercises.
Proposition
A proposition is a declarative sentence
(that is, a sentence that declares a fact) that
is either true or false, but not both.
Examples: 2 + 2 = 4 True
3 x 3 = 8 False
787009911 is a prime
Today is Tuesday.
Non- x+y>0
examples:
x2+y2=z2
They are true for some values of x and y
but are false for some other values of x and y.
Proposition
• Symbol: T T T
T F F
p = “Today is Friday “
F T F
q = “today is my birthday“
F F F
• pq = “Today is Friday and
today is my birthday”
Logical operators: OR
• Symbol:
p = “Today is Friday “
q = “today is my birthday“
Logical operators: Conditional
p q pq
T T T
T F F
F T T
F F T
Logical operators: Conditional
• A conditional means “if p then q”
• Symbol:
• pq = “If today is
Friday, then today p q pq
is my birthday” T T T
T F F
F T T
F F T
• p→q=¬pq
Logical operators: Bi-conditional
EXAMPLE
p = “You can take the flight,”
q = “You buy a ticket.”
Then p ↔ q is the statement
Solution
“You can take the flight if and only if you buy a ticket.”
Boolean operators summary
not not and or xor conditional Bi-conditional
T T F F T T F T T
T F F T F T T F F
F T T F F T T T F
F F T T F F F T T
pq
• It is below freezing and it is snowing p¬q
• It is below freezing but not snowing ¬p¬q
• It is not below freezing and it is not snowing pq
• It is either snowing or below freezing (or both) p→q
• ((pq)¬(pq))(p→
If it is below freezing, (then) it is also snowing
• It is either below freezing or it is snowing, ¬q)
but it is not snowing if it is below freezing
• That it is below freezing is necessary and p↔q
sufficient for it to be snowing
Exercises
Which of these sentences are propositions? What
are the truth values of those that are
propositions?
a) Boston is the capital of Massachusetts. Yes, T
b) Miami is the capital of Florida. Yes, F
c) 2 + 3 = 5. Yes, T
d) 5 + 7 = 10. Yes, F
e) x + 2 = 11. No
f ) Answer this question. No
01/27/25
Exercises
What is the negation of each of these
propositions?
a) Linda is younger than Sanjay.
Linda is not younger than Sanjay
01/27/25
Exercises
Construct a truth table for each of these
compound propositions.
a)
b)
c)
01/27/25
Exercises
Construct a truth table for each of these
compound propositions.
d)
e)
01/27/25
Exercises
Construct a truth table for each of these
compound propositions.
f) (p → q) → (q → p)
01/27/25
Exercises
Construct a truth table for each of these compound
a) (p ∨ q) → (p ⊕ q) b) (p ⊕ q) → (p ∧ q)
propositions.
b) (p ∨ q) ⊕ (p ∧ q) d) (p ↔ q) ⊕ (.p ↔ q)
c ) (p ⊕ q) → (p ⊕ .q)
01/27/25
Exercises
Construct a truth table for each of these compound
propositions.
01/27/25
Exercises
Construct a truth table for each of these compound
propositions. a)
b)
c) (p → q) ∨
d) (p → q) ∧
e) (p ↔ q) ∨
f) ↔ (p ↔ q)
01/27/25
Exercises
Construct a truth table
for (p ↔ q) ↔ (r ↔ s).
01/27/25
1.2 Applications of Propositional
Logic Logic Circuits
A logic circuit (or digital circuit) receives input
signals p , p ,…, p , each a bit [either 0 (off) or 1
1 2 n
a bit.
Propositional logic can be applied to the design of
computer hardware
Complicated digital circuits can be constructed from three
basic circuits, called gates,
1.2 Applications of Propositional
Logic
Example
Determine the output for the combinatorial circuit
in Figure
1.2 Applications of Propositional
Logic
Answer
1.2 Applications of Propositional
Example Logic
Build a digital circuit that produces the output
Answer
1.2 Applications of Propositional
Logic
Find the output of each of these combinatorial
circuits
1.2 Applications of Propositional
Logic
Find the output of each of these combinatorial
circuits
1.2 Applications of Propositional
Logic
Construct a combinatorial circuit using inverters, OR gates,
and AND gates that produces the output
from input bits p, q, and r.
1.3 Propositional Equivalences
A compound proposition that is always true, no
matter what the truth values of the propositional
variables that occur in it, is called a tautology.
A compound proposition that is always false is called
a contradiction.
A compound proposition that is neither a tautology
nor a contradiction is called a contingency.
1.3 Propositional Equivalences
example of tautologies
example of contradiction
1.3 Propositional Equivalences
Logical Equivalence
The compound propositions p and q are called
logically equivalent if p ↔ q is a tautology.
The notation p ≡ q denotes that p and q are logically
equivalent.
The symbol ⇔ is sometimes used instead of ≡ to denote
logical equivalence.
1.3 Propositional Equivalences
Logical Equivalence
p q p p q p q
0 0 1 1 1
0 1 1 1 1
1 0 0 0 0
1 1 0 1 1
s1 s2
1.3 Propositional Equivalences
Logical Equivalence
De Morgan laws
1.3 Propositional Equivalences
Logical Equivalence
De Morgan laws
1.3 Propositional Equivalences
p → q and
• Identity laws
Like adding 0
• Domination laws
Like multiplying by 0
• Idempotent laws
Delete redundancies
• Double negation
“I don’t like you, not”
• Commutativity
Like “x+y = y+x”
• Associativity
Like “(x+y)+z = y+(x+z)”
• Distributivity
L3 Like “(x+y)z = xz+yz” 57
• De Morgan
Tables of Logical Equivalences
• Excluded middle
• Negating creates opposite
• Definition of implication in
terms of Not and Or
1.3 Propositional Equivalences
1.3 Propositional Equivalences
1.3 Propositional Equivalences
p ( p q) : tautology
p ( p q) : contradiction
Propositional Logic - 2 more
defn…
A tautology is a proposition that’s always TRUE.
p p p p p p
T F T F
F T T F
Tautology example
Demonstrate that
[¬p (p q )]q
is a tautology in two ways:
1. Using a truth table – show that
[¬p (p q )]q is always true
2. Using a proof (will get to this later).
64
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T
T F
F T
F F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F
T F F
F T T
F F T
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F T
T F F T
F T T T
F F T F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F T F
T F F T F
F T T T T
F F T F F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]q
T T F T F T
T F F T F T
F T T T T T
F F T F F T
Tautologies, contradictions
and programming
The dual of p q is ( p q ) d p q
The Principle of Duality
each occurrence of p by r s
The converse of a logical implication is the reversal of the implication. I.e. the converse of p q is q p.
73
Converse
p q p q q p (p q) (q p)
Converse
p q p q q p (p q) (q p)
T T
T F
F T
F F
Logical Non-Equivalence of
Conditional and Converse
p q p q q p (p q) (q p)
T T T
T F F
F T T
F F T
Logical Non-Equivalence of
Conditional and Converse
p q p q q p (p q) (q p)
T T T T
T F F T
F T T F
F F T T
Logical Non-Equivalence of
Conditional and Converse
p q p q q p (p q) (q p)
T T T T T
T F F T F
F T T F F
F F T T T
Fundamentals of Logic
L3 82
Derivational Proof Techniques
A: Part of it is a tautology (p p ) and
the disjunction of True with any other
compound proposition is still True:
(p p ) ((sr)t )) (qr )
T ((sr)t )) (qr )
T
Derivational techniques formalize the
intuition of this example.
L3 83
Propositional Logic - an
infamous
if NOT (blue AND NOT red) OR red then…
(p q) q p q
L3 85
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
L3 86
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
L3 87
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
L3 88
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
¬ [¬p q ] q ULE
L3 89
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
¬ [¬p q ] q ULE
[¬(¬p) ¬q ] q DeMorgan
L3 90
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
¬ [¬p q ] q ULE
[¬(¬p) ¬q ] q DeMorgan
[p ¬q ] q Double Negation
L3 91
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
¬ [¬p q ] q ULE
[¬(¬p) ¬q ] q DeMorgan
[p ¬q ] q Double Negation
p [¬q q ] Associative
L3 92
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
¬ [¬p q ] q ULE
[¬(¬p) ¬q ] q DeMorgan
[p ¬q ] q Double Negation
p [¬q q ] Associative
p [q ¬q ] Commutative
L3 93
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
¬ [¬p q ] q ULE
[¬(¬p) ¬q ] q DeMorgan
[p ¬q ] q Double Negation
p [¬q q ] Associative
p [q ¬q ] Commutative
pT ULE
L3 94
Tautology by proof
[¬p (p q )]q
[(¬p p)(¬p q)]q Distributive
[ F (¬p q)]q ULE
[¬p q ]q Identity
¬ [¬p q ] q ULE
[¬(¬p) ¬q ] q DeMorgan
[p ¬q ] q Double Negation
p [¬q q ] Associative
p [q ¬q ] Commutative
pT ULE
T Domination
L3 95
Writing Logical Formula for a Truth Table
Digital logic:
1. (p q) (q p).
2. (p q) (q ¬p).
3. p ¬p.
4. (p ¬q) (q ¬p).
Use truth table to find
• ¬P Q P R
• P -Q R P R - Q
• A B -C D E F
• (P ↔ Q) (P˅ Q)
• [P ˄ (P Q)] Q
Which of the following equivalent
to ¬ (P˄Q)
• (¬p) ˄ (¬Q)
• P˅Q
• (¬P) ˄ Q
• (¬P) ˅ (¬Q)
Exercises
Use truth tables to verify these equivalences.
a) p ∧ T ≡ p
b) p ∨ F ≡ p
c) p ∧ F ≡F
d) p ∨ T ≡ T
e) p ∨ p ≡ p
f ) p ∧ p ≡ p.
01/27/25
Exercises
Use truth tables to verify the commutative laws
a)p ∨ q ≡ q ∨ p.
b) p ∧ q ≡ q ∧ p.
01/27/25
Exercises
Use a truth table to verify the distributive law
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r).
01/27/25
Exercises
Show that each of these conditional statements is a
tautology
by using truth tables.
a) (p ∧ q) → p
b) p → (p ∨ q)
01/27/25
Exercises
Show that each of these conditional statements is a
tautology
by using truth tables.
c) ¬ p → (p → q)
d) (p ∧ q) → (p → q)
01/27/25
Exercises
Show that each of these conditional statements is a
tautology
by using truth tables.
e) ¬(p → q) → p
f ) ¬(p → q) → ¬ q
01/27/25
Exercises
Show that (p ∨ q) ∧ (¬p ∨ r) → (q ∨ r) is a
tautology.
01/27/25
Thank
You
01/27/25