=============================================================== Lect 13 - November 6, 2008 - ECS 20 - Fall 2008 - Phil Rogaway =============================================================== Today: o Review o Infinite Sets (done well in Velleman Chapter 7) o Return, comment on your midterms -------------------------------------- 1. Review of big-O, Theta -------------------------------------- Special functions \lceil .. \rceil log(ab) = log(a) + log(b) log_a(b) = log_c(b) / log_c(a) e^ab = (e^a)^b a^x a^y = a^{x+y} Asymptotics O(g) = {f: \N -> \R: \exists C, N s.t. f(n) <= C g(n) for all n>= N} \Theta(g) = {f: \N -> \R: \exists c,C N s.t. c g(n) <= f(n) <= C g(n) for all n>= N} Example: True/False: If f is Theta(n^2) then f is O(n^2) TRUE n! = O(2^n) NO n! = O(n^n) YES (Truth: n! = Theta((n/e)^n sqrt(n))) Claim: H_n = 1/1 + 1/2 + ... + 1/n = O(lg n) Draw picture. Upperbound by 1 + \integral_1^n (1/x)dx = 1 + ln(n) = O(lg n) show Could I write O(log n) Sure; O(log n) = O(lg n) How many steps are sufficient to solve the Towers of Hanoi problem: "I don't recall exactly, but it's O(2^n)." Compute the asymptotic running time of the following algorithm: Given: a formula phi, decide if phi is satisfiable by trying all possible truth assignments. Suppose phi has n variables and takes m bits to write down. Answer: Need to try 2^n t.a. How long to try teach? O(m). All together? O(m 2^n). One reason asymptotic notation handy: O(n^2) + O(n^2) = O(n^2) O(n^2) + O(n^3) = O(n^3) O(n log n) + O(n) = O(n log n) etc. A reason we use asymptotic notation: model independence How long does the following code take to run for i=1 to n do for j=1 to i do s += (i+j)^2 - (i+j) How long to sort by bubble sort O(n^2) Already enough to distinguish from more sophisticated algorithms. ------------------------------------------------ 2. How big is that infinity? ------------------------------------------------ Puzzle: Which are there more of: natural number or integers? Mathematicians answer: they are the same. Not because they are both infinite, but because there is a bijective function f: \N -> \Z e.g, f(x) = \lceil x/2 \rceil if x is odd -x/2 if x is even Is there a bijective function from \Z to \N Answer 1: yes, automatic from above Answer 2, yes, f(x) = -2x if x>0 2x-1 if x is odd -3 -2 -1 0 1 2 3 0 Woops! -- student told after class that both I and the book had earlier defined \N not to include 0. In fact, both conventions are common, but I did not mean to vascillate. Puzzle: is there a bijective function from \N to \N x \N Technique: "Dovetailing" // Did not get to in lecture, Tung will do // this in discussion section Definition: Let A and B be sets. We say that A is *equinumerous* to B, A ~ B, if there is a bijection f from A to B. (Woops! In class I said "equicardinal", but Velleman uses "equinumerous") Definitions: A set is *finite* if it is equinumerous to I_n = {1,...,n} for some n\in \N. A set is *infinite* if it is not finite. A set is *countably infinite* it is equi numerable to \N A set is *countable* if it is finite or countably infinite. A set is *uncountable* if it is not countable. Proposition: ~ is an equivalence relation Proposition: \Q is countably infinite. Proposition: if A and B are countable then so is A x B and A u B Theorem: P(\N) is uncountable. (the powerset of the natural numbers) Proof. Suppose for contradiction that P(\N) were countable: say P(\N) = \{A_1, A_2, ...} We construct a subset B of \N as follows B contains i\in iff i \not\in A_i Now B is a subset of \N so it must be in the enumeration: say B = A_j But: is j \in B? j \in B iff j\not\in A_j = B Contradiction. Theorem: \R is uncountable. Prove it in the usual way. Proposition: (0,1) ~ \R (not done in class) 0 1 <-------------(-------)-------> f(x) = 2(x-1/3) = 2x-1 -1 0 1 <------(-------------)-------> g(x) = 1/(1-x) - 1 if x>=0 g(x) = 1/(1+x) - 1 if x<0 <-------------|---------------> Definition: For sets A, B, write A \le B if there exists a one-to-one function f: A -> B. Theorem: [ Cantor-Schr\"oder-Bernstein ] [not done in class] If A \le B and B \le A then A ~ B Corollary: \R ~ P(\N) Proofs: See your book! Names (kind of like numbers) for different size infinite \Aleph_0 c for the "size" of \R: |\R| = c Continuum Hypothesis: 1900, David Hilbert's first (of 23) problem. 1963 - Paul Cohen proved not provable under Zermelo-Frankel set theory with choice. There is no set with cardinality strictly between \Aleph_0 and c: Cannot be proven nor disproven under in ZFC! -------------------------------- 3. Return and comment on quizzes --------------------------------