0% found this document useful (0 votes)
19 views46 pages

Ds 2 Predicate

Uploaded by

hieua3xyz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views46 pages

Ds 2 Predicate

Uploaded by

hieua3xyz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Logics (cont.

Huynh Tuong Nguyen,


Nguyen An Khuong,

Chapter 2 Tran Tuan Anh, Le


Hong Trang, Nguyen
Tien Thinh

Logics (cont.)
Discrete Structures for Computing on August 5, 2020
Contents

Predicate Logic

Exercise

Huynh Tuong Nguyen, Nguyen An Khuong, Tran Tuan Anh, Le


Hong Trang, Nguyen Tien Thinh
Faculty of Computer Science and Engineering
University of Technology - VNUHCM
[email protected]
2.1
Logics (cont.)
Contents
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

1 Predicate Logic Contents

Predicate Logic

Exercise

2 Exercise

2.2
Logics (cont.)
Course outcomes
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
Course learning outcomes

L.O.1 Understanding of logic and discrete structures


L.O.1.1 – Describe definition of propositional and predicate logic
L.O.1.2 – Define basic discrete structures: set, mapping, graphs

L.O.2 Represent and model practical problems with discrete structures Contents
L.O.2.1 – Logically describe some problems arising in Computing Predicate Logic
L.O.2.2 – Use proving methods: direct, contrapositive, induction
Exercise
L.O.2.3 – Explain problem modeling using discrete structures

L.O.3 Understanding of basic probability and random variables


L.O.3.1 – Define basic probability theory
L.O.3.2 – Explain discrete random variables

L.O.4 Compute quantities of discrete structures and probabilities


L.O.4.1 – Operate (compute/ optimize) on discrete structures
L.O.4.2 – Compute probabilities of various events, conditional
ones, Bayes theorem

2.3
Logics (cont.)
Limits of Propositional Logic
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

• x>3 Contents

Predicate Logic
• All square numbers are not prime numbers. 100 is a square
Exercise
number. Therefore 100 is not a prime number.

2.4
Logics (cont.)
Predicates
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Definition
A predicate (vị từ) is a statement containing one or more
variables. If values are assigned to all the variables in a predicate, Contents

the resulting statement is a proposition (mệnh đề ). Predicate Logic

Exercise
Example:
• x > 3 (predicate)
• 5 > 3 (proposition)
• 2 > 3 (proposition)

2.5
Logics (cont.)
Predicates
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

• x > 3 → P (x) Contents

• 5 > 3 → P (5) Predicate Logic

Exercise
• A predicate with n variables P (x1 , x2 , ..., xn )

2.6
Logics (cont.)
Truth value
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

• x > 3 is true or false?


Contents
• 5>3 Predicate Logic

• For every number x, x > 3 holds Exercise

• There is a number x such that x > 3

2.7
Logics (cont.)
Quantifiers
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

• ∀: Universal – Với mọi


• ∀xP (x) = P (x) is T for all x Contents

Predicate Logic
• ∃: Existential – Tồn tại Exercise
• ∃xP (x) = There exists an element x such that P (x) is T
• We need a domain of discourse for variable

2.8
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Example Tien Thinh

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?

• P (3) = 3 < 2 is false Contents

• ⇒ ∀xP (x) is false Predicate Logic

Exercise

• 3 is a counterexample (phản ví dụ) of ∀xP (x)

Example
What is the truth value of the quantification ∃xP (x), where the
domain consists of all real number?

2.9
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Example Tien Thinh

Express the statement “Some student in this class comes from


Central Vietnam.”

Solution 1

• M (x) = x comes from Central Vietnam Contents

Predicate Logic
• Domain for x is the students in the class Exercise

• ∃xM (x)

Solution 2

• Domain for x is all people


• ...

2.10
Logics (cont.)
Negation of Quantifiers
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Statement Negation Equivalent form


∀xP (x) ¬(∀xP (x)) ∃x¬P (x)
∃xP (x) ¬(∃xP (x)) ∀x¬P (x)
Contents

Predicate Logic
Example
Exercise

• 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
Logics (cont.)
Another Example
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
Example
Translate these:
• All lions are fierce.
• Some lions do not drink coffee.
• Some fierce creatures do not drink coffee. Contents

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.12
Logics (cont.)
The Order of Quantifiers
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

• The order of quantifiers is important, unless all the quantifiers


are universal quantifiers or all are existential quantifiers
• Read from left to right, apply from inner to outer

Example Contents

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.13
Logics (cont.)
Translating Nested Quantifiers
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Example
∀x (C(x) ∨ ∃y (C(y) ∧ F (x, y)) )
Provided that:
• C(x): x has a computer, Contents

Predicate Logic
• F (x, y): x and y are friends, Exercise

• 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
Logics (cont.)
Translating Nested Quantifiers
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

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
• x, y, z ∈ all students in your school. Exercise

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
Logics (cont.)
Translating into Logical Expressions
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
Example

1 “There is a student in the class has visited Hanoi”.


2 “Every students in the class have visited Nha Trang or Vung
Tau”.
Contents

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.16
Logics (cont.)
Translating into Logical Expressions
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Example
Every people has only one best friend.
Contents

Predicate Logic
Solution
Exercise
Assume:
• B(x, y) : y is the best friend of x
We have:
∀x∃y∀z(B(x, y) ∧ ((y 6= z) → ¬B(x, z)))

2.17
Logics (cont.)
Translating into Logical Expressions
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Example
If a person is a woman and a parent, then this person is mother of
some one.
Contents
Solution Predicate Logic

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))

