Ds 2 Predicate
Ds 2 Predicate
Nguyen An Khuong,
Tran Tuan Anh, Mai
Chapter 2
Xuan Toan, Tran Hong
Tai
Predicate logic
Discrete Structures for Computing on June 16, 2024
Contents
Predicate Logic
Exercise
Nguyen An Khuong, Tran Tuan Anh, Mai Xuan Toan, Tran Hong
Tai
Faculty of Computer Science and Engineering
University of Technology - VNUHCM
trtanh@hcmut.edu.vn
2.1
Contents Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2 Exercise
2.2
Course outcomes Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.3
Limits of Propositional Logic Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Contents
• x>3 Predicate Logic
• All square numbers are not prime numbers. 100 is a square Exercise
number. Therefore 100 is not a prime number.
2.4
Predicates Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Definition
A predicate (và tø ) is a statement containing one or more
variables. If values are assigned to all the variables in a predicate,
the resulting statement is a proposition (m»nh · ). Contents
Predicate Logic
• x > 3 → P (x) Exercise
• 5 > 3 → P (5)
• A predicate with n variables P (x1 , x2 , ..., xn )
Example:
• x > 3 (predicate)
• 5 > 3 (proposition)
• 2>3 (proposition)
2.5
Truth value Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.6
Quantifiers Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.7
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
Let P (x) be the statement x < 2. What is the truth value of the
quantification ∀xP (x), where the domain consists of all real
number?
Contents
• P (3) = 3 < 2 is false
Predicate Logic
• ⇒ ∀xP (x) is false Exercise
Example
What is the truth value of the quantification ∃xP (x), where the
domain consists of all real number?
2.8
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
Express the statement "Some student in this class comes from
Central Vietnam."
Solution 1
Contents
• M (x) = x comes from Central Vietnam Predicate Logic
Exercise
• Domain for x is the students in the class
• ∃xM (x)
Solution 2
• Domain for x is all people
• ...
2.9
Negation of Quantifiers Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
• ∀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.10
Another Example Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
Translate these:
Solution
Let P (x), Q(x) and R(x) be the statements x is a lion, x is
fierce and x drinks coffee, respectively.
2.11
The Order of Quantifiers Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Contents
Example
Predicate Logic
∀x ∀y (x + y = y + x) Exercise
T for all x, y ∈ R
Example
∀x ∃y (x + y = 0) is T,
while
∃y ∀x (x + y = 0) is F
2.12
Translating Nested Quantifiers Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
∀x (C(x) ∨ ∃y (C(y) ∧ F (x, y)) )
Provided that:
Contents
• C(x): x has a computer, Predicate Logic
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.13
Translating Nested Quantifiers Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
∃x∀y∀z (((F (x, y) ∧ F (x, z) ∧ (y ̸= z)) → ¬F (y, z)))
Provided that: Contents
• F (x, y): x, y are friends Predicate Logic
Exercise
• x, y, z ∈ all students in your school.
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.14
Translating into Logical Expressions Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
1 There is a student in the class has visited Hanoi.
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.15
Translating into Logical Expressions Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Example Tai
Solution
Contents
We define:
Predicate Logic
• W (x) : x is woman Exercise
• 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:
2.16
Translating into Logical Expressions Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
"Every people has only one best friend." Contents
Assume: Predicate Logic
Exercise
• B(x, y) : y is the best friend of x
Solution
∀x∃y∀z(B(x, y) ∧ ((y ̸= z) → ¬B(x, z)))
2.17
Inference Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
• If I have a girlfriend, I will take her to go shopping.
• Exercise
If I buy my girlfriend expensive gifts, I will eat noodles for a
week.
• Today is March 8.
2.18
Propositional Rules of Inferences Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
p→q Exercise
∴ ¬p Modus tollens
p→q
q→r
Hypothetical syllogism
∴p→r
(Tam o¤n luªn gi£ ành)
p∨q
¬p
Disjunctive syllogism
∴q
(Tam o¤n luªn tuyºn)
2.19
Propositional Rules of Inferences Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.20
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Example Tai
2.21
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
1. ¬p ∧ q Hypothesis
• It is not sunny this afternoon
(¬p) and it is colder than 2. ¬p Simplification using (1)
yesterday (q )
• We will go swimming (r) only if 3. r → p Hypothesis Contents
2.22
Fallacies Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Definition
Fallacies (ngöy bi»n) resemble rules of inference but are based on
contingencies rather than tautologies. Contents
Predicate Logic
Example Exercise
Is [(p → q) ∧ q] → p a tautology?
2.23
Rules of Inference for Quantified Statements Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.24
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Example
• A student in this class has not gone to class
• Someone who passed the first exam has not gone to class Contents
Predicate Logic
Exercise
Hint
• C(x): x is in this class
• Premises???
2.25
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.26
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
a) p(0) Contents
b) p(1) Predicate Logic
Exercise
c) p(2)
d) ∃x, p(x)
e) ∀x, p(x)
2.27
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
a) p(2, 3)
b) p(2, 6) Contents
c) ∀y, p(1, y) Predicate Logic
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.28
Predicate logic
• M (x, y) : x is mother of y ,
• S(x, y) : x is sister of y ,
• B(x, y) : x is brother of y ,
• H(x, y) : x is spouse (wife/husband) of y,
Contents
• O(x, y) : x is elder than y .
Predicate Logic
Exercise
Express each of these statements using predicates:
a) `He (a person) has an elder sister and younger brother'.
2.29
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
2.30
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.31
Predicate logic
Nguyen An Khuong,
Given a predicate N (x) "x has been to Da Lat" with the domain
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
is the all students in Mathematics class. Translate the following
predicates into English
a) ∃xN (x)
b) ∀xN (x)
c) ¬∃xN (x) Contents
d) ∃x¬N (x) Predicate Logic
Exercise
e) ¬∀xN (x)
f) ∀x¬N (x)
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Given the predicate N (x) "x studies more than 5 hours in class
every weekday" with the domain is the all students in
Mathematics class. Express the following predicates:
Contents
a) ∃xN (x) Predicate Logic
Exercise
b) ∀xN (x)
c) ∃x¬N (x)
d) ∀x¬N (x)
2.33
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
}
return true;
• There are no mushrooms that are poisonous and purple.
2.34
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.35
Predicate logic
Contents
// Now look for a second match Predicate Logic
for (y=0; (y<numKids)&&(y!=x); y++) Exercise
if isParent(Peter, kids[y])
match2Found = true;
2.36
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Let P(x) be "x can speak Russian" and Q(x) be "x can use Java".
Formalize the following:
Giving the space is ll students in your university.
a) There is a student in your university that can speak Russian and can use
Java.
b) There is a student in your university that can speak Russian but can't Contents
use Java. Predicate Logic
c) Every student in your university can speak Russian or can use Java. Exercise
d) None of the student in your university can speak Russian or can use Java.
2.37
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Let L(x,y) be "x love y", where the space of x and y is the set of
all people in the world. Use logical quantifier to express the
following:
a) Everybody loves Jerry.
b) Everybody loves someone.
Contents
c) There is a person who everybody loves. Predicate Logic
d) Nobody loves everybody. Exercise
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.
2.38
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
b) ∃x(S(x) ∧ ¬P (x))
There are many ways to translate a formula to natural language
and the following is one of them
x is not easy.
2.39
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.40
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.41
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
2.42
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
Tai
Let:
- P (x, y): x is parent of y.
- M (x): x is male .
Given:
Contents
F (v, w) = M (v) ∧ ∃x∃y(P (x, y) ∧ P (x, v) ∧ (y ̸= v) ∧ P (y, w)), Predicate Logic
then F (v, w) means:
Exercise
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.43
Predicate logic
Nguyen An Khuong,
Tran Tuan Anh, Mai
Xuan Toan, Tran Hong
a) When a hard drive has less than 30GB free space, a warning
2.44