Contents / Combinatorics / Basic Counting
Chapter 1
Basic Counting
Permutations, combinations and the binomial coefficients, with the identities that follow and the models they each apply to.
Introduction
Permutations, combinations and the binomial coefficients, with the identities that follow and the models they each apply to.
1.1Counting as a Bijection
Counting a finite set means comparing it with a standard set. That comparison is the primitive notion from which everything else in this chapter is derived, so we start there rather than with formulas.
Notation (The standard finite sets). For a positive integer write , and . For a finite set , denotes its cardinality: the unique for which a bijection exists.
Definition 1.1 (Enumerative combinatorics). Enumerative combinatorics is the study of the cardinalities of finite sets that are specified by a description rather than by a list — typically a family indexed by a parameter, whose cardinality is sought as a formula, a recurrence, or an asymptotic in .
That "unique " in the notation box deserves a word: it is a theorem, not a convention, that no bijection exists when (the pigeonhole principle in its cleanest form). We take it as known. What we will use constantly is its companion, which turns every counting problem into a search for a bijection.
Theorem 1.2 (Bijection principle). Let and be finite sets. If there is a bijection , then .
Proof. Let , so there is a bijection . Then is a composition of bijections, hence a bijection, and so is its inverse . Therefore .∎
The principle is trivial to prove and is the most powerful tool in the chapter. Every identity established below — the formula for , stars and bars, Pascal's rule, Vandermonde's identity — is ultimately an instance of it: two descriptions of the same collection of objects, matched up one for one.
Intuition. To count the seats in a full theatre you do not count seats; you count the people, because "sit in a seat" is a bijection. Combinatorics is the discipline of noticing which map is the bijection.
The trick is that the easy side is not always the side the problem hands you. A good bijection replaces "arrangements of letters with these constraints" by "binary strings", or "committees with a designated chair" by "chairs with a committee around them", and the new description is one you already know how to count.
There is one more counting move that is not a bijection but a controlled failure of one. It appears whenever a symmetry makes several distinct-looking constructions produce the same object.
Theorem 1.3 (Division principle). Let be a surjection between finite sets such that every fibre has the same size , that is for every . Then
Proof. The fibres , for , are pairwise disjoint (a point of has exactly one image) and their union is (every point has an image). So . Divide by .∎
This is sometimes called the shepherd's principle: to count sheep, count legs and divide by four. It is exactly what licenses "divide by because order does not matter" and "divide by because rotations of a circle give the same arrangement" — two steps often performed on faith. They are not faith; they are the division principle, and they are valid precisely when every object is over-counted the same number of times.
Pitfall. The division principle fails silently when the fibres have different sizes. Counting the distinct arrangements of the letters of LEVEL as is wrong: counts arrangements of five labelled letters, and the correct divisor must account for both the two L's and the two E's, giving . Likewise, counting bracelets by dividing by is wrong in general, because an arrangement fixed by a reflection is over-counted fewer than times. When a symmetry can fix an object, naive division is invalid and one needs Burnside's lemma instead — a result beyond this chapter, resting on the orbit–stabiliser theorem from group theory.
Example 1.4 (Two descriptions of the same set). Show that the number of subsets of equals the number of binary strings of length , without computing either.
Solution. Define from subsets of to strings in by sending to its indicator string with if and otherwise.
is injective: if then for every we have , so . It is surjective: given a string , the set has equal to that string.
So is a bijection and the two counts agree by the bijection principle. We have not yet computed either one — that comes from the product rule in the next section, and gives . The point is the shape of the argument: define the map, check injective, check surjective, invoke the principle. Every bijective proof in this chapter has that skeleton.□
Example 1.5 (Counting by over-counting). A round table has seats and distinct guests. Two seatings are the same if one is a rotation of the other. Count the seatings using the division principle explicitly.
Solution. Let be the set of the ways to place the guests in six labelled chairs, let be the set of seatings-up-to-rotation, and let send a labelled placement to its rotation class.
Every class contains exactly labelled placements: rotating a placement by positions gives six labelled placements, and they are distinct because a nontrivial rotation moves every guest to a different chair. So each fibre has size , and is onto by construction. Hence
Sanity check: equivalently, fix one guest in a reference chair to remove the rotational freedom and arrange the other five, giving . The two routes agree, as they must.□
1.2The Four Counting Rules
Every elementary count is assembled from a small number of rules. Two of them are structural (sum and product), one is the division principle already proved, and one repairs the sum rule when the cases overlap. The trigger words are OR (disjoint alternatives → add) versus AND THEN (successive choices → multiply).
Theorem 1.6 (Addition rule). Let be pairwise disjoint finite sets, i.e. whenever . Then
Proof. It suffices to do ; the general case follows by induction on , since and the first bracket is disjoint from . For , let and be bijections, where and . Define by for and for . Injectivity uses disjointness (an element of is never an element of ), surjectivity is clear, so is a bijection and .∎
Theorem 1.7 (Product rule). For finite sets ,
Equivalently, in process form: if an object is built by successive choices, and for every way of making the first choices there are exactly options for the -th choice, then the number of objects is .
Proof. Again it suffices to treat and induct. Write . Then
and the sets in this union are pairwise disjoint (they differ in the first coordinate). Each has elements, since is a bijection . The addition rule gives .
For the process form, the objects are no longer literal tuples from fixed sets — the options at step may depend on earlier choices. Induct on : group the objects by their first choice. There are groups, pairwise disjoint, and each group is a set of objects built by successive choices with option counts , so each has elements by the inductive hypothesis. The addition rule finishes it.∎
The process form is the version worth memorising, and its hypothesis is the whole content of the rule: the number of options at each step must be the same no matter how the earlier steps went. The options themselves may differ; only their count must be constant.
Pitfall. "Independent choices" does not mean the later choice is unaffected by the earlier one. When dealing a second card from a deck, which cards remain depends entirely on the first card dealt — but how many remain is regardless, so the product rule applies and gives . Conversely, "choose a committee of from people, then choose a chair from outside the committee" has constant counts ( then ) and is fine, whereas "choose a nonempty subset of , then choose an element of " is not a product: the second count is , which varies from to . That one needs casework or a double count, not multiplication.
Intuition. Product: a shirt (5 colours) AND THEN trousers (3 styles) gives outfits, because each of the 5 shirts opens a fresh menu of 3.
Sum: desserts cakes (4) pies (3) ice creams (5) , because you take exactly one item and the three menus do not overlap.
Division: rotationally distinct round-table seatings of 6 guests, because the labelled seatings fall into groups of 6.
The addition rule needs disjointness. When the cases overlap, the repair is inclusion–exclusion; we state the two- and three-set versions here, which cover almost all elementary uses.
Theorem 1.8 (Inclusion–exclusion for two and three sets). For finite sets ,
Proof. Count the contribution of an arbitrary element to each side; since both sides are sums of cardinalities, it suffices that every such contributes exactly to the right-hand side (it contributes to the left by definition).
Say lies in exactly of the three sets. It is counted times in the single terms, times in the pairwise intersections, and times in the triple intersection, so its total contribution is
For this is ; for it is ; for it is . An element outside contributes to both sides. The two-set identity is the same computation with the column deleted.∎
These two cases cover almost every elementary use. The principle for sets, its complementary form, the Bonferroni truncations and the applications to sieves, derangements and surjections are the subject of Counting Principles.
A fifth move is not a new rule but a habit: complementary counting. If the objects you want are hard to describe but their complement inside an easy universe is easy, count the universe and subtract. "At least one" is the standing signal for it.
Example 1.9 (When to add, when to multiply). Licence plates consist of letters (A–Z) followed by digits (0–9). (a) How many are there if repetition is allowed? (b) How many if no letter may repeat? (c) How many contain at least one digit ?
Solution. (a) Six successive choices, with constant counts because repetition is allowed:
(b) The letter counts now shrink as letters are used up, but they shrink predictably: whatever the first letter was, exactly remain. So the process form applies with counts :
(c) "At least one 7" is a union of three overlapping events (digit 1 is a 7, digit 2 is, digit 3 is), so the addition rule does not apply directly. Complementary counting does: plates with no 7 have options in each digit slot, so
Sanity checks: (b) is smaller than (a), as forbidding repeats must reduce the count; and (c) is a fraction of (a), matching .□
Example 1.10 (Inclusion–exclusion in place). Of students, take French, take German, take Spanish, take French and German, take French and Spanish, take German and Spanish, and take all three. How many take none of the three?
Solution. By the three-set inclusion–exclusion formula,
Complementary counting then gives students taking none.
Sanity check by reconstructing the seven disjoint regions: all three, ; exactly F and G, ; exactly F and S, ; exactly G and S, ; only F, ; only G, ; only S, . These sum to , and all seven are non-negative, so the data are consistent.□
1.3Choosing the Right Model
Almost every mistake in elementary counting is a modelling mistake: the arithmetic is fine but the formula answers a different question. This section is the map. It is placed before the formulas are derived on purpose — you should know what you are aiming at while deriving it.
Two binary questions classify the four basic selection models. Given a pool of distinguishable objects from which are taken:
- Does order matter? Is the outcome a sequence or a set?
- May an object be taken more than once? With or without replacement?
Note (The four selection models). Taking objects from a pool of distinguishable objects:
| order matters | order does not matter | |
|---|---|---|
| repetition allowed | ||
| repetition forbidden |
Each entry is derived in a later section: and in the permutation sections, and in the section on unordered selections.
Note the asymmetry of the table: the two left entries differ by shrinking factors, and the two right entries are obtained from the left ones by dividing by — but only the bottom row division is exact. This is the single most important structural fact in the table.
Pitfall. The "divide by " step converts ordered selections into unordered ones only when repetition is forbidden. With repetition allowed, is usually not even an integer, and it is never the right answer: the fibres of "forget the order" have different sizes, because a multiset with repeated entries has fewer distinct orderings than one with all entries different. For the multisets are , , — three of them — whereas . The division principle is not applicable, which is exactly why combinations with repetition need their own argument (stars and bars) rather than a division.
Pitfall. A problem that sounds unordered may be ordered in disguise, and vice versa. The test is: would swapping two chosen items give a different outcome? "Choose 3 of 10 people to serve on a committee" — no, so . "Choose 3 of 10 people to be president, treasurer and secretary" — yes, so . "Choose 3 of 10 flavours for a three-scoop cone where scoops may repeat and the stacking order is visible" — yes, and with repetition, so . Same three numbers in the sentence, three different answers: , , .
The selection models are a special case of a more general and more useful classification: distributing balls into boxes. Every counting problem in this chapter can be phrased this way, and the phrasing makes the modelling decisions explicit, because it forces you to say whether the balls are labelled and whether the boxes are labelled.
Definition 1.11 (The distribution problem). Let balls be placed into boxes. The count depends on three independent binary choices:
- the balls are distinguishable (labelled ) or indistinguishable;
- the boxes are distinguishable or indistinguishable;
- the map is unrestricted, injective (at most one ball per box), or surjective (no box empty).
The resulting counts are the twelvefold way.
Read as functions, this is the classification of maps with , : "ball goes into box ". Indistinguishable balls means counting maps up to permutation of the domain; indistinguishable boxes, up to permutation of the codomain.
Theorem 1.12 (The twelvefold way). With balls and boxes, the number of distributions is:
| balls | boxes | any | injective ( per box) | surjective (none empty) |
|---|---|---|---|---|
| dist. | dist. | |||
| indist. | dist. | |||
| dist. | indist. | |||
| indist. | indist. |
Here is the Stirling number of the second kind (the number of partitions of an -set into exactly non-empty unlabelled blocks), is the number of partitions of the integer into exactly positive parts, and is if holds and otherwise.
Proof. The six entries in the first two rows are proved in this chapter. Row 1: is the count of sequences with repetition, and the count without, both established in the permutation sections — a distribution of labelled balls into labelled boxes is the sequence of box labels. Row 2: identical balls in labelled boxes are recorded only by the occupancy vector with and , counted by stars and bars as ; requiring means choosing which of the boxes are occupied, i.e. ; requiring is stars and bars for positive solutions, .
Rows 3 and 4 are a different matter. and have no closed product formula; they are defined by the counts in the surjective column, and the "any" column follows by the addition rule, splitting on the number of non-empty boxes. The relation in row 1 holds because a surjection onto labelled boxes is a partition into unlabelled blocks together with a bijection from the blocks to the labels, and there are such bijections — the product rule. The injective entries are immediate: with indistinguishable balls and boxes, an injective placement is determined by nothing at all, so the count is when and otherwise.
does satisfy a closed alternating sum, , which comes from inclusion–exclusion over the set of boxes left empty; and the partition numbers have no closed form at all, only generating functions and the Hardy–Ramanujan asymptotic. Both are beyond this chapter and are quoted, not proved, here.∎
Intuition. "Distinguishable" means the objects carry names you care about. Six labelled dice rolled at once are distinguishable (die 3 showing a 5 is different news from die 1 showing a 5); six identical marbles poured into cups are not.
A quick way to decide: imagine two of the objects swapping places. If the result is a genuinely different outcome for the purpose of the problem, they are distinguishable. If nobody could tell, they are not — and you are in one of the bottom rows.
Example 1.13 (One sentence, four models). Ten items are to be placed into four boxes. Count the distributions when (a) items and boxes are both labelled; (b) items are identical and boxes labelled; (c) items are identical, boxes labelled, and no box may be empty; (d) items are labelled, boxes labelled, and no box may be empty.
Solution. (a) Each of the labelled items independently picks one of labelled boxes: .
(b) Only the occupancy vector with and matters. By stars and bars,
(c) Now . Substituting with gives ; equivalently .
(d) This is , equal by inclusion–exclusion to
Sanity check on the ordering: (d) counts a subset of the objects counted in (a), and indeed ; the ratio is plausible since with balls in only boxes an empty box is unlikely. And (c) counts a subset of (b): . ✓□
Combinatorial counts are the engine of discrete probability: in a finite sample space where all outcomes are equally likely, , so every such probability question is two counting questions. They also govern algorithm analysis (how many comparisons does a sorting algorithm make?), coding theory (how many codewords of a given weight?), and statistical mechanics (how many microstates realise a macrostate?) — the last being literally row 2 and row 4 of the twelvefold way, known there as Maxwell–Boltzmann, Bose–Einstein and Fermi–Dirac statistics.
Example 1.14 (Counting for a probability). Five cards are dealt from a standard -card deck. What is the probability that the hand is a "full house" (three cards of one rank, two of another)?
Solution. The sample space is the set of unordered -card hands — order of dealing is irrelevant — so .
Build a full house by successive choices with constant counts: choose the rank appearing three times (), choose its three suits (), choose the different rank appearing twice (), choose its two suits (). By the product rule,
Sanity check: the equivalent route "choose the two ranks, then decide which is the triple" gives for the rank part, and the same for the suits. ✓□
Pitfall. In the full-house count the rank part is and must not be divided by . The two ranks play different roles — one is the triple, the other the pair — so swapping them gives a genuinely different hand, and the division principle does not apply. Divide by only when the chosen objects are interchangeable in the finished object.
1.4Factorials and Ordered Selections
We now derive the left column of the selection table. Order matters throughout this section.
Definition 1.15 (Factorial). For an integer , the factorial is defined recursively by
so that for .
The value is not a quirk. It is the empty product, and it is forced by every formula in which it appears: the recursion requires it, and so does the statement "there is exactly one arrangement of no objects" (namely the empty arrangement).
Definition 1.16 (Permutation). A permutation of a finite set is a bijection , equivalently a linear arrangement of the elements of in a row. A -permutation of (for ) is an injective map , equivalently an ordered selection of distinct elements of . Their number is written , where .
Theorem 1.17 (Arrangements of distinct objects). There are exactly permutations of a set of distinct objects.
Proof. Induction on . For there is one permutation of the empty set (the empty map), and . Suppose the claim holds for . An arrangement of objects is built by choosing the occupant of the first position ( options, whatever else will follow) and then arranging the remaining objects in the remaining positions. The second stage has outcomes by the inductive hypothesis, and this count does not depend on which object went first. The process form of the product rule gives .∎
Theorem 1.18 (Falling factorial). For integers ,
The product on the left has exactly factors and is called the falling factorial, written .
Proof. Fill the positions in order. Position admits any of the objects; once positions are filled, exactly objects are used up, so position admits objects — a count independent of which objects were used. The product rule gives .
For the closed form, multiply and divide by the missing tail:
Note the extreme cases: (the empty selection, consistent with an empty product) and , recovering the previous theorem.∎
Corollary 1.19 (Counting injections). The number of injective maps is , which is when .
Proof. An injective map is precisely an ordered selection of distinct elements of : the list , whose entries are distinct exactly because is injective. This correspondence is a bijection between injections and -permutations, so the counts agree by the bijection principle. When no injection exists (pigeonhole), and the falling factorial then contains the factor , so the formula remains correct.∎
Intuition. grows with terrifying speed: already, and exceeds — which is why "a well-shuffled deck is almost certainly in an order no deck has ever been in before" is literally true.
is with its tail cut off. Reading it as " factors counting down from " is faster and safer in practice than computing two factorials and dividing.
The growth rate deserves a precise statement, since it is quoted constantly in algorithm analysis and in probability.
Theorem 1.20 (Stirling's approximation). As ,
meaning the ratio of the two sides tends to . More precisely, for all .
Remark. The proof of Stirling's approximation is analytic, not combinatorial: it rests on comparing with to obtain the shape , and then on Wallis's product (or a Laplace-method estimate of ) to pin down the constant . Neither step is within the scope of this chapter, so we quote the result and use it only for estimates.
Example 1.21 (Ordered codes). How many -letter codes can be formed from the letters A–F if (a) letters may not repeat, (b) letters may repeat, (c) letters may not repeat and the code must contain the letter A?
Solution. (a) An ordered selection of distinct letters from :
(b) Each of the slots independently takes any of letters: .
(c) Choose the position of A ( ways), then fill the other two positions with distinct letters from the remaining five, in order: . By the product rule, .
Sanity check on (c) by complementary counting: codes with no A are , so codes containing A number . ✓ And (a) (b), as forbidding repetition must reduce the count.□
Example 1.22 (Arrangements with an adjacency constraint). In how many orders can distinct books be shelved if three particular volumes of one work must stand together, in any order among themselves?
Solution. Glue the three volumes into a single block. There are then objects to arrange (the block plus the other books), giving arrangements, and within the block the three volumes may be permuted in ways. These two stages have constant counts, so the product rule applies:
Sanity check: the answer must be smaller than the unrestricted , and the ratio is exactly the probability that three specified books land consecutively — plausible, and independently verifiable as . ✓□
1.5Sequences with Repetition
Removing the injectivity requirement changes the model completely, and gives the simplest formula in the chapter.
Theorem 1.23 (Sequences with repetition). The number of sequences of length whose entries come from an -element set, repetitions allowed, is
Equivalently, the number of functions is .
Proof. A sequence is an element of the Cartesian product ( factors) where , so the product rule gives . In process form: nothing is used up, so every one of the positions has the full options available regardless of the earlier positions.
For the function statement, the map sending to the sequence is a bijection — a function on a finite ordered domain is exactly its list of values — so the counts agree.∎
Corollary 1.24 (Number of subsets). A set with elements has exactly subsets.
Proof. By the earlier example, subsets of correspond bijectively to binary strings of length via the indicator string. By the theorem with symbols and length , there are such strings.∎
The contrast with the previous section is worth stating numerically, because it is the whole difference between "with replacement" and "without".
Remark. Compare with : the same number of factors, but the second has each factor reduced. Hence always, with equality only when . For and the ratio is below one half — this is the birthday paradox, and it is nothing but the gap between these two rows of the table.
Pitfall. The phrase "how many ways to choose from with repetition" is ambiguous in ordinary English and the two readings have very different answers. If the outcome is a sequence (a PIN, a dice roll recorded die by die, a word) the answer is . If the outcome is a multiset (a handful of coins, an unordered scoop selection, the multiset of values shown by identical dice) the answer is , derived later. Three dice thrown together give equally likely outcomes but only distinguishable multisets — and those are not equally likely, which is why using the wrong model quietly ruins a probability calculation.
Intuition. With repetition each slot has amnesia: it does not know or care what the previous slots took, so the menu never shrinks. Passwords, PINs and dice rolls work this way.
Without repetition the pool is a deck: every draw removes a card, so the menu shrinks by exactly one each time.
Example 1.25 (PINs and numbers). (a) How many -digit PINs are there, allowed? (b) How many -digit numbers are there (no leading zero)? (c) How many -digit PINs have all digits distinct? (d) How many have at least two equal digits?
Solution. (a) Four slots, options each: .
(b) The leading slot is restricted to –; the other three are unrestricted: . Check: these are the integers through , and . ✓
(c) No repetition, order matters: .
(d) Complementary counting against (a) and (c): .
Note that (d) could not be done directly by a product rule — "at least two equal" is not a sequence of choices with constant counts — which is exactly the situation complementary counting exists for.□
Example 1.26 (Counting functions with a constraint). How many functions satisfy ?
Solution. Choose the values in order. has options; then has (anything but — a count of whatever was); and have each. Constant counts at every stage, so
Sanity check: the total number of functions is , and those with number (pick the common value, then the last three freely). Indeed . ✓□
1.6Circular Arrangements and Multiset Permutations
Both topics in this section are applications of the division principle: we count something easy that over-counts, then divide by the size of the over-count. In both cases the hypothesis of the division principle — constant fibre size — has to be checked, and in one notorious case it fails.
Definition 1.27 (Circular arrangement). A circular arrangement of distinct objects is an arrangement of them around a circle in which two arrangements are identified when one is a rotation of the other; only the cyclic order matters.
Theorem 1.28 (Circular permutations). The number of circular arrangements of distinct objects is .
Proof. Let be the set of the arrangements in labelled seats around the circle and the set of circular arrangements, with the quotient map. is surjective. Each fibre is the set of the rotations of a given arrangement, and these labelled arrangements are pairwise distinct: a rotation by moves the object in seat to seat , so it changes the labelled arrangement. Hence every fibre has size exactly , and the division principle gives .∎
Pitfall. If the circle may also be flipped over — a bracelet or necklace rather than a seating plan — then reflections are identified too, and the naive answer is wrong in general, because the division principle no longer applies: an arrangement that is symmetric under some reflection has a fibre of size , not . For with all beads distinct no arrangement is reflection-symmetric, so is in fact correct there; but for , or as soon as beads repeat, the fibres genuinely differ in size and the count requires Burnside's lemma. Always check whether a symmetry can fix an object before dividing by the size of the symmetry group.
Definition 1.29 (Multiset and multiset permutation). A multiset on a set of types is an assignment of a multiplicity to each type ; its size is . A multiset permutation (or word) is a linear arrangement of the objects of such a multiset, two arrangements being the same when they agree position by position as sequences of types.
Theorem 1.30 (Permutations of a multiset). The number of distinct arrangements in a row of objects of types, with objects of type and , is
Proof. First proof (division principle). Temporarily label the objects of each type so that all are distinct; there are arrangements of these labelled objects. Let send a labelled arrangement to the word obtained by forgetting the labels. is surjective. Given a word , a labelled arrangement mapping to it is obtained by distributing the labels of type among the positions where type occurs, independently for each type, in ways. So every fibre has this same size and the division principle applies.
Second proof (successive choices). Build the word by deciding which positions each type occupies. Choose the positions for type from the available, in ways; then the positions for type from the remaining, in ways; and so on. The counts at each stage depend only on the , not on which positions were chosen, so the product rule gives
the intermediate factorials cancelling telescopically.∎
Definition 1.31 (Multinomial coefficient). The quantity , defined for non-negative integers summing to , is the multinomial coefficient. For it reduces to the binomial coefficient: .
Corollary 1.32 (Ordered set partitions). The number of ways to split a set of distinct objects into an ordered list of labelled groups of prescribed sizes (with ) is .
Proof. The second proof above is exactly this count: choosing the positions of type is choosing which objects go into group . Formally, the map sending a word to the tuple of sets positions of type is a bijection between multiset permutations and ordered size-prescribed partitions of .∎
Intuition. The multinomial coefficient answers "deal cards into hands of sizes ", and the two proofs are the two natural ways to do the deal: shuffle then cut ( divided by the internal shuffles you cannot see), or deal hand by hand (a product of binomials).
Because the second proof is a product of ordinary binomials, you never need the multinomial formula to compute — but you do need to recognise the situation, which is: more than two categories.
Pitfall. When the groups are unlabelled and of equal size, divide further. Splitting people into three labelled teams of gives ; splitting them into three unlabelled pairs gives , because each set of three pairs arises from orderings of the teams. The extra division is legitimate here because all the group sizes are equal, so every set of pairs is over-counted exactly times. If the group sizes were , no further division is right at all — the sizes themselves tell the groups apart.
Example 1.33 (MISSISSIPPI). How many distinct arrangements are there of the letters of MISSISSIPPI? How many of them have all four S's adjacent?
Solution. The multiset is M, I, S, P, of size . By the multiset permutation theorem,
For the second question, glue the four S's into a single block. The objects to arrange are the block, M, I, P — a multiset of size with multiplicities :
Sanity check: is the probability that a random arrangement has the S's together; a crude estimate — starting positions for the block out of position-sets for the S's — gives exactly. ✓□
Example 1.34 (Circular seating with a constraint). Six people, including Ana and Ben, sit at a round table; rotations are identified. In how many arrangements are Ana and Ben not adjacent?
Solution. Total circular arrangements: .
Count the arrangements where they are adjacent and subtract. Glue Ana and Ben into a block; we then have objects in a circle, giving circular arrangements, and the block has internal orders, so adjacent arrangements.
Sanity check by a direct argument: fix Ana's seat (killing the rotations). Of the remaining seats, are adjacent to Ana and are not, so Ben has allowed seats, and the other four people fill the rest in ways: . ✓□
1.7Unordered Selections and Stars and Bars
We now derive the right-hand column of the selection table. Both entries count sets or multisets rather than sequences, and the two proofs are of very different characters: the first is a division, the second is a bijection.
Definition 1.35 (Combination). A -combination of an -set is a -element subset of : which elements are taken matters, the order in which they are taken does not, and no element may be taken twice. The number of -combinations of an -set is written , read " choose ".
Theorem 1.36 (Combination formula). For integers ,
Proof. Let be the set of -permutations of , so , and let be the set of -subsets. Let send an ordered selection to the set of its entries. is surjective: any -subset can be listed in some order. Every fibre has size exactly : the ordered selections mapping to a given -set are precisely the orderings of , of which there are by the arrangements theorem — and crucially this number is the same for every , because the entries of a -permutation are distinct. The division principle gives
Remark. The third expression, , is the one to compute with: takes seconds, while invites a calculator overflow. It also makes visible that is a polynomial in of degree , which is how the definition is extended to non-integer upper arguments later on.
Intuition. A committee is a set; a lineup is a sequence. Going from lineups to committees loses exactly the information of the internal order, and there are internal orders, so you divide by .
This also reads in reverse and is often more useful: to count ordered things, first count the unordered thing and then multiply back by . Many problems are far easier in that direction.
Now the second entry: selections in which repetition is allowed but order is not. The outcome of such a selection is a multiset, so the object to be counted is a multiset of size on types.
Theorem 1.37 (Combinations with repetition (stars and bars)). The number of multisets of size drawn from types equals the number of integer solutions of
and both equal
Proof. The first equality is a bijection: a multiset is determined by, and determines, its multiplicity vector , where counts the copies of type and because the multiset has size .
For the second, encode a solution as a string of stars and bars: write stars, a bar, stars, a bar, …, a bar, then stars. For example with , , the solution becomes
This map sends solutions to strings of length over containing exactly bars. It is injective: the string determines every , namely the number of stars between bar and bar . It is surjective: given any such string, reading off the gaps between consecutive bars produces non-negative integers summing to (the total number of stars), and these map back to the string. So it is a bijection.
Finally, a string of symbols with exactly bars is determined by choosing which of the positions hold the bars — equivalently which hold the stars — so by the combination formula there are of them.∎
Corollary 1.39 (Positive solutions). The number of integer solutions of with every is
which is when .
Proof. Substitute . Then and , and the substitution is a bijection between the two solution sets (its inverse is ). By the theorem, the number of such is . If the sum is negative and no solution exists; the binomial coefficient is then by the convention for . In bars-and-stars language: lay out the stars in a row and choose of the internal gaps to place bars in, at most one per gap so that no part is empty.∎
Pitfall. Stars and bars counts non-negative solutions and requires the types (boxes, variables) to be distinguishable and the items (stars) to be indistinguishable. It is row 2 of the twelvefold way. If the items are distinguishable, the answer is , not ; if the types are indistinguishable, the answer is a partition number with no closed form. Before applying the formula, say out loud which of the four boxes-and-balls cases you are in.
Example 1.40 (Doughnuts). A shop sells varieties of doughnut. How many ways are there to buy a dozen, if varieties may repeat and the order in the box does not matter? How many if at least one of each variety is required?
Solution. This is a multiset of size on types, so by stars and bars
With at least one of each, the positive-solution corollary gives
Sanity check on the second by the substitution directly: after setting aside one of each variety, free doughnuts remain, giving . ✓ And , as a constraint must reduce the count.□
Example 1.41 (Bounded variables). How many integer solutions does have with for each ?
Solution. Count the unrestricted non-negative solutions and remove the bad ones by inclusion–exclusion. Unrestricted:
Let be the set of solutions with . Substituting turns the condition into a free non-negative solution of a sum equal to , so
Two variables cannot both be at least , since , so all pairwise intersections are empty. By inclusion–exclusion,
Sanity check by direct enumeration over : for the remaining pair must sum to within each, admitting solutions respectively. Total . ✓□
Example 1.42 (Ordered versus unordered, side by side). From distinct flavours, count (a) three-scoop cones where order on the cone matters and flavours may repeat; (b) three-scoop cups where order does not matter and flavours may repeat; (c) three-scoop cups with all flavours distinct; (d) three-scoop cones with all flavours distinct.
Solution. Each is one cell of the selection table with , .
(a) Ordered, with repetition: . (b) Unordered, with repetition: . (c) Unordered, without repetition: . (d) Ordered, without repetition: .
Sanity checks on the relations between them: , and indeed ✓ — the division by is exact without repetition. But , which is not and is not even an integer: with repetition the division is meaningless, as the pitfall in the modelling section warned. Note also the ordering and , all as expected.□
1.8Notation, Conventions and Symmetry
The binomial coefficient is used far beyond the counting of subsets — as a polynomial coefficient, as a probability weight, as an entry of a triangle — and each use wants slightly different conventions. This section fixes them.
Notation (Binomial coefficient conventions). For integers and any integer ,
In particular (one way to choose nothing, one way to choose everything) and .
The convention outside the range is not laziness; it makes identities true without side conditions. Pascal's rule, for instance, holds for all integers once the convention is in force, which is what allows the recursion to be iterated mechanically.
Definition 1.43 (Generalised binomial coefficient). For an arbitrary real (or complex) number and an integer ,
and for . For a non-negative integer this agrees with the previous definition, since the falling factorial then contains the factor as soon as .
Proposition 1.44 (Symmetry). For all integers and ,
Proof. Complementation is a map from -subsets of to -subsets, and it is its own inverse, hence a bijection. The bijection principle gives the identity. Algebraically the same thing: is unchanged when is replaced by . For outside both sides are .∎
Pitfall. Symmetry is a statement about the integer binomial coefficients only. is meaningless for non-integer — the right-hand side has a non-integer lower index — and false as soon as one tries to make sense of it. The generalised coefficient keeps Pascal's rule and the binomial series, but not symmetry.
Proposition 1.45 (Absorption identity). For integers ,
Proof. Count in two ways the pairs where has and — a "committee of size with a designated chair". Choosing the committee first and then the chair from within it gives . Choosing the chair first from all people and then the remaining members from the other gives . The two counts are of the same set, so they agree.∎
This is the prototype of a double count: a single set counted by two different schemes yields an identity for free, and the identity is explained rather than merely verified. Nearly all the identities in the last two sections have such a proof.
Proposition 1.46 (Unimodality and log-concavity). For fixed , the sequence increases up to the middle and decreases after it: for and for . Its maximum is .
Proof. From the formula, the ratio of consecutive entries is
which exceeds exactly when , i.e. , equals when is odd and , and is less than beyond. So the sequence rises strictly, possibly repeats one value at the centre of an odd row, then falls strictly; the maximum sits at (and also at ). Symmetry confirms the shape is a mirror image about the centre.∎
Intuition. Row of Pascal's triangle is a single hump: small at the ends, largest in the middle. That shape is why "about half heads" is overwhelmingly the most likely outcome of many coin tosses — the middle binomial coefficient dwarfs the ends. Stirling's approximation quantifies it: , so the central term is a fraction of the whole row sum .
Example 1.48 (Computing efficiently). Evaluate and , and verify the absorption identity for , .
Solution. Use symmetry to reduce the lower index first: — three factors instead of seventeen.
Absorption: the left side is ; the right side is . ✓ Both count the five-person committees with a designated chair drawn from twelve people.□
1.9Pascal's Rule and Subset Identities
The identities in this section all have the same two-line shape: describe a set, count it twice. They are the working vocabulary of combinatorial proof.
Theorem 1.49 (Pascal's rule). For all integers and all integers ,
Proof. Fix the element and split the -subsets of into two disjoint classes according to whether they contain .
Those that contain are determined by their other elements, chosen from : there are of them. Those that do not contain are -subsets of : there are . The two classes are disjoint and exhaust all -subsets, so the addition rule gives the identity.
The edge cases are covered by the zero convention: for or both sides reduce to the same value ( at , beyond the range).∎
Proposition 1.50 (Total number of subsets). For every integer ,
Proof. Both sides count the subsets of . The right side does so by the power-set corollary (each element independently in or out). The left side classifies the subsets by their size — the classes are disjoint and exhaust the power set — and the addition rule sums the class sizes.∎
Proposition 1.51 (Alternating sum). For every integer ,
equivalently an -set has as many even-sized subsets as odd-sized ones, namely of each.
Proof. Exhibit a bijection between even and odd subsets. Fix the element and define , i.e. remove from if present and adjoin it otherwise. Then changes by exactly , so it swaps parity, and , so it is a bijection. Hence the even-sized and odd-sized subsets are equinumerous; since together they number , each class has members, and the alternating sum — which is (evens) minus (odds) — vanishes. The hypothesis is needed for the element to exist; for the sum is , not .∎
Proposition 1.52 (Weighted subset sum). For every integer ,
Proof. Double count the pairs with and — a subset with a designated leader, of any size. Grouping by the size of gives . Grouping instead by the leader gives: choices of , then any subset of the remaining elements to complete , that is . Equating the two counts proves the identity. (Alternatively, sum the absorption identity over and apply the subset sum to row .)∎
Intuition. The rhythm of a double count is always the same: name a set of pairs (or of decorated objects), then count it by deciding the two coordinates in either order. "Committee with a chair" proves absorption; "subset with a leader" proves the weighted sum; "choose the first-year members, then the rest" will prove Vandermonde.
This is why combinatorial proofs feel like explanations rather than verifications: the identity is true because both sides are names for the same objects.
Example 1.53 (Pascal's rule at work). Verify Pascal's rule for , , and use the rule alone to compute from row of Pascal's triangle ().
Solution. Verification: , while . ✓
Row from row by adding adjacent pairs and capping with s: . So row is . Then .
Sanity check against the formula. ✓, and row sums to ✓.□
Example 1.54 (Counting with a parity condition). How many subsets of have an odd number of elements? How many have at least elements?
Solution. By the alternating-sum proposition, exactly half of the subsets are odd-sized: .
For the second, sum the top three terms of row :
Sanity check on the first by direct summation: . ✓□
1.10Pascal's Triangle and Lattice Paths
Definition 1.55 (Pascal's triangle). Pascal's triangle is the infinite triangular array whose -th row (rows indexed from ) is
By Pascal's rule each interior entry is the sum of the two entries above it, and each row begins and ends with .
The array can therefore be generated by addition alone, with no factorials and no multiplication:
Reading the triangle in different directions recovers the identities of the previous section as visual facts: rows are symmetric (symmetry of ), row sums are (the subset sum), the alternating sum of any row from row down is zero, and the second diagonal consists of the triangular numbers .
Intuition. Each entry is the sum of its two parents because a -subset of either takes the new element (left parent) or does not (right parent). The triangle is the recursion made visible.
Every counting question of the form "how many ways to choose from " for small can be read off the triangle faster than any formula can be evaluated.
Binomial coefficients also count paths on a grid, and this reading makes several identities geometrically obvious.
Theorem 1.56 (Lattice paths). The number of paths in the integer lattice from to using only unit steps right () and up () is
Proof. A path consists of exactly steps, of which exactly are and are (each raises the first coordinate by and each the second, and the endpoint requires those totals). Encode a path as the word of its steps, a string in with letters . This encoding is a bijection: the word determines the path step by step, and the path determines the word.
By the combination formula, the number of such words is the number of ways to choose which of the positions carry an , namely ; equivalently a multiset permutation, , which is the same number.∎
Corollary 1.58 (Pascal's rule, geometrically). The lattice-path count satisfies , since every path to arrives by its last step either from or from , and the two cases are disjoint.
Proof. Classify paths to by their final step. If the final step is , the rest of the path is an arbitrary path to , and there are of those. If it is , the rest is a path to , of which there are . Disjoint and exhaustive, so the addition rule applies. This is Pascal's rule with , .∎
Example 1.59 (Blocked grid). A city grid runs blocks east and blocks north. How many shortest routes from the south-west corner to the north-east corner (a) in total, (b) pass through the point east and north, (c) avoid that point?
Solution. (a) .
(b) A route through splits uniquely into a route to and a route from onward, and the two halves can be chosen independently:
(c) Complementary counting: .
Sanity check on (b): the split is a bijection between full routes through the point and pairs (first half, second half), which is what licenses the multiplication; and as it must be.□
Example 1.60 (Words and paths are the same object). Count the binary strings of length with exactly ones, and interpret the count as a path.
Solution. Choose which of the positions hold a one:
Reading a one as a step up and a zero as a step right, each string is a lattice path from to , and ✓ — the symmetry of the binomial coefficient is the symmetry of swapping the roles of the two coordinates.□
1.11The Binomial and Multinomial Theorems
The binomial coefficients were defined by counting subsets. The following theorem is the reason they are called binomial: they are exactly the coefficients that appear when a two-term sum is raised to a power.
Theorem 1.61 (Binomial theorem). For all elements of a commutative ring (in particular all real or complex numbers) and every integer ,
Proof. Combinatorial proof. Write the left side as a product of identical factors
Expanding by distributivity without collecting terms produces exactly one summand for each way of choosing one term — either or — from each of the factors; there are such summands, and each is a product of letters. A summand equals precisely when was chosen from exactly of the factors, and the set of those factors may be any -subset of the factors. By the combination formula there are such choices, so after collecting like terms the coefficient of is . Commutativity is what allows the letters within a summand to be reordered into the form .
Second proof, by induction on . For both sides are . Assume the formula for . Then
In the second sum substitute , and in the first write ; the coefficient of in the total is then , which equals by Pascal's rule (the zero convention handles and ).∎
Corollary 1.62 (Specialisations). Setting gives ; setting , gives for ; setting , gives the generating polynomial .
Proof. Each is a direct substitution into the theorem. Note that the first two re-prove, by algebra, the subset sum and alternating sum established combinatorially earlier — a good illustration that identities of this kind usually admit both a counting proof and an algebraic one.∎
Intuition. says: the polynomial is a catalogue of the subsets of , in which the coefficient of records how many have size . Algebraic manipulation of the polynomial then becomes manipulation of the whole family of counts at once. That idea, pushed further, is the theory of generating functions.
Pitfall. In the term the index is the exponent on the second letter. When asked for "the coefficient of in ", identify the roles first: here plays the role of the second letter (exponent , so counted from the constant term) — safest is to write the expansion explicitly as and read off , giving . Forgetting to raise the numerical factors and to their powers is the single most common slip in these questions.
The generalisation to more than two terms uses the multinomial coefficients of the earlier section.
Theorem 1.63 (Multinomial theorem). For commuting and an integer ,
Proof. Expand the product of factors by distributivity. Each summand is obtained by choosing one of the letters from each factor, so the summands correspond bijectively to the words of length over the alphabet . A word contributes exactly when it uses letter precisely times, and the number of such words is the multiset permutation count by the multiset theorem. Collecting like terms gives the stated coefficient. For this is the binomial theorem.∎
Corollary 1.64 (Number of monomials and the total). The expansion has distinct monomials, and setting every gives .
Proof. The monomials correspond to the exponent vectors with and , counted by stars and bars as . The second statement is the theorem evaluated at , whose left side is — equivalently, the total number of words of length over an -letter alphabet, classified by their letter multiplicities.∎
Theorem 1.65 (Newton's generalised binomial series). For any real and any real with ,
the series converging absolutely. When is a non-negative integer, all terms with vanish and the series is the finite binomial expansion.
Remark. This is an analytic statement, not a combinatorial one: the proof requires Taylor's theorem with a remainder estimate (or the theory of ordinary differential equations applied to , which satisfies ), together with a convergence argument on . Neither is in scope here, so we state it without proof and record only the combinatorially useful case for a positive integer , where
so that — a generating function whose coefficients are exactly the stars-and-bars counts. That is not a coincidence: it is the statement that distributing identical items among boxes is the -th coefficient of the -fold product .
Example 1.66 (Expansion and a single coefficient). (a) Expand . (b) Find the coefficient of in . (c) Find the coefficient of in .
Solution. (a) Row of Pascal's triangle is , so
Check: at both sides are ✓, and each term's exponents sum to ✓.
(b) Write . The term with has , and then carries exponent as required:
(c) By the multinomial theorem with :
Sanity check on (c): the sum of all multinomial coefficients for , is , and is a plausible share of it; the exponents ✓.□
1.12Vandermonde, the Hockey Stick, and Double Counting
This closing section collects the two identities that appear most often in applications, and proves both by double counting. The pattern to internalise is that the proof strategy — describe a set, classify its elements, count each class — is more valuable than either identity.
Theorem 1.67 (Vandermonde's identity). For non-negative integers and any integer ,
Proof. Let be a set of women and a set of men, disjoint, so . Count the -element subsets of in two ways.
Directly: there are of them.
By classification: sort the -subsets according to how many of their elements come from , say of them, where . The classes are pairwise disjoint and exhaust all -subsets. A subset in class is determined by choosing its elements from ( ways) and its remaining elements from ( ways), independently, so the class has members by the product rule. The addition rule over gives the sum.
The zero convention makes the formula correct even when or : the impossible terms simply vanish.∎
Corollary 1.68 (Sum of squares of a row). For every integer ,
Proof. Apply Vandermonde with and :
the last step by the symmetry .∎
Theorem 1.69 (Hockey-stick identity). For integers ,
Proof. Count the -element subsets of by their largest element. Every such subset has a unique largest element, so the classes are disjoint and exhaustive. If the largest element is (which requires , i.e. , and , i.e. ), the remaining elements form an arbitrary -subset of , of which there are . Summing over the possible largest elements gives , and the total is .∎
Intuition. The name comes from the picture: the summands lie along a diagonal of Pascal's triangle (the shaft of the stick) and the answer sits one step off the end, in the row below and to the side (the blade).
The special case is the schoolroom formula , and sums the triangular numbers.
Pitfall. The hockey-stick sum runs down a diagonal with the lower index fixed, not across a row. The superficially similar — a partial row sum — has no closed form at all; only the complete row sums to . Confusing the two is common; check which index is moving before reaching for the identity.
Example 1.71 (Vandermonde in a committee problem). A department has mathematicians and statisticians. How many committees of can be formed? Verify the answer by splitting on the number of mathematicians.
Solution. Directly: .
By Vandermonde with , , , classifying by the number of mathematicians:
The classification is also the efficient route to constrained versions: committees with at least one of each specialty are .□
Example 1.72 (Hockey stick and a running total). Evaluate , and use the identity to find .
Solution. By the hockey-stick identity with , :
Direct check: . ✓
The second sum is the first seven triangular numbers, that is , so it equals . Direct check: . ✓□
Example 1.73 (A double count with no formula in sight). Prove that for .
Solution. Double count the triples with , and , where and may coincide — "a subset with a chair and a secretary, possibly the same person".
Grouping by the size of : there are subsets of size and choices of the ordered pair inside it, giving .
Grouping instead by whether :
- If : choose the common person ( ways) and any subset of the remaining elements to complete (), giving .
- If : choose the ordered pair ( ways) and any subset of the remaining elements (), giving .
Adding the two disjoint cases,
Sanity check at : the left side is , and . ✓□
Summary (The identities of this chapter).
- Symmetry: .
- Pascal: .
- Absorption: .
- Row sum: ; alternating: for .
- Weighted: .
- Vandermonde: ; squares: .
- Hockey stick: .
- Binomial theorem: ; multinomial: coefficients .
- Multiplying when the option count varies. The product rule needs the number of options at each stage to be constant, not the options themselves. "Pick a non-empty subset, then pick a member of it" is not ; it needs a sum over subset sizes (and equals ).
- Adding overlapping cases. "Red cars OR fast cars" double-counts the fast red ones; inclusion–exclusion subtracts the overlap back out.
- Dividing by a symmetry that fixes something. for bracelets and for LEVEL are both invalid divisions — the fibres are not all the same size. Check before dividing.
- Assuming . It is , the empty product, and every formula here (, , the recursion ) breaks without it.
- Treating "with repetition" as a single model. With repetition and order gives ; with repetition and no order gives ; the two differ wildly and no division converts one into the other.
- Reaching for a formula before fixing the model. Decide first: ordered or not, repetition or not, labelled boxes or not. The formula follows from the model; guessing the formula first is how , , and get interchanged.
- Dividing by to "remove the order". Invalid whenever repetition is allowed, because multisets with repeats have fewer orderings than those without. Use stars and bars.
- Using stars and bars on distinguishable items. counts identical items in labelled boxes. Labelled items in labelled boxes is ; identical items in identical boxes is a partition number with no closed form.
- Forgetting the zero convention. for or is what makes Pascal's rule, Vandermonde and the hockey stick true without case analysis.
- Misreading the index in the binomial theorem. In the index is the exponent on the second letter, and numerical factors inside the letters must be raised to their powers too.
- Confusing a diagonal sum with a row sum. is a diagonal; a partial row sum has no closed form.