2.18
Logics (cont.)
Inference
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Example

• If I have a girlfriend, I will take her to go shopping.


• Whenever I and my girlfriend go shopping and that day is a
Contents
special day, I will surely buy her some expensive gift.
Predicate Logic
• If I buy my girlfriend expensive gifts, I will eat noodles for a Exercise

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
Logics (cont.)
Propositional Rules of Inferences
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
Rule of Inference Name
p
p→q
∴q Modus ponens
Contents
¬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.20
Logics (cont.)
Propositional Rules of Inferences
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Rule of Inference Name


p
Addition
∴p∨q
(Quy tắc cộng )
Contents
p∧q
Simplification Predicate Logic
∴p Exercise
(Rút gọn)
p
q
Conjunction
∴p∧q
(Kết hợp)
p∨q
¬p ∨ r
Resolution
∴q∨r
(Phân giải)

2.21
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Example Hong Trang, Nguyen
Tien Thinh

If it rains today, then we will not have a barbecue today. If we do


not have a barbecue today, then we will have a barbecue
tomorrow. Therefore, if it rains today, then we will have a
barbecue tomorrow.
Contents
Solution
Predicate Logic

• p: It is raining today Exercise

• q: We will not have a barbecue today


• r: We will have barbecue tomorrow
p→q
q→r
∴p→r
Hypothetical syllogism

2.22
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

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
it is sunny Predicate Logic
4. ¬r Modus tollens using (2) and (3)
• If we do not go swimming, then Exercise
we will take a canoe trip (s) 5. ¬r → s Hypothesis
• If we take a canoe trip, then we
will be home by sunset (t) 6. s Modus ponens using (4) and (5)
• We will be home by sunset (t)
7. s → t Hypothesis

8. t Modus ponens using (6) and (7)

2.23
Logics (cont.)
Fallacies
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Definition
Fallacies (ngụy biện) resemble rules of inference but are based on
contingencies rather than tautologies.
Contents

Predicate Logic
Example Exercise

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.
Is [(p → q) ∧ q] → p a tautology?

2.24
Logics (cont.)
Rules of Inference for Quantified Statements
Huynh Tuong Nguyen,
Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Rule of Inference Name


∀xP (x)
Universal instantiation
∴ P (c)
(Cụ thể hóa phổ quát) Contents

Predicate Logic
P (c)for an arbitrary c
Universal generalization Exercise
∴ ∀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.25
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
Example

• A student in this class has not gone to class


• Everyone in this class passed the first exam
• Someone who passed the first exam has not gone to class
Contents

Predicate Logic

Hint Exercise

• C(x): x is in this class


• B(x): x has gone to class
• P (x): x passed the first exam
• Premises???

