MathLogic2-Predicate-Logic
MathLogic2-Predicate-Logic
Chapter 2 Contents
Predicate Logic to
Logical Inference
Introduction to Mathematical Logic Exercise
on January 7, 2025
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 1 / 46
Contents
Contents
Predicate Logic
Predicate Logic to
1 Predicate Logic Logical Inference
Exercise
3 Exercise
2.2
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 2 / 46
Contents
Contents
Predicate Logic
Exercise
L.O.1 Understanding of logic and discrete structures
L.O.1.1 – Describe definition of predicate logic
L.O.1.2 – Define basic discrete structures: set, map, graph
L.O.2 Represent & model practical problems with discrete structures
L.O.2.1 – Logically describe KEY problems in Computing
L.O.2.2 – Use proving methods: contrapositive, induction
L.O.2.3 – Explain problem modeling using discrete structures
2.3
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 3 / 46
CHAPTER 2.
Predicate Logic
Predicate Logic
Contents
Predicate Logic
Predicate Logic to
Logical Inference
• x>3 Exercise
2.5
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 5 / 46
Predicate Logic
Definition Contents
Predicate Logic to
If values are assigned to all the variables in a predicate, the Logical Inference
resulting statement is a proposition . Exercise
• x > 3 → P (x)
• 5 > 3 → P (5)
• A predicate with n variables P (x1 , x2 , ..., xn )
Example:
• x > 3 (predicate)
• 5 > 3 (proposition)
• 2 > 3 (proposition)
2.6
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 6 / 46
Predicate Logic
Contents
Predicate Logic
Predicate Logic to
• x > 3 is true or false? Logical Inference
• 5>3 Exercise
2.7
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 7 / 46
Predicate Logic
Contents
Predicate Logic
• ∀: Universal – For all Predicate Logic to
• ∀xP (x) = P (x) is T for all x Logical Inference
Exercise
2.8
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 8 / 46
Predicate Logic
Predicate Logic
Predicate Logic
What is the truth value of the quantification ∀xP (x), Predicate Logic to
where the domain consists of all real number? Logical Inference
Exercise
Example
What is the truth value of the quantification ∃xP (x),
where the domain consists of all real number?
2.9
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 9 / 46
Predicate Logic
Predicate Logic
Example
Express the statement ”Some student in this class comes Contents
Predicate Logic to
Logical Inference
Solution 1
Exercise
• M (x) = x comes from Central Thailand
• Domain for x is the students in the class
• ∃xM (x)
Solution 2
• Domain for x is all people
• ...
2.10
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 10 / 46
Predicate Logic
Predicate Logic to
∃xP (x) ¬(∃xP (x)) ∀x¬P (x) Logical Inference
Exercise
Example
• All CSE students study Discrete Math 1
• Let C(x) denote ”x is a CSE student”
• Let S(x) denote ”x studies Discrete Math 1”
• ∀x : C(x) → S(x)
• ∃x : ¬(C(x) → S(x)) ≡ ∃x : C(x) ∧ ¬S(x)
• There is a CSE student who does not study Discrete
Math 1.
2.11
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 11 / 46
Predicate Logic
Example
Contents
Translate these: Predicate Logic
• All lions are fierce. Predicate Logic to
Logical Inference
• Some lions do not drink coffee. Exercise
• Some fierce creatures do not drink coffee.
Solution
Let P (x), Q(x) and R(x) be the statements “x is a lion”,
“x is fierce” and “x drinks coffee”, respectively.
• ∀x(P (x) → Q(x)).
• ∃x(P (x) ∧ ¬R(x)).
• ∃x(Q(x) ∧ ¬R(x)).
2.12
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 12 / 46
Predicate Logic
Exercise
Example
∀x ∀y (x + y = y + x)
T for all x, y ∈ R
Example
∀x ∃y (x + y = 0) is T,
while
∃y ∀x (x + y = 0) is F
2.13
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 13 / 46
Predicate Logic
Contents
Example
Predicate Logic
∀x (C(x) ∨ ∃y (C(y) ∧ F (x, y)) ) Predicate Logic to
Logical Inference
Provided that:
Exercise
• C(x): x has a computer,
• F (x, y): x and y are friends,
• x, y ∈ all students in your school.
Answer
For every student x in your school, x has a computer or
there is a student y such that y has a computer and x and y
are friends.
2.14
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 14 / 46
Predicate Logic
Contents
Answer
There is a student x, so that for every student y, every
student z not the same as y, if x and y are friends, and x
and z are friends, then y and z are not friends.
2.15
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 15 / 46
Predicate Logic
Example
Contents
1 “There is a student in the class has visited Hanoi”. Predicate Logic
2 “Every student in the class has visited Nha Trang or Predicate Logic to
Logical Inference
Vung Tau”. Exercise
Answer
Assume:
C(x) : x has visited Hanoi
D(x) : x has visited Nha Trang
E(x) : x has visited Vung Tau
We have:
1 ∃xC(x)
2 ∀x(D(x) ∨ E(x))
2.16
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 16 / 46
Predicate Logic
Example
Contents
If a person is a woman and a parent, then this person is Predicate Logic
mother of someone. Predicate Logic to
Logical Inference
Solution: We define: Exercise
• W (x) : x is woman
• P (x) : x is a parent
• M (x, y): x is mother of y
We have: ∀x((W (x) ∧ P (x)) → ∃yM (x, y))
Example
”Every people has only one best friend.”
Assume:
• B(x, y) : y is the best friend of x
2.17
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 17 / 46
Predicate Logic
Contents
Predicate Logic
Predicate Logic to
Example Logical Inference
Assume:
• B(x, y) : y is the best friend of x
Solution
∀x ∃y ∀z [B(x, y) ∧ ((y ̸= z) → ¬B(x, z))]
2.18
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 18 / 46
Predicate Logic to Logical Inference
Contents
Example Predicate Logic
• If I have a girlfriend, I will take her to go shopping. Predicate Logic to
Logical Inference
• Whenever I and my girlfriend go shopping and that day Exercise
is a special day, I will surely buy her some expensive gift.
• If I buy my girlfriend expensive gifts, I will eat noodles
for a week.
• Today is March 8.
• March 8 is such a special day.
• Therefore, if I have a girlfriend,...
• I will eat noodles for a week.
2.19
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 19 / 46
Predicate Logic to Logical Inference
Contents
Rule of Inference Name Predicate Logic
p Predicate Logic to
p→q Logical Inference
¬q
p→q
∴ ¬p Modus tollens
p→q
q→r
∴p→r Hypothetical syllogism
p∨q
¬p
∴q Disjunctive syllogism
2.20
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 20 / 46
Predicate Logic to Logical Inference
Contents
Predicate Logic to
p Logical Inference
∴p∨q Addition
Exercise
p∧q
∴p Simplification
p
q
∴p∧q Conjunction
p∨q
¬p ∨ r
∴q∨r Resolution
2.21
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 21 / 46
Predicate Logic to Logical Inference
Predicate Logic
Predicate Logic
barbecue tomorrow.
Predicate Logic to
Therefore, if it rains today, then we will have a barbecue Logical Inference
tomorrow. Exercise
Solution
• p: It is raining today
• q: We will not have a barbecue today
• r: We will have barbecue tomorrow
p→q
q→r
∴ p → r . This is Hypothetical syllogism
2.22
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 22 / 46
Predicate Logic to Logical Inference
Predicate Logic
Example
• It is not sunny this afternoon 1. ¬p ∧ q Hypothesis
Contents
(¬p) and it is colder than Predicate Logic
yesterday (q) 2. ¬p Simplification using (1)
Predicate Logic to
• We will go swimming (r) only 3. r → p Hypothesis
Logical Inference
if it is sunny Exercise
2.23
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 23 / 46
Predicate Logic to Logical Inference
Contents
Definition
Predicate Logic
Fallacies resemble rules of inference but are based on
Predicate Logic to
contingencies rather than tautologies. Logical Inference
Exercise
Example
If you do correctly every questions in mid-term exam, you
will get 10 grade.
You got 10 grade.
Therefore, you did correctly every questions in mid-term
exam.
2.24
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 24 / 46
Predicate Logic to Logical Inference
Contents
Rule of Inference Name Predicate Logic
Predicate Logic to
∀xP (x) Logical Inference
Universal instantiation
∴ P (c) Exercise
P (c)for an arbitrary c
Universal generalization
∴ ∀xP (x)
∃xP (x)
Existential instantiation
∴ P (c)for some element c
2.25
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 25 / 46
Predicate Logic to Logical Inference
Example Contents
• Someone who passed the first exam has not gone to Exercise
class ≡ γ?
Hint
We need 3 predicates
• C(x): x is in this class
• B(x): x has gone to class
• P (x): x passed the first exam
• Premises???
2.26
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 26 / 46
Predicate Logic to Logical Inference
Contents
1. α = ∃x(C(x) ∧ ¬B(x)) Premise Predicate Logic
2. C(a) ∧ ¬B(a) Existential instantiation from (1)
Predicate Logic to
3. C(a) Simplification from (2) Logical Inference
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 27 / 46
Exercise
Contents
Predicate Logic
Given the predicate p(x) :′′ x2 − 3x + 2 = 0′′ .
Predicate Logic to
Logical Inference
Exercise
What is the truth value of the following propositions:
a) p(0)
b) p(1)
c) p(2)
d) ∃x, p(x)
e) ∀x, p(x)
2.28
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 28 / 46
Exercise
Let x, y ∈ Z+ , and
Contents
the predicate: p(x, y): ”x is a divisor of y” Predicate Logic
Predicate Logic to
Logical Inference
Determine the truth value of the following propositions:
Exercise
a) p(2, 3)
b) p(2, 6)
c) ∀y, p(1, y)
d) ∀x, p(x, x)
e) ∀x∃y, p(x, y)
f) ∃y∀x, p(x, y)
g) ∀x∀y, (p(x, y) ∧ p(y, x)) → (x = y)
h) ∀x∀y∀z(p(x, y) ∧ p(y, z)) → (p(x, z))
2.29
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 29 / 46
Exercise
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 30 / 46
Exercise
Predicate Logic to
b) ‘All of her brothers are younger than her’. Logical Inference
∀x(B(x, m) → ¬O(x, m)). Exercise
2.31
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 31 / 46
Exercise
Contents
Translating the following nested quantifiers: Predicate Logic
2.32
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 32 / 46
Exercise
Predicate Logic
Solutions of D:
Man VM. Nguyen
a) B(c, m) ∧ (O(c, m) ∨ O(m, c)).
c is a brother (elder/younger) of m.
Contents
Predicate Logic
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 33 / 46
Exercise
c) ¬∃xN (x)
d) ∃x¬N (x)
e) ¬∀xN (x)
f) ∀x¬N (x)
a) There is a student in this class has been to Da Lat.
b) All students in Math class have been to Da Lat.
c) There is no exists a student in Math class has gone to Da Lat.
d) There is a student in this class has never gone to Da Lat.
e) Not all students in Math class have ever been to Da Lat.
f) All students in Math class have never been to Da Lat. 2.34
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 34 / 46
Exercise
Contents
Given the predicate
Predicate Logic
N (x) = ”x studies more than 5 hours in class every
Predicate Logic to
weekday” Logical Inference
2.35
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 35 / 46
Exercise
Predicate Logic to
Logical Inference
for (i = 0; i¡numObjects; i++) {
Exercise
Object x = Objects(i);
if isMushroom(x)
if isPoisonous(x) && isPurple(x)
return false;
}
return true;
2.36
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 36 / 46
Exercise
Contents
What is the propositional formula for the following pseudo
Predicate Logic
code: Predicate Logic to
Logical Inference
for (i=0; i¡numObjects; i++) { Exercise
Object x = Objects(i);
if isMushroom(x) && isPoisonous(x) && isPurple(x)
return true;
}
return false;
2.37
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 37 / 46
Exercise
Predicate Logic
if isParent(Peter, kids[x])
Predicate Logic to
match1Found = true; Logical Inference
//— Now look for a second match Exercise
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 38 / 46
Exercise
a) There is a student in your university that can speak Russian and Predicate Logic to
Logical Inference
can use Java.
Exercise
b) There is a student in your university that can speak Russian but
can’t use Java.
c) Every student in your university can speak Russian or can use
Java.
d) None of the student in your university can speak Russian or can
use Java.
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 39 / 46
Exercise
Exercise
b) Everybody loves someone.
c) There is a person who everybody loves.
d) Nobody loves everybody.
e) There is someone Lydica doesn’t love.
f) There is someone nobody loves.
g) There is exact one person everybody loves.
h) There are exact two person Lynn loves.
i) Everybody loves themselves.
j) There is a person who love nobody but himself.
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 40 / 46
Exercise
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 41 / 46
Exercise
Predicate Logic to
Logical Inference
F (p) is “Printer p is broken”, Exercise
B(p) is “Printer p is currently printing another document”,
L(j) is “Printing job j is lost”,
and Q(j) is “Printing job j is in queue.”
2.42
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 42 / 46
Exercise
Predicate Logic
a) Nobody is perfect.
Predicate Logic to
b) not everyone is perfect. Logical Inference
Exercise
c) All your friends are perfect.
d) At least one of your friend is perfect.
e) Everybody is your friend and they are perfect.
f) Not everybody is your friend or there is somebody not perfect.
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 43 / 46
Exercise
Exercise
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 44 / 46
Exercise
Let: Contents
- P (x, y): x is parent of y. Predicate Logic
- M (x): x is male . Predicate Logic to
Logical Inference
Exercise
Given: F (v, w) =
= M (v) ∧ ∃x∃y(P (x, y) ∧ P (x, v) ∧ (y ̸= v) ∧ P (y, w)),
then F (v, w) means:
A) v is brother of w
B) v is cousin of w
C) v is uncle of w
D) v is grand father of w
2.45
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 45 / 46
Exercise
Predicate Logic to
b) Do not back up the files if anyone is logging in the Logical Inference
system. Exercise
Man VM. Nguyen (Math Depart., MUSC) Predicate Logic January 7, 2025 46 / 46