The Ohio State University October 10, 2016
Combinatorics —
1 Functions and sets
Enumerative combinatorics (or counting), at its heart, is all about finding functions between different sets in such a way that reveals their size. A little combinatorics goes a long way: you’ll probably run into it in every discipline that involves numbers. Beyond numbers and sets, there is not much additional formal theory needed to get started. For sets A and B, a function f : A → B is any assignment of elements of B defined for every element of A. All f needs to do to be a function from A to B is that there is a rule defined for obtaining f(a) ∈ B for every element of a ∈ A. In some situations, it can be non-obvious that a rule in unambiguous (we will see examples), in which case it may be necessary to prove that f is well-defined. We will be interested in counting, which motivates the following three definitions.
Definition 1: A function f : A → B is injective if and only if for all x, y ∈ A, f(x) = f(y) ⇒ x = y.
These are sometimes called one-to-one functions. Think of injective functions as rules for placing A inside of B in such a way that we can undo our steps.
Lemma 1: A function f : A → B is injective if and only if there is a function g : B → A so that ∀x ∈ A g(f(x)) = x. This function g is called a left-inverse for f
Proof. ⇒ : We need to define g on all B. Let S ⊂ B be all those elements of B that can be reached using f (also called the range of f). Formally:
S = {b ∈ B : ∃ a ∈ A, f(a) = b} .
Then for each b ∈ S, define g(b) to be an arbitrary a so that f(a) = b. For each b ∈ B \S (the elements of B not in S), just define g to be any arbitrary assignment. Then by definition, for any a ∈ A, a0 = g(f(a)) is an element of A so that f(a0) = f(a), which by assumption implies a = a0 = g(f(a)), as desired. ⇐: Suppose x, y ∈ A have f(x) = f(y). Then x = g(f(x)) = g(f(y)) = y. There is a complementary definition for surjective functions.
Math 3345 Combinatorics1 Fall 2016 Definition 2: A function f : A → B is surjective if and only if for all y ∈ B there exists x ∈ A so that f(x) = y.
These are sometimes called onto functions. Think of surjective functions as rules for surely (but possibly inefficiently) covering every B by elements of A.
Lemma 2: A function f : A → B is surjective if and only if there is a function g : B → A so that ∀y ∈ B f(g(y)) = y. This function is called a right-inverse for f.
Proof. ⇒ : We need to define g on all B. By assumption, for any b ∈ B, there is an a ∈ A so that f(a) = b. Hence, let g(b) be any arbitrary choice of such an a. Then by definition, for any b ∈ B, f(g(b)) = b. ⇐: Suppose y ∈ B is arbitrary. Let a = g(y). Then f(a) = f(g(y)) = y, and so since y was arbitrary, f is surjective. Combining these two lemmas, we see that if g is the left-inverse of f (so that f is injective) then we also have that f is a right-inverse of g. This automatically implies that the left-inverse of an injective function f is surjective. By the same argument, the right-inverse of a surjective function f is injective. Finally, we define the main object of combinatorics, the function that is both injective and surjective.
Definition 3: A function f : A → B is bijective if it is both injective and bijective.
Just like with injective and surjective functions, we can characterize bijective functions according to what type of inverse it has.
Lemma 3: A function f : A → B is bijective if and only if there is a function g : B → A so that 1. ∀a ∈ A, g(f(a)) = a. 2. ∀b ∈ B, f(g(b)) = b. This function g is called a two-sided-inverse for f.
Proof. ⇒ : Using Lemmas 1 and 2, we know there are functions g, h : B → A so that 1. ∀a ∈ A, g(f(a)) = a. 2. ∀b ∈ B, f(h(b)) = b. The only trouble is that we don’t know g = h just from invoking the lemmas, but it turns out that must be true. Let b ∈ B be arbitrary. Then
h(b) = g(f(h(b))) = g(b),
Math 3345 Combinatorics2 Fall 2016 where in the first equality, we apply f followed by g to h(b), and in the second equality, we use that f(h(b)) = b. This shows g = h. ⇐: Because g exists, by Lemmas 1 and 2, we have f is both injective and surjective, and hence bijective.
Example 1: Let f : Z → Z be given by f(x) = 2x. Then f is injective because if f(x) = f(y), then 2x = 2y, which implies x = y. However, f is not surjective because there is no x ∈ Z so that f(x) = 1.
Example 2: Let f : R → R be given by f(x) = x3. Then f is bijective. The function g : R → R given by x 7→ x1/3 is a two-sided inverse for f.
Example 3: Let f : R → R≥0, where
R≥0 = {x ∈ R : x ≥ 0} ,
2 be given by f(x) =√x . Then f is surjective but not injective. The function g : R≥0 → R defined by g(x) = x which gives the non-negative square-root of a non-negative number x is a right-inverse for f. This is to say that ∀x ∈ R≥0, f(g(x)) = x. Therefore f is surjective. However, f(1) = 1 = f(−1), and so f is not injective. Also, ∀x ∈ R≥0, g(f(x)) = |x|, so g is not a left-inverse for f.
Exercise 1: Fix a ∈ R with 0 ≤ a ≤ 2π. Define the function fa(x) = sin(a + x) mapping [0, π] to [−1, 1]. For what values of a is fa injective? Surjective? Exercise 2: Fix b ∈ N. By the division algorithm, for every z ∈ Z, there are unique q, r ∈ Z with {0, 1, 2, . . . , b − 1} so that z = bq + r. Let fb : Z → {0, 1, 2, . . . , b − 1} be the function that sends z to r.
(a) Prove that the function fb is surjective.
(b) Prove that the function fb is not injective. (c) Fix a ∈ Z. Define the function g : {0, 1, 2, . . . , b − 1} → {0, 1, 2, . . . , b − 1} by g(z) = fb(a + z). Prove that the function g is bijective. (d) Fix a, b ∈ N. Define the function m : {0, 1, 2, . . . , b − 1} → {0, 1, 2, . . . , b − 1} by m(z) = fb(a · z). Prove that the function m is bijective if gcd(a, b) = 1. Comment: this is the basis of modular arithmetic, which allows one to define an addition and multiplication rule on {0, 1, 2, ··· , b − 1} that satisfy the normal axioms of addition and multiplication. Even better, one can show this has multiplicative inverses when b is prime.
Math 3345 Combinatorics3 Fall 2016 Composition We also need to be able to talk about compositions of functions. If f : A → B and g : B → C are functions, then g ◦ f : A → C (said “g compose f”) is the function that for all x ∈ A, (g ◦ f)(x) = g(f(x)). Injectivity, surjectivity, and bijectivity all behave nicely with respect to composition
Lemma 4: Let f : A → B and g : B → C be two functions. 1. If both f and g are injective, then g ◦ f is injective. 2. If both f and g are surjective, then g ◦ f is surjective. 3. If both f and g are bijective, then g ◦ f is bijective.
Exercise 3: Prove this lemma.
Set operations Finally, we need to define a few common set operations. For any two sets, A and B we define the union, intersection, and set difference by the following rules.
x ∈ A ∪ B ⇐⇒ (x ∈ A) ∨ (x ∈ B) x ∈ A ∩ B ⇐⇒ (x ∈ A) ∧ (x ∈ B) x ∈ A \ B ⇐⇒ (x ∈ A) ∧ (x∈ / B) Like with the logical operations ∨ and ∧, the set operations have distributivity rules, but for the moment we mostly need these for notation. When we do set theory, we will cover these rules further.
Example 4: Let A = {1, 2} and B = {2, 3} . Then A ∪ B = {1, 2, 3} A ∩ B = {2} A \ B = {1}
One way to think of two sets A and B for which there exists a bijection f : A → B is that B is somehow a relabeling of A. The function f tells us how to do the relabeling, and its properties ensure that for every element of B there is one and only one element of A in correspondence with it. The only information left over is the size, or cardinality, of the set.
Math 3345 Combinatorics4 Fall 2016 Definition 4: Two sets A and B have the same cardinality if and only if there exists a bijection f : A → B.
Cardinality makes sense for finite sets and infinite sets. Combinatorics is concerned with the finite case, for which reason we introduce the following.
Definition 5: Let [n] ⊂ N be the set [n] = {1, 2, 3, . . . , n} . Say a set A has cardinality n if and only if there is bijection f : A → [n] and write |A| = n.
The two basic counting principles, on which everything is built, are the addition principle and the multiplication principle.
Lemma 5 (Addition Principle): If A and B are two disjoint finite sets, then the union A ∪ B (the set which contains everything that is either in A or in B) has cardinality |A ∪ B| = |A| + |B|.
Proof. Let S = A ∪ B. Let |A| = n and |B| = m. Then by definition, there are bijections f1 : A → [n] and f2 : B → [m]. Define a function g : S → [n + m] by ( f (x) if x ∈ A, and g(x) = 1 n + f2(x) if x ∈ B. This rule would not be well-defined if A and B had any overlap. As we assume they are disjoint, this rule is unambiguous. Checking that g is a bijection is elementary and left as an exercise. The addition principle extends by induction to larger collections of disjoint sets. That is, if A1,A2,...,Ak are finite, disjoint sets, then
|A1 ∪ A2 ∪ · · · ∪ Ak| = |A1| + |A2| + ··· + |Ak|.
Example 5: If A is a set of 7 apples, B is a set of 2 bananas, and C is a set of 6 cherries, then the set of all fruit S has |S| = |A ∪ B ∪ C| = |A| + |B| + |C| = 15.
The addition principle, has many consequences as related to finite cardinalities. To start we can generalize this principle slightly:
Lemma 6: If A and B are finite sets, then |A ∪ B| = |A| + |B| − |A ∩ B|.
Math 3345 Combinatorics5 Fall 2016 Proof. This follows from the original addition principle in the following way. Let C = B \ A. Then on the one hand, A ∪ B = A ∪ C, but A and C are disjoint by construction. Therefore
|A ∪ B| = |A ∪ C| = |A| + |C|. (0-1)
On the other hand, B = C ∪ (A ∩ B), and C is disjoint from A ∩ B. Therefore
|B| = |C| + |A ∩ B|.
Rearranging this equation (solving for |C|) and substituting it into (0-1), the equation in the statement of the lemma follows. We can also use this principle to show that an injection from a finite set to itself is necessarily a bijection.
Lemma 7: Suppose A is a finite set and f : A → A is an injection. Then f is a bijection.
Proof. Define the range of f by
Range(f) = {a ∈ A : ∃ b ∈ A, f(b) = a} .
These are exactly the points in A that can be reached using f. By definition, f takes values in Range(f), more specifically than taking values in A. So, f : A → Range(f). Moreover, f is a surjection to Range(f), and hence as it is still an injection (check!)
|A| = | Range(f)|.
On the other hand A = Range(f) ∪ (A \ Range(f)), which is a decomposition of A into disjoint sets. Therefore by the addition principle,
|A| = | Range(f)| + |A \ Range(f)|.
Combining this with what we know about the size of Range(f), it follows that |A\Range(f)| = 0. Hence, there are no elements in this set. Or in other words, Range(f) = A. Since f is a surjection on Range(f), it follows f is surjection to A. This shows f is a bijection. The same idea holds for surjections, which follows from this as a simple consequence.
Corollary 1: Suppose A is a finite set and f : A → A is a surjection. Then f is a bijection.
Math 3345 Combinatorics6 Fall 2016 Proof. This proof is what is called, half-jokingly, abstract nonsense. It is automatic in a sense from the definitions and from the Lemma. Let’s begin. If f is a surjection, there is a right-inverse g for f. A right-inverse is necessarily an injection (because f is a left-inverse for g), and therefore applying the Lemma to g, g is a bijection. A one-sided inverse for a bijection is necessarily a two-sided inverse (check!), and so f is a bijection. To state the multiplication principle, we first need to introduce a corresponding multi- plcation for sets.
Definition 6: For two sets A, B, the cartesian product A × B is the set of all pairs (a, b) where a ∈ A and b ∈ B.
The multiplication principle states that the cardinality of a product of sets is the product of cardinalities of those sets.
Lemma 8 ((weak) Multiplication Principle): If A and B are two finite sets, then the cartesian product A × B has cardinality
|A × B| = |A| · |B|.
We will first give a more general, stronger version of the multiplication principle that has more applications. So, we’ll delay the proof until that point. This multiplication also extends to larger products in a natural way, so for multiple finite sets A1,A2,...,Ak the product A1 × A2 × · · · × Ak is the set of all k-tuples (a1, a2, . . . , ak) where each ai ∈ Ai. By applying induction and the multiplication principle, the cardinality of this set is the product of cardinalities:
|A1 × A2 × · · · × Ak| = |A1| · |A2| · · · |Ak|.
There is a much more useful, strong version of the multiplication principle that generalizes the weak multiplication principle given above. To introduce this principle, we need the idea of a k-to-one map.
Definition 7: Fix a k ∈ N. A function f : A → B is called k-to-one if for every b ∈ B, there are either 0 elements a ∈ A so that f(a) = b or there are k elements of A so that f(a) = b.
Example 6: Let A and B be finite sets with cardinalities n and m. Define f : A×B → B by f(a, b) = b for all (a, b) ∈ A × B. Then f is n-to-one.
Math 3345 Combinatorics7 Fall 2016 Lemma 9 (Multiplication Principle): If S and A are two sets, and f : S → A is a k-to-one surjection, then |S| = k|A|.
Proof. Let |A| = n. For each a ∈ A, let Va ⊂ S be all those elements that get mapped to a by f. By assumption, |Va| = k for all a ∈ A. Moreover, [ S = Va, a∈A that is to say, every element of S is in some Va (since every element of S gets mapped to something by f). Furthermore, for any a 6= b that are elements of A, Va and Vb are disjoint, since any element of S is only mapped to at most one element of A. Hence by the addition principle X |S| = |Va| = k|A|. a∈A
Example 7: We will count the number of two digit numbers in N whose digits are neither 0 nor equal to one another. These numbers are all written as ab for some a, b ∈ [9]. Let S be the set of all pairs (a, b) for which ab is one of the two digit numbers discussed. Define a mapping f : S → [9] by letting f(a, b) = a. For every pair (a, b), we have that b can be any number in [9] except for a. Therefore f is 8-to-one. So |S| = 72.
Exercise 4: Let n = 2635.
(a) How many positive divisors are there of n?
(b) How many positive divisors of n are there whose prime factorization contains a different number of 2’s and 3’s?
Exercise 5: Fix n, m ∈ N. Prove, by counting [n + 1] × [n + m] in two ways, that
m + (m + 2) + (m + 4) + ··· + (m + 2n) = (n + 1)(n + m).
Exercise 6: Two integers are called relatively prime if their greatest common divisor is 1.
(a) How many positive integers in [15] are relatively prime to both 3 and 5?
(b) Let p and q be two prime numbers. Find a formula for the number of integers between 1 and p · q (in [pq]) that are relatively prime to both p and q and prove it.
Math 3345 Combinatorics8 Fall 2016 3 Counting Stuff!
To get started with combinatorics, these are all the formal tools we will need. There are essentially 12 basic combinatorial counting problems, which taken together are called the twelvefold way. We’ll summarize this later. For now, we will introduce some of the most important counting problems in this array. The first counting problem we’ll do is just to count the number of functions between two sets.
Definition 8: Let AB denote the set of all functions from B → A.
Example 8: {0, 1}{x,y} is the set of all functions from {x, y} to {0, 1} . These functions are
1. f(x) = 0, f(y) = 0.
2. f(x) = 0, f(y) = 1.
3. f(x) = 1, f(y) = 0.
4. f(x) = 1, f(y) = 1.
Theorem 1: For finite sets A, B the cardinality of AB is |A||B|.
In effect, the idea here is that a function from B to A is just an ordered list of information, with no constraints. Proof. Let |B| = m. Define a set
S = A × A × · · · × A | {z } m copies
So S is a collection of m-tuples, where each entry is an element of A. By the multiplication principle |S| = |A|m. To finish the proof, we define a bijection ϕ from AB to S. This bijection should take the data in a function from A to B and recast it as a vector. Since |B| = m, there is a bijection g from [m] → B. Then define, for any f ∈ AB
ϕ(f) = (f(g(1)), f(g(2)), f(g(3)), . . . , f(g(m))) .
Checking that ϕ is a bijection is an exercise. The most important special case of this counting problem is to count the number of subsets of a set.
Definition 9: For a set S, let P(S) be the set of all subsets (including S and ∅) of S.
Math 3345 Combinatorics9 Fall 2016 Example 9: The subsets of [3] are
{1, 2, 3} {1, 2}{1, 3}{2, 3} , {1}{2}{3} ∅ for a total of 8.
Theorem 2: For a finite set S, |P(S)| = 2|S|.
Exercise 7: Prove this theorem. Hint: construct a bijection between P(S) and {0, 1}S .
Permutations are a rich source of counting problems, which tie naturally to many other counting problems.
Definition 10: For any set S, let Let Per(S) be the set of all bijections from S to itself. These are called the permutations of S. The set Per(∅) is conventionally considered to have one element in it, the function that does nothing (the identity map).
Exercise 8: Prove that if X,Y are finite sets with |X| = |Y | then:
(a) | Per(X)| = | Per(Y )| (Hint: X and Y must be in bijective correspondence, as they have the same cardinality. Use this bijection to construct a bijection of Per(X) and Per(Y )).
(b) The number of bijections from X to Y is | Per(X)|.
Moreover, there’s no particular reason to study Per(S) instead of Per([n]), since we can always identify the two sets of permutations. This allows us to develop some notation. The first and most useful notation for us will be one-line notation for a permutation. To write a permutation f :[n] → [n] in one-line notation, just write the ordered list f(1), f(2), . . . , f(n). Conventionally, we don’t write the commas so long as it doesn’t cause confusion.
Example 10: The permutation f ∈ Per([3]) that is defined by f(1) = 2, f(2) = 3, f(3) = 1 is given in this notation by 231
Math 3345 Combinatorics10 Fall 2016 in one-line notation. The complete list of permutations of [3] is 123 132 213 231 312 321
Inversion table We want to show that Per([n]) = n(n − 1)(n − 2) ··· (2)(1), that is to say that Per([n]) = n! We will do this by finding an explicit bijection between Per([n]) and the set [1] × [2] × [3] × · · · × [n]. This bijection is constructed algorithmically, and we’ll start by illustrating it with an example.
Example 11: We will build a permutation by specifying the relative location of numbers to one another in one-line notation. We will work with the permutation 14532. Let’s start by placing the largest number on a line: 5 Now we’ll place the 4 in relative position to the 5. There are two places for it: before or after the 5. We place it before. 45 We now place the 3. There are now 3 places to put it: to the left of the 4, between the 4 and 5 or after the 5. We put it at the end. 453 This continues, until all the numbers have been placed. Summarizing the whole procedure. 5 45 453 4532 14532
The data we needed to record at each step was the relative location of the number j.
Definition 11: The inversion table map ϕ : [1] × [2] × [3] × · · · × [n] → Per([n])
Math 3345 Combinatorics11 Fall 2016 is given by the following iterative algorithm. Suppose (a1, a2, . . . , an) is an element of [1] × [2] × · · · × [n]. Start with an empty list of numbers. For each j = n, n − 1, n − 2,..., 1 insert j into this list in the an−j+1 position.
Formally, there are lots of things to check to see that this algorithm actually produces a permutation: for exmaple are there n − j + 1 positions before the insertion at step j? In principle, one could use induction to give a formal proof that the algorithm produces a permutation, but it’s relatively obvious if the algorithm itself makes sense. To show the map ϕ is a bijection, we need to either work with the definition of a bijection or produce a two-sided inverse for ϕ. In this situation, it’s almost certainly easier to create the inverse map. We pose this as an exercise. Exercise 9: Define (using an algorithm) the inverse map of ϕ, which maps Per([n]) to [1] × [2] × [3] × · · · × [n].
Corollary 2: The cardinality of Per([n]) is n!
We also provide, for comparison, a non-algorithmic approach to showing this corollary.
Lemma 10: For any n ≥ 1, | Per([n])| = n · | Per([n − 1])|.
Proof. Let B(X,Y ) denote the set of bijections between two sets. When |X| = |Y |, we know from exercise 8 that |B(X,Y )| = | Per(X)|. The idea now is to partition the permutations f :[n] → [n] according to the value of f(n). After restricting f to [n − 1], what remains is a bijection from [n − 1] to [n] \ f(k). Hence, if m = | Per([n − 1])|, then the function
ϕ : Per([n]) → [n]
given by ϕ(f) = f(n) is an m-to-one surjection. By the multiplication principle, | Per([n])| = nm, which is the statement of the lemma. Using induction, this gives rise to the same formula for the cardinality of the set of permutations of [n]. The inversion table provides other useful information, though. For example, the inversion number of a permutation is one measure of how scrambled it is:
Definition 12: The inversion number Inv(f) of a permutation f ∈ Per([n]) is the sum −1 −1 of the numbers that appear in ϕ (f) minus n. In symbols, if (a1, a2, . . . , an) = ϕ (f) then
n X Inv(f) = (ai − 1). i=1
Exercise 10: This exercise tests some basic properties of the inversion number.
(a) Which permutations of n have inversion number 0?
Math 3345 Combinatorics12 Fall 2016 (b) How many permutations of n have inversion number 1? (c) A permutation is called even (resp. odd) if it has an even (resp. odd) number of inversions? Prove that there are the same number of even and odd permutations. Hint: map a permutation to is inversion table, do something to the table and then map it back.
Counting injections In light of Lemma 7, counting permutations of [n] could also be considered as counting injections from [n] to [n]. It turns out the related problem of counting injections from [k] to [n] is of similar difficulty. Let I (k, n) be the set of injections from [k] to [n]. The idea is the same as what is given in Lemma 10. Exercise 11: In this exercise, we assume k and n are positive integers with k ≤ n. (a) Show that so long as k ≥ 1, |I (k, n)| = n|I (k − 1, n − 1)| using the multipli- cation principle.
(b) Conclude using induction that |I (k, n)| = n(n − 1)(n − 2) ··· (n − k + 1). Because of its frequent appearance, this formula is given a specific name.
Definition 13: The falling factorial is denoted by [n]k. It is defined by n(n − 1)(n − n! 2) ··· (n − k + 1). When k ≤ n are positive integers this can also be written as (n−k)! .
Remark 1: Mathematical conventions vary wildly when it comes to how to notate the falling factorial. Be warned!
5 Subsets