2.26
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

1. ∃x(C(x) ∧ ¬B(x)) Premise


2. C(a) ∧ ¬B(a) Existential instantiation from (1)
3. C(a) Simplification from (2)
4. ∀x(C(x) → P (x)) Premise Contents

5. C(a) → P (a) Universal instantiation from (4) Predicate Logic

6. P (a) Modus ponens from (3) and (5) Exercise

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.27
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Given the predicate p(x) :00 x2 − 3x + 2 = 000 . What is the truth


value (chân trị) of the following propositions:
a) p(0)
Contents
b) p(1) Predicate Logic

c) p(2) Exercise

d) ∃x, p(x)
e) ∀x, p(x)

2.28
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Let x, y ∈ Z+ , and the predicate: p(x, y): "x is a divisor of y"


Determine the truth value of the following propositions:
a) p(2, 3)
b) p(2, 6)
Contents
c) ∀y, p(1, y)
Predicate Logic
d) ∀x, p(x, x) Exercise

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
Logics (cont.)
Provided that: Huynh Tuong Nguyen,
Nguyen An Khuong,
• F (x, y) : x is father of y, Tran Tuan Anh, Le
Hong Trang, Nguyen
• M (x, y) : x is mother of y, Tien Thinh

• 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,
• O(x, y) : x is elder than y. Contents

Predicate Logic
Express each of these statements using predicates: Exercise

a) ‘He (a person) has an elder sister and younger brother’.


b) ‘All of her brothers are younger than her’.
c) ‘Thuyen has only one husband’ (Thuyen is a private name).
d) ‘One of his sisters is younger than him’.
e) ‘Everyone has grandfather, grandmother, maternal
grandfather, maternal grandmother’.
f) ‘A father of a person cannot be a mother of other ones’.

2.30
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Solutions: Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
a) ‘He (a person) has an elder sister and younger brother’.
∃x∃y(S(x, m) ∧ O(x, m) ∧ B(y, m) ∧ ¬O(y, m)).
b) ‘All of her brothers are younger than her’.
∀x(B(x, m) → ¬O(x, m)).
c) ‘Thuyen has only one husband’ (Thuyen is a private name). Contents
∃x∀y H(x, Thuyen) ∧ H(y, Thuyen) → (x = y) Predicate Logic
or ∃x∀y H(x, Thuyen) ∧ (x 6= y) → ¬H(y, Thuyen). Exercise

d) ‘One of his sisters is younger than him’.


∃x∀y(S(x, m) ∧ ¬O(x, m) ∧ S(y, m) ∧ (x 6= y) → O(y, m)).
e) ‘Everyone has grandfather, grandmother, maternal
grandfather, maternal grandmother’. ∀x∃y∃z∃y1 ∃y2 ∃z1 ∃z2
(F (y, x)∧M (z, x)∧F (y1 , y)∧M (y2 , y)∧F (z1 , z)∧M (z2 , z)).
f) ‘A father of a person cannot be a mother of other ones’.
∃x∃y∀z(F (x, y) → ¬M (x, z)).

2.31
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Translating the following nested quantifiers:

a) B(c, m) ∧ (O(c, m) ∨ O(m, c)).


b) B(c, m) ∧ F (a, m) → O(a, c) ∧ F (a, c). Contents

Predicate Logic
c) ∀x∀y(S(x, m) ∧ B(c, y) → x = y). Exercise

d) ∃x((S(x, m) ∨ H(c, x)) ∨ ∃x(H(x, m) ∧ O(x, m))).


e) ∀x∀y(S(x, m) ∧ S(y, m) → O(x, y) ∨ O(y, x))

2.32
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Solutions: Hong Trang, Nguyen
Tien Thinh

a) B(c, m) ∧ (O(c, m) ∨ O(m, c)).


c is a brother (elder/younger) of m.
b) B(c, m) ∧ F (a, m) → O(a, c) ∧ F (a, c).
If c is a brother of m and a is a father of m, then a is elder
than c and a is the father of c. Contents

