Predicate Logic Exercises and Concepts
Predicate Logic Exercises and Concepts
Logics (cont.)
Discrete Structures for Computing on September 3, 2021
Contents
Predicate Logic
Exercise
Predicate Logic
Exercise
2 Exercise
2.2
Logics (cont.)
Course outcomes
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Course learning outcomes
Contents
L.O.2 Represent and model practical problems with discrete structures
L.O.2.1 – Logically describe some problems arising in Computing Predicate Logic
2.3
Logics (cont.)
Limits of Propositional Logic
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Contents
• x>3
Predicate Logic
• All square numbers are not prime numbers. 100 is a square Exercise
2.4
Logics (cont.)
Predicates
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
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
Logics (cont.)
Truth value
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Exercise
• For every number x, x > 3 holds
• There is a number x such that x > 3
2.6
Logics (cont.)
Quantifiers
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
2.7
Logics (cont.)
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
Logics (cont.)
Solution 1
Contents
• M (x) = x comes from Central Vietnam Predicate Logic
• ∃xM (x)
Solution 2
• Domain for x is all people
• ...
2.9
Logics (cont.)
Negation of Quantifiers
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Predicate Logic
Example Exercise
2.10
Logics (cont.)
Another Example
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
Translate these:
• All lions are fierce.
• Some lions do not drink coffee.
Contents
• Some fierce creatures do not drink coffee. Predicate Logic
Exercise
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.11
Logics (cont.)
The Order of Quantifiers
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
∀x ∃y (x + y = 0) is T,
while
∃y ∀x (x + y = 0) is F
2.12
Logics (cont.)
Translating Nested Quantifiers
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
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
Logics (cont.)
Translating Nested Quantifiers
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
∃x∀y∀z (((F (x, y) ∧ F (x, z) ∧ (y 6= z)) → ¬F (y, z)))
Provided that: Contents
• F (x, y): x, y are friends Predicate Logic
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
Logics (cont.)
Translating into Logical Expressions
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
Predicate Logic
Answer Exercise
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
Logics (cont.)
Translating into Logical Expressions
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
If a person is a woman and a parent, then this person is mother of
someone.
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:
• B(x, y) : y is the best friend of x
2.16
Logics (cont.)
Translating into Logical Expressions
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
"Every people has only one best friend." Contents
Solution
∀x∃y∀z(B(x, y) ∧ ((y 6= z) → ¬B(x, z)))
2.17
Logics (cont.)
Inference
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Example
special day, I will surely buy her some expensive gift. Predicate Logic
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.18
Logics (cont.)
Propositional Rules of Inferences
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
¬q Predicate Logic
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
Logics (cont.)
Propositional Rules of Inferences
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
2.20
Logics (cont.)
Exercise
• 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
Hypothetical syllogism
2.21
Logics (cont.)
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
Logics (cont.)
Fallacies
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Definition
Fallacies (ngụy biện) resemble rules of inference but are based on
contingencies rather than tautologies. Contents
Predicate Logic
Example Exercise
2.23
Logics (cont.)
Rules of Inference for Quantified Statements
Huynh Tuong Nguyen,
Tran Tuan Anh, Nguyen
An Khuong, Le Hong
Trang
Predicate Logic
P (c)for an arbitrary c Exercise
Universal generalization
∴ ∀xP (x)
(Tổng quát hóa phổ quát)
∃xP (x)
Existential instantiation
∴ P (c)for some element c
(Cụ thể hóa tồn tại)
P (c)for some element c
Existential generalization
∴ ∃xP (x)
(Tổng quát hóa tồn tại)
2.24
Logics (cont.)
Example
Predicate Logic
Exercise
Hint
• C(x): x is in this class
• B(x): x has gone to class
• P (x): x passed the first exam
• Premises???
2.25
Logics (cont.)
Predicate Logic
5. C(a) → P (a) Universal instantiation from (4)
Exercise
6. P (a) Modus ponens from (3) and (5)
7. ¬B(a) Simplification from (2)
8. P (a) ∧ ¬B(a) Conjunction from (6) and (7)
9. ∃x(P (x) ∧ ¬B(x)) Existential generalization from (8)
2.26
Logics (cont.)
Exercise
c) p(2)
d) ∃x, p(x)
e) ∀x, p(x)
2.27
Logics (cont.)
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
Logics (cont.)
Predicate Logic
Exercise
Express each of these statements using predicates:
2.29
Logics (cont.)
2.30
Logics (cont.)
2.31
Logics (cont.)
f) ∀x¬N (x)
2.32
Logics (cont.)
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
c) ∃x¬N (x)
d) ∀x¬N (x)
2.33
Logics (cont.)
Predicate Logic
if isPoisonous(x) && isPurple(x)
Exercise
return false;
}
return true;
2.34
Logics (cont.)
2.35
Logics (cont.)
if isParent(Peter, kids[y])
match2Found = true;
2.36
Logics (cont.)
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
Logics (cont.)
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
2.38
Logics (cont.)
b) ∃x(S(x) ∧ ¬P (x))
There are many ways to translate a formula to natural language
and the following is one of them
a) If x is a math problem, to say x is hard is the same as saying
x is not easy.
b) There is unsolvable non-math problem.
2.39
Logics (cont.)
2.40
Logics (cont.)
2.41
Logics (cont.)
that has the same educational goal as a ABET satisfied program Predicate Logic
2.42
Logics (cont.)
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 6= 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
Logics (cont.)
a) When a hard drive has less than 30GB free space, a warning
will be issued to all the users.
b) Do not back up the files if anyone is logging in the system.
c) YouTube’s videos will be buffered if there are at least 8MB
Contents
memory and 56kb/s line rate.
Predicate Logic
d) Few computer student is good at programming. Exercise
2.44