Ds 1 Propositional
Ds 1 Propositional
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Chapter 1
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Logics
Discrete Structures for Computing on January 4, 2023
Contents
Propositional Logic
Logical Equivalences
Exercise
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
1 Propositional Logic
Contents
Propositional Logic
Logical Equivalences
2 Logical Equivalences Exercise
3 Exercise
1.2
Course outcomes
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
L.O.2 Represent and model practical problems with discrete structures Contents
L.O.2.1 Logically describe some problems arising in Computing Propositional Logic
L.O.2.2 Use proving methods: direct, contrapositive, induction Logical Equivalences
L.O.2.3 Explain problem modeling using discrete structures Exercise
1.3
Logic
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Definition (Averroes)
The tool for distinguishing between the true and the false.
Contents
Definition (Penguin Encyclopedia) Propositional Logic
Logical Equivalences
The formal systematic study of the principles of valid inference Exercise
and correct reasoning.
1.4
Applications in Computer Science
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
• Artificial intelligence
• Many more...
1.5
Propositional Logic
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Definition
• 1+1=2
• 2+2=3
1.6
Examples
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
• 2n ≥ 100
• The Sun circles the Earth.
• Today is Thursday.
• Proposition only when the time is specified
1.7
Notations
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Contents
• Propositions are denoted by p, q, . . . Propositional Logic
Logical Equivalences
• The truth value (ch¥n trà) is true (T) or false (F)
Exercise
1.8
Operators
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
1.9
Operators
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
1.10
Operators
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
1.11
More Expressions for Implication p → q
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
• if p, then q
• p implies q
Contents
• p is sufficient for q
Propositional Logic
• q if p Logical Equivalences
• p only if q Exercise
• q unless ¬p
• If you get 100% on the final, you will get 10 grade.
1.12
Conditional Statements From p → q
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
1.13
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Exercise
1.14
Biconditionals
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
p↔q
p if and only if q
p q p↔q Contents
Propositional Logic
T T T
Logical Equivalences
T F F
Exercise
F T F
F F T
1.15
The order of operators
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
• 1. in the bracket()
Contents
• 2. negation ¬ Propositional Logic
• 3. ∨, ∧, ⊕ Logical Equivalences
Exercise
• 4. →
• 5. ↔
1.16
Translating Natural Sentences
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Exercise
I will buy a new phone only if I have enough money to buy iPhone
Contents
4 or my phone is not working.
Propositional Logic
Logical Equivalences
• p: I will buy a new phone
Exercise
• q: I have enough money to buy iPhone 4
• r: My phone is working
• p → (q ∨ ¬r)
1.17
Translating Natural Sentences
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Contents
Exercise
Propositional Logic
He will not run the red light if he sees the police unless he is too Logical Equivalences
risky. Exercise
1.18
Construct Truth Table
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Exercise
T T F T T T
T F T T F F
F T F F F T
F F T T F F
1.19
Exercise - Truth table
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
¬p → (¬q ∨ r)
p q r ¬p ¬q ¬q ∨ r ¬p → (¬q ∨ r)
T T T F F T T
T T F F F F T
T F T F T T T
T F F F T T T
Contents
F T T T F T T
F T F T F F F Propositional Logic
F F T T T T T Logical Equivalences
F F F T T T T
Exercise
a) (p ∧ q) → ¬q
b) (p ∨ r) → (r ∨ ¬p)
c) (p → q) ∨ (q → p)
d) (p ∨ ¬q) ∧ (¬p ∨ q)
e) (p → ¬q) ∨ (q → ¬p)
f) ¬(¬p ∧ ¬q)
g) (p ∨ q) → (p ⊕ q)
h) (p ∧ q) ∨ (r ⊕ q)
1.20
Applications
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
• System specifications
Contents
• When a user clicked on Help button, a pop-up will be shown Propositional Logic
up
Logical Equivalences
• Boolean search Exercise
• type dai hoc bach khoa in Google
• means dai AND hoc AND bach AND khoa
1.21
Applications (cont.)
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
• Logic puzzles
• There are two kinds of inhabitants on an island, knights, who Contents
always tell the truth, and their opposites, knaves, who may Propositional Logic
lie. You encounter two people A and B . What are A and B if Logical Equivalences
A says B is a knight and B says The two of us are Exercise
opposite types ?
• Bit operations
• 101010011 is a bit string of length nine.
1.22
Tautology and Contradiction
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Definition
Example
• p ∨ ¬p (tautology)
• p ∧ ¬p (contradiction)
1.23
Question
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
a) (p ∨ q) → (p ∧ q) Contents
Propositional Logic
b) (p ∧ q) → (p ∨ q) Logical Equivalences
c) p → (¬q → p) Exercise
d) p → (p → q)
e) p → (p → p)
f) (p → q) → [(p → r) → (q → r)]
1.24
Proposition? Truth value?
Logics
Nguyen An Khuong,
d) Stand up!
e) x+1=0
g) 0 is a positive number.
v) x is a prime number if it doesn't have any divisor other than 1 and x.
1.25
Logical Equivalences
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Definition
Contents
The compound compositions p andq are called logically equivalent
Propositional Logic
if p↔q is a tautology, denoted p ≡ q. Logical Equivalences
Exercise
Example
1.26
Logical Equivalences
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
1.27
Logical Equivalences
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r) Associative laws
Contents
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r) Luªt k¸t hñp Propositional Logic
Logical Equivalences
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) Distributive laws
Exercise
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) Luªt ph¥n phèi
p ∨ (p ∧ q) ≡ p Absorption laws
p ∧ (p ∨ q) ≡ p Luªt hót thu
1.28
Logical Equivalences
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Equivalence
p ∨ ¬p ≡ T
p ∧ ¬p ≡ F Contents
1.29
Constructing New Logical Equivalences
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Example
Solution
Contents
Propositional Logic
¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬(¬p ∧ q) by the second De Morgan law
Logical Equivalences
≡ ¬p ∧ [¬(¬p) ∨ ¬q] by the first De Morgan law Exercise
1.30
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Example
p → (¬q ∧ r)
By using the truth table, we can prove that p→q and ¬p ∨ q are
Contents
logical equivalence.
Propositional Logic
Negate: ¬(p → (¬q ∧ r)) Logical Equivalences
≡ ¬(¬p ∨ (¬q ∧ r)) Exercise
≡ p ∧ ¬(¬q ∧ r)
≡ p ∧ (q ∨ ¬r)
a) p ∧ (q ∨ r) ∧ (¬p ∨ ¬q ∨ r)
b) (p ∧ q) → r
c) p ∨ q ∨ (¬p ∧ ¬q ∧ r)
d) [[[(p ∧ q) ∧ r] ∨ [(p ∧ r) ∧ ¬r]] ∨ ¬q] → s
1.31
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
a) ¬(p ↔ q) v ¬p ↔ q Contents
Propositional Logic
b) (p → q) ∧ (p → r) v p → (q ∧ r) Logical Equivalences
c) (p → r) ∧ (q → r) v (p ∨ q) → r Exercise
d) (p → q) ∨ (p → r) v p → (q ∨ r)
e) ¬p → (q → r) v q → (p ∨ r)
f) p↔q v (p → q) ∧ (q → p)
1.33
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
a) p ∧ (p → q) v p∧q Contents
b) p→q v ¬p ∨ (p ∧ q) Propositional Logic
Logical Equivalences
c) p→q v ¬p ∨ ¬q
Exercise
d) ¬p v ¬(p ∨ q) ∨ (¬p ∧ q)
e) [(p ↔ q) ∧ (q ↔ r) ∧ (r ↔ p)] v
[(p → q) ∧ (q → r) ∧ (r → p)]
f) [(p ∧ q) ∨ (q ∧ r) ∨ (r ∧ p)] v [(p ∨ q) ∧ (q ∨ r) ∧ (r ∨ p)]
1.34
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
1.36
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Let p and q be:
A) (p ∧ q) → r
B) p→q
C) p∨q
D) p∧q
E) p↔q
F) ¬p → ¬q
G) ¬p ∨ (p ∧ q)
H) None of the others.
1.38
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Let P , Q, R be: Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
a) x ∈ {x}
b) {x} ⊆ {x}
c) {x} ∈ {x} Contents
d) {x} ∈ {{x}} Propositional Logic
Logical Equivalences
e) ∅ ⊆ {x} Exercise
A) a
B) b
C) c
D) d
E) none of the others.
1.40
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
B) p → (p ∧ q) Logical Equivalences
Exercise
C) ¬p → (p → q)
D) ¬(p → q) → q
E) none of the others.
1.41
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Contents
Propositional Logic
Which of the following compounds formalize the theorem: if Logical Equivalences
ABC is an isosceles triangle and has a 60o angle then it is an Exercise
equilateral triangle ?
A) (p ∧ q) → r
B) (p ∧ r) → q
C) (p ∧ r) ∨ q
D) q → (p ∨ r)
E) none of the others.
1.42
Exercise
Logics
Nguyen An Khuong,
Tran Tuan Anh, Nguyen
Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
d. A and F
e. A and D
Knowing that there are 4 half true statements and 1 totally false
statement. What teams are in the grand final?
1.43
Exercise Logics
Find the truth values of the following statements (with brief Nguyen An Khuong,
Tran Tuan Anh, Nguyen
explanations): Tien Thinh, Mai Xuan
Toan, Tran Hong Tai
b) ∃x ∈ R, x2 + x + 1 ≤ 0
c) ∃n ∈ N, (n3 − n) is not a multiple of 3.
d) ∀n ∈ N ∗, n2 − 1 is a multiple of 3.