Predicate Logic
c) ∀x∀y(S(x, m) ∧ B(c, y) → x = y).
Exercise
Whoever is the sister of m, then c is also a brother of that
person.
d) ∃x((S(x, m) ∨ H(c, x)) ∨ ∃x(H(x, m) ∧ O(x, m))).
There is a sister of m or c is her husband, or there is a
husband of m and elder than m.
e) ∀x∀y(S(x, m) ∧ S(y, m) → O(x, y) ∨ O(y, x))
All of the sisters of m are older or younger together.

2.33
Logics (cont.)

Huynh Tuong Nguyen,


Given a predicate N (x) "x has been to Da Lat" with the domain Nguyen An Khuong,
Tran Tuan Anh, Le
is the all students in Mathematics class. Translate the following Hong Trang, Nguyen
Tien Thinh
predicates into English
a) ∃xN (x)
b) ∀xN (x)
c) ¬∃xN (x)
d) ∃x¬N (x) Contents

Predicate Logic
e) ¬∀xN (x) Exercise

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
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Given the predicate N (x) "x studies more than 5 hours in class Tien Thinh

every weekday" with the domain is the all students in


Mathematics class. Express the following predicates:
a) ∃xN (x)
b) ∀xN (x)
Contents
c) ∃x¬N (x)
Predicate Logic
d) ∀x¬N (x) Exercise

a) There is a student who studies in the class over 5 hours in class every
weekday.
b) All of the students in Math class study over 5 hours every weekday.
c) There is a student who does not study in the class over 5 hours every
weekday.
d) There are no student studies in the class over 5 hours every weekday.

2.35
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
Hãy cho biết công thức vị từ của đoạn mã giả (pseudo code) sau:

for (i = 0; i<numObjects; i++) {


Object x = Objects(i);
if isMushroom(x) Contents
if isPoisonous(x) && isPurple(x) Predicate Logic
return false; Exercise

}
return true;

• There are no mushrooms that are poisonous and purple.


• ∀xM ushroom(x) → ¬(P oisonous(x) ∧ P urple(x))

2.36
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Hãy cho biết công thức vị từ của đoạn mã giả (pseudo code) sau:

for (i=0; i<numObjects; i++) {


Object x = Objects(i);
if isMushroom(x) && isPoisonous(x) && isPurple(x) Contents

return true; Predicate Logic

} Exercise

return false;

• There is a mushroom that is purple and poisonous.


• ∃xM ushroom(x) ∧ P oisonous(x) ∧ P urple(x)

2.37
Logics (cont.)

Huynh Tuong Nguyen,


Cho đoạn mã giả (pseudo code) sau: Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

//— Look for first match


for (x=0; x<numKids; x++)
if isParent(Peter, kids[x])
match1Found = true;
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;

return match1Found && match2Found;


Biết rằng: Mảng kids gồm 3 phần tử: { Alice, Bob, Charles } và
Peter chỉ có 1 con là Alice.
Hãy cho biết công thức vị từ của câu "Peter có ít nhất 2 con".
∃x∃y(P arentOf (P eter, x) ∧ P arentOf (P eter, y) ∧ ¬(x = y))

2.38
Logics (cont.)

Huynh Tuong Nguyen,


Cho P(x) là câu "x nói được tiếng Nga" và Q(x) là câu "x biết Nguyen An Khuong,
Tran Tuan Anh, Le
ngôn ngữ Java". Hong Trang, Nguyen
Tien Thinh
Hãy diễn đạt các câu sau bằng cách dùng P(x), Q(x), các lượng
từ và các liên từ logic.
Cho không gian đối với các lượng từ là tập hợp tất cả sinh viên ở
trường bạn.
a) Có một sinh viên ở trường bạn nói được tiếng Nga và biết Java.
Contents
b) Có một sinh viên ở trường bạn nói được tiếng Nga nhưng không biết
Predicate Logic
Java.
Exercise
c) Mọi sinh viên ở trường bạn đều nói được tiếng Nga hoặc biết Java.
d) Không có một sinh viên nào ở trường bạn nói được tiếng Nga hoặc biết
Java.

a) ∃x(P (x) ∧ Q(x))


b) ∃x(P (x) ∧ ¬Q(x))
c) ∀x(P (x) ∨ Q(x))
d) ∀x¬(P (x) ∧ Q(x))

