Logics (Cont.) : Discrete Structures For Computing On 08 March 2011
Logics (Cont.) : Discrete Structures For Computing On 08 March 2011
Chapter 2
Logics (cont.)
Discrete Structures for Computing on 08 March 2011
2.2
Logics (cont.)
Limits of Propositional Logic
Huynh Tuong Nguyen,
Tran Huong Lan
x>3
All square numbers are not prime numbers. 100 is a square
number. Therefore 100 is not a prime number.
2.3
Logics (cont.)
Predicates
Huynh Tuong Nguyen,
Tran Huong Lan
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 (mnh ).
Example:
x > 3 (predicate)
5 > 3 (proposition)
2 > 3 (proposition)
2.4
Logics (cont.)
Predicates
Huynh Tuong Nguyen,
Tran Huong Lan
x > 3 P (x)
5 > 3 P (5)
A predicate with n variables P (x1 , x2 , ..., xn )
2.5
Logics (cont.)
Truth value
Huynh Tuong Nguyen,
Tran Huong Lan
2.6
Logics (cont.)
Quantifiers
Huynh Tuong Nguyen,
Tran Huong Lan
: Universal Vi mi
xP (x) = P (x) is T for all x
: Existential Tn ti
xP (x) = There exists an element x such that P (x) is T
We need a domain of discourse for variable
2.7
Logics (cont.)
Example
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?
Example
What is the truth value of the quantification xP (x), where the
domain consists of all real number?
2.8
Logics (cont.)
Example
Express the statement Some student in this class comes from
Central Vietnam.
Solution 1
Solution 2
2.9
Logics (cont.)
Negation of Quantifiers
Huynh Tuong Nguyen,
Tran Huong Lan
Example
2.10
Logics (cont.)
Another Example
Huynh Tuong Nguyen,
Tran Huong Lan
Example
Translate these:
All lions are fierce.
Some lions do not drink coffee.
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.11
Logics (cont.)
The Order of Quantifiers
Huynh Tuong Nguyen,
Tran Huong Lan
Example
x y (x + y = y + x)
T for all x, y R
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 Huong Lan
Example
x (C(x) y (C(y) F (x, y)) )
Provided that:
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
Huynh Tuong Nguyen,
Tran Huong Lan
Example
xyz (((F (x, y) F (x, z) (y 6= z)) F (y, z)))
Provided that:
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
Huynh Tuong Nguyen,
Tran Huong Lan
Example
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
Huynh Tuong Nguyen,
Tran Huong Lan
Example
Every people has one best friend.
Solution
Assume:
B(x, y) : y is the best friend of x
We have:
xyz(B(x, y) ((y 6= z) B(x, z)))
2.16
Logics (cont.)
Translating into Logical Expressions
Huynh Tuong Nguyen,
Tran Huong Lan
Example
If a person is a woman and a parent, then this person is mother of
some one.
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
Huynh Tuong Nguyen,
Tran Huong Lan
Example
2.18
Logics (cont.)
Propositional Rules of Inferences
Huynh Tuong Nguyen,
Tran Huong Lan
2.19
Logics (cont.)
Propositional Rules of Inferences
Huynh Tuong Nguyen,
Tran Huong Lan
2.20
Logics (cont.)
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
tomorrow. Therefore, if it rains today, then we will have a
barbecue tomorrow.
Solution
p: It is raining today
q: We will not have a barbecue today
r: We will have barbecue tomorrow
pq
qr
pr
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
it is sunny
4. r Modus tollens using (2) and (3)
If we do not go swimming, then
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
2.22
Logics (cont.)
Fallacies
Huynh Tuong Nguyen,
Tran Huong Lan
Definition
Fallacies (ngy bin) resemble rules of inference but are based on
contingencies rather than tautologies.
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
Huynh Tuong Nguyen,
Tran Huong Lan
2.24
Logics (cont.)
Example
Hint
2.25
Logics (cont.)
2.26
Logics (cont.)
Introduction
Huynh Tuong Nguyen,
Tran Huong Lan
Definition
A proof is a sequence of logical deductions from
- axioms, and
- previously proved theorems
that concludes with a new theorem.
2.27
Logics (cont.)
Terminology
Huynh Tuong Nguyen,
Tran Huong Lan
2.28
Logics (cont.)
2.29
Logics (cont.)
Proving a Theorem
Huynh Tuong Nguyen,
Tran Huong Lan
2.30
Logics (cont.)
Methods of Proof
Huynh Tuong Nguyen,
Tran Huong Lan
2.31
Logics (cont.)
Direct Proofs
Huynh Tuong Nguyen,
Tran Huong Lan
Definition
A direct proof shows that p q is true by showing that if p is
true, then q must also be true.
Example
2.32
Logics (cont.)
Proof by Contraposition
Huynh Tuong Nguyen,
Tran Huong Lan
Definition
p q can be proved by showing (directly) that its contrapositive,
q p, is true.
Example
2.33
Logics (cont.)
Proofs by Contradiction
Huynh Tuong Nguyen,
Tran Huong Lan
Definition
p is true if if can show that p (r r) is true for some
proposition r.
Example
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
Huynh Tuong Nguyen,
Tran Huong Lan
2.35
Logics (cont.)
Mathematical Induction
Huynh Tuong Nguyen,
Tran Huong Lan
Definition (Induction)
To prove that P (n) is true for all positive integers n, where P (n)
is a propositional function, we complete two steps:
Basis Step: Verify that P (1) is true.
Inductive Step: Show that the conditional statement
P (k) P (k + 1) is true for all positive integers k
Logic form:
[P (1) kP (k) P (k + 1))] nP (n)
2.36
Logics (cont.)
Example on Induction
Huynh Tuong Nguyen,
Example Tran Huong Lan
n(n + 1)
1 + 2 + ... + n = .
2
Solution
Let P (n) be the proposition that sum of first n is n(n + 1)/2
1(1+1)
Basis Step: P (1) is true, because 1 = 2
Inductive Step:
k(k+1)
Assume that 1 + 2 + . . . + k = 2
.
Then:
k(k + 1)
1 + 2 + . . . + k + (k + 1) = + (k + 1)
2
k(k + 1) + 2(k + 1)
=
2
(k + 1)(k + 2)
=
2
Example
Prove that n < 2n for all positive integers n.
Solution
Let P (n) be the proposition that n > 2n .
Basis Step: P (1) is true, because 1 > 21 = 2
Inductive Step:
Assume that P (k) is true for the positive k, that is, k < 2k .
Add 1 to both side of k < 2k , note that 1 2k .
k + 1 < 2k + 1 2k + 2k = 2 2k = 2k+1 .
2.38