Counting II: Fundamental Forms and Types
Counting II: Fundamental Forms and Types
Counting II: Fundamental Forms and Types
Correspondence Principle
If two finite sets can be placed into 1-1 onto correspondence, then they have the same size.
)(
) = ?
Choice Tree
A choice tree is a rooted, directed tree with an object called a choice associated with each edge and a label on each leaf.
A choice tree provides a choice tree representation of a set S, if 1)! Each leaf label is in S 2)!No two leaves have the same label.
Reversibility: From each object we should be able to deduce the choices that were made to create it.
n! n n = = r r!(n-r)! n-r
# of ways to pick r out of n elements = # of ways to choose the (n-r) elements to omit
n! (n-r)!
Ordered
n! n = r!(n-r)! r
Unordered
Total:
Order the 2,598,560 Poker hands lexicographically [or in any fixed manner]
To store a hand all I need is to store its index of size !log(2,598,560) "=22 bits. Hand 0000000000000000000000 Hand 0000000000000000000001 Hand 0000000000000000000010 . . .
22 Bits Is OPTIMAL
221 < 2,598,560 There are more poker hands than there are 21 bit strings. Hence, you cant have a string for each hand.
An n-element set can be stored so that each element uses !log2(n) " bits.
Furthermore, any representation of the set will have some strings of that length.
Information Counting Principle: If each element of a set can be represented using k bits, the size of the set is bounded by 2k
+ +
+ +
)(
+
+ +
) =
+
b1 t1 t2
b2 t1 t2
b3 t1 t2
b1 t1 t2
b2 t1 t2
b3 t1 t2
b 1 t1 b 1 t2
b 2 t1 b 2 t2 b 3 t1 b 3 t2
b1 t1 t2
b2 t1 t2
b3 t1 t2
b1 t1 t2
b2 t1 t2
b3 t1 t2
b 1 t1 b 1 t2
b 2 t1 b 2 t2 b 3 t1 b 3 t2
b 1 t1 b 1 t2
b 2 t1 b 2 t2 b 3 t1 b 3 t2
b1 t1 t2
b2 t1 t2
b3 t1 t2
b1 t1 t2
b2 t1 t2
b3 t1 t2
b 1 t1 b 1 t2
b 2 t1 b 2 t2 b 3 t1 b 3 t2
b 1 t1 b 1 t2
b 2 t1 b 2 t2 b 3 t1 b 3 t2
b1 t1 t2
b2 t1 t2
b3 t1 t2
b1 t1 t2
b2 t1 t2
b3 t1 t2
b 1 t1 b 1 t2
b 2 t1 b 2 t2 b 3 t1 b 3 t2
b 1 t1 b 1 t2
b 2 t1 b 2 t2 b 3 t1 b 3 t2
There is a correspondence between paths in a choice tree and the cross terms of the product of polynomials!
1
X2
X2
X2
X3
(1 + X) n
n times
(1 + X) n = c 0 + c1 X + c2X2 +. . .+c n Xn
&n # ck = $ $k ! ! % "
& n # &n # & n # 2 &n # n (1 + x) n = $ $0! !+$ $1 ! !x + $ $2! !x + ... + $ $n ! !x % " % " % " % "
Binomial Coefficients
binomial expression
& n # &n # & n # 2 &n # n ! $ ! $ ! $ (1 + x) n = $ + x + x + ... + $ 0 ! $ 1 ! $2! $n ! !x % " % " % " % "
& n # & n # 1 n '1 & n # 2 n ' 2 &n # n 0 $ ! !+$ $ ! !x y + $ $ ! !x y + ... + $ $ ! !x y (x + y)n = $ 0 1 2 % " % " % " %n "
By playing these two representations against each other we obtain a new representation of a previous insight:
n !n" (1 + x ) n = ( $ % # x k k =0 & k '
Let x= -1.
n "n# 0 = ) % & $ ( !1) k k =0 ' k (
Let x=1.
n !n" 2n = ( $ % k =0 & k ' ! "#
Equivalently,
n k even
) %k & = ) %k & = 2
' (
k odd
"n#
"n# ' (
n !1
The number of even-sized subsets of an n element set is the same as the number of odd-sized subsets.
n "n# (1 + x ) n = ) % & $ x k k =0 ' k (
Let x= -1.
n "n# 0 = ) % & $ ( !1) k k =0 ' k (
Equivalently,
n k even
) %k & = ) %k & = 2
' (
k odd
"n#
"n# ' (
n !1
We could discover new identities by substituting in different numbers for X. One cool idea is to try complex roots of unity, however, the lecture is going in another direction.
n k even
( $k % = ( $k % = 2
& '
k odd
"n#
n !1
Proofs that work by manipulating algebraic forms are called algebraic arguments. Proofs that build a 1-1 onto correspondence are called combinatorial arguments.
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 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 one-toone correspondence between On and En
An attempt at a correspondence
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 0010011 ! 1101100 1001101 ! 0110010
...but do even n work? In f6 we have 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
The binomial coefficients have so many representations that many fundamental mathematical identities emerge
Pascals Triangle: kth row are the coefficients of (1+X)k (1+X)0 = (1+X)1 = (1+X)2 = (1+X)3 = (1+X)4 = 1 1 + 1X 1 + 2X + 1X2 1 + 3X + 3X2 + 1X3 1 + 4X + 6X2 + 4X3 + 1X4
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)
Pascals Triangle
!0" #0$ = 1 % & !1 " !1" #0$ = 1 #1$ = 1 % & % & !2" !2" #1 $ = 2 #2$ = 1 % & % & ! 3" !3" ! 3" #1 $ = 3 #2$ = 3 # 3$ = 1 % & % & % &
Pascals Triangle
It is extraordinary 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 1 6 5 15 10 20 10 15 5 6 1 1
1 =1 =2 =4 =8 =16 =32 1 1 6 1 5 15 1 4 10 20 1 3 6 10 15 1 2 3 4 5 6 1 1 1 1 1 1
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 =64
6+20+6 = 1+15+15+1
( i = ( $1% = $
1 1 1 5
' # k $ = # k + 1$
% & % &
! i " ! n + 1"
1
=2 =3 1 2 1 =5 =8 1 3 3 1 =13
1 1 1 1 1 1 6 1 1 5 6 1 4 10 15
2
1 2 6 20
2
1 4
2 2
12 32 32 1 10
1 1 5 6 1
4 10 15
6 20
4 10 15
1 5
1 5 1 6 1
15
Al-Karaji Squares
1 1 1 1 1 1 1 1 1 4 10 15 1 5 6 1 2 + 2*1 3 + 2*3 4 + 2*6 20 =0 =1 =4 =9 =16 =25 1=36
All these properties can be proved inductively and algebraically. We will give combinatorial proofs using the Manhattan block walking representation of binomial coefficients.
5 + 2*10 6 + 2*15
Manhattan
jth Street 4 3 2 1 0 0 1 kth Avenue 2 3 4
10
Level n
Manhattan
0 kth Avenue 0 . 1 1 2 2 3 3 4 4
Level n
Manhattan 1
0 kth Avenue 0 . 1 2 2 3 3 4 4
level n . . . . . .
. . . . . . . . .1 . 1 . . .1 . 2 . . . 3 .1 .1 4 6
6 5
1 3
kth Avenue
1 4 1
1 5 10 10 15 20 15 6
1 1 2 3 6 10 20 15 4 5 1 1
kth Avenue
1 1 6
1 1 2 3 6 10 20 15 4 5 1 1
kth Avenue
1 1 6
1 1 2 3 6 10 20 15 4 5 1 1
kth Avenue
1 1 6
11
Application (Al-Karaji):
By convention:
n
/i
(empty product = 1)
i =0
= 12 + 22 + 32 + ! + n 2
0! = 1
= (1 ! 0 + 1) + (2 ! 1 + 2) + (3 ! 2 + 3) + ! + ( n( n " 1) + n) = 1 ! 0 + 2 ! 1 + 3 ! 2 + ! + n( n " 1) + / i
i =1 n
#% 2 & % 3 & % 4 & % 5 & % n & $ % n + 1& = 2 ') * + ) * + ) * + ) * + ! + ) * ( + ) * 2 2 2 2 + 2 ,. + 2 , -+ , + , + , + , % n + 1 & % n + 1 & (2n + 1)( n + 1)n = 2) *+) *= 6 + 3 , + 2 ,
1 + X1 + X2 + X 3 + + Xn-1 + Xn =
Xn+1 - 1 X- 1
1 + X1 + X2 + X 3 + + Xn + .. =
1 1-X
1 + X1 + X2 + X 3 + + Xn + .. =
1 1-X
12
1 + X1 + X2 + X 3 + + Xn + .. =
1 1-X
1 1 - aX
Vector Programs
Lets 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,>
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: V! := <6>; V! := RIGHT(V!) + <42>; V! := RIGHT(V!) + <2>; V! := RIGHT(V!) + <13>; Stare V! = <6,0,0,0,..> V! = <42,6,0,0,..> V! = <2,42,6,0,..> V!= <13,2,42,6,.>
13
Vector Programs
Example: V! := <1>; Loop n times: V! := V! + RIGHT(V!); Stare V! = <1,0,0,0,..> V! = <1,1,0,0,..> V! = <1,2,1,0,..> V! = <1,3,3,1,.>
!+1 !X
2 !+ !X
!X3
Vector Programs
PV := 1;
PV := PV + PV X;
RIGHT(V! ) is represented by
14
Vector Programs
Example: V! := <1>; Loop n times: V! := V! + RIGHT(V!); PV := 1; Example: V! := <1>;
Vector Programs
PV := PV (1+ X);
PV = (1+ X)n
( 1 + X + X2 + X3 + X4 + . . . . )n =
! # n + k " 1$ k 1 = ) % &X n n -1 ( (1 " X ) k =0 '
a0 + a1 + a2 + .. + ak
15
Lets add an instruction called PREFIXSUM to our VECTOR language. W! := PREFIXSUM(V!) means that the ith position of W contains the sum of all the numbers in V from positions 0 to i.
0 kth Avenue 1 2 3 4
Can you see how PREFIXSUM can be represented by a familiar polynomial expression?
W! := PREFIXSUM(V!) is represented by
PW = PV / (1-X) = PV (1+X+X2+X3+ .. )
Al-Karaji Program
Zero_Ave := PREFIXSUM(<1>); First_Ave := PREFIXSUM(Zero_Ave); Second_Ave :=PREFIXSUM(First_Ave); Output:= First_Ave + 2*RIGHT(Second_Ave)
Al-Karaji Program
Zero_Ave = 1/(1-X); First_Ave = 1/(1-X)2; Second_Ave = 1/(1-X)3; Output = 1/(1-X)2 + 2X/(1-X)3
16
(1+X)/(1-X)3
Zero_Ave := PREFIXSUM(<1>); First_Ave := PREFIXSUM(Zero_Ave); Second_Ave :=PREFIXSUM(First_Ave); Output:= RIGHT(Second_Ave) + Second_Ave
(1+X)/(1-X)3 outputs <1, 4, 9, ..> X(1+X)/(1-X)3 outputs <0, 1, 4, 9, ..> The kth entry is k2
X(1+X)/(1-X)4 expands to : X(1+X)/(1-X)3 = # k2Xk What does X(1+X)/(1-X)4 do? # Sk Xk where Sk is the sum of the first k squares
Aha! Thus, if there is an alternative interpretation of the kth coefficient of X(1+X)/ (1-X)4 we would have a new way to get a formula for the sum of the first k squares.
THUS:
1
(1 & X )
! "k + 3# k = )$ %X 3 ( k =0 '
17
(1 & X )
! "k + 3# k = )$ %X 3 ( k =0 '
! x = F0 x 0 + F1 x1 + F2 x 2 + F3 x 3 + ! = # Fi x i 2 1" x " x i =0
The action of dividing one polynomial by another can simulate a program to recursively compute Fibonacci numbers.
18
Fibonacci Numbers
Recurrence Relation Definition:
F0 = 0, F1 = 1, Fn = Fn !1 + Fn !2 , n > 1
Vector Recurrence Relation Definition: F! = RIGHT( F! + <1> ) + RIGHT( RIGHT( F! ) )
F! = a 0 , a 1
, a 2, a 3, a 4, . . .
F = a 0 + a 1 X + a 2 X2 + a 3 X3 +
RIGHT(F + 1) = (F+1) X
= 0, 0
, a 0, a 1, a 2, a 3, .
RIGHT( RIGHT( F ) )
F X2
F = (F + 1) X + F X2
F= a 0 + a 1 X + a 2 X2 + a 3 X3 + . . .
F = F X + X + F X2
Solve for F. F - FX - FX2 = X F(1-X-X2) = X F = X/(1-X-X2)
RIGHT(F + 1) = (F+1) X
RIGHT( RIGHT( F ) )
F X2
19
Since the bottom is quadratic we can factor it. X / (1-X-X2) = X/(1- $X)(1 (-$)-1X) where $ = The Golden Ratio
X (1 $X)(1- (-$-1X)
#n=0..!
Xn
#n=0..1
Xn
1 (1 $X)(1- (-$-1X)
X (1 $X)(1- (-$-1X)
#n=0.. !
$n+1 (-$-1)n+1 !5
Xn
#n=0.. !
20
! x 0 1 2 3 = F x + F x + F x + F x + ! = Fi x i # 0 1 2 3 1 " x " x2 i =0
! x 0 1 2 3 = F x + F x + F x + F x + ! = Fi x i # 0 1 2 3 1 " x " x2 i =0
*
i =0
$ ' ' )
References
Applied Combinatorics, by Alan Tucker
There is much, much more to be said about how polynomials encode counting questions!
has # &
integer solutions.
21