0% found this document useful (0 votes)
2 views45 pages

DS2 PredicateLOGIC

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)
2 views45 pages

DS2 PredicateLOGIC

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/ 45

MATHEMATICAL LOGICS- Predicate Logic

MATHEMATICAL
LOGICS-
Predicate Logic

Chapter 2 Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦
MATHEMATICAL LOGICS-
Predicate Logic Contents

Predicate Logic

Predicate Logic to
Discrete Structures for Computing on January 11, 2024 Logical Inference

Exercise
Tran Tuan Anh†,
Nguyen An Khuong†,
Man Nguyen♦
Faculty of Computer Science and Engineering
† University of Technology - VNUHCM
[email protected]
♦ MUSC, Thailand
2.1
MATHEMATICAL LOGICS- Predicate Logic
Contents

MATHEMATICAL
Contents LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦

1 Predicate Logic Contents

Predicate Logic

Predicate Logic to
Logical Inference
2 Predicate Logic to Logical Inference
Exercise

3 Exercise

2.2
MATHEMATICAL LOGICS- Predicate Logic
Contents

MATHEMATICAL
Course outcomes LOGICS-
Predicate Logic
Course learning outcomes Tran Tuan Anh†,
Nguyen An
Khuong†,
L.O.1 Understanding of logic and discrete structures Man Nguyen♦
L.O.1.1 – Describe definition of predicate logic
L.O.1.2 – Define basic discrete structures: set, map, graph Contents
L.O.2 Represent & model practical problems with discrete structures
Predicate Logic
L.O.2.1 – Logically describe KEY problems in Computing
Predicate Logic to
L.O.2.2 – Use proving methods: contrapositive, induction Logical Inference
L.O.2.3 – Explain problem modeling using discrete structures
Exercise
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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Limits of Propositional Logic LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦

Contents
• x>3 Predicate Logic
• All square numbers are not prime numbers. Predicate Logic to
Logical Inference
100 is a square number.
Exercise
Therefore 100 is not a prime number.

2.4
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Predicates LOGICS-
Predicate Logic

Tran Tuan Anh†,


Definition Nguyen An
Khuong†,
A predicate (vị từ) is a statement containing one or more Man Nguyen♦

variables. If values are assigned to all the variables in a


predicate, the resulting statement is a proposition . Contents

Predicate Logic

• x > 3 → P (x) Predicate Logic to


Logical Inference
• 5 > 3 → P (5) Exercise

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


Example:
• x > 3 (predicate)
• 5 > 3 (proposition)
• 2 > 3 (proposition)
2.5
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Truth value LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦

• x > 3 is true or false? Contents

• 5>3 Predicate Logic

Predicate Logic to
Logical Inference
• For every number x, x > 3 holds Exercise

• There is a number x such that x > 3

2.6
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Quantifiers LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦
• ∀: Universal – Với mọi
• ∀xP (x) = P (x) is T for all x Contents

Predicate Logic

• ∃: Existential – Tồn tại Predicate Logic to


Logical Inference
• ∃xP (x) = There exists an element x such that P (x) is Exercise
T

• We need a domain of discourse for variable

2.7
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
LOGICS-
Example Predicate Logic

Let P (x) be the statement “x < 2”. Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦
What is the truth value of the quantification ∀xP (x),
where the domain consists of all real number? Contents

Predicate Logic
• P (3) = 3 < 2 is false
Predicate Logic to
• ⇒ ∀xP (x) is false Logical Inference

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.8
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
LOGICS-
Example Predicate Logic

Tran Tuan Anh†,


Express the statement "Some student in this class comes Nguyen An
Khuong†,
from Central Vietnam." Man Nguyen♦

Solution 1 Contents

Predicate Logic
• M (x) = x comes from Central Vietnam
Predicate Logic to
• Domain for x is the students in the class Logical Inference

Exercise
• ∃xM (x)

Solution 2
• Domain for x is all people
• ...

2.9
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Negation of Quantifiers LOGICS-
Predicate Logic
Statement Negation Equivalent form Tran Tuan Anh†,
Nguyen An
∀xP (x) ¬(∀xP (x)) ∃x¬P (x) Khuong†,
Man Nguyen♦

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


Contents

Predicate Logic
Example
Predicate Logic to
Logical Inference
• All CSE students study Discrete Math 1 Exercise
• 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.10
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Another Example LOGICS-
Predicate Logic
Example Tran Tuan Anh†,
Nguyen An
Translate these: Khuong†,
Man Nguyen♦
• All lions are fierce.
• Some lions do not drink coffee. Contents

