file

advertisement
CS1231
Tutorial 1
Proofs and Logic
1. Identify the mistake in each of the following statements and correct it.
a. The negation of “1 < a < 5” is “1 ≥ a ≥ 5”.
b. “P only if Q” means “if Q then P ”.
Solution:
a. A statement of the form “1 < a < 5” is short-form for “1 < a and a < 5”. Thus, by De
Morgan’s law, its negation is “1 ≥ a or a ≥ 5”.
b. “P only if Q” means that P can hold only in the situations where Q holds. This means
that if Q does not hold, then P does not hold, or equivalently, “if P holds then Q holds”,
which is written as “if P then Q” or “P → Q”.
2. Use Theorem 2.1.1 to verify the logical equivalences for the following parts. Supply a reason for
each step (eg: “by the commutative law”).
a. ∼(p ∨ ∼q) ∨ (∼p ∧ ∼q) ≡ ∼p.
b. (p ∧ ∼(∼p ∨ q)) ∨ (p ∧ q) ≡ p.
Solution:
a. ∼(p ∨ ∼q) ∨ (∼p ∧ ∼q)
≡ ∼p ∧ ∼∼q ∨ (∼p ∧ ∼q)
≡ (∼p ∧ q) ∨ (∼p ∧ ∼q)
≡ ∼p ∧ (q ∨ ∼q)
≡ ∼p ∧ true
≡ ∼p
by
by
by
by
by
b. (p ∧ (∼(∼p ∨ q))) ∨ (p ∧ q)
≡ (p ∧ (∼∼p ∧ ∼q)) ∨ (p ∧ q)
≡ (p ∧ (p ∧ ∼q)) ∨ (p ∧ q)
≡ ((p ∧ p) ∧ ∼q) ∨ (p ∧ q)
≡ (p ∧ ∼q) ∨ (p ∧ q)
≡ p ∧ (∼q ∨ q)
≡ p ∧ true
≡p
De Morgan’s law
the double negative law
the distributive law
the negation law
the identity law
by
by
by
by
by
by
by
De Morgan’s law
the double negative law
the associative law
the idempotent law
the distributive law
the negation law
the identity law
CS1231
3. If P ↔ Q is a tautology, what can be said about the relationship between P and Q? Use a truth
table to verify each tautology below.
a. (p ∧ (q ∨ r)) ↔ ((p ∧ q) ∨ (p ∧ r))
b. (p → (q → r)) ↔ ((p ∧ q) → r)
Solution: If P ↔ Q is a tautology, then P and Q are logically equivalent. Also, if P and Q
are logically equivalent, then P ↔ Q is a tautology. Thus we can determine whether P ↔ Q is
a tautology by checking whether P and Q are logically equivalent.
a.
p
T
T
T
T
F
F
F
F
q
T
T
F
F
T
T
F
F
r
T
F
T
F
T
F
T
F
q∨r
T
T
T
F
T
T
T
F
b.
p
T
T
T
T
F
F
F
F
q
T
T
F
F
T
T
F
F
r
T
F
T
F
T
F
T
F
q→r
T
F
T
T
T
F
T
T
p∧q
T
T
F
F
F
F
F
F
p∧q
T
T
F
F
F
F
F
F
p∧r
T
F
T
F
F
F
F
F
p ∧ (q ∨ r)
T
T
T
F
F
F
F
F
p → (q → r)
T
F
T
T
T
T
T
T
Page 2
(p ∧ q) ∨ (p ∧ r)
T
T
T
F
F
F
F
F
(p ∧ q) → r
T
F
T
T
T
T
T
T
CS1231
4. Some of the arguments below are valid, whereas others exhibit the converse or the inverse error.
Use symbols to write the logical form of each argument. If the argument is valid, identify the rule
of inference that guarantees its validity. Otherwise, state whether the converse or the inverse error
is made.
a. Sandra knows Java and Sandra knows C++.
∴ Sandra knows C++.
b. If at least one of these two numbers is divisible by 6, then the product of these two numbers is
divisible by 6.
Neither of these two numbers is divisible by 6.
∴ The product of these two number is not divisible by 6.
c. If there are as many rational numbers as there are irrational numbers, then the set of all
irrational numbers is infinite.
The set of all irrational numbers is infinite.
∴ There are as many rational numbers as there are irrational numbers.
d. If I get a Christmas bonus, I’ll buy a stereo.
If I sell my motorcycle, I’ll but a stereo.
∴ If I get a Christmas bonus or I sell my motorcycle, then I’ll buy a stereo.
Solution:
a.
1. Let p = (Sandra knows Java).
2. Let q = (Sandra knows C++).
3. p ∧ q. (Premise)
4. ∴ q. (Valid by specialization)
b.
1. Let p = (the first number is divisible by 6).
2. Let q = (the second number is divisible by 6).
3. Let r = (the product of these two numbers is divisible by 6).
4. p ∨ q → r. (Premise)
5. ∼p ∧ ∼q. (Premise)
6. //∴ ∼r. (Invalid; inverse error. Explicit counter-example is 2 and 3.)
(Note that such a deduction step is invalid even if there is no counter-example!)
c.
1. Let p = (there as as many rational numbers as there are irrational numbers).
2. Let q = (the set of all irrational numbers is infinite).
3. p → q. (Premise)
4. q. (Premise)
5. //∴ p. (Invalid; converse error. In fact p is false although the assumptions are true.)
d.
1. Let p = (I get a Christmas bonus).
2. Let q = (I sell my motorcycle.
3. Let r = (I’ll buy a stereo).
4. p → r. (Premise)
5. q → r. (Premise)
6. ∴ (p ∨ q) → r. (Valid by cases)
Page 3
CS1231
5. Knights and Knaves
The logician Raymond Smullyan describes an island containing two types of people: knights who
always tell the truth and knaves who always lie. You visit the island and have the following
encounters with natives.
a. Two natives A and B address you as follows:
A says: Both of us are knights.
B says: A is a knave.
What are A and B?
b. Another two natives C and D approach you but only C speaks:
C says: Both of us are knaves.
What are C and D?
c. You then encounter natives E and F .
E says: F is a knave.
F says: E is a knave.
How many knights and knaves are there?
Solution:
a. A is a knave and B is a knight.
Proof.
1. If A is a knight then:
1. What A says is true. (by definition of knight)
2. ∴ B is a knight also. (That’s what A said.)
3. ∴ What B says is true. (by definition of knight)
4. ∴ A is a knave. (That’s what B said.)
5. ∴ A is not a knight. (A knave cannot also be knight.)
6. ∴ Contradiction. (contrary to the assumption that A is a knight.)
2. Therefore A is not a knight. (by the contradiction rule)
3. (Note that whatever statements we have derived under the assumption that A is a
knight is useless since we now know that that assumption is false. That does not mean
that those statements are false either. Rather their truth values are unknown.)
4. ∴ A is a knave. (since A is either a knight or a knave)
5. ∴ What B says is true. (B said A was a knave, which we now know to be true.)
6. ∴ B is a knight. (by definition of knight)
b. C is a knave and D is a knight.
Proof.
1. If C is a knight then:
1. What C says is true. (by definition of knight)
2. ∴ C is a knave. (That’s what C said.)
3. ∴ C is not a knight. (A knave cannot also be knight.)
4. ∴ Contradiction. (contrary to the assumption that C is a knight.)
2. Therefore C is not a knight. (by the contradiction rule)
3. ∴ C is a knave. (negation of supposition)
4. ∴ What C says is false. (by definition of knave)
5. ∴ Not both C and D are knaves. (C said both are knaves, and what he said is false.)
6. ∴ D is a knight. (since C is a knave)
Page 4
CS1231
c. There is one knight and one knave.
Proof.
1. If E is a knight:
1. What E says is true. (by definition of knight)
2. ∴ F is a knave. (That’s what E said.)
2. If E is not a knight:
1. E is a knave. (since E is either a knight or a knave)
2. ∴ What E says is false. (by definition of knave)
3. ∴ F is a knight. (E said F is a knave, and what he said is false.)
3. Therefore in all cases there is one knight and one knave. (by division into cases)
6. Prove that there exist positive integers x, y, z such that x2 + y 2 = z 2 .
Solution: These triples of integers are known as Pythagorean triples. There are infinitely
many solutions, some common ones are: (x, y, z) = (3, 4, 5), (5, 12, 13), (7, 24, 25), (8, 15, 17) and
their multiples. Thus, a simple proof is:
Proof. (by Construction)
1. Let x = 3, y = 4, z = 5.
2. Then x, y, z ∈ N+ and x2 + y 2 = 32 + 42 = 25 = 52 = z 2 .
3. Thus ∃x, y, z ∈ N+ (x2 + y 2 = z 2 ). (by existential introduction)
7. After reading Slide 29 of proofs-handout.pdf, I.M. Smart, your CS1231 classmate, attempts to
prove the same statement (reproduced here for convenience):
∀a, b, c ∈ Z, if a | b and a | c, then ∀x, y ∈ Z, a | (bx + cy).
Smart’s proposed proof is as follows:
Proof (Proposed proof ). (Direct proof)
1. For integers a, b, and c, suppose a | b.
2. Then ak = b and a | c such that aq = c where k and q are integers.
3. Now b + c = ak + aq = a(k + q), thus a | (b + c).
4. Then consider bx + cy for x, y ∈ Z.
5. bx + cy = akx + aqy = a(kx + qy).
6. Therefore by direct proof, a | (bx + cy) if a | b and a | c.
Is the proposed proof correct? If so, suggest how to improve it so that it is concise, polished and
rigorous. If not, where is the error?
Page 5
CS1231
Solution: The proof has essentially the correct ideas, but contains irrelevant steps (eg. Line
3), and lacks justification. A better version is:
Proof (Revised proof ).
1. For any a, b, c ∈ Z:
1. If a | b and a | c:
1. Let k ∈ Z such that b = ak. (such a k exists by definition of divisibility)
2. Let m ∈ Z such that c = am. (such an m exists by definition of divisibility)
3. For any x, y ∈ Z:
1. bx + cy = (ak)x + (am)y = a(kx) + a(my) = a(kx + my). (by basic algebra).
2. Note that kx + my ∈ Z. (by closure of addition and multiplication over
integers)
3. Thus a | bx + cy. (by definition of divisibility)
2. Therefore ∀a, b, c ∈ Z (a | b ∧ a | c → ∀x, y ∈ Z (a | bx + cy).
8. Consider the statement:
∀b, c ∈ Z, if b and c are not colorful, then bx + cy is not colorful, ∀x, y ∈ Z.
In English: If integers b and c are not colorful, then neither is their linear combination.
(Recall that the linear combination of numbers m, n is the number mr + ns, where r, s are integers.)
If the statement is correct, prove it; otherwise, find a counterexample.
Solution: The statement is false.
A counterexample was given on Slide 23 of
proofs-handout.pdf, namely, b = 10, c = 14, x = y = 1. It is obvious that b, c are not colorful,
because they are not divisible by 3. However, bx + cy = 24 is colorful.
By comparing the definitions of colorful and divisibility, students should realize that “colorful”
means “divisible by 3”. The purpose of this question is for students to understand the math
symbols in the statement, and link the two definitions.
Page 6
CS1231
9. Read the definition of decimal representation on page 179 of Epp’s book, just before Exercise 44.
Now prove Exercise 47. You may wish to use the hint given on page A-24 for this question.
Solution: This is a harder problem. We will use the given hint, which says:
∀k ∈ Z+ , 10k = 1 + 9
k−1
X
10r .
(1)
r=0
Proof.
1. Let the decimal representation of n ∈ Z+ be dk dk−1 . . . d1 d0 .
2. Then, by definition, n = dk · 10k + dk−1 · 10k−1 + . . . + d1 · 10 + d0
Pk−1
Pk−2
= dk 1 + 9 r=0 10r + dk−1 1 + 9 r=0 10r + . . . + d1 (1 + 9) + d0 (by substituting
Eq (1)).
"
3. Thus n = 9 dk
k−1
X
r
10 + dk−1
r=0
|
k−2
X
r=0
{z
M
#
r
10 + . . . + d1 + dk + dk−1 + . . . + d1 + d0 .
|
{z
}
D
}
4. Thus n = 9M + D, where M ∈ Z by the closure properties, and D is the sum of the digits.
5. Clearly, 9 | 9M .
6. If 9 | D then:
1. 9 | (9M + D) (by Question 7 in this tutorial), and hence 9 | n.
7. Therefore 9 | D → 9 | n.
Thus the statement: “if the sum of the digits in n is divisible by 9, then n is divisible by 9” is
true. To test if n is divisible by 9, simply test if the sum of its digits is divisible by 9. This may
be repeated as needed, e.g. n = 123456789, so 1 + 2 + 3 + . . . + 9 = 45, and 4 + 5 = 9 which is
clearly divisible by 9, and thus 9 | 123456789.
Note that the converse is true also: re-write as D = n − 9M , from which we immediately see
that if 9 | n then 9 | D.
Page 7
Download