You're offered a million dollars if you can win at least 2
  consecutive games out of 3 1-on-1 games of Jeopardy against two
  adversaries, IBM's Watson and me (a rank amateur).  You get to
  choose: you can either play me-Watson-me or Watson-me-Watson.  Which
  should you choose to maximize your chance of striking it rich as a

Administrative info
  Course website has class description, what to expect this summer,
  course policy, advice, exam dates.
  Collaboration: we want you to collaborate, but there is good and bad
  collaboration. Read the policy on the website.
  Should be on mailing list, have access to Piazzza.
  Reader is available at Copy Central. We will cover the notes in the
  Enrollment: everyone who is on waitlist by end of today will be let

Discuss problem on board
  This class will teach you how to formally analyze such a situation.

Course outline
  Propositions, logic, and proofs
    Common language for CS70, rest of EECS.
    Language is precise, unlike English.
    Used in programming, hardware.
    Why proofs?
      So people know something is true: teacher on exam, algorithm is
      So computers know something is true: proof carrying code.
    Example: stable marriage problem
  Modular arithmetic, RSA, polynomials ECC
    Keeping your money safe.
    Send data reliably over unreliable networks.
  Probability theory
      Load balancing
      Bayesian inference (machine learning)
  Continuous probability
    Prove that it's impossible to write a debugger can will determine
    if a program will halt.

  Feel free to ask questions at any point during lectures.

