DS Ch2 Predicate Logic and Proving Methods Handout
DS Ch2 Predicate Logic and Proving Methods Handout
Nguyen An Khuong,
Huynh Tuong Nguyen
Chapter 2
Logics (cont.) Contents
Predicate Logic
Contents
Predicate Logic
1 Predicate Logic Proof Methods
2 Proof Methods
2.2
Logics (cont.)
Limitations of Propositional Logic
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Proof Methods
2.3
Logics (cont.)
Predicates
Nguyen An Khuong,
Definition Huynh Tuong Nguyen
Predicate Logic
• 5>3
Proof Methods
2.5
Logics (cont.)
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Let P (x) be the statement “x < 2”. What is the truth value of the
Contents
quantification ∀xP (x), where the domain consists of all real
Predicate Logic
number? Proof Methods
Example
What is the truth value of the quantification ∃xP (x), where the
domain consists of all real number?
2.6
Logics (cont.)
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Express the statement “Some student in this class comes from
Central Vietnam.” Contents
Predicate Logic
Proof Methods
Solution 1
Some problems for
discussion
• M (x) = x comes from Central Vietnam
• Domain for x is the students in the class
• ∃xM (x)
Solution 2
2.7
Logics (cont.)
Negation of Quantifiers
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
2.8
Logics (cont.)
Another Example
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Translate these: Contents
Predicate Logic
• All lions are fierce.
Proof Methods
• Some lions do not drink coffee. Some problems for
discussion
• Some fierce creatures do not drink coffee.
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.9
Logics (cont.)
The Order of Quantifiers
Nguyen An Khuong,
Huynh Tuong Nguyen
• Read from left to right, apply from inner to outer Proof Methods
Example
∀x ∃y (x + y = 0) is T, while
∃y ∀x (x + y = 0) is F
2.10
Logics (cont.)
Quantifiers plus ∧ and ∨
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Show ∀x(P (x) ∧ Q(x)) ≡ ∀xP (x) ∧ ∀xQ(x). (That is, show that
no matter what the domain is, these 2 propositions always have Contents
Proof Methods
Chứng minh.
First assume that ∀x(P (x) ∧ Q(x)) is true. So for all x, P (x) is
true and Q(x) is true. Therefore ∀xP (x) is true, and ∀xQ(x) is
true. Therefore ∀xP (x) ∧ ∀xQ(x) is true.
Now assume ∀xP (x) ∧ ∀xQ(x) is true. So ∀xP (x) is true and
∀xQ(x) is true. So for all x, P (x) is true and for all x, Q(x) is
true. Therefore, for all x, P (x) ∧ Q(x) is true. So
∀x(P (x) ∧ Q(x)) is true.
Nguyen An Khuong,
Huynh Tuong Nguyen
Proof Methods
2 The following is true though:
Some problems for
discussion
∃x(P (x) ∧ Q(x)) −→ ∃xP (x) ∧ ∃xQ(x).
2.12
Logics (cont.)
Translating Nested Quantifiers
Nguyen An Khuong,
Huynh Tuong Nguyen
Example Contents
Predicate Logic
∀x (C(x) ∨ ∃y (C(y) ∧ F (x, y)) ) Proof Methods
Provided that: Some problems for
discussion
• C(x): x has a computer,
• F (x, y): x and y are friends,
• 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.13
Logics (cont.)
Translating Nested Quantifiers
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Example
Predicate Logic
∃x∀y∀z (((F (x, y) ∧ F (x, z) ∧ (y 6= z)) → ¬F (y, z))) Proof Methods
Provided that: Some problems for
discussion
• F (x, y): x, y are friends
• 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
Logics (cont.)
Translating into Logical Expressions
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Contents
1 “There is a student in the class has visited Hanoi”.
Predicate Logic
2 “Every students in the class have visited Nha Trang or Vung Proof Methods
Answer
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
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Example Proof Methods
Every people has one and only one best friend. Some problems for
discussion
Solution
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.16
Logics (cont.)
Translating into Logical Expressions
Nguyen An Khuong,
Huynh Tuong Nguyen
Example Contents
Predicate Logic
If a person is a woman and a parent, then this person is mother of Proof Methods
some one. Some problems for
discussion
Solution
We define:
• C(x) : x is woman
• D(x) : x is a parent
• E(x, y): x is mother of y
We have: ∀x((C(x) ∧ D(x)) → ∃yE(x, y))
2.17
Logics (cont.)
Inference
Nguyen An Khuong,
Huynh Tuong Nguyen
Example Contents
Predicate Logic
• If I have a girlfriend, I will take her to go shopping. Proof Methods
• Whenever I and my girlfriend go shopping and that day is a Some problems for
discussion
special day, I will surely buy her some expensive gift.
• If I buy my girlfriend expensive gifts, I will eat noodles for a
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
Nguyen An Khuong,
Huynh Tuong Nguyen
2.19
Logics (cont.)
Propositional Rules of Inferences
Nguyen An Khuong,
Huynh Tuong Nguyen
2.20
Logics (cont.)
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
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 Contents
• 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.)
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
1. ¬p ∧ q Hypothesis Contents
• It is not sunny this afternoon
Predicate Logic
(¬p) and it is colder than 2. ¬p Simplification using (1) Proof Methods
yesterday (q)
Some problems for
• We will go swimming (r) 3. r → p Hypothesis discussion
only if it is sunny
4. ¬r Modus tollens using (2) and (3)
• If we do not go swimming,
then we will take a canoe trip 5. ¬r → s Hypothesis
(s)
• If we take a canoe trip, then 6. s Modus ponens using (4) and (5)
we will be home by sunset (t)
7. s → t Hypothesis
• We will be home by sunset
(t)
8. t Modus ponens using (6) and (7)
2.22
Logics (cont.)
Fallacies
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Definition Predicate Logic
Fallacies (ngụy biện) resemble rules of inference but are based on Proof Methods
Example
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.23
Logics (cont.)
Rules of Inference for Quantified Statements
Nguyen An Khuong,
Huynh Tuong Nguyen
Predicate Logic
∀xP (x) Proof Methods
Universal instantiation
∴ P (c) Some problems for
(Cụ thể hóa phổ quát) discussion
P (c)for an arbitrary c
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.)
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Contents
• A student in this class has not gone to class
Predicate Logic
• Everyone in this class passed the first exam Proof Methods
• Someone who passed the first exam has not gone to class Some problems for
discussion
Hint
2.25
Logics (cont.)
Nguyen An Khuong,
Huynh Tuong Nguyen
Predicate Logic
2. C(a) ∧ ¬B(a) Existential instantiation from (1)
Proof Methods
3. C(a) Simplification from (2)
Some problems for
4. ∀x(C(x) → P (x)) Premise discussion
2.26
Logics (cont.)
Introduction
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Proof Methods
2.27
Logics (cont.)
Terminology
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Proof Methods
2.28
Logics (cont.)
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Proof Methods
2.29
Logics (cont.)
Proving a Theorem
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Proof Methods
Many theorem has the form ∀xP (x) → Q(x) Some problems for
discussion
Goal:
• Show that P (c) → Q(c) is true with arbitrary c of the domain
• Apply universal generalization
⇒ How to show that conditional statement p → q is true.
2.30
Logics (cont.)
Methods of Proof
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Proof Methods
2.31
Logics (cont.)
Direct Proofs
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Definition Predicate Logic
Example
2.32
Logics (cont.)
Proof by Contraposition
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition Contents
2.33
Logics (cont.)
Proofs by Contradiction
Nguyen An Khuong,
Huynh Tuong Nguyen
Definition
p is true if if can show that ¬p → (r ∧ ¬r) is true for some Contents
Proof Methods
√
Ex.: Prove that 2 is irrational.
√
Pr.: Let p is the proposition
√ “ 2 is irrational”. Suppose
√ ¬p is true,
which means 2 is rational. If so, ∃a, b ∈ Z, 2 = a/b, a, b
have no common factors. Squared, 2 = a2 /b2 , 2b2 = a2 , so
a2 is even, and a is even, too. Because of that a = 2c, c ∈ Z.
Thus, 2b2 = 4c2 , or b2 = 2c2 , which means b2 is even and so
is b. That means 2 divides both a and b, contradict with the
assumption.
2.34
Logics (cont.)
Problem
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
Proof Methods
2.35
Logics (cont.)
Mathematical Induction
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Definition (Induction)
Predicate Logic
To prove that P (n) is true for all positive integers n, where P (n) Proof Methods
2.36
Logics (cont.)
Example on Induction
Nguyen An Khuong,
Example Huynh Tuong Nguyen
n(n + 1) Contents
1 + 2 + ... + n = .
2 Predicate Logic
Proof Methods
Example
Prove that n < 2n for all positive integers n. Contents
Predicate Logic
Proof Methods
Solution
Some problems for
Let P (n) be the proposition that n > 2n . discussion
k + 1 < 2k + 1 ≤ 2k + 2k = 2 · 2k = 2k+1 .
2.38
Logics (cont.)
On drinking in pubs
Nguyen An Khuong,
Huynh Tuong Nguyen
• Is this true?
• Or more precisely: Is this a tautology in classical predicate
logic?
• I.e. is it true independent of the domain (here pubs, people)
and the meanings of pub and to drink?
• Predicate formula:
∃x ∈ P, [D(x) −→ ∀y ∈ P, D(y)].
• Law of excluded middle (LEM): p ∨ ¬p is a tautology.
2.39
Logics (cont.)
Some MCQs
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
2.40
Logics (cont.)
Some MCQs (cont’d)
Nguyen An Khuong,
Huynh Tuong Nguyen
MCQ2
Giả sử D(x, y) là một vị từ với ý nghĩa “số nguyên y là một ước Contents
của số nguyên x.” Phát biểu nào dưới đây tương đương diễn đạt ý Predicate Logic
nghĩa của công thức Proof Methods
2.41
Logics (cont.)
Some MCQs (cont’d)
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Predicate Logic
MCQ3
Proof Methods
Which of the following are semantically and syntactically correct Some problems for
discussion
translations of “No dog bites a child of its owner”?
A. ∀xDog(x) −→ ¬Bites(x, Child(Owner(x))).
B. ¬∃x, yDog(x) ∧ Child(y, Owner(x)) ∧ Bites(x, y).
C. ∀xDog(x) −→ (∀yChild(y, Owner(x)) −→ ¬Bites(x, y)).
D. ¬∃xDog(x) −→ (∃yChild(y, Owner(x)) ∧ Bites(x, y)).
2.42
Logics (cont.)
Convert Codes to English and Predicate Formula
Nguyen An Khuong,
Huynh Tuong Nguyen
Example
Contents
Proof Methods
{
Some problems for
Object x = Objects(i); discussion
if isMushroom(i)
if isPoisonous(x) && isPurple(x)
return false;
}
return true;
2.43
Logics (cont.)
Convert Codes to English and Predicate Formula (cont’d)
Nguyen An Khuong,
Huynh Tuong Nguyen
Contents
Proof Methods
2.44