Download Formal Methods Key to Homework Assignment 2, Part 3

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Root of unity wikipedia , lookup

Factorization wikipedia , lookup

Eisenstein's criterion wikipedia , lookup

Exponentiation wikipedia , lookup

Fundamental theorem of algebra wikipedia , lookup

Transcript
Formal Methods
Key to Homework Assignment 2, Part 3
February 7, 2007
• Prove that the integer n is even iff −n is even.
Since this is an equivalence, we need to prove two implications: n even implies −n
even, and −n even implies n even.
1. Proof that n even implies −n even. If n is even, there is an integer k such that
n = 2k. So −n = −2k = 2(−k), and if we define l = −k, l is an integer such that
−n = 2l. So −n is even.
2. Proof that −n even implies n even. If −n is even, there is an integer k such that
−n = 2k. So n = −(−n) = −2k = 2(−k), and l = −k is an integer such that
n = 2k. So n is even.
• Prove that if n is an integer, then there exists an integer k such that n = 2k + 1 iff
there exists an integer m such that n = 2m − 1.
Once again, since this is an equivalence we need to prove two implications: ∃k such
that n = 2k + 1 implies ∃m such that n = 2m − 1, and ∃m such that n = 2m − 1
implies ∃k such that n = 2k + 1.
1. Proof that ∃k such that n = 2k + 1 implies ∃m such that n = 2m − 1. If there is
an integer k such that n = 2k + 1, then
n = 2k + (2 − 2) + 1 = (2k + 2) − 1 = 2(k + 1) − 1.
So if we define m = k + 1, we see that n = 2m − 1.
2. Proof that ∃m such that n = 2m − 1 implies ∃k such that n = 2k + 1. If there is
an integer m such that n = 2m − 1, then
n = 2m + (−2 + 2) − 1 = (2m − 2) + 1 = 2(m − 1) + 1.
So if we define k = m − 1, we see that n = 2k + 1.
62. Let A, B, C, M, and N be integers. Prove that if A divides each of B and C, then A
divides N B + M C.
1
Proof. Suppose that A|B and A|C. Then there exist integers k and l such that Ak = B
and Al = C. (We need to find an integer p such that Ap = N B + M C.) We have
N B + M C = N Ak + M Al = A(N k + M l).
So if we define p = N k + M l, we see that Ap = N B + M C and A|(N B + M C).
63. Let A be an even integer and B be an odd integer. Prove that A + B is odd and AB
is even.
Proof. Since A is even and B is odd, there exist integers k and l such that A = 2k
and B = 2l + 1. So
A + B = 2k + (2l + 1) = 2(k + l) + 1,
and if we define p = k + l, we see that p is an integer such that A + B = 2p + 1. So
A + B is odd.
We also have
AB = (2k)(2l + 1) = 2[k(2l + 1)],
and if we define q = k(2l + 1), q is an integer such that AB = 2q and AB is even.
67. Let A and B be integers. Prove that if AB is odd, then A + B is even.
To prove this, we first prove a couple of familiar results.
– AB is odd iff both A and B are odd.
We need to see that AB odd implies both A and B are odd, and both A and B
odd implies AB odd.
First we give a direct proof that A and B odd implies AB odd. Since A and B
are odd, there exist integers k and l such that A = 2k + 1 and B = 2l + 1. So
AB = (2k + 1)(2l + 1) = 4kl + 2k + 2l + 1 = 2(2kl + k + l) + 1.
So if we define p = 2kl + k + l, then AB = 2p + 1 and AB is odd.
To prove the converse, AB odd implies that both A and B are odd, we prove
the contrapositive: if at least one of A and B is even, then AB is even. (This
assumes the result we proved in class that every integer is odd or even, but not
both.) Suppose that A is even. Then there exists an integer k such that A = 2k.
So AB = (2k)B = 2(kB), and if we define p = kB, then p is an integer such that
AB = 2p, and AB is even. The proof in case B is even is virtually identical, and
we omit it.
– A + B is even iff both A and B are even or both A and B are odd.
Another way to say “both A and B are even or both A and B are odd” is “A and
B have the same parity.” So the result can be restated as A + B is even iff A and
B have the same parity.
Since this is an equivalence, we need to prove A + B even implies A and B have
the same parity, and A and B have the same parity implies A + B is even.
2
First we give a direct proof of A and B have the same parity implies A + B is
even. We consider the two cases: both A and B are even and both A and B are
odd. If both A and B are even, then there exist integers k and l such that A = 2k
and B = 2l. So A + B = 2k + 2l = 2(k + l), and A + B is even in this case. If
both A and B are odd, there exist integers m and n such that A = 2m + 1 and
B = 2n + 1. So A + B = (2m + 1) + (2n + 1) = 2(m + n + 1), and A + B is also
even in this case.
To prove the converse, we prove the contrapositive: if A and B have different
parities, then A + B is odd. So suppose A is even and B is odd. Then there exist
integers k and m such that A = 2k and B = 2m + 1. So A + B = 2k + 2m + 1 =
2(k + m) + 1 and A + B is odd. A completely analogous proof shows that A + B
is odd when A is odd and B is even.
Proof of Result. If we assume that AB is odd, then by the first result, both A and
B are odd. So by the second result A + B is even.
70. Let n be an integer such that n2 is even. Prove that n2 is divisible by 4.
Proof. We proved in class that n is even iff n2 is even. So if we assume that n2 is even,
then n is even. So there exists an integer k such that n = 2k. Thus n2 = (2k)2 = 4k 2 ,
and if we define m = k 2 , m is an integer such that n2 = 4m. So n2 is divisible by 4.
78. Prove that if x is a positive real number, then
x
x+1
<
x+1
x+2
Proof. We use contradiction. So we assume that x is a positive real number but
x
x+1
≥
.
x+1
x+2
Since x is positive, x + 1 and x + 2 are both positive. So (x + 1)(x + 2) is positive and
we can multiply both sides of the inequality by it to get
x(x + 2) = x2 + 2x ≥ (x + 1)2 = x2 + 2x + 1.
But this is absurd: if we subtract x2 + 2x from both sides, we get 0 ≥ 1. So the
assumption
x
x+1
≥
x+1
x+2
must be false, and we must have
x
x+1
<
.
x+1
x+2
79. Prove that if x and y are positive real numbers and x 6= y, then x + y > 4xy/(x + y).
3
Proof. Suppose to the contrary that
x+y ≤
4xy
.
x+y
Since x and y are positive, x + y > 0. So we can multiply both sides of the inequality
by x + y and get
(x + y)2 = x2 + 2xy + y 2 ≤ 4xy.
Subtracting 4xy from both sides gives
x2 − 2xy + y 2 = (x − y)2 ≤ 0.
Since x and y are real numbers, their difference is a real number. So the square
(x − y)2 ≥ 0. In fact, we know that the product of two real numbers is 0 iff one of the
factors is, but by assumption x 6= y. So x − y 6= 0, and (x − y)2 > 0. This contradicts
the conclusion that (x − y)2 ≤ 0. So the assumption
x+y ≤
4xy
x+y
x+y >
4xy
.
x+y
must be false, and we must have
4