Great Theoretical Ideas in Computer Science

Slides:



Advertisements
Similar presentations
Great Theoretical Ideas in Computer Science for Some.
Advertisements

CompSci 102 Discrete Math for Computer Science March 27, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Counting Chapter 6 With Question/Answer Animations.
Counting III: Pascal’s Triangle, Polynomials, and Vector Programs Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2003 Lecture.
Discrete Structures & Algorithms More Counting. + + ( ) + ( ) = ? Counting II: Recurring Problems and Correspondences.
CSE115/ENGR160 Discrete Mathematics 04/17/12
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 10Feb 12, 2004Carnegie.
Binomial Identities.
Lecture 5 Counting 4.3, Permutations r-permutation: An ordered arrangement of r elements of a set of n distinct elements. Example: S={1,2,3}:
Counting II: Pascal, Binomials, and Other Tricks Great Theoretical Ideas In Computer Science A. Gupta D. Sleator CS Fall 2010 Lecture 8Sept. 16,
CompSci 102 Discrete Math for Computer Science March 22, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
Fibonacci Numbers, Polynomial Coefficients, and Vector Programs.
Rev.S08 MAC 1140 Module 12 Introduction to Sequences, Counting, The Binomial Theorem, and Mathematical Induction.
Lecture 11 Feb 17, 1998 Doug Beeferman Carnegie Mellon University Count your blessings... … faster !
Discrete Mathematics, 1st Edition Kevin Ferland
Chapter 8. Section 8. 1 Section Summary Introduction Modeling with Recurrence Relations Fibonacci Numbers The Tower of Hanoi Counting Problems Algorithms.
Basic Counting. This Lecture We will study some basic rules for counting. Sum rule, product rule, generalized product rule Permutations, combinations.
Section 2.4. Section Summary Sequences. Examples: Geometric Progression, Arithmetic Progression Recurrence Relations Example: Fibonacci Sequence Summations.
Binomial Coefficients, Inclusion-exclusion principle
Chapter 6 With Question/Answer Animations 1. Chapter Summary The Basics of Counting The Pigeonhole Principle Permutations and Combinations Binomial Coefficients.
Great Theoretical Ideas in Computer Science.
Great Theoretical Ideas in Computer Science.
Counting III: Pascal’s Triangle, Polynomials, and Vector Programs Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2003 Lecture.
Sequences and Summations
Lecture 5 Counting 4.3, Permutations r-permutation: An ordered arrangement of r elements of a set of n distinct elements. Example: S={1,2,3}:
1 Binomial Coefficients CS 202 Epp, section ??? Aaron Bloomfield.
COMPSCI 102 Discrete Mathematics for Computer Science.
Discrete Mathematics for Computer Science. + + ( ) + ( ) = ? Counting II: Recurring Problems and Correspondences Chapter 9 slides 1-54.
Great Theoretical Ideas in Computer Science.
Fibonacci Numbers, Vector Programs and a new kind of science.
COMPSCI 102 Discrete Mathematics for Computer Science.
The Pigeonhole Principle. The pigeonhole principle Suppose a flock of pigeons fly into a set of pigeonholes to roost If there are more pigeons than pigeonholes,
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science John LaffertyCS Fall 2005 Lecture 7Sept 20, 2005Carnegie.
Choose Your Representation! Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2005 Lecture 14 Feb 24, 2005 Carnegie Mellon University.
Spring 2016 COMP 2300 Discrete Structures for Computation
Counting II: Recurring Problems And Correspondences Great Theoretical Ideas In Computer Science V. AdamchikCS Spring 2006 Lecture 6Feb 2, 2005Carnegie.
Binomial Coefficients: Selected Exercises
CS Lecture 8 Developing Your Counting Muscles.
Section 6.4. Powers of Binomial Expressions Definition: A binomial expression is the sum of two terms, such as x + y. (More generally, these terms can.
Binomial Coefficients and Identities
Polynomials Count! CS Lecture 9 X1 X1 X2 X2 + + X3 X3.
Counting III: Pigeonhole principal, Pascal’s Triangle and more Great Theoretical Ideas In Computer Science S. Rudich V. Adamchik CS Spring 2006.
Sequences Lecture 11. L62 Sequences Sequences are a way of ordering lists of objects. Java arrays are a type of sequence of finite size. Usually, mathematical.
Copyright © 2004 Pearson Education, Inc.. Chapter 7 Further Topics in Algebra.
Induction in Pascal’s Triangle
L14: Permutations, Combinations and Some Review
Binomial Coefficients: Selected Exercises
Introduction to Discrete Mathematics
Developing Your Counting Muscles
Modeling with Recurrence Relations
Generalized Permutations & Combinations: Selected Exercises
Induction: One Step At A Time
Counting III: Pascal’s Triangle, Polynomials, and Vector Programs
To Exclude Or Not To Exclude?
Binomial Identities.
Great Theoretical Ideas in Computer Science
Basic Counting.
Binomial Identities.
Michael Duquette & Whitney Sherman
Sequences and the Binomial Theorem
Counting III: Pascal’s Triangle, Polynomials, and Vector Programs
Counting II: Recurring Problems And Correspondences
Great Theoretical Ideas in Computer Science
Algebraic Structures: Group Theory
Discrete Mathematics for Computer Science
Introduction to Discrete Mathematics
Cardinality Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted |A| = |B|, if and only if there is a one-to-one correspondence.
Counting II: Recurring Problems And Correspondences
Counting I: Choice Trees and Correspondences
Presentation transcript:

Great Theoretical Ideas in Computer Science 15-251 Great Theoretical Ideas in Computer Science

Counting III Lecture 8 (September 20, 2007) X1 X2 + X3

Arrange n symbols: r1 of type 1, r2 of type 2, …, rk of type k n-r1 r2 n - r1 - r2 - … - rk-1 rk … n! (n-r1)!r1! = (n-r1)! … (n-r1-r2)!r2! = n! r1!r2! … rk!

CARNEGIEMELLON 14! = 3,632,428,800 2!3!2!

5 distinct pirates want to divide 20 identical, indivisible bars of gold. How many different ways can they divide up the loot?

24 4 How many different ways to divide up the loot? Sequences with 20 G’s and 4 /’s 24 4

How many different ways can n distinct pirates divide k identical, indivisible bars of gold? n + k - 1 n - 1 n + k - 1 k =

How many integer solutions to the following equations? x1 + x2 + x3 + … + xn = k x1, x2, x3, …, xn ≥ 0 n + k - 1 n - 1 n + k - 1 k =

67 12 7 Identical/Distinct Dice Suppose that we roll seven dice How many different outcomes are there, if order matters? 67 12 7 What if order doesn’t matter? (E.g., Yahtzee) (Corresponds to 6 pirates and 7 bars of gold)

Identical/Distinct Objects If we are putting k objects into n distinct bins. Objects are distinguishable nk Objects are indistinguishable k+n-1 k

Binomial Coefficients The Binomial Formula n n 1 n (1+X)n = X0 + X1 +…+ Xn Binomial Coefficients binomial expression

What is the coefficient of (X1r1X2r2…Xkrk) in the expansion of (X1+X2+X3+…+Xk)n? n! r1!r2!...rk!

  Power Series Representation n k (1+X)n = Xk n k Xk = n k = 0  For k>n, “Product form” or “Generating form” n k = 0 “Power Series” or “Taylor Series” Expansion

The number of subsets of an n-element set By playing these two representations against each other we obtain a new representation of a previous insight: n n k  (1+X)n = Xk k = 0 n k  k = 0 2n = Let x = 1, The number of subsets of an n-element set

   By varying x, we can discover new identities: n k (1+X)n = Xk n 0 = (-1)k Let x = -1, n k  k even k odd = Equivalently,

The number of subsets with even size is the same as the number of subsets with odd size

n n k  (1+X)n = Xk k = 0 Proofs that work by manipulating algebraic forms are called “algebraic” arguments. Proofs that build a bijection are called “combinatorial” arguments

We just saw an algebraic proof that k  k even k odd = Let On be the set of binary strings of length n with an odd number of ones. Let En be the set of binary strings of length n with an even number of ones. We just saw an algebraic proof that On  =  En 

A combinatorial proof must construct a bijection between On and En Let On be the set of binary strings of length n with an odd number of ones Let En be the set of binary strings of length n with an even number of ones A combinatorial proof must construct a bijection between On and En

An Attempt at a Bijection Let fn be the function that takes an n-bit string and flips all its bits fn is clearly a one-to-one and onto function for odd n. E.g. in f7 we have: ...but do even n work? In f6 we have 0010011  1101100 1001101  0110010 110011  001100 101010  010101 Uh oh. Complementing maps evens to evens!

A Correspondence That Works for all n Let fn be the function that takes an n-bit string and flips only the first bit. For example, 0010011  1010011 1001101  0001101 110011  010011 101010  001010

n n k  (1+X)n = Xk k = 0 The binomial coefficients have so many representations that many fundamental mathematical identities emerge…

n k n-1 k n-1 k-1 + = Either we do not pick n: Or we do pick n: then we have to pick k elements out of the remaining n-1. Or we do pick n: then we have to pick k-1 elts. out of the remaining n-1. Set of all k-subsets of {1..n}

Pascal’s Triangle: kth row are coefficients of (1+X)k The Binomial Formula (1+X)0 = 1 (1+X)1 = 1 + 1X (1+X)2 = 1 + 2X + 1X2 (1+X)3 = 1 + 3X + 3X2 + 1X3 (1+X)4 = 1 + 4X + 6X2 + 4X3 + 1X4 Pascal’s Triangle: kth row are coefficients of (1+X)k Inductive definition of kth entry of nth row: Pascal(n,0) = Pascal (n,n) = 1; Pascal(n,k) = Pascal(n-1,k-1) + Pascal(n-1,k)

“Pascal’s Triangle” = 1 1 = 1 1 = 1 2 = 1 2 1 = 2 2 = 1 3 = 1 3 1 = 3 = 1 1 = 1 1 = 1 2 = 1 2 1 = 2 2 = 1 3 = 1 3 1 = 3 3 2 = 3 3 = 1 Al-Karaji, Baghdad 953-1029 Chu Shin-Chieh 1303 Blaise Pascal 1654

Pascal’s Triangle “It is extraordinary how fertile in 1 properties the triangle is. Everyone can try his hand” 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1

 Summing the Rows n 2n = k k = 0 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 = 1 + + + + + + + + + + + + + + + + + + + + + = 2 = 4 = 8 = 16 = 32 = 64

Odds and Evens 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 1 + 15 + 15 + 1 = 6 + 20 + 6

  Summing on 1st Avenue i i 1 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 n+1 2 = =

 Summing on kth Avenue 1 1 1 n+1 i = 1 2 1 k+1 k 1 3 3 1 1 4 6 4 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1  i = k n i k n+1 k+1 =

Fibonacci Numbers 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 = 2 = 3 = 5 = 8 = 13

Sums of Squares 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 2 2 2 2 2 2 2

Al-Karaji Squares 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1 1 6 15 20 15 6 1 = 1 +2 = 4 +2 = 9 +2 = 16 +2 = 25 +2 = 36

Pascal Mod 2

All these properties can be proved inductively and algebraically All these properties can be proved inductively and algebraically. We will give combinatorial proofs using the Manhattan block walking representation of binomial coefficients

How many shortest routes from A to B? 10 5 B

shortest routes from (0,0) to (j,k) Manhattan 1 1 jth street kth avenue 2 2 3 3 4 4 j+k k There are shortest routes from (0,0) to (j,k)

shortest routes from (0,0) to (n-k,k) Manhattan 1 Level n kth avenue 1 2 2 3 3 4 4 n k There are shortest routes from (0,0) to (n-k,k)

Manhattan 1 Level n kth avenue 1 2 2 3 3 4 4 n k There are 1 Level n kth avenue 1 2 2 3 3 4 4 n k There are shortest routes from (0,0) to level n and kth avenue

1 Level n kth avenue 1 1 2 2 1 1 3 1 2 1 3 4 1 3 3 1 4 1 4 6 4 1 1 5 1 10 10 5 6 15 20 15 6

n k n-1 k-1 n-1 k = + Level n kth avenue 1 1 2 1 1 1 2 1 3 1 3 3 1 4 1 Level n kth avenue 1 1 2 1 1 1 2 1 3 1 3 3 1 4 1 4 6 4 1 1 5 10 + 10 5 1 6 20 15 6 15 n k n-1 k-1 n-1 k = +

1 Level n kth avenue 1 2 2 3 3 4 4 n k  k = 0 2 2n n =

1 Level n kth avenue 1 2 2 3 3 4 4 n+1 k+1 i k  i = k n =

Vector Programs < * , * , * , * , *, *, … > Let’s define a (parallel) programming language called VECTOR that operates on possibly infinite vectors of numbers. Each variable V can be thought of as: < * , * , * , * , *, *, … >

Vector Programs Let k stand for a scalar constant <k> will stand for the vector <k,0,0,0,…> <0> = <0,0,0,0,…> <1> = <1,0,0,0,…> V + T means to add the vectors position-wise <4,2,3,…> + <5,1,1,….> = <9,3,4,…>

RIGHT( <1,2,3, …> ) = <0,1,2,3,…> Vector Programs RIGHT(V) means to shift every number in V one position to the right and to place a 0 in position 0 RIGHT( <1,2,3, …> ) = <0,1,2,3,…>

Vector Programs Example: Store: V! := <6>; V! := RIGHT(V!) + <42>; V! := RIGHT(V!) + <2>; V! := RIGHT(V!) + <13>; V! = <6,0,0,0,…> V! = <42,6,0,0,…> V! = <2,42,6,0,…> V!= <13,2,42,6,…> V! = < 13, 2, 42, 6, 0, 0, 0, … >

V! = nth row of Pascal’s triangle Vector Programs Example: Store: V! := <1>; Loop n times V! := V! + RIGHT(V!); V! = <1,0,0,0,…> V! = <1,1,0,0,…> V! = <1,2,1,0,…> V!= <1,3,3,1,…> V! = nth row of Pascal’s triangle

Vector programs can be implemented by polynomials! X1 + X2 + X3 Vector programs can be implemented by polynomials!

Programs  Polynomials The vector V! = < a0, a1, a2, . . . > will be represented by the polynomial:  i = 0  aiXi PV =

 Formal Power Series aiXi PV = The vector V! = < a0, a1, a2, . . . > will be represented by the formal power series:  i = 0  aiXi PV =

 V! = < a0, a1, a2, . . . > aiXi PV = i = 0  <0> is represented by <k> is represented by k V! + T! is represented by (PV + PT) RIGHT(V!) is represented by (PV X)

V! = nth row of Pascal’s triangle Vector Programs Example: V! := <1>; Loop n times V! := V! + RIGHT(V!); PV := 1; PV := PV + PV X; V! = nth row of Pascal’s triangle

V! = nth row of Pascal’s triangle Vector Programs Example: V! := <1>; Loop n times V! := V! + RIGHT(V!); PV := 1; PV := PV(1+X); V! = nth row of Pascal’s triangle

V! = nth row of Pascal’s triangle Vector Programs Example: V! := <1>; Loop n times V! := V! + RIGHT(V!); PV = (1+ X)n V! = nth row of Pascal’s triangle

Here’s What You Need to Know… Polynomials count Binomial formula Combinatorial proofs of binomial identities Vector programs Here’s What You Need to Know…