DS2 PredicateLOGIC
DS2 PredicateLOGIC
MATHEMATICAL
LOGICS-
Predicate Logic
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
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
MATHEMATICAL
Limits of Propositional Logic LOGICS-
Predicate Logic
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
Predicate Logic
MATHEMATICAL
Truth value LOGICS-
Predicate Logic
Predicate Logic to
Logical Inference
• For every number x, x > 3 holds Exercise
2.6
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic
MATHEMATICAL
Quantifiers LOGICS-
Predicate Logic
Predicate Logic
2.7
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic
MATHEMATICAL
LOGICS-
Example Predicate Logic
Predicate Logic
• P (3) = 3 < 2 is false
Predicate Logic to
• ⇒ ∀xP (x) is false Logical Inference
Exercise
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
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♦
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♦
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
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
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♦
Predicate Logic
Predicate Logic to
Answer Logical Inference
Assume: Exercise
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
MATHEMATICAL
Translating statements into Logical Expressions (III) LOGICS-
Predicate Logic
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
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
• 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
2.19
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference
MATHEMATICAL
Propositional Rules of Inferences (II) LOGICS-
Predicate Logic
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
2.22
MATHEMATICAL LOGICS- Predicate Logic
Predicate Logic to Logical Inference
MATHEMATICAL
Fallacies LOGICS-
Predicate Logic
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.
MATHEMATICAL
Rules of Inference for Quantified Statements LOGICS-
Predicate Logic
MATHEMATICAL
Reasoning with Premises and Rules of Inference LOGICS-
Predicate Logic
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
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)
MATHEMATICAL
Exercise A LOGICS-
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
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♦
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
Predicate Logic
c) ‘Jane has only one husband’
Predicate Logic to
∃x∀y H(x, Jane) ∧ H(y, Jane) → (x = y) Logical Inference
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
Predicate Logic to
Logical Inference
c) ∀x∀y(S(x, m) ∧ B(c, y) → x = y). Exercise
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♦
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
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
Predicate Logic
Object x = Objects(i);
Predicate Logic to
if isMushroom(x) Logical Inference
if isPoisonous(x) && isPurple(x) Exercise
return false;
}
return true;
2.35
MATHEMATICAL LOGICS- Predicate Logic
Exercise
MATHEMATICAL
Exercise H LOGICS-
Predicate Logic
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;
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
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.
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.
MATHEMATICAL
Exercise M (or Doing MATHEMATICS? !) LOGICS-
Predicate Logic
MATHEMATICAL
Exercise N (Printing in Network) LOGICS-
Predicate Logic
2.41
MATHEMATICAL LOGICS- Predicate Logic
Exercise
MATHEMATICAL
Exercise P (Perfectness of Human-being?) LOGICS-
Predicate Logic
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♦
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
MATHEMATICAL
Exercise R (Relationship in families?) LOGICS-
Predicate Logic
- M (x): x is male .
Contents
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♦
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