Predicate Logic
• Some fierce creatures do not drink coffee.
Predicate Logic to
Logical Inference

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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
The Order of Quantifiers LOGICS-
Predicate Logic
• The order of quantifiers is important, unless all the Tran Tuan Anh†,
quantifiers are universal quantifiers or all are existential Nguyen An
Khuong†,
quantifiers Man Nguyen♦

• Read from left to right, apply from inner to outer


Contents

Predicate Logic
Example
Predicate Logic to
Logical Inference
∀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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Translating Nested Quantifiers (I) LOGICS-
Predicate Logic

Tran Tuan Anh†,


Example Nguyen An
Khuong†,
Man Nguyen♦
∀x (C(x) ∨ ∃y (C(y) ∧ F (x, y)) )
Provided that: Contents
• C(x): x has a computer, Predicate Logic

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


Logical Inference

• x, y ∈ all students in your school. Exercise

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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Translating Nested Quantifiers (II) LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Example Khuong†,
Man Nguyen♦

∃x∀y∀z (((F (x, y) ∧ F (x, z) ∧ (y ̸= z)) → ¬F (y, z)))


Provided that: Contents

Predicate Logic
• F (x, y): x, y are friends
Predicate Logic to
• x, y, z ∈ all students in your school. Logical Inference

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.14
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Translating statements into Logical Expressions (I) LOGICS-
Predicate Logic
Example Tran Tuan Anh†,
Nguyen An
1 “There is a student in the class has visited Hanoi”. Khuong†,
Man Nguyen♦

2 “Every student in the class has visited Nha Trang or


Vung Tau”. Contents

Predicate Logic

Predicate Logic to
Answer Logical Inference

Assume: Exercise

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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Translating statements into Logical Expressions (II) LOGICS-
Predicate Logic
Example Tran Tuan Anh†,
Nguyen An
If a person is a woman and a parent, then this person is Khuong†,
Man Nguyen♦
mother of someone.
Solution: We define: Contents

Predicate Logic
• W (x) : x is woman
Predicate Logic to
• P (x) : x is a parent Logical Inference

• M (x, y): x is mother of y Exercise

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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic

MATHEMATICAL
Translating statements into Logical Expressions (III) LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦
Example
Contents
"Every people has only one best friend."
Predicate Logic
Assume:
Predicate Logic to
• B(x, y) : y is the best friend of x Logical Inference

Exercise

Solution
∀x ∃y ∀z [B(x, y) ∧ ((y ̸= z) → ¬B(x, z))]

2.17
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Logical Inference LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Example Khuong†,
Man Nguyen♦
• If I have a girlfriend, I will take her to go shopping.
• Whenever I and my girlfriend go shopping and that day Contents

Predicate Logic
is a special day, I will surely buy her some expensive gift.
Predicate Logic to
• If I buy my girlfriend expensive gifts, I will eat noodles Logical Inference

for a week. Exercise

• 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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Propositional Rules of Inferences (I) LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Rule of Inference Name Khuong†,
Man Nguyen♦
p
p→q
Contents
∴q Modus ponens
Predicate Logic
¬q
Predicate Logic to
p→q Logical Inference
∴ ¬p Modus tollens Exercise
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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Propositional Rules of Inferences (II) LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Rule of Inference Name Man Nguyen♦

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

2.20
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Example LOGICS-
Predicate Logic

If it rains today, then we will not have a barbecue today. Tran Tuan Anh†,
Nguyen An
If we do not have a barbecue today, then we will have a Khuong†,
Man Nguyen♦
barbecue tomorrow.
Therefore, if it rains today, then we will have a barbecue Contents
tomorrow. Predicate Logic

