Math 55 - Fall 07 - Lecture notes # 3 - Aug 31 (Friday)

  Announcments: Delay part of first homework?

  Today's goals: more on quantifiers ("for all x, x+1>x", "there exists x, x+1=2x")
                 proof techniques


            EG: (Lewis Carroll, author of 'Alice in Wonderland')
                Universe of Discourse = 'creatures'
                "All bears are fierce"
                "Some bears do not drink Peet's coffee"
                "Some fierce creatures do not drink Peet's coffee"
                 Let B(x) = "x is a bear"
                 Let F(x) = "x is fierce"
                 Let P(x) = "x drinks Peet's coffee"
                Express above using forall, thereexists:
 ASK&WAIT       "All bears are fierce"
 ASK&WAIT       "Some bears do not drink Peet's coffee"
 ASK&WAIT       why not "there exists x (B(x) -> not P(x))" ?
 ASK&WAIT       "Some fierce creatures do not drink Peet's coffee"

 ASK&WAIT   EG: forall real x, thereexists real y, x=y+1 
 ASK&WAIT   EG: thereexists real y, for all real x, x=y+1 

            EG: From calculus: lim(x -> a) f(x) = b really means
                forall eps>0 therexists delta>0 forall x
                       0<abs(x-a)<delta -> abs(f(x)-b)<eps
 ASK&WAIT   What about
                forall eps>0 therexists delta>0 forall x
                       0<=abs(x-a)<delta -> abs(f(x)-b)<eps

 ASK&WAIT   EG: restate not( forall x p(x) ) using thereexists:
 ASK&WAIT   EG: restate not( thereexists x p(x) ) using forall:

            DEF: A variable is bound, if it is either fixed, or
                 in a "for all" or "there exists". Only if all variables
                 in a propositional function are bound is it a proposition.
                 An unbound variable called free
            EG: P(x,y,z) = x=y and y<z
                there exists y for all z P(0,y,z)
 ASK&WAIT   is this T or F?
            CS: analogy: to evaluate a function, need to know all the
                arguments

     Proof techniques (aka rules of inferences, tautologies)

     [ p and (p -> q)] -> q
     Names: modus ponens, law of detachment, "common sense"
     EX: p = "3|n", q = "9|n^2", then "p -> q" is clearly true.
           So for example, if n=6, so that p is true, you can conclude 9|6^2

     Other common sense stuff:
     [(p -> q) and (q -> r)] -> (p -> r)
     EX: p = '3|n', q = '9|n^2', r = '18|2*n^2', so p->q and q->r
         Thus p->r, i.e. 3|n -> 18|2*n^2

     (p and q) -> p
     EX: p = "3|n" , q = "2|n", (p and q) = '6|n', so 6|n -> 3|n

     p -> (p or q)
     EX: p = '3|n', q = '2|n', so 3|n -> (3|n or 2|n)

     [ not q and (p -> q) ] -> not p
     Name: modus tollens, contrapositive
     Works because (p -> q) <-> (not q -> not p)
     EX: Show "if 3n+2 is odd then n is odd",
         use p="n is even", q="3n+2 is even"; then p -> q is clearly true,
         so 3n+2 odd and (p -> q) is the same as not q and (p -> q) whence
         not p i.e. n is odd

     [ not p -> F) ] -> p
     Name: proof by contradiction
     EX: cuberoot(5) is irrational, i.e. cannot be written as a/b where
         a and b are nonzero integers without common divisor
         let p = "cuberoot(5) is irrational"
         so not p = "cuberoot(5) is rational"
                  -> cuberoot(5) = a/b, where a and b have no common divisor, b != 0
                  -> 5 = a^3/b^3, or 5 b^3 = a^3 (use b != 0)
                  -> 5 | a^3 -> 5 | a -> a=5*c -> 5 b^3 = 125 c^3 (why 5|a ?)
                  -> b^3 = 25 c^3 -> 5 | b^3 -> 5 | b
                  -> 5|a and 5|b 
                  -> a and b have a common factor and do not have a 
                     common factor 
                  -> false
         so p is true

      case analysis
      EX: show that min(x,y) + max(x,y) = x+y
          Three possible cases: x<y, x=y and x > y
             Case 1: min(x,y) = x, max(x,y)=y, so min+max=x+y
             Case 2: min(x,y) = x = y, max(x,y) = y = x, so min+max=x+y=2*x
             Case 3: min(x,y) = y, max(x,y)= x , so min+max=y+x=x+y

      EX: Are this statement and its proof correct?
          Let a(0), a(1), and a(2) be three different points in the plane, 
          and let T be the triangle they form. Let 
             theta(1) be the clockwise angle from the line segment
                  (a(0),a(1)) to the segment (a(1),a(2))
             theta(2) be the clockwise angle from the line segment
                  (a(1),a(2)) to the segment (a(2),a(0))
             theta(0) be the clockwise angle from the line segment
                  (a(2),a(0)) to the segment (a(0),a(1))
          Then theta(1)+theta(2)+theta(3) = 180 degrees.
          Proof: Draw the figure
                       a(1)-----a(0)
                         \       /
                          \     /
                           \   /
                            a(2)
                 and use the fact that the sums of the angles in a triangle
                 is 180 degrees.

