Homework 6. CSE 240, Fall, 2014 Due, Tuesday October 28. Can turn in at the beginning of class, or earlier in the mailbox labelled Pless in Bryan Hall, room 509c. Practice Problems: 1. Given two arbitrary sets A,B, prove that (A intersection B) union (A intersection B-complement) equals A. You may *not* use a venn diagram. You may define characteristic functions for A,B so that A = {x PA(x}), and B = {x PB(x)}. Let A(x) be x is an element of A, and B(x) be x is an element of B. Our expression on sets can then be written in logical terms: (A(x) ^ B(x)) v (A(x) ^ ~B(x)) <--> A(x) To prove this equivalence, we start with the left side, and derive the right side: (A(x) ^ B(x)) v (A(x) ^ ~B(x)) <--> A(x) ^ (B(x) v ~B(x)) <--> A(x) ^ T <--> A(x). q.e.d. 2. Let f(x) = 2x + 1 and g(x) = (x-3)2. For each definition of Domain and Co-Domain defined below, answer (i) is the function injective? (ii) is the function surjective? (iii) Is the function a bijection? (iv) If the function if bijective, give its inverse (a) the function f, when the domain and co-domain are the reals. ANSWER: f is injective, surjective and a bijection. the inverse of f is: invf(y) = y/2-1/2. This is an inverse because invf(f(x)) = x: (2x+1)/2-1/2 = x + 1/2-1/2 = x. (b) the function f, when the domain in the integers and co-domain is the reals. ANSWER: f is injective (1-1), but not surjective (onto), and not a bijection. (c) the function (f o g) when the domain and co-domain are the reals. [Recall, (f o g)(x) = f(g(x))] ANSWER: (f 0 g)(x) = f(g(x)) = 2 (x-3)/2 + 1 = x-3 + 1 = x-2 this is injective, surjective and bijective. the inverse of f, invf is invf(y) = y+2 3. List the elements of the following sets: (a) {1, 2, 3} {a, b} (1,a), (2,a), (3,a), (1,b), (2,b), (3,b) [no braces needed because I didn t ask you to define 1
(b) P owerset({1, 2, 3}) P owerset({1, 2, 4}) {}, {1}, {2}, {1,2} 4. Prove the cardinality of all finite length binary strings (strings over the alphabet {0, 1}) is the same as the cardinality of all finite length strings over the alphabet {0, 1, 2, 3} A = all string {0,1} B = all strings {0,1,2,3} Proof A <= B if I can find an f: B --> A that is onto, then A < B f(s) = s if all characters is s are 0 or 1. f(s) = 0 if there is any character that is a 2 or a 3. this is an onto function because f(s) = s for strings in B that are also in A and all strings that are in A are also in B. Proof A >= B if I can find an f: A --> B that is onto, then A > B f(s): f is going to map strings in A as follows: s = a binary string of 0 s and 1 s. For example: 00101001110101. we break that string into pairs of characeters: 00 10 10 01 11 01 01 and replace each pair with the number that binary pair represents: 0 2 2 1 3 1 1 and that becomes our output string: 0221311 Proof that f is onto: Let y be any element of B take each element of y, represent it as a 2 bit binary string, and concatenate all those bit strings together to make y. Then f(y ) = y because that is how we constructed f. Therefore f is onto and A >= B 2
Since A >= B and A <= B, it must be that A = B 5. Sets that are the same size as the integers are called countable, which is short for countably infinite. Which of the following sets are countable? Give an intuitive answer that describes a mapping between these sets and the integers, or argue in a few sentences why this isn t possible. (example) The set of even integers. ANSWER: f(x) = x 2 integers. is a bijection between even integers and (example) The set of finite length binary strings. ANSWER: there is a bijection between the binary strings and the positive integers they represent. (a) P (N) (the powerset of natural numbers). ANSWER: This is uncountable. You can map each element of: P (N) onto an infinitely long bit string of 0 s and 1 s (like we have mapped the subsets of finite sets onto bitstrings), and then you can prove that there are more infinitely long bitstrings than there are integers following the same diagonalization proof that we used to prove the real numbers are bigger. (b) The set of all possible functions f : N {0, 1}. ANSWER: This is uncountable. You can map each possible function f onto an infinitely long bit string of 0 s and 1 s (that gives the definition of that function for each natural number). Then you can prove that there are more infinitely long bitstrings than there are integers following the same diagonalization proof that we used to prove the real numbers are bigger. (c) The set of all possible functions f : {0, 1} N. This is countable. This is the same size as the rational number. To define one possible function f, you need to specify f(0) and f(1), which is a pair of integers. So each function f can be mapped to an integer coordinate, and we can map those to the integers the same way we mapped the rational numbers to the integers. 6. Let A, B, and C be any sets that each have at least 1 element. Also, let f, g, h be functions, where: g : A B, h : A C, and f : A B C, where f is defined by g, h so that: f(x) = (g(x), h(x)) Prove or give a counterexample for each of the following statements. (In this case, a counterexample must include a definition of sets A,B,C and a definition of the functions g,h that make the statement false.). (a) If g or h is one-to-one, then f is one-to-one We prove the contrapositive of this statement: if $f$ is NOT one-to-one, then g is not one-to-one and h is not one-to-one. Assume that $f$ is not one-to-one. Then there are to elements in A (let s call them a1 and a2), such that f(a1) = f(a2) and (a1 is not equal to a2)... if no two elements like this exist, then f would be one to one. So, f(a1) = f(a2). By definition of f: By definition of f: f(a1) = (g(a1), h(a1)), and f(a2) = (g(a2), h(a2)) 3
So, if f(a1) = f(a2), then (g(a1), h(a1)) = (g(a2), h(a2)), and because two ordered pairs are only the same if both elements are the same, then g(a1) = g(a2) and h(a1) = h(a2). This proves that neither g or h are one-to-one. Therefor if $f$ is NOT one-to-one, then g is not one-to-one and h is not one-to-one. Therefore if g is one-to-one and h is one-to-one then g is one to one. (b) If neither g or h is one-to-one, then f is not one-to-one Counter example: A = {1,2,3,...,10} B = {1,2} C = {1,2,3,4,5} g: A -> B is defined so that: g(1) = 1 g(2) = 1 g(3) = 1 g(4) = 1 g(5) = 1 g(6) = 2 g(7) = 2 g(8) = 2 g(9) = 2 g(10) = 2 h: A -> C is defined so that h(1) = 1 h(2) = 2 h(3) = 3 h(4) = 4 h(5) = 5 h(6) = 1 h(7) = 2 h(8) = 3 h(9) = 4 h(10) = 5 then neither g or h is one to one, but f(1) = (1,1) f(2) = (1,2) f(3) = (1,3). 4
. f(6) = (2,1) f(7) = (2,2) but f is 1-1 (many examples are possible). Problems to turn in: 1. Let A be the set {2, 3, 4}, and B be the set {1, 2, 3, 4, 5}. Let P(A) be the powerset of A, and P(B) be the powerset of B. (a) How many elements does the set A B have? 3 5 = 15. (b) How many elements does A P (A) have? 3 2 3 = 24. (c) list two different elements of A P (A) (2, {}), (3, {1, 3, 4}) (d) How many elements does P (A) P (B) have? 2 3 2 5 = 8 32 = 256 2. Let A, B, and C be any sets that each have at least 1 element. Also, let f, g, h be functions, where: g : A B, h : A C, and f : A B C, where f is defined by g, h so that: f(x) = (g(x), h(x)) Prove or give a counterexample for each of the following statements. (In this case, a counterexample must include a definition of sets A,B,C and a definition of the functions g,h that make the statement false.). (a) If f is onto, the both g and h are onto. Assume f is onto Prove g is onto. Let y be any element of B Let c be any element of C. (y, c) B C, by definition of cartesian product. There is some x A such that f(x) = (y, c), because f is onto. by definition of f, f(x) = (y,c) means that g(x) = y, andh(x) = c. therefore, this value of x has the property that g(x) = y. therefore g is onto (we started with an arbitrary value of y and showed that there is an x such that g(x) = y Prove h is onto. [This is almost exactly the same as the above proof: Let y be any element of C Let b be any element of B. (b, y) B C, by definition of cartesian product. There is some x A such that f(x) = (b, y), because f is onto. by definition of f, f(x) = (y,c) means that g(x) = b, andh(x) = y. therefore, this value of x has the property that h(x) = y. therefore h is onto (we started with an arbitrary value of y and showed that there is an x such that h(x) = y). Therefore, if f is onto, the both g and h are onto. 5
(b) if g and h are both onto, then f is onto. Define A = B = C = {1, 2, 3}. Define g(x) = h(x) = x. Then f(x) = (x, x). Both g, h are onto, but f is not onto because it never creates the element (1,2). (there are other elements it doesn t create, but you just need to show one. 6