Discrete Mathematics (Math 27), Spring 2004 Assignment 3 with Solutions. Recall the definition of functions, one-to-one functions, and onto functions. (a) Consider the function f : R R with f(x) x x. i. Is f one-to-one? ii. Is f onto? Explain your answers. Recall that for all x R we have x < x x (). i. Claim: f is not one-to-one. Proof. For any x R we have x x (x + m) x + m (this follows from the identity x + m x + m, which is proved analogous to 3.(a).) For instance, 2 2 2 and ( + ) ( ) 2 + 2 + 2 2. Therefore, f is not one-to-one. ii. Claim: f is not onto. Proof. For any x R we have 0 x x < by (). Therefore, f is not onto. (b) Let A and B be non-empty finite sets with A B (e.g. A B {, 2, 3, 4}). Prove or disprove: For any function f : A B, f is one-to-one if and only if f is onto. Claim: Let A, B, and f be as above. Then f is one-to-one if and only if f is onto. Proof. This follows from the pigeon-hole principle: Let f be one-to-one, then for all a, a 2 A we have f(a ) f(a 2 ) a a 2, so each b B that has a preimage a A has exactly one unique such preimage. Since A and B are finite sets with A B and since f is a function, it follows that each b B must have a preimage a A under f. So f is onto. Conversely, let f be onto. So every b B has a preimage a A. Again, since A and B are finite sets with A B and since f is a function, it follows that each a A must have exactly one unique image b B under f. So f in one-to-one. Since f is onto if f is one-to-one and vice versa, this proves the claim. (c) Let A and B be infinite sets with A B (e.g. A B Z). Prove or disprove: For any function f : A B, f is one-to-one if and only if f is onto. Claim: Let A, B, and f be as above. Then there exist functions f such that f is one-to-one but not onto, and there exist functions f such that f is not one-to-one but onto. Proof. Let A B R. The function f(x) 2 x is one-to-one but not onto (2 x > 0 for all x R), and the function f(x) tan(x) is not one-to-one (tan is a periodic function, i.e. tan(x) tan(x + kπ) for any k Z) but onto. (d) Recall how to prove that two functions are identical. For any real number x let f(x) x x 2, x 2 and g(x) x, x. State the ranges of f and g, state (f g)(x), and prove or disprove: f is the inverse of g. Let y x/(x 2), then yx 2y x and 2y/(y ) x. Since x is not defined for y but for any other y R, it follows that im f R {}. Likewise, let y /(x ), then yx y and y/(y 2) x. Since x is not defined for y but for any other y R, it follows that im f R {2}.
Discrete Mathematics (Math 27), Spring 2004 2 For (f g) we have f g)(x) f(g(x)) x x 2 2 2 x. f is indeed the inverse of g as f (x) g(x) and dom f im f dom g. (e) State the range of the following functions on R and state the inverse or explain, why an inverse doesn t exist: i. f(x) x 2 + ii. f(x) x 5 + iii. f(x) 3 x iv. f(x) 3 x 2 v. f(x) x vi. f(x) x x vii. f(x) e x viii. f(x) e x i. f(x) x 2 + : im f {y R : x }. Since f(x) f( x) for all real x, f is not one-to-one and thus has no inverse function. ii. F(x) x 5 + : im f R. f is one-to-one as x 5 + x5 2 + is equivalent to x5 x5 2, i.e. x x x x x x 2 x 2 x 2 x 2 x 2 or x x x ( x ) ( x ) x 2 x 2 x 2 ( x 2 ) ( x 2 ) or x ( x ) ( x ) ( x ) ( x ) x 2 ( x 2 ) ( x 2 ) ( x 2 ) ( x 2 ); all of these cases imply x x 2 (x x 2 and x x 2 is only satisfied for x x 2 0). The inverse of f is f (x) 5 x. iii. f(x) 3 x : im f R. f(x) is one-to-one as 3 x 3 x 2 is equivalent to x x 2 and thus x x 2. The inverse of f(x) is f (x) x 3 +. iv. f(x) 3 x 2 : im f {y R : x }. Since f(x) f( x) for all x R, f is not one-to-one and thus has no inverse function. v. f(x) x : im f {y R : x 0}. Since f(x) f( x) for all x R, f is not one-to-one and thus has no inverse function. vi. f(x) x x : im f R. f is one-to-one as f(x) x 2 for x 0 and f(x) x 2 for x < 0, and x 2 ( x) 2, but f(x) f( x) for all x R. The inverse of f is f (x) x if x 0 and f (x) x for x < 0. vii. f(x) e x : im f {y R : y > 0}. f is one-to-one since f is strictly monotonic, i.e. for all x, x 2 R we have x < x 2 f(x ) < f(x 2 ); this can be seen as follows: for any real t > 0 we have x + t > x and e t >, thus e x+t e x e t > e x. The inverse of f is f (x) ln x. viii. f(x) e x : im f {y R : y < }. f is one-to-one since f is strictly monotonic, i.e. for all x, x 2 R we have x < x 2 f(x ) < f(x 2 ); this can be seen as follows: for any real t > 0 we have x + t > x and e t /e t <, thus e (x+t) e x e t < e x, and therefore e (x+t) > e x. The inverse of f is f (x) ln( x). (f) Recall the pigeon-hole principle. A bitstring of length l is technically a list of length l with entries from {0, }, e.g. the bitstring 00 corresponds to the list (, 0, 0,, ). If l is fixed, then bitstrings shorter than l are padded with leading zeros, so for l 5 we write 0 as 000. (The length of 000 is still 3, not 5.) A compression algorithm is supposed to map bitstrings of a certain length to shorter bitstrings. The compression is loss-free if and only if the map is bijective (i.e. one-to-one
Discrete Mathematics (Math 27), Spring 2004 3 and onto). Fix l, and let f l : {0, } l {0, } l, and for any bitstring x let length(x) denote the length of x without leading zeros. Prove or disprove: There exists a loss-free compression map f l such that x {0, } l : length ( f l (x) ) < length(x). That says (make sure you understand this): There is a loss-free compression map such that every bitstring of length l can be bijectively mapped (i.e. compressed) to a shorter bitstring. Claim: There exists no such loss-free compression map f l with the asserted property. Proof. We use a simple counting argument and exploit the pigeon-hole principle. Consider bitstrings of length l. There are 2 l bitstrings of length l with leading (the leftmost bit is fixed to, all other bits can be chosen freely and independently, so the multiplication principle can be invoked). Likewise for any other length k < l there are 2 k bitstrings of length k with leading. So there are l k 2k bitstrings strictly shorter than l with a leading. As seen in the lecture l k 2k l k0 2k 2 l. So the set of bitstrings of exactly length l is larger than the set of bitstrings strictly shorter than l. By the pigeon-hole principle there cannot exist a bijective map between (finite) sets of different cardinality. Therefore, at least one bitstring cannot be compressed. This says that no matter what compression algorithm you use (zip, gzip, etc.), it will not work on every input (e.g. note that compressed files in general cannot be further compressed). 2. Prove the following statements by mathematical induction or the well ordering principle. Recall how to write a clean proof. The proofs for the statements below can be written in a quite short way, so try to avoid needless clutter. And remember: Don t use the statement that what you want to prove in the proof. (a) Let A(n) : n k0 a k an+ a Prove A(n) for all natural numbers n 0. for any real a. Proof. Base case: For n 0 we have a 0 and a, so A(n) is true for n 0. a I.H.: Let A(m) be true for some m 0. We derive A(m + ) from A(m). We have [ m+ m ] a k a k + a m+ k0 k0 [ a m+ ] + a m+ by I.H. a am+ + (a )a m+ a am+ + a m+2 a m+ a am+2 a Thus, m+ k0 ak a(m+)+ a, which is A(m + ). Since A(0) is true and A(m) A(m + ), A(n) is true for all n 0..
Discrete Mathematics (Math 27), Spring 2004 4 (b) Let B(n) : n k0 ( 2k + Prove B(n) for all natural numbers n 0. ) 2k + 2 Proof. Base case: For n 0 we have a 0 and (2n + 2)!. 2 0 + 2 0 + 2 2, so B(n) is true for n 0. (2 0 + 2)! I.H.: Let B(m) be true for some m 0. We derive B(m + ) from B(m). We have m+ k0 ( 2k + ) 2k + 2 [ m k0 ( 2k + ) ] 2k + 2 [ ] (2m + 2)! 2m + 3 (2m + 4)! (2(m + ) + 2)! 2(m + ) + 2m + 4. 2(m + ) + 2 by I.H. Thus, m+ ( k0 2k+ ) 2k+2 (2(m+)+2)!, which is B(m + ). Since B(0) is true and B(m) B(m + ), B(n) is true for all n 0. (c) Let n+ C(n) : k 2 k n 2 n+2 + 2. k Prove C(n) for all natural numbers n. Proof. Base case: For n we have 2 k k 2k 2 + 2 2 2 0 and 2 3 + 2 0, so C(n) is true for n. I.H.: Let C(m) be true for some m. We derive C(m + ) from C(m). We have m+2 k k 2 k [ m+ k k 2 k ] [ ] m 2 m+2 + 2 + (m + 2) 2 m+2 + (m + 2) 2 m+2 by I.H. (2m + 2) 2 m+2 + 2 2(m + ) 2 m+2 + 2 (m + ) 2 m+3 + 2. Thus, m+2 k k 2k (m + ) 2 (m+)+2, which is C(m + ). Since C() is true and C(m) C(m + ), C(n) is true for all n. (d) Let D(n) : + nx ( + x) n for any real number x >. Prove D(n) for all natural numbers n 2. Proof. Base case: For n 2 we have + + + x 2 ( + x) 2 since x 2 0, so D(n) is true for n 2. I.H.: Let D(m) be true for some m 2. We derive D(m + ) from D(m). First note the following: If x 0, then +x and thus (+x) m ; and if < x < 0, then 0 < + x < and thus 0 < ( + x) m <. In both cases we have x x( + x) m ().
Discrete Mathematics (Math 27), Spring 2004 5 We have ( ) [ ] + (m + )x ( + mx) + x [( + x) m ] + x by I.H. ( + x) m + x( + x) m by () ( + x) m ( + x) ( + x) m+. Thus, ( + (m + )x) ( + x) m+, which is D(m + ). Since D() is true and D(m) D(m + ), D(n) is true for all n 2. (e) Let E(n) : 7 2 3n. Prove E(n) for all natural numbers n. This is a bit different from the previous problems: Proof. Base case: For n we have 2 3 8 7, so E(n) is true for n. I.H.: Let E(m) be true for some m. In particular, since 7 2 3m, there exists an integer s such that 2 3m 7s. We derive E(m + ) from E(m). We have 2 3(m+) 2 3 2 3m 2 3 2 3m + 2 3m 2 3m [ ] 2 3 2 3m 2 3m + 2 3m (2 3 ) 2 3m + [ 7s ] by I.H. 7 2 3m + 7s 7(2 3m + s). Thus, 7 2 3(m+), which is E(m + ). Since E() is true and E(m) E(m + ), E(n) is true for all n. (f) Let the sequence g 0, g, g 2,... be defined by g 0 2, g 29, and g k 5g k 6g k 2 for all natural number k 2, and let F(n) : g n 5 3 n + 7 2 n. Prove F(n) for all natural numbers n 0. This is a bit different from the previous problems: Proof. Base case: For n 0 we have 5 3 0 + 7 2 0 2 g 0, and for n we have 5 3 + 7 2 29 g, so F(n) is true for n 0 and n. Note: It is important to check for F(0) and F(), just F(0) or F() is not sufficient. I.H.: Let F(m) and F(m + ) be true for some m 0. We derive F(m + 2) from F(m) and F(m + ). We have g m+2 5 [g ] [ ] m+ 6 gm [ 5 5 3 m+ + 7 2 m+] [ 6 5 3 m + 7 2 m] by I.H. (5 5 3 6 5) 3 m + (5 7 2 6 7) 2 m 45 3 m + 28 2 m ( 5 3 2) 3 m + ( 7 2 2) 2 m 5 3 m+2 + 7 2 m+2. Thus, g m+2 5 3 m+2 + 7 2 m+2, which is F(m + 2). Since F(0) and F() are true and F(m) F(m + ) F(m + 2), F(n) is true for all n 0.
Discrete Mathematics (Math 27), Spring 2004 6 3. Recall the definition of and and the fundamental inequalities involved. Also recall how to compute the gcd of two integers. (a) Prove that for any real x and any integer m we have x + m x + m. Proof. Recall that for all x R, we have x x < x +, () where x x if and only if x Z. Also observe the following simple fact: n, m Z : n < m n m n + m, (2) which follows from the basic properties of the integers and the relations < and. Finally, we make the following claim: x R : s, t Z : x s < x + x t < x + s t. (3) This says that there is exactly one integer in the set {y R : x y < x + }. This can be proved in two (albeit similar) ways: Observe that x s < x + (4) and x t < x + (5) imply two things: First, x s < x + t +, which implies x s t by (2), and second, x t < x + s +, which implies x t s by (2). This finally implies s t. Alternative proof: Observe that (5) is equivalent to x < t x (6). If we add (4) and (6), then we arrive at < s t <. Invoking (2) again implies that 0 s t 0, i.e. s t. Now back to the initial question. Since () implies x + m x + m < x + m + as well as x + m x + m < x + m +, the claim with s x + m and t x + m implies x + m x + m. (b) Prove that if x R Z, then x x. Proof. Since x is not an integer, we have x < x < x + () and x < x < x (2). Note that (2) is equivalent to x < x < x (3). We add () and (3) to obtain 0 < x x < 2. Invoking (2) of 3.(a) yields x x, which implies x x. Note: Since x / Z, we have x < x < x and x < x < x +, it might be tempting to invoke (2) of 3.(a) on x < x < x < x +, which looks contradictory. However, (2) of 3.(a) is only valid for integers. (c) Prove for all a, b Z with a, b > 0 that a b a b +. Proof. First observe that (a )/b < (a )/b + (a )/b + is equivalent to a < b (a )/b + b a + b (), because b >. Using (2) of 3.(a) on both inequalities of () yields a b (a )/b + b < a + b, which is equivalent to a/b (a )/b + < a/b +. Since we also have a/b a/b < a/b +, it follows from (3) of 3.(a) that a/b (a )/b +. Note that showing a/b (a )/b + is equivalent to showing that a/b (a )/b + 0; subtracting the according systems of inequalities yields that 0 a/b (a )/b + 0. (However, it is crucial to transform the inequalities for (a )/b such that a is replaced by a, otherwise this does not work.)
Discrete Mathematics (Math 27), Spring 2004 7 (d) Compute d gcd(7369, 5472) and compute the integers x and y such that 7369x + 5472y d. We use the scheme presented in the lecture to compute gcd(7369, 5472) and the representation thereof: k a k q k x k y k 0 7369 0 5472 3 0 2 953 5 3 3 707 5 6 4 246 2 6 9 5 25 7 54 6 3 6 23 73 7 29 55 492 8 2 4 78 565 9 2 2647 8402 So we have gcd(7369, 5472), where x 2647 and 8402, and it is easy to check that indeed 7369 ( 2647) + 5472 8402. (e) Prove that no pair of integers x, y satisfy 54x + 260y 3. Proof. It can easily be checked that gcd(54, 260) 2. Clearly, if d a and d b then d ax + by for any integers x and y. However, 2 3, so x and y can t be integers. (f) Prove that for every even integer n we have gcd(n, n + 2) 2 and find integers x and y such that nx + (n + 2)y 2. Proof. We use again the standard scheme to compute a gcd with representation. Since n is even, let n 2m. k a k q k x k y k 0 2m + 2 0 2m 0 2 2 m 3 0 So we have gcd(n+2, n) 2, where x and y, and clearly 2 (n+2)+( ) n. (g) Prove that for every integer n we have gcd(0n + 7, 7n + 5) and find integers x and y such that (0n + 7)x + (7n + 5)y. Proof. We resort again to the scheme for gcd computation with representation: k a k q k x k y k 0 0n + 7 0 7n + 5 0 2 3n + 2 2 3 n + 2 2 3 4 n 5 7 5 n 7 0 So we have gcd(0n + 7, 7n + 5), where x 7 and y 0, and it is easy to check that indeed 7 (0n + 7) + 0(7n + 5).