ASK&WAIT: Are this statement and its proof correct?

      EX: Are this statement and its proof correct?
          The number of primes is infinite:
          Proof: Suppose that the number of primes is finite; we will
                 get a contradiction.  Denote these primes by
                 p1,p2, ... , pn. Let N = p1*p2*...*pn+1. N is not
                 divisible by any of p1, p2, ..., pn, because it has
                 a remainder of 1 when you divide by any of them.
                 Therefore N is another prime.
                 
ASK&WAIT: Are this statement and its proof correct?

      Recall Def: "p if and only if q" means "p <-> q"
           To prove this is true you have to show that p and q are 
           both true at at the same time, and both false at the same time
                 
      EX: Are this statement and its proof correct?
          a*b is rational if and only a and b are rational
          Proof: Suppose a=p/q and b=r/s are rational, i.e. quotients
                 of integers. Then a*b = (p*r)/(q*s) is rational.

ASK&WAIT: Are this statement and its proof correct?

      Proving "NOT EXIST x such that P(x)" is same as
          "FORALL x NOT P(x)"
      EX: Are following statement and proof correct?
          There is no polynomial p(n) with integer coefficients 
          such that p(n) is prime for all integers n >= 0.
          In other words, there is no simple (polynomial) formula for
          generating primes.
          Proof: instead show "FORALL polynomials p(n), 
                 there is an n >= 0 such that p(n) is not prime":
                Write p(n) = p_(d)*n^d + p_(d-1)*n^(d-1) + ... + p_(1)*n + p_(0)
                           = r(n) + p_(0)
                 If p_(0) = 0, then p(0)=0 is not prime
                 If p_(0) = 1 or -1, then p(0)=1 or -1, so not prime
                 If p_(0) is composite, so is p(0) = p_(0)
                 If p_(0)=q is prime, then q|r(i*q), so q|p(i*q)=r(i*q)+q

ASK&WAIT: Are this statement and its proof correct?

Here are two more reason why proofs are important (beyond proving that some
theorem is true, or algorithm is correct)

     It is possible to embed proofs in downloadable programs and email,
     so that the recipient is guaranteed (by running a program to check
     the proof) that the program or email does not contain a virus, or
     will not otherwise cause mischief.

     For example, Java enabled cell-phones in Japan use this technique
     of "proof-carrying code" when they download code. When a phone downloads
     Java code it checks the proof that the code will not cause damage
     (eg write into memory it should not). The alternative
     is to run them using an interpreter that keeps downloaded code from
     causing mischief. But it uses fewer instructions (and so
     less battery power!) to check a proof and then run noninterpreted code.
     Prof. George Necula has pioneered this idea (www.cs.berkeley.edu/~necula)

     Bill Gates once proposed a list of techniques to combat spam, 
     including proof-carrying-email, which would contain a
     proof that the email did not come from a spammer, i.e. sent out to
     lots and lots of people.  One way to do this would be for the email
     to contain a very difficult puzzle and its solution, where the puzzle
     is known to be so difficult that only by spending at least, say,
     1 CPU second could the puzzle have been solved, although it is easy
     for your mailer to check that the solution is correct.
     Thus, sending a billion spam messages would cost a billion CPU seconds
     instead of a few seconds, making span uneconomical to send.
     Unfortunately, this would just motivate spammers to try to take over
     other machines and make them spammer-zombies, which they do already.
     Obviously a good solution to spam still awaits us...