Predicate Logic to
Solution Logical Inference

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 . This is Hypothetical syllogism
2.21
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
LOGICS-
Predicate Logic
Example
Tran Tuan Anh†,
1. ¬p ∧ q Hypothesis Nguyen An
• It is not sunny this afternoon Khuong†,
Man Nguyen♦
(¬p) and it is colder than 2. ¬p Simplification using (1)
yesterday (q)
Contents
• We will go swimming (r) only 3. r → p Hypothesis
Predicate Logic
if it is sunny
• If we do not go swimming, 4. ¬r Modus tollens Predicate Logic to
Logical Inference
using (2) and (3)
then we will take a canoe trip Exercise
(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.22
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Fallacies LOGICS-
Predicate Logic

Tran Tuan Anh†,


Definition Nguyen An
Khuong†,
Man Nguyen♦
Fallacies (ngụy biện) resemble rules of inference but are
based on contingencies rather than tautologies.
Contents

Predicate Logic
Example
Predicate Logic to
Logical Inference
If you do correctly every questions in mid-term exam, you
Exercise
will get 10 grade.
You got 10 grade.
Therefore, you did correctly every questions in mid-term
exam.

Q: Is [(p → q) ∧ q] → p a tautology? Say for any p, q?


2.23
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Rules of Inference for Quantified Statements LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Rule of Inference Name Khuong†,
Man Nguyen♦
∀xP (x)
Universal instantiation Contents
∴ P (c)
(Cụ thể hóa phổ quát) Predicate Logic

P (c)for an arbitrary c Predicate Logic to


Logical Inference
Universal generalization
∴ ∀xP (x) Exercise
(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
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Reasoning with Premises and Rules of Inference LOGICS-
Predicate Logic

Example Tran Tuan Anh†,


Nguyen An
Khuong†,
• A student in this class has not gone to class ≡ α Man Nguyen♦

• Everyone in this class passed the first exam ≡ β


Contents
• Someone who passed the first exam has not gone to
Predicate Logic
class ≡ γ? Predicate Logic to
Logical Inference

Exercise
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.25
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference

MATHEMATICAL
Solution of the last example LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
1. α = ∃x(C(x) ∧ ¬B(x)) Premise Khuong†,
Man Nguyen♦
2. C(a) ∧ ¬B(a) Existential instantiation from (1)
3. C(a) Simplification from (2) Contents
4. β = ∀x(C(x) → P (x)) Premise Predicate Logic

Predicate Logic to
5. C(a) → P (a) Universal instantiation Logical Inference

Exercise
from Premise (4)
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
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise A LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Given the predicate p(x) :′′ x2 − 3x + 2 = 0′′ . Man Nguyen♦

What is the truth value (chân trị) of the following Contents

propositions: Predicate Logic

Predicate Logic to
a) p(0) Logical Inference

b) p(1) Exercise

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

2.27
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise B LOGICS-
Predicate Logic

Let x, y ∈ Z+ , and Tran Tuan Anh†,


Nguyen An
the predicate: p(x, y): "x is a divisor of y" Khuong†,
Man Nguyen♦

Determine the truth value of the following propositions:


Contents
a) p(2, 3) Predicate Logic

b) p(2, 6) Predicate Logic to


Logical Inference
c) ∀y, p(1, y) Exercise

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.28
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise C- Provided that: LOGICS-
Predicate Logic
• F (x, y) : x is father of y, M (x, y) : x is mother of y,
Tran Tuan Anh†,
• S(x, y) : x is sister of y, B(x, y) : x is brother of y, Nguyen An
Khuong†,
• H(x, y) : x is spouse (wife/husband) of y, Man Nguyen♦

• O(x, y) : x is elder than y.


Contents

Predicate Logic
Express each of these statements using predicates:
Predicate Logic to
Logical Inference
a) ‘He (a person) has an elder sister and younger brother’.
Exercise
b) ‘All of her brothers are younger than her’.
c) ‘Jane has only one husband’ (Jane - 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.29
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Solutions: LOGICS-
Predicate Logic

Tran Tuan Anh†,


a) ‘He (a person) has an elder sister and younger brother’. Nguyen An
∃x∃y(S(x, m) ∧ O(x, m) ∧ B(y, m) ∧ ¬O(y, m)). Khuong†,
Man Nguyen♦

b) ‘All of her brothers are younger than her’.


∀x(B(x, m) → ¬O(x, m)). Contents

Predicate Logic
c) ‘Jane has only one husband’
Predicate Logic to
∃x∀y H(x, Jane) ∧ H(y, Jane) → (x = y) Logical Inference

or ∃x∀y H(x, Jane) ∧ (x ̸= y) → ¬H(y, Jane). Exercise

d) ‘One
 of his sisters is younger than him’. ∃x ∀y 
S(x, m) ∧ ¬O(x, m) ∧ S(y, m) ∧ (x ̸= y) → O(y, m) .
e) DIY
f) ‘A father of a person cannot be a mother of other
ones’. ∃x∃y∀z(F (x, y) → ¬M (x, z)).
2.30
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise D LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Khuong†,
Translating the following nested quantifiers: Man Nguyen♦

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

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

