F12:Homework:H14
Total Page:16
File Type:pdf, Size:1020Kb
H14-F12-CS40 page 1 section first name last name First name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (M2,M5,M7 or T4) initial initial (color-in initial) Last name A B C D E F G H I J K L M N O P Q R S T U V W X Y Z (color-in initial) H14: Due Mon 11.05 in Lecture. Total Points: 50 MAY ONLY BE TURNED IN DURING Lecture ON Mon 11.05, or offered in person, for in person grading, during instructor or TAs office hours. See the course syllabus at https://foo.cs.ucsb.edu/40wiki/index.php/F12:Syllabus for more details. (1) (10 pts) Fill in the information below. Also, fill in the A-Z header by coloring in the first letter of your first and last name (as it would appears in Gauchospace), writing either M2, M5, M7 or T4 to indicate your discussion section meeting time, i.e., Monday at 2pm, Monday at 4pm, or Tuesday at 5pm. writing your first and last initial in large capital letters (e.g. P C). All of this helps us to manage the avalanche of paper that results from the daily homework. name: umail address: @umail.ucsb.edu Your reading assignment for H14/H15 includes The handout given out with this assignment (which can be found on the wiki under the link for Homework H11---it is part of the printable PDF) Skimming selected portions of Sections 2.4 in the textbook, as guided by that handout. Section 4.4 in the textbook. We may come back, as time permits, and look more deeply into some parts of this material we may have skimmed over on our first pass. (2) We learn in Section 2.4 that the set ℕ×ℕ is countable (more specifically, countably infinite) (a) (3 pts) Briefly, what does it mean for a set to be countably infinite? (b) (3 pts) ℕ×ℕ can be shown to be countable using "Cantor's pairing function". What is the value of Cantor's pairing function for (2,1)? (c) (3 pts) Which element of ℕ×ℕ is paired with the number 7? F12-H11-page 2 (3) Find problem 2(a) on page 274, then look at the answer in the back of the textbook. Also, review the notes from class where that proof was done on the board. Then, consider an inductive proof for 2d. 2 + 6 + 10 + ... + (4n - 2) = 2n2. On this assignment, less help than you had for H13, but still some help. (a) (3 pts) Define f(n) as the sum. That is, write down: Let f(n) = 2 + 6 + 10 + ... + (4n - 2) (Go ahead, write it, for practice—so that you learn that this is a step in proof by induction for sums like this one.) Then, fill in the empty spaces in the following table. A few have been done as examples, so you know what I'm looking for. (Note: this step is NOT a necessary step in the formal proof; it is just an exercise to help you understand what is going on in these inductive proofs.) f(0) = 0 f(0) = 0 (0 terms) f(1) = (4*1 - 2) = 2 f(1) = 2 (1 term) f(2) = f(2) = (2 terms) f(2) = f(2) = (3 terms) ... f(5) = 2 + 6 + 10 + 14 + (4*5 - 2) = 2 + 6 + 10 + 14 + 18 f(5) = 50 (5 terms) ... (b) (5 pts) Define P(n) as an appropriate proposition, using the appropriate notation. (a) (5 pts) Write down the proof for the base case, P(0). (b) (8 pts) In the next step, you prove a statement of the form "if p then q". p is your inductive hypothesis, something that you assume is true. q is the thing you prove, given the assumption that p is true. Please identify both p and q: p: q: (c) (10 pts) Now, finish the proof—given your formulation of p and q, show that if p then q, which together with the base case, shows that P(n) is true for all n∈ℤ,n≥0. CS40-F12-H14 Handout Page 1 Handout to go with H14/H15 Reading Assignment: Skimming through 2.4 Our main goal for this section of the course is to really learn proof by induction well. To create the time to go DEEP on proof by induction, we have to skim over a lot of other topics. Those topics we need to skim over are covered on 118 pages of the text (pages 121 to 238) in sections 2.4, 3.1, 3.2, 3.3, 4.1, 4.2, and 4.3 Because it isn't reasonable to expect you to do a deep reading of all of that in the time given, I'm going to first guide you through material, focusing JUST the portions of that material that are necessary for an understanding of proof by induction. I'll mention the other parts and we'll come back to them if time permits. Your reading assignment for H14 includes This handout Skimming selected portions of Sections 2.4 as guided by this handout. Notes on: Section 2.4: Countability, 2.4.1, Sizes of Sets Why should I care about countability? Two fundamental questions in Computer Science with real world implications: Can such-and-such a problem be solved (i.e. can we write a computer program to solve this problem) If we can solve that problem, can we write it in a way that will scale (i.e. so that as the input gets large, the program will run in less time than a year, a human lifetime, or the age of the universe). One of the most interesting aspects of Computer Science (one that you may investigate further in upper division courses such as CS130A, CS130B and/or CS138) is that there ARE problems: that "can't be solved" by any computer program that always terminates with a correct answer (technically, these are "uncomputable" or "undecidable" problems) for which there is no "known" algorithm that runs in a reasonable amount of time for large size inputs. (these are the NP-hard and/or NP-complete problems.) Even if you don't go on to take further upper-division CS courses, you may run into descriptions of problems in Math, Computer Engineering and Computer Science, that are "undecidable", "NP-hard", or "NP-complete", and it is helpful to have some insight into what those things mean. It turns out that all of the following are important tools to establishing whether problems belong to the "undecidable", "NP-hard", or "NP- complete" class problems: 1-to-1 functions, onto functions and bijections the relative sizes of sets, i.e, for two sets A and B, which one is the case: Is A bigger than B Is B bigger than A Are A and B exactly the same size Or is it not possible to even say? whether a specfic set is finite, countably infinite, or uncountably infinite (we'll discuss what each of those terms mean.) CS40-F12-H14 Handout page 2 An injection (1-to-1 function) f: A→B means |A| ≤ |B| You've probably already figured out that a function can't be 1-to-1 from A to B if there are fewer elements in B than A. Think of it this way: a 1-to-1 function means that every element of A gets a different dance partner in set B—none of the elements of A have to share the same dance partner. That only works if there are enough elements in B to "go around". If there are 5 element in A, and only 4 in B, then at least two elements of A have to dance with the same element of B, and that means the function is no longer 1-to-1. (That's essentially an 'informal sketch' of how you prove this, using the "pigeonhole principle". A surjection (onto function) f: A→B means |A| ≥ |B| You've probably already figured out that a function can't be onto from A to B if there are fewer elements in A. Think of it this way: an onto function means that every element of B gets a dance partner. For the mapping to be a function, no-one in A is allowed to dance with more than one element of B (otherwise, it isn't a "function".) That means if there are 4 dancers in A, but 5 dancers in B, that at least one dancer in B has to sit out the dance. What it means for a function to be onto, is that every dancer in B gets to dance. Bijection means sets are the same size, |A| = |B| If you can construct a function from set A to set B, f: A→B that is both 1-to-1 and onto, that function is called a bijection. It if is both 1-to-1 and onto, then |A| ≤ |B| and |B| ≥ |A| And the only way those can both be true is if |A| = |B|. That is, it is only possible to construct a bijection between two sets A and B if and only if the sets A and B have the same number of elements (i.e. the same cardinality). Mathematicians like to make up new words for things, so they made the word "equipotent" to mean "the sets are the same size." Countably infinfite: bijection with ℕ A set is "countable" if it is finite (because clearly you can count anything that is finite).