Lecture 2

ECS 20 (Prof. Rogaway)

Scribed by Zach M



If you’re going to drop the class, please drop now! Students are trying to get in and I can't give out PTA numbers because we're at the room maximums for both discussion sections.


  1. Card Shuffling

    From last time, said if you shuffle a deck 5 times, it is not well mixed. (The result, due to Bayer and Diaconis (1992), is that you need to shuffle the deck 7 times to mix it well or, more generally, 3 / 2 log2n times with n cards.)

    5 shuffles is not enough to mix a deck of cards
    A rising sequence R in the sequence S is a subsequence of S that contains successive integers and cannot be extended on the right or the left, preserving this property.

    So for example, in the following sequence:

    3, 6, 7, 2, 2, 8, 4, 5

    There are 4 rising sequences (6,7,8; 3,4,5; 2; and 1). The sequence 3,6,7,8 is not a rising sequence because 3 and 6 are not successive integers.


    Let nr(S) = the number of rising sequences needed to cover S.

    Why is this number well-defined? Because the set of rising sequences is uniquely defined from the sequence, determined by the natural algorithm. So their cardinality is well defined, too. Check that definitions are well-defined (you get the same answer, no matter the process)

    So for a deck with 52 cards:

    The case where the cards are in increasing order:
    Sinc = 1, 2, 3, ... , 51, 52 Sequence where everything is increasing
    nr(Sinc) = 1.

    The case where the cards are in decreasing order.
    Sdec = 52, 51, 50, ... , 2, 51 Sequence where everything is decreasing.
    nr(Sinc) = 52.

    Cutting the deck of cards and riffling will at most give you twice the number of rising sequences, because a given rising sequence remain in-tact up to the point where the deck was cut. New elements might appear at the front of the rising sequence or at the end, but the elements of the rising sequence cannot end up in more than two different rising sequences in the riffled deck S'. So


    If S´is a shuffle of S (so that SS´ in one shuffle)

    Then rs(S´) ≤ 2rs(S)

    To illustrate, in the sequence:

    3, 4, 5, 6, 7, 8, 9

    The “cut” part of the shuffle could fall between any two numbers in the list, or it might not cut the sequence at all. Suppose it cuts between 6 and 7, then the single rising sequence 3,4,5,6,7,8,9 becomes 3,4,5,6 and 7,8,9. Actually, we could capture additional cards to the left of 3 or right of 6 or to the left of 7 or to the right of 9, but certainly 3,4,5,6 and 7,8,9 will each appear in some rising sequence.

    S rs(S)
    Sinc =1
    S1 ≤ 2
    S2 ≤ 4
    S3 ≤ 8
    S4 ≤ 16
    S5 ≤ 32

    S5 has at most 32 rising sequences, which is still less than the 52 required. Specifically, five shuffles can't transform Sinc to Sdec. If we can't even reach all the possible ways of mixing up the deck, we can't possibly be well mixed. This proves that five shuffles is not enough to mix a deck of cards.

  2. Sentential Logic

    Sentential means no quantifiers. Quantifiers are either the universal quantifier for all or the existential quantifier there exists.

    We will assign truth values to each proposition symbol—variables like P, Q, P1, Q1, or ItsRaining). Each proposition symbol takes on a value of true or false

    Here are some other ways to represent true and false.

    true T 1
    false F 0

    I'll usually use the last of these notations. Here are some binary operators (with common alternative notations) on the boolean values, all arranged in a truth table:

    P Q “Disjunct”
    P or Q
    P || Q
    P and Q
    P && Q
    “Not P and Q
    PQ (?)
    P nand Q
    “Neither P nor Q
    PQ (?)
    P nor Q
    “Either P or Q
    P xor Q
    P if and only if Q
    P iff Q
    “If P then Q
    P implies Q
    PQ PQ
    0 0 0 0 1 1 0 1 1
    0 1 1 0 1 0 1 0 1
    1 0 1 0 1 0 1 0 0
    1 1 1 1 0 0 0 1 1

    There is also the unary operator ¬, or “Not“

    P “Not P
    0 1
    1 0


    1. “If my name is Peter then it is snowing” is true because the professor’s name is not Peter.
    2. People like to try to translate English into logical expressions, an enterprise that does not always work very well. Let's try a simple example:

      “Either you won’t go skiing, or you will and there won’t be any snow.”

      Using proposition symbols skiing and isSnow, we create the logical expressions:

      skiing ⇔ ¬snow
      ¬skiing ∨ ¬snow

      I'm not really sure which was the speaker's intent. I think the speaker was just trying to be ironic, and math doesn't capture that real well.

    3. Given the statements:
      1. Jane and Pete won’t both win the math prize
      2. Pete will win either the math prize or the chemistry prize
      3. Jane will win the math prize
      4. ∴ Pete will win the math prize
      We make the proposition symbols:
      • JM (Jane wins the math prize)
      • JC (Jane wins the chemistry prize)
      • PM (Pete wins the math prize)
      • PC (Pete wins the chemistry prize)
      And rewrite the previous four statements.
      1. JMPM
      2. PMPC
      3. JM
      4. PC
      These statements follow, and can be confirmed by creating a truth table.
    4. The NSF National Science Foundation

      “The project description must be brief (no more than 2 to 5 pages)”

      The logical meaning is unclear. Perhaps this means that the the description should be anywhere between two to five pages. Or maybe it means at most two pages. Or maybe it means at most five pages. You'd think the NSF could be more clear.

    Because of incompatibilities between English and sentential logic, we do not assign truth values to certain statements.

    Have Truth Values Don‘t Assign Truth Values
    There are 168 primes < 1000 What’s a rational number
    17 is an even number Is it raining?
    22 is rational Bush sucks
    Note that something might have a truth value but you don't know what it is. That's very different from being a statement not having a truth value.

    Let P be a (finite or countably infinite) set (the proposition symbols) not containing any symbol in the set {0,1(,),∨,∧,¬,→&harr}.

    Then the well-formed formulas (WFFs) over P are the following:

    1. 0 and 1 are WFFs
    2. PP is a WFF
    3. If α and β are WFFs, then so are
      1. (3) (α ∨ β)
      2. (4) (α ∧ β)
      3. (5) (¬α)
      4. (6) (α → β)
      5. (7) (α ↔ β)

    Nothing else is a WFF.

    1. ( (P ∨ (¬Q) → R) is a WFF. Using the earlier definitions, we can trace the following:

      1. Using (2), P, Q, and R are WFFs
      2. Using (5), ¬Q is a WFF
      3. Using (3), (P ∨ (¬Q) is a is a WFF
      4. Using (6), ( (P ∨ (¬Q) → R) is a is a WFF
    2. (¬¬P) is not a WFF, but we can regard it as one by adding some elided parentheses.
    3. →∨Q is not a WFF. How could you prove this?

    To give a truth value to a WFF like (PQ) → Q, we use truth assignment. This is a function t: P → {0, 1}
    t(P) = t(Q) = 0: the example formula comes out true
    t(P) = t(Q) = 1: the example formula comes out false

    A tautological formula is one that is always true, for any truth assignment. (PQ) → Q is tautological because no matter what truth values you assign to the variables, the formula comes out true.