Predicate Logic to
Logical Inference
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.31
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Solutions of D: LOGICS-
Predicate Logic
a) B(c, m) ∧ (O(c, m) ∨ O(m, c)). Tran Tuan Anh†,
c is a brother (elder/younger) of m. Nguyen An
Khuong†,
Man Nguyen♦

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


Contents
If c is a brother of m and a is a father of m, then a is
Predicate Logic
elder than c and a is the father of c.
Predicate Logic to
Logical Inference

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))).
DIY
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.32
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise E LOGICS-
Predicate Logic
Given a predicate N (x) "x has been to Da Lat" with the
Tran Tuan Anh†,
domain is the all students in Mathematics class. Nguyen An
Khuong†,
Translate the following predicates into English Man Nguyen♦

a) ∃xN (x)
Contents
b) ∀xN (x)
Predicate Logic
c) ¬∃xN (x)
Predicate Logic to
d) ∃x¬N (x) Logical Inference

Exercise
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.33
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise F LOGICS-
Predicate Logic

Tran Tuan Anh†,


Nguyen An
Given the predicate Khuong†,
Man Nguyen♦
N (x) = "x studies more than 5 hours in class every
weekday"
Contents
with the domain is the all students in Mathematics class.
Predicate Logic

Predicate Logic to
Express the following predicates by natural English Logical Inference

sentences: Exercise

a) ∃xN (x)
b) ∀xN (x)
c) ∃x¬N (x)
d) ∀x¬N (x)

2.34
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise G LOGICS-
Predicate Logic

What is the propositional formula for Tran Tuan Anh†,


Nguyen An
the following pseudo code: Khuong†,
Man Nguyen♦

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

Predicate Logic
Object x = Objects(i);
Predicate Logic to
if isMushroom(x) Logical Inference
if isPoisonous(x) && isPurple(x) Exercise

return false;
}
return true;

• There are no mushrooms that are poisonous and purple.


• ∀x, M ushroom(x) −→ ¬(P oisonous(x)∧P urple(x)).

2.35
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise H LOGICS-
Predicate Logic

Tran Tuan Anh†,


What is the propositional formula for the following pseudo Nguyen An
Khuong†,
code: Man Nguyen♦

Contents
for (i=0; i<numObjects; i++) { Predicate Logic
Object x = Objects(i); Predicate Logic to
if isMushroom(x) && isPoisonous(x) && isPurple(x) Logical Inference

Exercise
return true;
}
return false;

• There is a mushroom that is purple and poisonous.


• ∃x, M ushroom(x) ∧ P oisonous(x) ∧ P urple(x)

2.36
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise J- Giving the following pseudo code: LOGICS-
Predicate Logic
//— Look for first match Tran Tuan Anh†,
for (x=0; x<numKids; x++) Nguyen An
Khuong†,
if isParent(Peter, kids[x]) Man Nguyen♦

match1Found = true;
Contents
//— Now look for a second match
Predicate Logic
for (y=0; (y<numKids)&&(y!=x); y++)
Predicate Logic to
if isParent(Peter, kids[y]) Logical Inference

match2Found = true; Exercise

return match1Found && match2Found;


Knowing that: kids array has 3 elements: { Alice, Bob,
Charles } and Peter only have 1 child Alice.
What is the propositional formula for "Peter has at least 2
children".
∃x∃y
(P arentOf (P eter, x) ∧ P arentOf (P eter, y) ∧ ¬(x = y))
2.37
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise K LOGICS-
Predicate Logic
Let P(x) be "x can speak Russian" and
Tran Tuan Anh†,
Q(x) be "x can use Java". Formalize the following: Nguyen An
Khuong†,
Giving the space is ll students in your university. Man Nguyen♦
a) There is a student in your university that can speak Russian and
can use Java. Contents

b) There is a student in your university that can speak Russian but Predicate Logic
can’t use Java. Predicate Logic to
Logical Inference
c) Every student in your university can speak Russian or can use
Exercise
Java.
d) None of the student in your university can speak Russian or can
use 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.38
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise L (or Loving?!) LOGICS-
Predicate Logic

Let L(x,y) be "x love y", where the space of x and y is the Tran Tuan Anh†,
Nguyen An
set of all people in the world. Use logical quantifier to Khuong†,
Man Nguyen♦
express the following:
a) Everybody loves Jerry. =⇒ ∀x, L(x, Jerry)
Contents
b) Everybody loves someone.
Predicate Logic
c) There is a person who everybody loves. Predicate Logic to
Logical Inference
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.

