Math 55 - Fall 07 - Lecture notes # 2 - Aug 29 (Wednesday) Announcments: see webpage for first homework Today's goals: variables and quantifiers ("for all integers x, x+1 > x") Proof techniques From last time: recall propositional logic propositions p,q,r,... (variables that can be T=1 or F=0): operations not p, p and q, p or q, p xor q, p -> q ("p implies q", same as (not p) or q) p <-> q ("p if and only if q", same as (p->q) and (q->p) ) Application to Web search In www.google.com you can type into the Advanced Search form: With all the words: guano and With at least one of the words: geometry tickle Same as "find all web pages W for which the proposition is true" (W contains guano) and ((W contains geometry) or (W contains tickle)) ASK&WAIT: what web pages do you get? (besides the Ma55 2004 web page...) EX: Mass movement in cave sediments, how the geometry depends on bat guano deposits. contains guano and geometry, not tickle EX: Magazine article about "tickle down economics" of Christmas toys and a town in Florida that smells like alligator guano contains guano and tickle, not geometry EX: poems in on-line poetry magazine Lynx contains all 3 Now let's try google with With all the words: guano and With at least one of the words: geometry tickle and Without the words the ASK&WAIT: Same as "find all web pages W for which the proposition is true" (W contains guano) and ((W contains geometry) or (W contains tickle)) and (not(W contains the)) ASK&WAIT: what web pages do you get? EX: "G" page of a dictionary contains guano, geometry, not tickle or the Next Goal: simplifying compound propositions or replacing an expression depending on p, q, r, ... combined with "and", "or", etc. with another "equivalent" and "simpler" one that has the same truth/false value for all values of p, q, r, ... (just like when you learned algebra in high school; algebra with variables that can only have values True and False is called "Boolean Algebra") What is "equivalence"? Recall DEF: p <-> q means (p -> q) and (q -> p); true if p and q are both true or both false (show truth table) DEF: propositions p and q are called logically equivalent if p <-> q is always true (a tautology); write p <=> q; EG: p <=> not(not(p)) EG: p or not(p) <=> True (p or not(p) a "tautology") EG: p and not(p) <=> False (p and not(p) a "contradiction") When is q "simpler" than p? Roughly, if q is a "smaller" compound expression, with fewer operations like and, or etc Motivation: 1) Proofs: if the compound prop. p equivalent to True (p a tautology), then you have proved a theorem 2) In programming, simple expressions (in "if" statements) are easier to understand and debug, faster to evaluate, since each "and" or "or" costs an operation 3) In computer design: A computer stores and computes with "bits" which are either 1 (true) or 0 (false), represented by electrical signals. The computations are done with little pieces of hardware that, say, take two input bits and compute their "and" to get an output bit. Each little piece of hardware corresponds to one of the operations "and", "or", etc. that we have talked about, and so computer hardware is just evaluating compound propositions. A "simpler" compound proposition needs fewer pieces of hardware to evaluate it, which is smaller, cheaper, faster... See also CS150, Chap 11, other "CAD" courses in EECS, and whole industries. Rules we can use to simplify compound propositions: EG: True and q <=> q EG: False or q <=> q EG: True or q <=> True (domination) ASK&WAIT EG: (I am a student at Stanford) or (2+2=4) <=> True EG: False and q <=> False (domination) EG: p or q <=> q or p (commutativity) EG: ( p or q ) or r <=> p or ( q or r ) (associativity) EG: DeMorgan's laws not(p or q) <=> (not p) and (not q) not(p and q) <=> (not p) or (not q) proof: Truth table ASK&WAIT EG: Prove that not(p -> q) -> p a tautology, i.e. <=> True not(p -> q) -> p not(not(p) or q) -> p Def -> not(not(not(p) or q)) or p Def -> (not(p) or q) or p Double negative not(p) or (q or p) associativity not(p) or (p or q) commutativity (not(p) or p) or q associativity (True ) or q not(p) or p <=> True True true or q <=> true Like musical instrument: practice Also: Truth Table (Ref: EECS291B - logic verification, 150 vars) EG: p or (q and r) <=> (p or q) and (p or q) distributivity EG: p and (q or r) <=> (p and q) or (p and q) distributivity (notice that names of rules -- distributivity etc -- are same as rules for regular algebra with numbers, since the rules are analogous) How does one interpret an expression like not p or q? as (not p) or q, or as not(p or q), which are quite different The precedence for operators in absence of parentheses is Highest to Lowest: not, ( and, or ), ( -> , <-> ) If there is ambiguity, I will use parentheses Next goal: dealing with variables in propositions So far, our propositions cannot include variables, like 'x'. So, we can't say "x<1 -> x+1<2"; we'd like to. We introduce them by having propositional functions p(x). It becomes true or false once we assign the variable x a value ASK&WAIT EG: p(x) = 'x > 3', p(2) = ?? , p(4) = ?? ASK&WAIT EG: q(x,y) = ' x = y-1', q(1,2) = ? ASK&WAIT EG: p(x) = ' x is prime ', p(111201) = ? EG: p(x) = ' x is student at Berkeley ' ASK&WAIT EG: If (x>0) then y=x+1; is this a propositional function? Note: x must "type check" for these to make sense, i.e. DEF: The Universe of Discourse is the set of values x is allowed to take in p(x) ASK&WAIT What are Universes of Discourse for above examples? DEF: "for all x p(x)" is a proposition which is true if and only if p(x) is true for all x in the universe of discourse; also called "for each x, p(x)", "universal quantification of p(x)" some times write "for all x in U. of D., p(x)" ASK&WAIT EG: for all integers n, 2*n is even ASK&WAIT EG: for all real numbers z, z^2 > 0 ASK&WAIT EG: for all real numbers z, 0 z^2 < .5 ASK&WAIT EG: for all integers z, 0 z^2 < .5 ASK&WAIT EG: for all Berkeley EECS students S, S must take discrete math ASK&WAIT EG: For all positive integers n, x, y, z, n>2 -> x^n != y^n + z^n (Fermat's Last Theorem) DEF: "there exists an x such that p(x)" is a proposition which is true if and only if p(x) is true for at least one x in the universe of discourse, "existential quantification" ASK&WAIT EG: there exists an integer n, 2*n is even ASK&WAIT EG: there exists a Berkeley Student S, S works hard ASK&WAIT EG: there exists a real number z, z^2 < 0 ASK&WAIT EG: there exists a real number z, z^2 <= 0 ASK&WAIT EG: there exists a real number z, z^2 <= 1