Formal Methods Key to Homework Assignment 4, Part 1

advertisement
Formal Methods
Key to Homework Assignment 4, Part 1
February 16, 2007
1. Prove that the sum of an irrational number and a rational number is irrational. (Hint:
use contradiction.)
Proof. Suppose x is irrational and y is rational. Also suppose to the contrary that
x + y is rational. Then there exist integers m, n, p, and q with n and q nonzero such
that
m
p
y=
and x + y = .
n
q
Substituting the expression for y into x + y gives
x+y =x+
p
p m
np − mq
m
= or x = −
=
.
n
q
q
n
nq
Then since np − mq is an integer and nq is a nonzero integer, we get that x is rational,
contradicting our assumption that it is irrational. So the assumption that x + y is
rational must be false, and we can conclude that if x is irrational and y is rational,
then x + y is irrational.
2. Prove or disprove: the product of two irrational numbers is irrational.
√
√ √
This is false. We know that 2 is irrational, but 2 2 = 2, which is rational.
3. Recall the following definitions. If x and y are real numbers, then
x, if x ≥ y
max(x, y) =
,
y, if x < y
and
min(x, y) =
x, if x ≤ y
.
y, if x > y
Prove that max(x, y) + min(x, y) = x + y. (Hint: use cases.)
Proof. We consider three cases: x > y, x = y, and x < y.
Case 1. Suppose x > y. Then max(x, y) = x, and min(x, y) = y. So in this case
max(x, y) + min(x, y) = x + y.
1
Case 2. Suppose x = y. Then max(x, y) = x, and min(x, y) = x = y. So in this
case
max(x, y) + min(x, y) = x + y.
Case 3. Finally, suppose x < y. Then max(x, y) = y, and min(x, y) = x. So in
this last case
max(x, y) + min(x, y) = y + x = x + y.
4. Extra Credit. If x and y are real numbers, then
|x + y| ≤ |x| + |y|.
Proof. We consider four main cases: x and y nonnegative, x nonnegative and y
negative, x negative and y nonnegative, and x and y negative.
Case 1. Suppose x ≥ 0 and y ≥ 0. Then x + y ≥ 0. So |x| = x, |y| = y and
|x + y| = x + y, and in this case,
|x + y| = x + y = |x| + |y|.
Case 2. Suppose x ≥ 0 and y < 0. Then |x| = x, and |y| = −y. In order to
evaluate |x + y|, we need to determine whether x + y is nonnegative or negative.
So we consider two subcases:
Subcase 2a. Suppose x + y ≥ 0. Then |x + y| = x + y. Now |x| + |y| = x − y,
and since y < 0, −y > y. So
|x + y| = x + y < x + (−y) = x − y = |x| + |y|.
Subcase 2b. Suppose x + y < 0. Then |x + y| = −(x + y) = −x − y. Since
x ≥ 0, −x ≤ x. So
|x + y| = −x − y < x + (−y) = |x| + |y|.
Case 3. Suppose x < 0 and y ≥ 0. Then |x| = −x, and |y| = y. As in case 2, we
consider two subcases:
Subcase 3a. Suppose x + y ≥ 0. Then |x + y| = x + y. Now |x| + |y| = −x + y,
and since x < 0, −x > x. So
|x + y| = x + y < −x + y = |x| + |y|.
Subcase 3b. Suppose x + y < 0. Then |x + y| = −(x + y) = −x − y. Now
since y ≥ 0, −y ≤ y. So
|x + y| = −x − y < −x + y = |x| + |y|.
Case 4. Finally suppose that both x and y are negative. In this case, |x| = −x
and |y| = −y. Furthermore, since x + y < 0, |x + y| = −(x + y) = −x − y, and
|x + y| = −x − y = |x| + |y|.
2
Download