Date: 20/07/2026
Permutations and Combinations: A Rigorous Treatise on Combinatorics
Preface
Combinatorics has a curious reputation: it is thought of as the branch of mathematics with the fewest prerequisites and the highest difficulty ceiling. Anyone who can count on their fingers can state a combinatorics problem; almost no one can solve the hard ones on sight. There is no vast machinery to hide behind, no theorem so powerful that it renders the problem trivial — every configuration must be understood on its own terms, usually by finding the right way to look at it.
This treatise is written for the reader who has outgrown the "select the correct formula" stage of combinatorics and is ready for the "construct the correct argument" stage — the level demanded by JEE Advanced, the ISI (B.Stat/B.Math) and CMI entrance examinations, and the Olympiad circuit (INMO, IMO). We assume comfort with sets, functions, basic algebra, and mathematical induction. We do not re-derive the factorial or explain what a "permutation" is in the elementary sense; instead we build outward from these atoms toward the tools — Inclusion-Exclusion, the Pigeonhole Principle, double counting, and generating functions — that separate contestants who know combinatorics from those who compute it.
Every major section follows the same discipline: Definitions fix vocabulary, Theorems are stated with precision, Proofs are given in full wherever they illuminate a counting technique (and are named and cited, rather than silently omitted, when they require machinery — such as Burnside's Lemma — that lies formally outside our scope), Remarks and Tricks collect the folklore that experienced problem-solvers carry in their heads, Examples are fully worked, and each Part closes with one or two Challenge Problems — genuinely hard, fully solved, at competition level.
Combinatorics rewards patience and punishes haste. Read the proofs; do not skip to the formulas.
Table of Contents
- Conventions and Notation
- Part I — Fundamental Counting Principles & Basic Configurations
- 1.1 The Rule of Sum and the Rule of Product
- 1.2 Permutations and Combinations
- 1.3 Permutations of a Multiset
- 1.4 Circular Permutations
- 1.5 Problem-Solving Tricks: Bundling, Gaps, and Lexicographic Rank
- 1.6 Challenge Problems
- Part II — Distributions, Partitions, and Stars & Bars
- 2.1 The Stars and Bars Theorem
- 2.2 Constrained Distributions: Bounds and PIE
- 2.3 The Twelvefold Way (Basics)
- 2.4 The Multinomial Theorem
- 2.5 Challenge Problems
- Part III — The Principle of Inclusion–Exclusion & Derangements
- 3.1 PIE: Statement and Proof
- 3.2 Derangements
- 3.3 Surjections
- 3.4 Hidden PIE in Number Theory
- 3.5 Challenge Problem: The Problème des Ménages
- Part IV — Pigeonhole Principle & Combinatorial Proofs
- 4.1 The Pigeonhole Principle, Basic and Generalized
- 4.2 Applications in Number Theory and Geometry
- 4.3 Double Counting
- 4.4 Key Identities via Combinatorial Proof
- 4.5 Challenge Problems
- Part V — Generating Functions & Recurrence Relations
- 5.1 Motivation
- 5.2 Ordinary Generating Functions: A Working Table
- 5.3 Coefficient Extraction
- 5.4 Catalan Numbers
- 5.5 Challenge Problems
- Appendix — Master Formula Sheet
- Closing Remark — The Unifying Theme
Conventions and Notation
| Symbol | Meaning |
|---|---|
| The set | |
| or | Cardinality of the finite set |
| factorial, with | |
| Falling factorial , terms | |
| , | Number of -permutations of distinct objects; |
| , | Number of -combinations of distinct objects |
| Multinomial coefficient | |
| The symmetric group: all permutations (bijections) of | |
| The number of derangements of | |
| Stirling number of the second kind: ways to partition an -set into nonempty unlabeled blocks | |
| The -th Catalan number | |
| Euler's totient function | |
| Non-negative integers | |
| The coefficient of in the power series | |
| End of proof |
Throughout, "arrangement" means an ordered sequence and "selection" or "collection" means an unordered set (or multiset, when explicitly noted). Unless stated otherwise, all objects within a single problem are assumed distinguishable — the moment objects become identical, we say so explicitly, because this is precisely where most counting errors are born.
Part I — Fundamental Counting Principles & Basic Configurations
1.1 The Rule of Sum and the Rule of Product
Everything in enumerative combinatorics is ultimately built from two axioms about finite sets.
Axiom 1.1 (Rule of Sum). If a finite set is partitioned into disjoint subsets (that is, and for ), then
Combinatorially: if a task can be accomplished in exactly one of mutually exclusive ways, and the -th way can be done in ways, the task can be done in ways.
Axiom 1.2 (Rule of Product). Suppose a procedure consists of successive stages, and no matter which choices are made at stages , stage always offers exactly choices. Then the total number of ways to complete the whole procedure is
Remark (Independent vs. dependent choices). The Rule of Product does not require that the choices be "independent" in the sense of being unaffected by earlier stages — it only requires that the number of available choices at each stage be constant, regardless of what was chosen earlier. For instance, "choose a letter, then choose a different letter from the same alphabet of 26" has outcomes: the second stage's count (25) is fixed even though the specific available letters depend on the first choice. When even the count of choices varies with earlier decisions, the product rule fails outright and one must fall back on casework (repeated application of the Sum Rule) or a cleverer bijection.
Example 1.1. A password consists of 4 characters: the first two must be distinct uppercase letters, the last two must be distinct digits (0–9), and additionally the password must not start with the letter 'Q'. Count the passwords.
Solution. Stage 1 (first letter, ): 25 choices. Stage 2 (second letter, distinct from the first): 25 choices (26 minus the one already used — note 'Q' is now available again unless it was excluded only from stage 1). Stage 3 (first digit): 10 choices. Stage 4 (second digit, distinct): 9 choices. By the Product Rule: .
1.2 Permutations and Combinations
Definition 1.1. An -permutation of a set of distinct objects is an ordered sequence of of those objects, no repetitions. We write or for the count.
Theorem 1.1.
Proof. Fill the positions in sequence. Position 1 may be filled in ways; having used one object, position 2 has remaining choices; and so on, until position , which has choices. The Rule of Product gives the product of these terms.
Definition 1.2. An -combination of a set of distinct objects is an unordered selection of of them. We write or for the count.
Theorem 1.2.
Proof. Every -combination corresponds to exactly distinct -permutations (obtained by ordering its elements in every possible way), and every -permutation arises from exactly one -combination this way. This is a -to-one correspondence from permutations to combinations, so , and the result follows by Theorem 1.1.
Theorem 1.3 (Symmetry).
Algebraic proof. Immediate from , which is symmetric under .
Combinatorial (bijective) proof. Choosing elements to include in a subset is the same act as choosing the complementary elements to exclude. The map is a bijection between -subsets and -subsets of .
Remark. The two proofs above illustrate the central methodological split in this subject: an algebraic proof manipulates a formula; a combinatorial (or bijective, or story) proof exhibits the equality as an obvious restatement of the same counting problem. Competition mathematics prizes the second kind enormously, both because it is more robust (it generalizes without re-deriving algebra) and because it is frequently the only tractable route when the objects involved are not simple integers.
Theorem 1.4 (Pascal's Identity).
Combinatorial proof. Fix a distinguished element in the -set. Every -subset either contains (in which case the other elements are chosen from the remaining : ways) or does not contain (in which case all elements come from the remaining : ways). These two cases are disjoint and exhaustive, so the Rule of Sum gives the identity.
1.3 Permutations of a Multiset
Theorem 1.5 (Multiset Permutations). Given objects consisting of distinguishable types, with indistinguishable copies of type (so ), the number of distinguishable linear arrangements of all objects is
Proof. Temporarily label the copies of type as distinct (e.g. subscript them ), producing fully distinguishable objects, which admit linear arrangements. In this inflated count, every genuine arrangement of the original multiset has been counted once for each way of permuting the labels within each type — that is, times, since permuting the fake labels within a type produces the same multiset-arrangement. Hence the number of genuinely distinct arrangements is .
Example 1.2. The number of distinct arrangements of the letters of COMBINATORICS (13 letters: C×2, O×2, M×1, B×1, I×2, N×1, A×1, T×1, R×1, S×1) is
1.4 Circular Permutations
Theorem 1.6. The number of ways to arrange distinct objects around a circle, where arrangements related by rotation are considered identical, is .
Proof. Every circular arrangement corresponds to exactly linear arrangements (start reading at any of the positions), and every linear arrangement of the objects gives rise to exactly one circular arrangement. This is an -to-one correspondence from the linear arrangements to the circular ones, so the count is . Equivalently: fix one object's seat arbitrarily to kill the rotational symmetry, then arrange the remaining objects in the remaining seats in ways.
Remark (Necklaces vs. Garlands — reflection symmetry). A circular arrangement in which reflections (flipping the whole arrangement over, as one physically can with a necklace or a garland of flowers, but not with people seated at a table) are also considered identical is sometimes called a bracelet or necklace arrangement, as opposed to a garland/table arrangement where only rotations are identified. Since reflection is an additional symmetry of order 2 (and is a genuine, non-trivial symmetry whenever ), the count for distinct objects is
Caution: this simple halving trick works because for distinct objects, no arrangement is its own mirror image, so every reflection pairs two genuinely different rotational-arrangements into one bracelet. If the objects repeat (a multiset) or is small, some arrangements may be symmetric under reflection, and the naive halving overcounts the reduction; the fully general tool for such symmetric counting is Burnside's Lemma (equivalently, the Cauchy–Frobenius Orbit-Counting Theorem), which we state without proof here, as its proof requires group-action machinery beyond our scope:
We will use this freely by name whenever a problem's symmetry group is non-trivial enough to demand it.
Trick (Restricted circular arrangements). Circular restriction problems (" and must/must not sit together", "men and women must alternate") are almost always solved by combining Theorem 1.6 with the Bundling or Gap tricks of §1.5, applied after fixing one object to linearize the circle. We will do exactly this in Challenge Problem 1.2 below and again with the Problème des Ménages in Part III.
1.5 Problem-Solving Tricks
The Tie/Bundle Method (objects always together)
Trick. To count arrangements of distinct objects in which a specified subset of of them must all be mutually adjacent (in some order, forming an unbroken block), glue them into a single "super-object." This leaves units to arrange (the block, plus the remaining individual objects), and the block's internal order can be permuted in ways independently. Hence:
(The circular count uses by Theorem 1.6 applied to the units.)
The Gap Method (objects never together)
Trick. To count arrangements of distinct objects in which specified objects are pairwise non-adjacent (no two of the special objects stand next to each other), first arrange the remaining objects: ways. This creates "gaps" — one before, one after, and one between each pair of consecutive objects — into which the special objects must be inserted, at most one per gap (to guarantee no two specials are adjacent), and in order:
Example 1.3. In how many ways can 5 boys and 3 girls be arranged in a row so that no two girls are adjacent?
Solution. Arrange the 5 boys: ways, creating 6 gaps. Place the 3 girls into 3 of these 6 gaps, in order: . Total: .
Lexicographic (Dictionary) Rank
Trick. To find the rank of a word among all distinct permutations of its letters, arranged in dictionary order: process left to right. At each position , for every letter strictly smaller (alphabetically) than still available in the remaining multiset, count how many arrangements of the remaining letters (after placing that smaller letter at position ) are possible — this is a multiset-permutation count via Theorem 1.5 — and add this to a running total. After placing itself (not counted, since we want words before ) and consuming it from the multiset, proceed to position . After all positions are processed, the rank of is
We defer a complete worked instance of this trick — with repeated letters, which is where the bookkeeping becomes genuinely delicate — to Challenge Problem 1.1 below.
1.6 Challenge Problems
Challenge Problem 1.1. Find the rank of the word MISSISSIPPI among all of its distinct letter-permutations, arranged in dictionary order.
Solution. The letters are , total length , and the alphabetical order of the letters present is . We apply the lexicographic-rank algorithm of §1.5, tracking the remaining multiset at each step.
| Pos. | Letter | Remaining multiset before this position | Smaller letters available, and arrangements of the rest | Contribution |
|---|---|---|---|---|
| 1 | M | : remaining (10 letters); arrangements | ||
| 2 | I | none smaller than | ||
| 3 | S | : ; : | ||
| 4 | S | : ; : | ||
| 5 | I | none smaller than | ||
| 6 | S | : ; : | ||
| 7 | S | : ; : | ||
| 8 | I | none smaller than | ||
| 9 | P | : | ||
| 10 | P | : | ||
| 11 | I | none smaller than |
Summing the contributions: .
Remark. The pattern of zero contributions at every position where the actual letter placed is the smallest remaining letter (, at positions 2, 5, 8, 11) is not a coincidence — it is the reason MISSISSIPPI is comparatively "early" in the dictionary relative to its length; each such position forces the running sum to pause. Recognizing this in advance is a useful sanity check against arithmetic slips.
Challenge Problem 1.2. Nine people, including a group of siblings and (separately) a pair of rivals, are to be seated around a circular table (rotations identified, reflections distinct). The siblings insist on sitting together as an unbroken block; the two rivals refuse to sit next to each other. How many seating arrangements are possible?
Solution. We compute (arrangements with siblings together) (arrangements with siblings together and rivals also together), by inclusion–exclusion on the single "bad" event.
Step 1 — Siblings together, no other restriction. Bundle the 3 siblings into one block (Tie Method). This leaves units to seat circularly: ways, times internal orderings of the block:
Step 2 — Siblings together AND the two rivals also adjacent (to be subtracted). Now bundle the rivals into a second block as well. We have the siblings-block, the rivals-block, and remaining individuals: units total, arranged circularly in ways, times (siblings' internal order) times (rivals' internal order):
Step 3 — Subtract.
Part II — Distributions, Partitions, and Stars & Bars
2.1 The Stars and Bars Theorem
Theorem 2.1 (Stars and Bars — non-negative case). The number of solutions in non-negative integers to
is .
Proof. Represent a solution as a row of identical stars () separated into groups by bars (): the number of stars in the -th group is . Conversely, every arrangement of stars and bars in a row corresponds to exactly one solution. So we are counting arrangements of a multiset of symbols, of which are stars and are bars — by Theorem 1.5, this is
This device is affectionately called the Beggars' Method: identical coins ("stars") are to be distributed among beggars, separated by dividers.
Theorem 2.2 (Stars and Bars — positive case). The number of solutions in positive integers to (assuming ) is .
Proof. Substitute . The equation becomes , with . By Theorem 2.1, this has solutions, and the substitution is a bijection.
2.2 Constrained Distributions: Bounds and PIE
Lower bounds (). Substitute ; the equation becomes , reducing to Theorem 2.1 (provided , else there are solutions).
Upper bounds () — requires PIE. Let be the set of all non-negative-integer solutions to (ignoring upper bounds), counted by Theorem 2.1. Let be the "bad" event that (violates its upper bound). We want , computed via the Principle of Inclusion–Exclusion (proved formally in §3.1): for a subset , the intersection forces for each , which (after the shift for ) is itself a Stars-and-Bars count with total , namely (interpreted as if the top is negative). Hence:
giving the number of valid (bounded) solutions as
Inequality constraints (). Introduce a non-negative slack variable so that exactly; this converts the inequality into an equality in variables, reducing again to Theorem 2.1.
Trick (Complementary/Conjugate Substitution). When the target sum is close to the sum of the upper bounds — specifically when the "deficit" is small — it is often far faster to substitute . The constraint becomes with , and if is small enough that no single could exceed its own bound except in one or two easily-enumerated edge cases, the PIE collapses to a tiny calculation. We use exactly this shortcut in Challenge Problem 2.1.
2.3 The Twelvefold Way (Basics)
Distributing objects into boxes is, formally, choosing a function from an -set to a -set. The count depends on three binary choices: whether the objects are distinguishable, whether the boxes are distinguishable, and whether is required to be arbitrary, injective (at most one object per box — needs ), or surjective (every box non-empty — needs ). This gives Rota's Twelvefold Way:
| Objects (rows) / Boxes (columns) | Any function | Injective () | Surjective () |
|---|---|---|---|
| Distinct objects, distinct boxes | |||
| Distinct objects, identical boxes | |||
| Identical objects, distinct boxes | |||
| Identical objects, identical boxes |
Here is the Stirling number of the second kind — the number of ways to partition an -set into non-empty, unlabeled blocks — and is the number of ways to partition the integer into exactly positive parts (with counting partitions into at most parts). The bracket is the Iverson bracket, equal to if true and otherwise.
The Stirling numbers satisfy the recurrence
by considering whether element joins one of the existing blocks of a partition of into blocks (that block can be chosen in ways), or forms a new singleton block on top of a partition of into blocks. Dividing the surjection count (Theorem 3.3, ahead) by (to un-label the boxes) gives the closed form
which we will derive as a Principle of Inclusion–Exclusion consequence in §3.3.
Row 3 of the table is precisely the connective tissue between Part II and Part III — the count of ways to distribute distinct objects into distinct non-empty boxes is the count of surjective functions, our next major topic.
2.4 The Multinomial Theorem
Theorem 2.3 (Multinomial Theorem). For a positive integer ,
Proof. Expanding the product by full distributivity produces one term for every way of choosing, from each of the factors, one of the variables — i.e. one term for every function from an -set (the factors) to a -set (the variables). Collecting terms with the same monomial means counting the functions in which exactly of the factors chose variable — by Theorem 1.5 (equivalently, row 1 of the Twelvefold Way with distinguishable factors and a fixed "type profile"), this is .
Corollary (Number of terms). The number of distinct monomials appearing in the expansion equals the number of non-negative integer solutions to , which by Theorem 2.1 is — the Multinomial Theorem and Stars-and-Bars are two faces of the same coin.
Example 2.1. Find the coefficient of in the expansion of .
Solution. Since , the coefficient is .
2.5 Challenge Problems
Challenge Problem 2.1. Find the number of non-negative integer solutions to
Solution via direct PIE. By §2.2, with :
- : .
- : subtract respectively remainders , giving .
- : the six pairwise sums are , giving remainders : .
- : sums for ; only gives a non-negative remainder (), contributing ; the rest vanish.
- : sum , contributes .
Cross-check via the Complementary Substitution trick. Set . Then , with . Since the total deficit is only , and the smallest bound is , the only way any 's own bound could be violated is (impossible for since their bounds all exceed , except is exactly tight and cannot be exceeded by a total of only either). Unconstrained solutions to in 4 non-negative variables: . Subtract the single bad case (forcing , exactly solution): .
Both methods agree: .
Challenge Problem 2.2. Find the coefficient of in .
Solution. Write , so we want . Expand each factor:
(the second expansion is Theorem 2.1 in generating-function clothing — see §5.2). The coefficient of in the product is
- : .
- : .
- : .
- : .
Part III — The Principle of Inclusion–Exclusion & Derangements
3.1 PIE: Statement and Proof
Theorem 3.1 (Principle of Inclusion–Exclusion). For finite sets inside a universe,
i.e.
Proof (via the Binomial Theorem). We show every element of the universe contributes equally to both sides. An element that lies in none of the contributes to the left side and to every intersection term on the right, so both sides agree () for such .
Now suppose lies in exactly of the sets . On the left side, is counted exactly once (union membership is Boolean). On the right side, for a given size (), belongs to precisely for those of size that are subsets of the -element index set on which lies — there are such . So 's total contribution to the right side is
By the Binomial Theorem, for , so , hence . Thus contributes exactly to the right side as well, matching the left side. Since both sides agree term-by-term for every element of the universe, the two sets have equal cardinality.
3.2 Derangements
Definition 3.1. A derangement of is a permutation with no fixed point: for all . Write for the number of derangements of .
Theorem 3.2 (Closed form).
Proof. Let be the set of permutations fixing point : . Then . For any -subset , (the points are fixed; the other are freely permuted). By Theorem 3.1,
So
(the term of this last sum is exactly ). Now , so
Remark. As , , so ; in fact is always the integer nearest to . This is a favourite "surprising constant" result in olympiad folklore.
Theorem 3.3 (Recurrence I). for (with ).
Proof (from the closed form).
Theorem 3.4 (Recurrence II). for .
Combinatorial proof. Consider a derangement of , and examine for some ; there are choices for . Split into two cases:
- Case (a): . Elements and swap. The remaining elements must be deranged among themselves (none can be a fixed point, and none of them can map to or either, but since are already fully accounted for by the swap, this is exactly a derangement of an -set): ways.
- Case (b): . Define a new permutation of the -set by (whenever , i.e. everywhere except possibly at itself, and there by assumption) and for . One checks this is precisely a derangement of : no element maps to itself, because didn't, and the only subtlety — that might now "want" to equal , which is not in the domain — cannot happen since we assumed . This correspondence is a bijection onto derangements of an -set: ways.
Since the two cases are disjoint and exhaustive for each fixed value , and there are choices of , we obtain .
3.3 Surjections
Theorem 3.5. The number of surjective functions from an -set onto an -set (with ) is
Proof. Let the codomain be and let be the set of functions that miss value (i.e. ). We want . For a -subset of indices, is the set of functions avoiding all values in , i.e. functions into a codomain of size : there are such functions. By PIE,
so the surjection count is .
Corollary. , since each un-ordered partition of into non-empty blocks corresponds to exactly surjections (assign the labeled boxes to the blocks in every order). This recovers the closed form for Stirling numbers cited in §2.3.
3.4 Hidden PIE in Number Theory
Trick. Counting integers coprime to is a PIE problem in disguise: if , let be the multiples of in . An integer is coprime to iff it lies in none of the .
Theorem 3.6 (Euler's Totient Formula).
Proof. (the multiples of up to ), and more generally (multiples of , since the are distinct primes). By PIE,
where the last step is simply expanding the product via distributivity and recognizing each resulting term as the contribution from one subset .
Remark. This is a template worth internalizing: any "count things avoiding all of several divisibility/adjacency/collision conditions" problem is a candidate for exactly this PIE-on-primes (or PIE-on-forbidden-events) machinery — we will see it again, in a much richer combinatorial disguise, in the Challenge Problem below.
3.5 Challenge Problem: The Problème des Ménages
Challenge Problem 3.1. In how many ways can married couples be seated around a circular table with pre-designated alternating seats (4 "male" seats, 4 "female" seats), such that men and women alternate and no spouse sits next to their own partner? (Rotations of the whole table are considered identical seatings; reflections are considered distinct.)
This is the classical Problème des Ménages, first posed by Édouard Lucas. For general couples it is solved by a technique — reducing the adjacency-avoidance condition to counting non-attacking rook placements (equivalently, matchings) on a forbidden board that turns out to be a cycle graph, then applying PIE — that we now carry out in full for ; the same argument produces the general Touchard formula as a by-product.
Solution.
Step 1 — Fix the men. Using up the rotational symmetry, seat man at seat ; the remaining men are then arranged in the other male seats in ways (Theorem 1.6). Fix, for the moment, one such reference arrangement: at seats respectively (going around the table), with female seats interleaved.
Step 2 — Identify the forbidden board. Seat lies between and , so it is forbidden to and (their respective wives); seat (between ) is forbidden to ; seat (between ) is forbidden to ; and seat (between and , wrapping around) is forbidden to . Drawing an edge between each wife and each of her two forbidden seats produces exactly an -cycle:
Step 3 — PIE over the forbidden board (rook polynomial method). We must count bijections {wives} {female seats} avoiding all forbidden (wife, seat) pairs. By the general PIE-for-forbidden-positions formula,
where is the number of ways to choose forbidden pairs no two of which share a wife or a seat — i.e., is the number of matchings of size in the forbidden graph, here the -cycle .
The number of -matchings in a cycle ( vertices) is the classical formula
For :
(Sanity checks: correctly counts the edges of — i.e. the forbidden pairs themselves. : choosing any of the edges gives pairs, of which exactly share a vertex — one "adjacent pair" per vertex of the cycle — leaving , confirming . correctly counts the two perfect matchings of an -cycle: the "odd" edges and the "even" edges.)
Step 4 — Compute.
So, with the men fixed in the reference arrangement, there are exactly valid ways to seat the wives.
Step 5 — Assemble the total. By the symmetry of the construction, this count of is the same for every one of the arrangements of the men (relabeling the men merely relabels which wife is forbidden which seat, without changing the combinatorial structure of the cycle). Hence the total number of valid seatings is
Remark (The general formula). Nothing in Steps 2–4 used specifically; repeating the argument for general couples (forbidden board the cycle ) yields
which is precisely Touchard's formula (1934) for the ménage numbers. One can check (giving ) and as derived above — matching the known ménage sequence for .
Part IV — Pigeonhole Principle & Combinatorial Proofs
4.1 The Pigeonhole Principle, Basic and Generalized
Theorem 4.1 (Basic Pigeonhole Principle, PHP). If objects are placed into boxes, some box contains at least objects.
Proof. If every box contained at most object, the total number of objects would be at most , contradicting that there are .
Theorem 4.2 (Generalized PHP). If objects are placed into boxes, some box contains at least objects.
Proof. Suppose, for contradiction, every box contains at most objects. Then the total is at most (using ), a contradiction.
Remark. PHP is trivial to state and often extraordinarily hard to apply — the entire difficulty of a PHP olympiad problem is almost always in the construction of the right "boxes." This is a recurring meta-skill: a good PHP proof is really a good partition.
4.2 Applications in Number Theory and Geometry
Example 4.1 (Number theory). Given any integers (not necessarily distinct), prove that some non-empty subset of consecutive terms has sum divisible by .
Proof. Consider the partial sums , and reduce each modulo . There are partial sums but only residue classes mod , so by PHP two of them are congruent: for some . Then , and this is a sum of consecutive terms.
Example 4.2 (Geometry). Any points placed inside (or on the boundary of) a unit square contain two points at distance at most .
Proof. Partition the unit square into congruent sub-squares of side (a grid). By PHP, since points are placed into regions, some sub-square contains at least of the points. The diameter (maximum possible distance between two points) of a square is its diagonal, . So those two points are at distance at most .
4.3 Double Counting
Trick (Double Counting / "Counting in Two Ways"). To prove a combinatorial identity , invent a set of objects (often pairs, or configurations satisfying a property) whose cardinality can be computed in two different ways — one way naturally yielding , the other naturally yielding . Since both computations count the same set, . This is often called a story proof: rather than manipulating symbols, one tells a combinatorial story that is self-evidently counted two ways.
4.4 Key Identities via Combinatorial Proof
Theorem 4.3 (Vandermonde's Identity).
Proof (story). Consider a group of men and women, from which we choose a committee of people; the right side counts this directly. Alternatively, classify by the number of men on the committee (): choose men ( ways) and the remaining members from the women ( ways), then sum over all valid . Both computations count exactly the set of -person committees, so the sums are equal.
Theorem 4.4 (Hockey Stick Identity).
Proof (story). The right side counts -element subsets of . Classify such a subset by its largest element, say (so ): the remaining elements are chosen from , in ways. Summing over the possible largest elements gives , which must equal .
Theorem 4.5.
Proof (story). Consider a group of "red" and "blue" people ( total), from which we choose a committee of people; the right side, , counts this directly. Alternatively, classify by the number of red people on the committee: choose reds ( ways) and blues ( ways). By the symmetry (Theorem 1.3), this is ; summing over gives . (This is also simply Vandermonde's Identity, Theorem 4.3, with and , using the symmetry substitution in one factor.)
4.5 Challenge Problems
Challenge Problem 4.1 (Ramsey's Theorem, ). Prove that among any people at a party, either of them are pairwise mutual acquaintances, or of them are pairwise mutual strangers.
Solution. Model the party as the complete graph on vertices, with each edge colored red (acquainted) or blue (strangers). We must show some triangle is monochromatic.
Fix any vertex . It has edges to the other vertices. By the Generalized PHP (Theorem 4.2) with objects (edges) into boxes (colors), some color — say red, without loss of generality — is used on at least of these edges. Let be three vertices joined to by red edges.
Now examine the triangle on :
- If any edge among , , is red — say — then form an all-red triangle (since are all red).
- If none of is red, all three are blue, and form an all-blue triangle.
Either way, a monochromatic triangle exists among the people.
Remark (Sharpness). The bound is tight: on vertices, colour the edges of a pentagon (a -cycle) red and the edges of the complementary pentagram (the other -cycle) blue. Neither the red graph nor the blue graph — each being a -cycle — contains a triangle, since a -cycle has no chords. So people can avoid a monochromatic triangle entirely, proving exactly, not just .
Challenge Problem 4.2 (Subset-of-a-subset identity). Prove, for , that
Solution (double counting). Consider the set of all pairs with and — i.e., a "small" -subset nested inside a "large" subset of arbitrary size.
Count 1 (condition on first). Choose to have size (for ): ways. Then choose with : ways. Summing over : .
Count 2 (condition on first). Choose directly: ways. Then must be any superset of within — equivalently, freely choose, for each of the remaining elements of , whether or not it belongs to : ways. Total: .
Both counts enumerate the same set of pairs , so they are equal:
Part V — Generating Functions & Recurrence Relations
5.1 Motivation
A generating function encodes an entire infinite sequence as the coefficients of a single formal power series
"Formal" is the operative word: we manipulate algebraically without worrying about convergence, treating as a bookkeeping symbol rather than a number. The power of this idea is that combinatorial operations on structures translate into algebraic operations on generating functions:
- Disjoint choice (either structure of type or of type , Rule of Sum) addition: .
- Independent combination (a structure of type together with an independent structure of type , sizes adding) multiplication (convolution): , since .
- Shifting a sequence multiplying by a power of .
- Summing a sequence's partial sums multiplying by .
- Weighted-by-index sums (, etc.) differentiation: .
A hard counting problem often becomes an easy algebra problem once translated into this language — this is the central promise of the method, and Part V is devoted to cashing in on it.
5.2 Ordinary Generating Functions: A Working Table
| Sequence | OGF |
|---|---|
| ( terms, then ) | |
| (Stars-and-Bars, fixed) | |
| , fixed | |
| Fibonacci () | |
| Catalan | (derived in §5.4) |
Derivation of the Stars-and-Bars row. By the Generalized Binomial Theorem, for any real (not necessarily a positive integer),
Take , : . Hence — reproducing Theorem 2.1 purely algebraically, with no combinatorial argument at all. This is the generating-function proof of Stars and Bars, complementing the bijective proof of §2.1.
Remark (OGF vs. EGF). The table above concerns ordinary generating functions, appropriate when we are counting unlabeled or unordered structures (or extracting raw coefficients). When objects being combined are labeled and order-sensitive interleavings matter (as in permutations), the natural tool is instead the exponential generating function — for instance, -GF of while the derangement numbers satisfy . We do not develop EGF machinery further here, but flag it as the natural next tool beyond this treatise.
5.3 Coefficient Extraction
Trick. Once a counting sequence is recognized as of some closed-form generating function, the problem reduces to algebraic manipulation: partial fractions (for rational functions, isolating simple poles), the Generalized Binomial Theorem (for -type factors), or known series expansions (, , etc.).
Example 5.1. Recover the bounded Stars-and-Bars count of §2.2 via generating functions: the number of solutions to with each is . Expanding, , and for a given one reads off (terms with vanish) — precisely the PIE formula of §2.2, now derived as an automatic consequence of multiplying two known series rather than as a fresh combinatorial argument.
5.4 Catalan Numbers
Definition 5.1. The Catalan numbers are defined by and the recurrence
The Catalan numbers are the single most ubiquitous integer sequence in enumerative combinatorics after the binomial coefficients themselves; the recurrence above arises, essentially unchanged, from at least the following combinatorial models:
- Balanced bracket sequences. counts sequences of pairs of balanced parentheses, e.g. for :
()(),(()). (The recurrence: split at the position where the first bracket closes, after some balanced pairs nested inside it and balanced pairs following it.) - Monotone lattice paths. counts paths from to using unit right/up steps that never rise strictly above the diagonal .
- Triangulations of a convex polygon. counts triangulations of a convex -gon into triangles using non-crossing diagonals.
- Binary trees. counts binary trees with internal (non-leaf) nodes.
Theorem 5.1 (Closed form).
We give the full generating-function derivation of this closed form as our first Challenge Problem below, exactly as requested by a purely-analytic route (no combinatorial bijection to the binomial coefficient is used).
5.5 Challenge Problems
Challenge Problem 5.1. Derive using only the Catalan recurrence, its generating function, and the Generalized Binomial Theorem.
Solution. Let . The recurrence (for ) says that the sequence is the convolution of with itself, shifted up by one index — precisely the statement (multiplying by implements the "shift by one" and implements the convolution, by the multiplication rule of §5.1). Since , we get the functional equation
Solving this quadratic (in the unknown ) via the quadratic formula:
We must choose the sign so that is finite (equal to ) as . Expanding near : the "" branch gives — discard it. The "" branch gives a removable singularity:
Now expand via the Generalized Binomial Theorem: . For ,
(the first factor is positive; the remaining factors are negative, contributing sign ). Using (splitting into its odd and even factors), we get
Multiplying by :
(using ).
So , giving
Re-indexing :
(Check: , matching the recurrence directly.)
Challenge Problem 5.2. Solve the linear recurrence using its ordinary generating function.
Solution. Let . Multiply the recurrence (valid for ) by and sum over :
Substituting : , i.e. . Since ,
By the Generalized Binomial Theorem (or by differentiating once, term-by-term, in ), ; setting :
(re-indexing ). Hence
(Check: ✓; , formula gives ✓; , formula gives ✓.)
Appendix — Master Formula Sheet
Fundamental Principles
- Rule of Sum: disjoint cases add. Rule of Product: sequential independent-count stages multiply.
Part I — Basic Configurations
Part II — Distributions
Twelvefold Way — see table in §2.3 for all twelve cases (distinct/identical objects × distinct/identical boxes × arbitrary/injective/surjective).
Part III — PIE & Derangements
Part IV — Pigeonhole & Identities
Part V — Generating Functions
Closing Remark — The Unifying Theme
It is worth pausing, at the very end, on something remarkable that has happened quietly across Part V: a problem about counting — the most discrete possible kind of mathematics, where objects are indivisible and answers are integers — has been solved by borrowing the tools of continuous mathematics. We built a formal power series, treated it as an algebraic (indeed, analytic) object, applied the quadratic formula to it as though it were an ordinary real number, expanded a square root using a theorem originally about real exponents, and out fell an exact integer sequence, term by term.
This is not a trick unique to the Catalan numbers. It is the governing idea of an entire branch of mathematics — analytic combinatorics — in which the coefficients of a generating function are recovered not just by algebraic expansion but by contour integration and the calculus of residues; in which asymptotics of combinatorial sequences (how fast does , or , or the number of graphs on vertices, actually grow?) are read off from the location and nature of a generating function's singularities on the complex plane; and in which a discrete symmetry-counting problem (as in Burnside's Lemma, invoked briefly in Part I) is resolved by summing an analytic average over a continuous group action.
The lesson is this: the wall between "discrete" and "continuous" mathematics is far thinner than the undergraduate curriculum suggests. A sequence of integers is, secretly, a function; a counting identity is, secretly, an algebraic identity between power series; and the machinery of polynomials, roots, and calculus — built for the continuum — turns out to be exactly the right lens through which to view the finite and the exact. Whenever a combinatorics problem feels intractable by direct bijection or casework, it is always worth asking: what does this look like as a coefficient?