2.39
Cho L(x,y) là câu "x yêu y", với không gian của cả x và y là tập Logics (cont.)

hợp mọi người trên thế giới. Hãy dùng các lượng từ để diễn đạt Huynh Tuong Nguyen,
Nguyen An Khuong,
các câu sau Tran Tuan Anh, Le
Hong Trang, Nguyen
a) Mọi người đều yêu Jerry. Tien Thinh
b) Mọi người đều yêu một ai đó.
c) Có một người mà tất cả mọi người đều yêu.
d) Không có ai yêu tất cả mọi người.
e) Có một người mà Lydia không yêu.
f) Có một người mà không ai yêu.
g) Có đúng một người mà tất cả mọi người đều yêu.
h) Có đúng hai người mà Lynn yêu. Contents
i) Mọi người đều yêu chính mình. Predicate Logic
j) Có một người nào đó không yêu ai ngoài chính mình. Exercise

a) ∀xL(x, Jerry)
b) ∀x∃yL(x, y)
c) ∃y∀xL(x, y)
d) ¬(∃x(∀yL(x, y)), ¬(∃x(∧y L(x, y)) hoặc ∀x¬(∧y L(x, y))
e) ∃x¬L(Lydia, x)
f) ∃x∀y¬L(x, y)
g) ∃x(∀yL(x, y) ∧ ∀z((∀wL(w, z)) → z = x))
h) ∃x∃y(x 6= y ∧ L(Lynn, x) ∧ L(Lynn, y) ∧ ∀z(L(Lynn, z) →
(z = x ∨ z = y)))
i) ∀xL(x, x)
j) ∃x∀y(L(x, y) → x = y) 2.40
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Cho các vị từ: Tran Tuan Anh, Le
Hong Trang, Nguyen
. -P(x): "x là một vấn đề toán học". Tien Thinh

. -Q(x): "x khó" (theo một tiêu chuẩn được định nghĩa tốt
nào đó).
. -R(x): "x dễ" (theo một tiêu chuẩn được định nghĩa tốt nào
đó - giống như trên).
. -S(x): "x không thể giải được". Contents

Diễn giải những công thức vị từ sau dưới dạng ngôn ngữ tự nhiên Predicate Logic

Exercise
a) ∀x(P (x) → (Q(x) ⇐⇒ ¬R(x)))
b) ∃x(S(x) ∧ ¬P (x))
Vì có nhiều cách diễn đạt một công thức vị từ dưới dạng ngôn
ngữ tự nhiên và sau đây là một cách
a) Nếu x là một vấn đề toán học thì x là bài toán khó tương
đương với x không dễ.
b) Có vấn đề không toán học không thể giải được

2.41
Logics (cont.)

Huynh Tuong Nguyen,


Dịch các bản mô tả sau đây sang tiếng Việt trong đó F (p) là Nguyen An Khuong,
Tran Tuan Anh, Le
“Máy in p bị hỏng”, Hong Trang, Nguyen
Tien Thinh
B(p) là “Máy in p đang bận in tài liệu khác”,
L(j) là “Việc in j đã bị mất”,
và Q(j) là “Việc in j đang trong hàng đợi.”
a) ∃p(F (p) ∧ B(p)) → ∃jL(j)
b) ∀pB(p) → ∃jQ(j) Contents

c) ∃j(Q(j) ∧ L(j)) → ∃pF (p) Predicate Logic

Exercise
d) (∀pB(p) ∧ ∀jQ(j)) → ∃jL(j)
a) Nếu có một máy in nào đó bị hỏng trong khi đang bận in tài liệu thì
chắc chắn sẽ có tài liệu bị mất.
b) Nếu tất cả máy in đều đang bận in tài liệu thì sẽ có tài liệu đang đợi
được in.
c) Nếu một tài liệu đang được đợi in nhưng lại bị mất, chứng tỏ có máy in
nào đó đã bị hỏng.
d) Khi tất cả các máy in đều đang bận in tài liệu khác, mà tất cả các công
việc in vẫn phải chờ, thì sẽ có một việc in nào đó bị mất.