DEF: "Proposition" is anything with a definite truth value.
Which of the following are propositions?
  2+2 = 4 (Y)
  2+2 = 3 (Y)
  826th digit of pi is 4 (Y)
  all dinosaurs were warm-blooded (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)
    (Goldbach's Conjecture; best result known to be true is <= 6
  Johnny Depp is a good actor (N)
Propositions generally denoted by capital letters (P, Q, R)

Logical operators
    ¬: negation
    ∧: and (conjunction)
    ∨ : or (disjunction)
    ⊕: xor (exclusive or)

Truth table
  Illustrates logical operators
  Truth tables for ¬, ∧, &or, ⊕
    P  ¬P
    T  F
    F  T

    P  Q  P∧Q  P∨Q  P⊕Q
    T  T   T     T     F
    T  F   F     T     T
    F  T   F     T     T
    F  F   F     F     F

  ¬(2+2 = 4)
  2+2=3 ∧ 2+2=4
  2+2=3 ∨ 2+2=4
  2+2=3 ⊕ 2+2=4

Translate English into propositional forms
  "My name is Amir and I love math."  (P ∧ Q)
  "You will do the homework, or you will regret it."  (P ∨ Q)
    Or is it xor? See why we use logic!
  "either 1+2 != 4, or my name is mud." (¬P ∨ Q)

  P => Q defined as ¬P ∨ Q
  Pronounced as "P implies Q."
  Sometimes translated to English as "if P, then Q," "P sufficient for
  Q", "Q necessary for P."
  When in doubt, refer back to the definition! The English equivalents
  can be confusing.

Truth table for implication
  P  Q  P=>Q
  T  T   T
  T  F   F
  F  T   T
  F  F   T

  2+2=3 => 2+2=4 (F => T = ¬F ∨ T = T)
  2+2=4 => 2+2=3 (T => F = ¬T ∨ F = F)
  2+2=3 => 2+2=5 (F => F = ¬F ∨ F = T)
  moon is made of cheese => speed limit is 55mph (F => F)
  "If I am exactly 18 years old, then I am allowed to vote." (T => T)
  "if 1+2 = 4, my name is mud." (F => T)

Notes on implication:
  false implies anything
    When P is false, P=>Q is always true
      "If 2+2=5, then I am the Pope."
  anything implies true
    When Q is true, P=>Q is always true
      "If today is Friday, then 2+2=4."

  Contrapositive of P=>Q is ¬Q=>¬P
    "If today is Saturday, it is the weekend."
    "If it is not the weekend, today is not Saturday."
  True exactly when P=>Q is
  Truth table
    P  Q  P=>Q  ¬Q=>¬P
    T  T   T      T
    T  F   F      F
    F  T   T      T
    F  F   T      T

Converse of implication
  Converse of P=>Q is Q=>P
    "If I am exactly 18 years old, then I am allowed to vote."
    "If I am allowed to vote, then I am exactly 18 years old."
  Not necessarily true if P=>Q is
  Truth table
    P  Q  P=>Q  Q=>P
    T  T   T     T
    T  F   F     T
    F  T   T     F
    F  F   T     T
  Common fallacy
    "If the mill were polluting the river, then we would
    see an increase in fish deaths.  And fish deaths have increased.
    Therefore, the mill is polluting the river."
    ("P=>Q.  Q.  Therefore P.")
    (not necessarily: something else might be causing the deaths)
    "If you do every exercise in the textbook, you will
    learn ^^(to hate)^^ discrete mathematics.  You didn't do every
    exercise in the book.  Therefore you haven't learned discrete
    mathematics."  ("P=>Q.  ¬P.  Therefore ¬Q.")
    (not necessarily; you might learn discrete math anyway)

  If and only if, abbrev. iff: P <=> Q
    "You will pass CS70 iff you take the final exam."
  Truth table
    P  Q  P<=>Q
    T  T    T
    T  F    F
    F  T    F
    F  F    T
  What is this the negation of?

Questions for break
  Suppose we have four cards on a table, the 1st about Alice, 2nd
  about Bob, 3rd Charlie, 4th Donna.
  On side of each card is the person's destination, on the other is
  mode of travel.
  Consider the experimental rule: "If a person travels to Chicago,
  he/she flies."
  Suppose you see that Alice went to Baltimore, Bob drove, Charlie
  went to Chicago, and Donna flies.
  Which cards do you need to flip to test the rule?
  == Answer: Bob's and Charlie's
  Now suppose the cards say what each person has for dessert, the
  other what they did after dinner.
  New rule: "If a child has ice cream for dessert, he/she has to do
  the dishes after dinner."
  Cards: Alice: fruit, Bob: watched TV, Charlie: ice cream, Donna: did
  Now what cards do you have to flip?
  == Answer: still Bob's and Charlie's
  Called "Wason selection task." Only ~25% of population gets first
  right, but 65-80% gets second, even though they are the same!  But
  if you switch to a converse, i.e. "If a child does dishes after
  dinner, he/she had ice cream for dessert," almost everyone gets it
  wrong! They look for cheaters, even though the rule doesn't tell
  them to.
  That's crazy! But it shows that our mental circuits are hard-wired
  in funny ways, and specialized at solving certain kinds of problems
  that were important in the stone age -- but may not be so well
  adapted for modern tasks of reasoning and mathematics.  To be more
  reliable, it is helpful to have a formal framework for reasoning
  about logical implications, and that's what I'll introduce in this

  We'd like to reason about statements such as "x > 0 => x + 1 > 1,"
  but simple propositions don't provide us enough power.
  Predicates: propositions with holes, or free variables.
  EX: R(x) = "x > 0"
    R is a function from the natural numbers to the set of
    propositions; R(7) is the proposition that "7 > 0" (true!)
    What about R(0)?
    S(x) = "x > 0 => x + 1 > 1"
    When is S(x) true?
  When is a predicate true? When is R(x) true?
    Need quantifiers to reason about this.

  We want to say something like, "all positive integers are greater
  than 0."
  Need universe over which the statement applies. These are sets.
    N = {0, 1, ...} (natural numbers)
    Z = {.., -1, 0, 1, ...} (integers)
    Z^+ (positive integers)
    See appendix 1 for more common sets.
  Forall (upside down A for "all")
    (∀x∈S)(P(x)) means "P(x) is true for all x in S"
    Different notations used: no parens, dot between set and
    Will be careful writing domain of quantifier early, less so later
    in semester when domain is obvious.
      (∀x∈Z^+)(x > 0)
        Equivalent to "1 > 0 ∧ 2 > 0 ∧ 3 > 0 ∧ ..."
      (∀x∈Z)(x > 0 => x + 1 > 1)
      "the square of a number is always non-negative"
          ∀x∈N . x^2 >= 0 (true)
          Note the different notation!
      "doubling a number always makes it larger"
          ∀x∈N . 2x > x (false; x=0)
          ∀x∈N . 2x >= x (true.)
        but: latter proposition is false in integers! (x<0)
        highlights need to include set over which you're quantifying
    Domain of statement can be further restricted using implications
      "The square of all natural numbers greater than 5 is greater
      than 25."
        ∀x∈N . x > 5 => x^2 > 25
        Is predicate true for x = 2? Why?
        Is predicate true for x = 6? Why?
  Exists (backwards E for "exists")
    Can't use upside down E! (Or backwards A for forall.)
    (∃x∈S)(P(x)) means "P(x) is true for some x in S"
      (∃x∈N)(x = x^2)
        Equivalent to "0 = 0 ∨ 1 = 0 ∨ 2 = 0 ∨ ..."
      "there exists a number greater than 5"
        ∃x∈N . x > 5