Math 55 - Fall 07 - Lecture notes # 1 - Aug 27 (Monday) Name, class, URL (www.cs.berkeley.edu/~demmel/ma55_Fall07) on board Advertise CS 70 (T Th 11-12:30) as alternative to Ma55 Read Course Outline on web page for course rules and grading policies You are responsible for reading this and knowing the rules! Class outline: Basics (Chap 1) - common language for rest of course logic (basis of proofs, logical operations in programs (CS61) hardware design (CS150)) proof techniques Why proofs? So people know something is true So computers know something is true: Some Java enabled cell phones have required downloaded programs to be "proof carrying codes", that contain a proof that they can't do anything bad to your cell phone (see www.cs.berkeley.edu/~necula) Sets, functions, sequences, summations (Chap 2) (same proof of 3 results: (1) can show that can't write a program to implement every possible function, because there are more functions than programs; (2) can show it is impossible to to write a debugger that finds "infinite loops" in other programs (CS 172)) (3) there are more real numbers than rational numbers (even though there are infinitely many of both Sequences & Summations: Analyzing how fast a program runs Used in most of math curriculum Integer algorithms (Chap 3) Big-O notation (measure approximately how fast a function f(n) increases as n increases) Using Big-O to analyze speed of algorithms (used in CS61, CS170) Prime numbers, GCD (Greatest common divisors), "modular arithmetic" (a mod b), Chinese remainder theorem Applications: generating random numbers integer with "bignums" cryptography (eg RSA used for internet security) (Ma 113, CS 170) More proof techniques (Chap 3) induction (knowing when a theorem, or program, is correct) (CS 17x, most of math curriculum) Probability theory and counting (Chaps 4, 5, 6) analyzing, designing algorithms (CS 170, CS 162, CS 188...) (sometimes an algorithm that uses "random numbers" is faster than one that does not) You can have 9 pieces of fruit, which can be apples, bananas or cherries. How many ways can you take 9 pieces of fruit? (2nd grade version) You can have n pieces of fruit, of which there are k different kinds. How many ways can you take n pieces of fruit? (sophomore version) how to gamble in Reno (or not) algorithms that use random numbers EX: suppose you build a web search engine (or a web page to sell books or some other web service) you buy 100 PCs and put them in a room when a request comes in, you pick a PC at random, and send it to that PC what is the average waiting time to service a request? EX: Suppose you have an election, and B's reported vote total is 2,912,790, and G's reported vote total is 2,912,253, and the chance of each vote having been mistakenly counted wrong is 1 out of 1000, what is the chance that B did not actually win the election? Start reading Chapter 1 of book, homework due Wednesday Sep 5 at the beginning of section (will be posted on web page) Begin course: DEF: Proposition is a statement that must be either true (T) or false (F) EG: 2+2 = 4 (Y) 2+2 = 3 (Y) Is 2+2=4? (N) Let x = 3. (N) x+1 = 2 (N, unless we know the value of x) Every even number > 2 is the sum of two primes. (Y) Notation: propositions denoted p,q,r ... DEF: not p , p or q (disjunction), p and q (conjunction), p xor q (exclusive or) Truth tables DEF: a compound proposition is formed by simple propositions connected by logical operators and parentheses; EG: (p and q) or (r and s) programming example below DEF: p -> q, "if p, then q", "p implies q", "p sufficient for q", "q necessary for p"; p -> q same as not(p) or q; EG: if it is sunny, then we go to the beach p = it is sunny, q = we go to the beach (T unless it is sunny (p) and we don't go (not q)) Truth table ASK&WAIT EG: if (today is Friday), then (2+3 = 6); on which days is this true? p = (today is Friday), q = (2+3=6) T every day except Friday ASK&WAIT EG: if (1+1=3) then (2+2=4) Note that p and q need not have anything to do with one another in order to form the expression p -> q ASK&WAIT EG: if (1+1=3) then (2+2=3) DEF: The converse of p -> q is q -> p; they need not be true at the same time ASK&WAIT EG: If I am exactly 18 years old then I am allowed to vote; converse is if I am allowed to vote, then I am exactly 18 years old note that converse not necessarily true if original is DEF: The contrapositive of p -> q is not q -> not p; these are the same ASK&WAIT EG: If I am exactly 18 years old then I am allowed to vote; converse is if I am not allowed to vote, then I am not exactly 18 years old contrapositive is true Truth table proof of prop <=> contrapositive DEF: p <-> q "p if and only if q", "p->q and q->p", biconditional Application to programming (Java or C syntax) if (compound proposition, or logical expression) then do something... if ((n>0) && (m0) and (m