2.42
Logics (cont.)

Chuyển các câu sau sang vị từ, lượng từ và toán tử logic: Huynh Tuong Nguyen,
Nguyen An Khuong,
a) Không có ai là hoàn hảo. Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh
b) Không phải mọi người đều hoàn hảo.
c) Tất cả bạn bè của bạn đều hoàn hảo.

d) Ít nhất có một đứa bạn của bạn là hoàn hảo.


e) Mọi người đều là bạn của bạn và họ hoàn hảo.
f) Không phải tất cả mọi người là bạn của bạn hoặc có ai đó không hoàn
hảo. Contents

Predicate Logic
C(x): x là hoàn hảo.
Exercise
D(x): x là bạn của bạn.
E(x): x là bất kỳ người nào khác.
a) ¬∃xC(x)
b) ∃x¬C(x)
c) ∀xD(x) → C(x)
d) ∃x∀y(D(x) ∧ D(y) ∧ (x 6= y)) → C(x) =⇒ ∃y(D(y) → C(y))
e) ∀x(D(x) ∧ C(x))
f) ∀x∃y(D(y) ∧ (y 6= x) ∨ ¬C(y)) =⇒ ¬∀xD(x) ∨ ∃yC(y)

2.43
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Cho các vị từ sau: Hong Trang, Nguyen
Tien Thinh
- P(x): Chương trình x đáp ứng chuẩn ABET.
- Q(x,y): Chương trình x có mục tiêu đào tạo giống chương
trình y.
- R(x): Kết quả đầu ra của chương trình x là có thể kiểm
chứng được.
Contents
Mệnh đề vị từ nào sau biểu diễn câu : "Mọi chương trình đào tạo
Predicate Logic
nếu có mục tiêu giống một chương trình khác đã đáp ứng chuẩn
Exercise
ABET và kết quả đầu ra có thể kiểm chứng được thì cũng tuân
theo chuẩn ABET"
A) ∀x(P (x) ∧ ¬Q(x)) → ∃x(R(x))
B) ∀x(∃y(Q(x, y) ∧ P (y) ∧ R(x)) → P (x))
C) ∀x(∃y(Q(x, y) ∧ P (y) ∧ R(x)) → P (x) ∨ R(x))
D) ∀x(∀y(Q(x, y) ∧ P (y) ∨ R(x)) → P (x))

2.44
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Tran Tuan Anh, Le
Hong Trang, Nguyen
Tien Thinh

Trong câu hỏi này giả sử các vị từ:


- P (x, y): x là phụ huynh của y.
- M (x): x là nam giới .
Nếu ta cho:
F (v, w) = M (v) ∧ ∃x∃y(P (x, y) ∧ P (x, v) ∧ (y 6= v) ∧ P (y, w)), Contents

thì F (v, w) có nghĩa là Predicate Logic

Exercise
A) v là anh của w
B) v là cháu trai của w
C) v là chú của w
D) v là ông của w

2.45
Logics (cont.)

Huynh Tuong Nguyen,


Nguyen An Khuong,
Chuyển các câu sau sang vị từ, lượng từ và toán tử logic: Tran Tuan Anh, Le
Hong Trang, Nguyen
a) Khi ổ cứng còn ít hơn 30 GB, một thông điệp cảnh báo sẽ Tien Thinh

được gửi tới mọi người dùng.


b) Không được sao lưu hệ thống tập tin nếu có một người nào
đó đang đăng nhập vào hệ thống.
c) Đoạn phim Youtube sẽ được buffer khi còn ít nhất 8 MB bộ
nhớ và tốc độ đường tuyền tối thiểu là 56 kbits/s. Contents

Predicate Logic
d) Chỉ vài sinh viên máy tính lập trình tốt. Exercise

e) Không một sinh viên máy tính nào không cần cù.
f) Không phải tất cả các sinh viên máy tính đều thông minh.
g) Tất cả người Pompei hoặc trung thành với Caesar hoặc ghét
ông ta.
h) Mỗi người đều trung thành với một người nào đó.
i) Người ta chỉ muốn ám sát những nhà cầm quyền mà người ta
không trung thành.

2.46

You might also like