Definitions: Suppose S is a (finite) set and n, k 0 are integers The set C(S, k) of k - combinations consists of all subsets of S that have exactly k elements The set P (S, k) of k - permutations consists of all k-tupels (s 1,, s k ) of pairwise distinct elements s i of S Write C(n, k) and P (n, k) for the cardinalities of C([n], k), and of P ([n], k), respectively Comments: C(S, k) = {A S: A = k} P(S) is a set of subsets of S P (S, k) S k = S S consists of k-sequences (s }{{} 1, s 2, s k ) k-times of elements s i S More precisely, P (n, k) is the the set of one-to-one functions from [n] to S C( S, k) = C(S, k) and P ( S, k) = P (S, k) are numbers
Idea: Reduce the problem of counting P ([n], k) to counting P ([n 1], k 1) Any sequence (s 1,, s k ) P ([n], k) which does not contain n among its first (k 1) components is mapped to (s 1,, s k 1 ) P ([n 1], k 1) If s i = n for some i < k then map it to (s 1,, s i 1, s k, s i+1,, s k 1 ) which is again in P ([n 1], [k 1]) because s j n for j i For illustration consider the example Φ 5,3 : P ([5], 3) P ([4], 2), with Φ 5,3 broken up into two steps: Φ 5,3 = (1, 2, 3) (1, 2, 4) (1, 2, 5) (1, 5, 2) (1, 5, 3) (2, 4, 5) (2, 5, 1) (5, 1, 2) (5, 4, 3) (1, 2, 3) (1, 2, 4) (1, 2, 5) (1, 2, 2) (1, 3, 3) (1, 3) (2, 4, 5) (2, 4) (2, 1, 1) (2, 1) (2, 1, 2) (2, 1) (3, 4, 3) (3, 4) Check for understanding: Find all elements x P ([5], 3) such that Φ 5,3 (x) = (2, 1), ie find Φ 1 5,3(2, 1) Find Φ 1 5,3(3, 4) Find all elements x P ([5], 3) such that (x) = (3, 2, 1), ie Ψ 1 5,3(3, 2, 1) Find Ψ 1 5,3(3, 2, 3) find
Definitions: For n k >1 the function Ψ n,k : P ([n], k) [n 1] k is defined by Ψ n,k (s 1, s k ) = (s 1, s i 1, s i, s i+1 s k 1, s k ) if s i n for all i k (s 1, s i 1, s k, s i+1 s k 1, s k ) if s i = n Also define π n 1,k : [n 1] k [n 1] k 1 by π n 1,k (s 1, s k ) = (s 1, s k 1 ), and Φ n,k : P ([n], k) P ([n 1], k 1) by Φ n,k = π n 1,k Ψ n,k Exercises: For all n > 2 and all k > 1: verify that Ψ n,k (s) [n 1] k for every s P ([n], k), verify that π n 1,k (Ψ n,k (s)) [n 1] k 1 ) for every s P ([n], k), verify that π n 1,k (Ψ n,k (s)) P ([n 1], k 1) for every s P ([n], k), prove that Φ n,k is onto P ([n 1], k 1), prove that Ψ n,k is one-to-one, describe precisely which (s 1, s k ) lie in the image of P ([n], k) under Ψ n,k show that Φ n,k is n-to-one, Show that a left inverse of Ψ n,k (defined on the image of Ψ n,k ) is given by Ψ 1 n,k(s 1, s k ) = (s 1, s 2, s k 1, s k ) if s i s k for all i < k (s 1, s i 1, n, s i+1 s k 1, s k ) if s i = s k
Definition: Recursively define the counting functions f m+k,k : P ([m+k], k) Z for n 1 by f n,1 (i) = i, and for m 1, k > 1 by f m+k,k (s 1, s k ) = s k + (m + k) (f m+k 1,k 1 Φ m+k,k (s 1, s k ) 1) Theorem: For every pair of integers m 0, k 1 the function f m+k,k is a bijection from P ([m + k], k) onto (m+k)! Proof (by induction on k): Induction start: If k = 1 then f m+1,1 is the identity map on [m+1] = [ ] (m+1)! Induction hypothesis: Suppose f m+k 1,k 1 : P ([m + k 1], k 1) Z is a bijection onto (m+k 1)! for all m 0 and some k 1 1 Induction step: Assuming that f m+k 1,k 1 : P ([m + k 1], k 1) (m+k 1)! is a bijection for all m 0, consider now f m+k,k First show that f m+k,k is one-to-one: Suppose s = (s 1, s k ) and s = (s 1, s k) are in P ([m + k], k) such that f m+k,k (s) = f m+k,k (s ) This means that ( ) s k s k = (m + k) f m+k 1,k 1 (Φ m+k,k (s )) f m+k 1,k 1 (Φ m+k,k (s)) The left side takes integer values in the interval [ (m + k 1), m + k 1], while the right hand side is an integer multiple of (m + k), hence both sides are zero Use the induction hypothesis and the fact that the right side is zero to conclude that Φ m+k,k (s ) = Φ m+k,k (s) Combine this with the left side being zero, ie s k = s k to conclude Ψ m+k,k (s ) = (Φ m+k,k (s ), s k) = (Φ m+k,k (s), s k ) = Ψ m+k,k (s) Since Ψ m+k,k was shown to be one-to-one this proves that s = s To show that f m+k,k is onto, suppose y 1 is an integer such that y (m + k)!/k! Write y in the form y = z (m + k) + r with z 0 and 0 < r m + k (ie r is basically the remainder of y after division by (m + k) but we allow r = m + k instead of the usual requirement that 0 r < m + k) Note that 0 z < y m + k (m + k)! (m + k) = (m + k 1)! and thus, by induction hypothesis, there exists s = (s 1, s k 1 ) P ([m + k 1], k 1) such that f m+k 1,k 1 (s) = z + 1 If s i = r for some i then define s = (s 1,, s i 1, m + k, s i+1, s k 1, r), else define s = (s, r) Note that in either case s has no repetitions, and each s i [m + k], ie s P ([m + k], k) It is straightforward to check that indeed f m+k,k (s) = y
Counting combinations Definition: Recursively define for n 0 the counting functions f n,k : C([n], k) Z: For k = 0 define f n,0 ( ) = 1 For k = n define f n,n ([n]) = 1 For 0 < k < n define { fn 1,k (A) if n A f n,k (A) = f n 1,k 1 (A \ {n}) + (n 1)! else Theorem: For any integers n 0, 0 k n the function f n,k is a bijection from C([n], k) onto [ (n k)! k! ] Proof (by induction on n) Induction start If n = 0 then the only choice is k = 0, and f 0,0 : C([0], 0) = { } [1] = [ 0! ] is a bijection 0! 0! Induction hypothesis Suppose f n 1,k is a bijection onto [ ] for some n 1 0 and all 0 k n 1 Induction step Assuming the induction hypothesis consider now f n,k for 0 k n If k = 0 then f n,0 : C([n], 0) = { } {1} = [ ] is a bijection (n 0)! 0! If k = n then f n,n : C([n], n) = {[n]} {1} = [ ] is a bijection 0! (n 0)! For the remainder assume 0 < k < n To show that f n,k is one-to-one, suppose A, A C([n], k) are such that f n,k (A) = f n,k (A ) Beware The combination of two 1-1 functions need not be 1-1: The functions f 1 (x) = { x and f 2 (x) = x are 1-1 on any domain, but their f1 (x) if x < 0, combination f(x) = is f(x) = x which is not 1-1 f 2 (x) if x 0 Distinguish two cases: If f n,k (A) (and thus also f n,k (A ) ), then f n 1,k (A)=f n,k (A)=f n,k (A )=f n 1,k (A ) By induction hypothesis f n 1,k is 1-1 and thus A=A If f n,k (A) > (and thus also f n,k (A ) > f n 1,k 1 (A\{n}) = f n,k (A) ), then = f n,k(a ) = f n 1,k 1(A \{n}) By induction hypothesis f n 1,k 1 is one-to-one and thus A \ {n} = A \ {n} Together with n A and also n A (because of f n,k (A) > and f n,k(a ) > this shows that again A = A Beware: In general A\B =A \B does not imply A=A To show that f n,k is onto [ ) ] suppose 1 y Again consider two cases (n k)! k! (n k)! k! then, by induction hypothesis, there exists A C([n 1], k) such that If y f n 1,k (A) = y Since A is also a subset of [n], and it does not contain n, clearly also f n,k (A) = y If y > then, with a little algebra verify all steps in this calculation 0 < y (n k)! k! = n (n k) = (n k)! k! ((n 1) (k 1))! (k 1)! by induction hypothesis, there exists A C([n 1], k 1) such that f n 1,k 1 (A ) = y Define A = A {n} Then A = A + 1 = (k 1) + 1 = k because n A, Thus A C([n], k) and f n,k (A) = f n 1,k 1 (A ) + (n 1)! = y This shows that f n,k is onto [ ] (n k)! k!