Comp Sci 102 Discrete Math for Computer Science

  • Slides: 50
Download presentation
Comp. Sci 102 Discrete Math for Computer Science 1 1 1 1 2 3

Comp. Sci 102 Discrete Math for Computer Science 1 1 1 1 2 3 4 5 6 1 3 6 10 15 1 1 4 10 20 1 5 15 March 27, 2012 Prof. Rodger 1 6 1 Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily by Prof. Steven Rudich.

Announcements • More on Counting

Announcements • More on Counting

Counting III 1 X+ 2 X+ 3 X

Counting III 1 X+ 2 X+ 3 X

Power Series Representation n (1+X)n = k=0 “Product form” or “Generating form” = k=0

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

By playing these two representations against each other we obtain a new representation of

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

Example 4 0 4 1 4 2 24 4 3 4 4 = 16

Example 4 0 4 1 4 2 24 4 3 4 4 = 16 Number of subsets of size 0, size 1, size 2, size 3, and size 4

By varying x, we can discover new identities: n (1+X)n = k=0 n Let

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

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

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

n (1+X)n = k=0 n k Xk Proofs that work by manipulating algebraic forms

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

n k odd n k n = k even n k Let On be

n k odd n k n = k even n k 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 gave an algebraic proof that On = En

A Combinatorial Proof Let On be the set of binary strings of length n

A Combinatorial Proof 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

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 f 7 we have: . . . but do even n work? In f 6 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

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 101001101 0001101 110011 010011 101010 001010

n (1+X)n = k=0 n k Xk The binomial coefficients have so many representations

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

The Binomial Formula (1+X)0 = 1 (1+X)1 = 1 + 1 X (1+X)2 =

The Binomial Formula (1+X)0 = 1 (1+X)1 = 1 + 1 X (1+X)2 = 1 + 2 X + 1 X 2 (1+X)3 = 1 + 3 X 2 + 1 X 3 (1+X)4 = 1 + 4 X + 6 X 2 + 4 X 3 + 1 X 4 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” 0 =1 0 1 =1 0 2 =1 0 3 =1 0

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

Pascal’s Triangle “It is extraordinary 1 how fertile in properties the 1 1 triangle

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

Summing the Rows n 2 n = n k 1 =1 1 + 1

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

Odds and Evens 1 1 1 1 2 3 4 5 6 1 3

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

Summing on 1 st Avenue n 1 1 1 1 2 3 4 5

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

Summing on kth Avenue 1 1 1 1 6 2 4 6 1 4

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

Fibonacci Numbers 1 =2 1 1 =3 = 5 1 2 1 =8 1

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

Sums of Squares 1 1 1 1 2 2 2 3 2 2 4

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

Al-Karaji Squares 1 1 =1 2 +2 1 =4 1 1 3 +2 3

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

Pascal Mod 2

Pascal Mod 2

All these properties can be proved inductively and algebraically. We will give combinatorial proofs

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? A B 10 5

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

Manhattan jth street 4 There are j+k k 3 2 1 0 0 1

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

Manhattan Example jth street 4 3 2 1 0 0 1 2 kth avenue

Manhattan Example jth street 4 3 2 1 0 0 1 2 kth avenue 3 4 2 cd street, 3 rd ave j+k k = 5 3 6 points on that row, this is the 4 th binomial coefficient of 6 items

Manhattan Level n 4 There are 3 2 n k 1 0 0 1

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

Manhattan Level n 4 3 2 1 0 0 1 2 kth avenue 3

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

Level n 4 3 2 1 1 1 6 0 0 1 5 1

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

Level n 4 3 2 1 0 1 kth avenue 1 1 1 3

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

Level n 4 n k=0 3 n k 2 1 2 = 0 0

Level n 4 n k=0 3 n k 2 1 2 = 0 0 2 n n 1 2 kth avenue 3 4 Example: Show for n=3

Show for n=3 2 3 3 + 1 0 12 20 + 32 2

Show for n=3 2 3 3 + 1 0 12 20 + 32 2 2 3 3 3 + + 2 + 32 + 2 = 12 6 3 =

Level n 4 3 2 1 0 0 1 2 kth avenue 3 4

Level n 4 3 2 1 0 0 1 2 kth avenue 3 4 Show for k=2, n=5 n i=k i k n+1 = k+1

Show for k=2, n=5 3 2 + 2 2 1 + 3 4 5

Show for k=2, n=5 3 2 + 2 2 1 + 3 4 5 + + 2 2 + 6 3 = 10 = 20

Vector Programs Let’s define a (parallel) programming language called VECTOR that operates on possibly

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 Programs Let k stand for a scalar constant <k> will stand for the vector <k, 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, …>

Vector Programs RIGHT(V!) means to shift every number in V! one position to the

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>;

Vector Programs Example: Store: V! : = <6>; V! : = RIGHT(V!) + <42>; 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, … >

Vector Programs Example: Store: V! : = <1>; V! = <1, 0, 0, 0,

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

1 X + 2 X + Vector programs can be implemented by polynomials! 3

1 X + 2 X + Vector programs can be implemented by polynomials! 3 X

Programs Polynomials The vector V! = < a 0, a 1, a 2, .

Programs Polynomials The vector V! = < a 0, a 1, a 2, . . . > will be represented by the polynomial: PV = i=0 a i. X i

Formal Power Series The vector V! = < a 0, a 1, a 2,

Formal Power Series The vector V! = < a 0, a 1, a 2, . . . > will be represented by the formal power series: PV = i=0 a i. X i

V ! = < a 0, a 1, a 2, . . . >

V ! = < a 0, a 1, a 2, . . . > PV = a i. X i i=0 <0> is represented by 0 <k> is represented by k V! + T! is represented by RIGHT(V!) is represented by (PV + PT) (PV X)

Vector Programs Example: V! : = <1>; PV : = 1; Loop n times

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

Vector Programs Example: V! : = <1>; PV : = 1; Loop n times

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

Vector Programs Example: V! : = <1>; Loop n times V! : = V!

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

 • Polynomials count • Binomial formula • Combinatorial proofs of binomial identities •

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