VIEWS: 5 PAGES: 4 POSTED ON: 3/27/2010 Public Domain
CPSC-121: Indirect proofs, random stuﬀ, and number representation Week 5 Tutorial outline Matt Hoﬀman 1 Proof by contradiction For a proof by contradiction we want to prove (A ⇒ B) ≡ (¬A ∨ B) ≡ ¬(A ∧ ¬B) and will assume A ∧ ¬B to arrive at some logical contradiction. 2 Examples 1. Show that “there is no largest integer.” Proof. Assume that there is a largest integer, let’s call it x. This means that ∀y ∈ Z : x ≥ y. Our number x is an integer, so we can always add one to get another integer, say z = x + 1. This means that x ≥ x + 1 =⇒ 0 ≥ 1. This is a contradiction, so our assumption must be wrong, and there is no largest integer. 2. Show that “an integer is even if and only if its square is even.” Proof. We have to prove this two ways. Showing that n is even implies that n2 is even is easy: n ∈ Z is even =⇒ ∃x ∈ Z : n = 2x =⇒ n2 = (2x)2 = 2(2x2 ) =⇒ n2 is even 1 Next we have to prove that n2 even implies n is even. Given that n2 is even let’s assume that n is odd. We know that a product is even only if at least one of its subparts is even—but this contradicts our assumption that n is odd. Therefore our assumption is false, and n must be even. 3. Show that if a, b, c are odd integers, then ax2 + bx + c = 0 has no solution in the set of rational numbers. Proof. Assume there is a rational solution x, which can be written p ∃p, q ∈ N : x = , q = 0, q p and here we assume that q is in its lowest form. This can be substituted in to obtain 2 p p a + b + c = 0, q q ap2 + bpq + cq 2 = 0. Since we assumed that p was in its lowest form, then p and q cannot both q be even. If p is even and q odd, then the cq 2 term is odd, similarly if q is even and p is odd then the ap2 term is odd—meaning the polynomial is odd. If both p and q are odd, the polynomial will be the sum of 3 odd numbers, and thus odd. Therefore the polynomial is odd, and since 0 is even, the polynomial can- not be equal to 0. This contradiction means our assumption is wrong, and thus there is no solution to the polynomial in the rational numbers. 4. Given an eight-by-eight checkerboard. (a) Given a domino shape (ie one square black, one square white) and the checkerboard with opposite corners removed, prove that the re- maining squares cannot be covered exactly by dominoes. (b) Given a T-shape, where the center square can be either black or white, and a checkerboard with two squares removed from opposite corners—prove that the remaining squares cannot be covered exactly by the T-shapes. 2 3 Incorrect “proof ” Let x and y be integers, and suppose that x = y. x = y =⇒ x2 = xy multiply by x 2 2 2 =⇒ x − y = xy − y subtract y 2 =⇒ (x + y)(x − y) = y(x − y) factor =⇒ x + y = y divide by (x − y) = 0. error! For x = y = 1, this implies that 2 = 1. What’s wrong with the proof? 4 Number representation 1. Base 10. Numbers in base 10 can be written as 21710 = 2(102 ) + 1(101 ) + 7(100 ). 2. Base 2. If we want to represent things on a computer, we have to use bits (transistors)—switches that can be on or oﬀ. For example • 10112 = 1(23 ) + 0(22 ) + 1(21 ) + 1(20 ) = 8 + 2 + 1 = 11. • How many numbers can be represented with one bit? 2 (either on or oﬀ). • Adding one more bit doubles the amount, you have all the previous bits, either with the last bit as a 0, or a 1. • n bits gives 2n distinct numbers. • Adding two numbers is just like adding two numbers in base-10. 00110 +10011 11001 3. Negatives. Negative numbers are usually represented with a minus-sign, but all we’ve got are bits. So we can take the easy way out and just let one bit represent negative-or-not. • Adding/subtracting is a pain. • We’ve got two representations for 0, 10 . . . 0 = 00 . . . 0. 4. Two’s complement. A better way to represent negative numbers. 3 • Wrap the numbers around the n bits. This looks like: {−2n−1 , . . . , 0, . . . , 2n−1 − 1}, i.e. {−256, . . . , 0, . . . , 255}. • Positive numbers are just as before, but negative numbers we repre- sent as 2n − x. Two easy ways to ﬁnd −x: (a) Easy: ﬂip the bits of x, add 1. (b) Easier: ignore everything starting at the right up to and includ- ing the ﬁrst 1, ﬂip every other bit. • Finally, addition works just the same as above, and adding negative numbers just works without needing to check the sign bit. 4