DIY for the others.


2.39
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise M (or Doing MATHEMATICS? !) LOGICS-
Predicate Logic

Giving the following: Tran Tuan Anh†,


Nguyen An
. -P(x): "x is a math problem". Khuong†,
Man Nguyen♦
. -Q(x): "x is hard" (based on a well-defined standard).
. -R(x): "x is easy" (based on a well-defined standard).
Contents
. -S(x): "x is not solvable". Predicate Logic
Translate the following formulas to natural English Predicate Logic to
Logical Inference
a) ∀x(P (x) → (Q(x) ⇐⇒ ¬R(x)))
Exercise
b) ∃x(S(x) ∧ ¬P (x))
There are many ways to translate a formula to a 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.40
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise N (Printing in Network) LOGICS-
Predicate Logic

Tran Tuan Anh†,


Translate the following propositional formulas to natural Nguyen An
Khuong†,
English statements where: Man Nguyen♦

F (p) is “Printer p is broken”, Contents

B(p) is “Printer p is currently printing another document”, Predicate Logic

L(j) is “Printing job j is lost”, Predicate Logic to


Logical Inference
and Q(j) is “Printing job j is in queue.” Exercise

a) ∃p(F (p) ∧ B(p)) → ∃jL(j)


b) ∀pB(p) → ∃jQ(j)
c) ∃j(Q(j) ∧ L(j)) → ∃pF (p)
d) (∀pB(p) ∧ ∀jQ(j)) → ∃jL(j)

2.41
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise P (Perfectness of Human-being?) LOGICS-
Predicate Logic

Formalize the following sentences: Tran Tuan Anh†,


Nguyen An
Khuong†,
Man Nguyen♦
a) Nobody is perfect.
b) not everyone is perfect.
Contents
c) All your friends are perfect.
Predicate Logic
d) At least one of your friend is perfect. Predicate Logic to
Logical Inference
e) Everybody is your friend and they are perfect.
Exercise
f) Not everybody is your friend or there is somebody not perfect.

Giving: C(x): x is perfect.


D(x): x is your friend.
E(x): x is someone else.
ANSWER:
f) ∀x∃y(D(y) ∧ (y ̸= x) ∨ ¬C(y)) =⇒ ¬∀xD(x) ∨ ∃yC(y)
2.42
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise Q (Quality control in Education?) LOGICS-
Predicate Logic
Giving the following Predicate: Tran Tuan Anh†,
- P(x): Training Program x satisfies ABET standard. Nguyen An
Khuong†,
- Q(x,y): x has the same educational goal as program y. Man Nguyen♦

- R(x): Educational outcome from program x is verifiable.


Contents

Predicate Logic
Which of the following formalize this sentence :
Predicate Logic to
"Every program that has the same educational goal as a Logical Inference
ABET satisfied program and verifiable Educational outcome Exercise

also satisfies ABET standard"

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.43
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise R (Relationship in families?) LOGICS-
Predicate Logic

Tran Tuan Anh†,


Let: Nguyen An
Khuong†,
- P (x, y): x is parent of y. Man Nguyen♦

- M (x): x is male .
Contents

Given: F (v, w) = Predicate Logic

= M (v) ∧ ∃x∃y(P (x, y) ∧ P (x, v) ∧ (y ̸= v) ∧ P (y, w)), Predicate Logic to


Logical Inference
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.44
MATHEMATICAL LOGICS- Predicate Logic
Exercise

MATHEMATICAL
Exercise S (Summary of Chapter 1 and 2) LOGICS-
Predicate Logic
Formalize the following sentences using predicate logic:
Tran Tuan Anh†,
a) When a hard drive has less than 30GB free space, a Nguyen An
Khuong†,
warning will be issued to all the users. Man Nguyen♦

b) Do not back up the files if anyone is logging in the


Contents
system.
Predicate Logic
c) YouTube’s videos will be buffered if there are at least
Predicate Logic to
8MB memory and 56kb/s line rate. Logical Inference

Exercise
d) Few computer student is good at programming.
e) No computer student is not hard working.
f) Not all computer students are smart.
g) All the Pompeians are either loyal to or hate Caesar.
h) Everyone is loyal to someone.
i) People only want to assassinate the dictator whom they
are not loyal to. 2.45

You might also like