Applications of the Pigeonhole Principle
Suppose you are handed a sequence of 101 distinct integers. They are arranged in some arbitrary order, with no further structure imposed. Must there be a long stretch that is entirely increasing or entirely decreasing? This seems like it could depend delicately on how the sequence is scrambled. Yet the answer is a clean, unconditional yes. Every sequence of 101 distinct reals contains a monotone subsequence of length at least 11. Results of this flavor are surprising. They assert that disorder is impossible past a certain scale. No matter how adversarially a structure is arranged, some large orderly piece is forced to appear. The Pigeonhole Principle itself is almost embarrassingly simple to state. If more than objects are placed into boxes, some box holds at least two objects. Yet it is one of the most productive proof engines in combinatorics. This is precisely because it says nothing about which box, only that some box is overcrowded. This article is about the second, deeper layer of pigeonhole reasoning. These are applications where the "boxes" are not given but must be cleverly invented. Here the conclusion is a genuine structural theorem rather than a mere counting fact. The three case studies here are the classical training ground for this style of thinking. They are the Erdős–Szekeres monotone subsequence theorem, a Ramsey-type friendship statement, and a number-theoretic divisibility argument. The unifying idea is this. To prove that some object with a desired property must exist, define an auxiliary labeling function on the objects at hand. Show the label can take only few values. Invoke pigeonhole to force a repeated or extremal label. Then unpack what that repetition means back in the original setting. The labels are invented, not given. Inventing the right label is the entire difficulty and the entire art. This article develops that machinery rigorously. We prove the Erdős–Szekeres theorem in full, with a sharp example showing the bound is tight. We prove a Ramsey-flavored existence statement about acquaintances at a party. We also prove a divisibility statement about subset sums. Each proof is self-contained. Each bound is checked against an explicit extremal construction. Each argument is presented as a template for inventing your own pigeonhole labelings.
- Pigeonhole becomes powerful when the "boxes" are a clever invented labeling, not a literal physical container.
- The Erdős–Szekeres theorem: any sequence of distinct reals has an increasing subsequence of length or a decreasing one of length .
- The bound is sharp: an explicit block construction of length has no longer monotone run.
- A Ramsey-flavored corollary: among any people, two have the same number of acquaintances inside the group.
- A number-theoretic pigeonhole argument shows any integers chosen from contain two with one dividing the other.
- Key idea: invent a labeling of the objects such that a collision or an extreme value of the labels, once unpacked, is exactly the structure you wanted to find.
Where this lives today
The Erdős–Szekeres theorem is a direct ancestor of the modern theory of patience sorting and the Robinson–Schensted correspondence in algebraic combinatorics, where the pair generalizes to full Young tableaux encoding permutation structure; this connects the theorem to representation theory and symmetric function theory. In computer science, the same longest-increasing-subsequence computation underlies efficient algorithms used in patience-sorting-based sorting analysis, in bioinformatics for comparing genomic sequences, and in version-control diff algorithms that seek minimal edit scripts between two files. The underlying "invent a bounded labeling, then pigeonhole" technique is the core proof strategy of Ramsey theory broadly, which finds applications in theoretical computer science (lower bounds, communication complexity), in combinatorial number theory (van der Waerden and Szemerédi-type theorems on arithmetic progressions), and in the design of error-correcting codes where forced repetitions of patterns must be ruled out or exploited. The divisibility pigeonhole argument is a staple first example in elementary and analytic number theory courses illustrating how coarse invariants (here, "odd part") can be leveraged to prove existence statements about subsets of integers, and echoes in sieve-theoretic arguments bounding how "divisor-free" a set of integers can be. The acquaintance/degree argument is the seed of extremal graph theory's study of degree sequences, feeding directly into the Handshaking Lemma and into questions of graphical sequence realizability studied via the Erdős–Gallai theorem.
Ask the tutor: How does the Robinson–Schensted correspondence generalize the labeling used in the Erdős–Szekeres proof into full Young tableaux?
(Basic form.) If or more objects are distributed among boxes, then at least one box contains two or more objects.
(Generalized form.) If objects are distributed among boxes, then some box contains at least objects.
(Function formulation, used throughout this article.) If is a function between finite sets with , then is not injective: there exist distinct with . More generally, if for a positive integer , then some has . Both forms follow from the same counting fact: if every box held at most objects, the total number of objects would be at most times the number of boxes, contradicting .
Intuition
The basic pigeonhole principle is a one-line counting fact, but its applications in this article all follow the same three-step ritual. First, look at the raw combinatorial objects in front of you — a sequence of numbers, a set of people, a set of integers. Second, invent an auxiliary function that sends each object to some small, cleverly chosen set of labels; the choice of label is designed so that a repeated label, or an extreme label value, forces the structure you are hunting for. Third, apply pigeonhole to the labels and translate the resulting collision back into a statement about the original objects. For the monotone subsequence theorem, the invented label attached to each entry of a sequence is a pair recording the length of the longest increasing run ending at that entry and the length of the longest decreasing run ending at that entry. The miracle is that this pair is never repeated across the sequence — and pigeonhole, run in reverse (too few available labels for too many entries), forces one of the two coordinates to grow large.
For the acquaintance problem, the invented labels are simply the possible degrees — the number of acquaintances a person could have inside the room — and the trick is noticing that two extreme degree values (namely and ) cannot both occur, shrinking the box count by one. For the divisibility statement, each integer is labeled by its odd part, and the pigeonhole collision of odd parts directly produces a divisibility relation between two integers of the chosen set.
Let be positive integers and let be a sequence of distinct real numbers. Then the sequence contains either 1. an increasing subsequence of length (indices with ), or 2. a decreasing subsequence of length (indices with ). Moreover this bound is sharp: for every there exists a sequence of exactly distinct reals with no increasing subsequence of length and no decreasing subsequence of length .
Existence (pigeonhole argument). For each index define
Both are well-defined positive integers, since the single-term subsequence is always available, giving and . Claim: the map is injective on . Suppose are two distinct indices with . Since the are all distinct, either or .
- If : take the increasing subsequence of length ending at position and append to it (valid since and ). This produces an increasing subsequence of length ending at , so , contradicting .
- If : symmetrically, append to the longest decreasing subsequence ending at to get a decreasing subsequence of length ending at , forcing , contradicting .
Either way we reach a contradiction, so the claim holds: the pairs are pairwise distinct. Now suppose, for contradiction, that the theorem's conclusion fails: there is no increasing subsequence of length and no decreasing subsequence of length . Then for every ,
so each pair lies in the finite set , a set of exactly elements. But we have indices , each mapped to a distinct element of this -element set — impossible, since an injective function from an -element domain into an -element codomain cannot exist (this is precisely the Pigeonhole Principle in its function formulation: forces a repetition, contradicting injectivity). This contradiction shows the assumption was false, so an increasing subsequence of length or a decreasing one of length must exist.
Sharpness (explicit extremal construction). Arrange the numbers through into an array of blocks as follows. Partition into consecutive blocks of size :
Define the sequence by listing in increasing order, then in increasing order, ..., then in increasing order — that is, blocks appear in decreasing order of their values, but each block internally is written increasing. Concretely the sequence is:
No increasing subsequence of length : any strictly increasing subsequence can use at most one element from each block. Indeed, within a block the values are consecutive integers in increasing position order, but distinct blocks are arranged so that all values in an earlier-positioned block exceed all values in a later-positioned block; hence an increasing subsequence, reading left to right, must have strictly decreasing block index — impossible to repeat a block and impossible to increase in value while moving to a later (smaller-valued) block. Thus an increasing subsequence takes at most one entry per block, and there are only blocks, so its length is at most . No decreasing subsequence of length : within a single block of size , the entries are already listed in strictly increasing order, so a strictly decreasing subsequence can use at most one element from each block (two elements from the same block are increasing, not decreasing, in position order). Moving between blocks, the block appearing earlier has strictly larger values than any later block, so decreasing subsequences may certainly jump blocks — but within any one block only one term can be picked. Since a decreasing subsequence can select at most elements per each of its chosen positions across blocks only if it stays inside a single block (as just shown at most per block) — we must bound differently: a decreasing subsequence corresponds to choosing at most one element from each block only fails to bound it by ; instead observe the correct bound directly: within a block the increasing order forces at most element per block for a decreasing run, and there are blocks total, which bounds decreasing runs by , not . Let us instead verify sharpness the standard way, symmetric to the first case. Re-examine: a decreasing subsequence may pick at most one element from each block, since inside a block values increase left-to-right. There are blocks, so naively decreasing subsequences have length at most — but we want the bound , so let us instead pick at most one element per position within a block, across blocks, using the standard argument: fix a decreasing subsequence; any two of its terms lying in the same block would have to be decreasing while the block itself is increasing, forbidden — so it has at most one term per block, i.e. length . That bounds decreasing subsequences by , and by the symmetric argument on increasing ones we get length (since increasing subsequences can pick at most one term per "column" — the position-within-block index, of which there are values, because two terms in the same relative position of two different blocks lie in different blocks with the later block position having smaller values, so an increasing subsequence moving left to right must strictly increase in block-order which is only possible... ) This double-indexing is easiest to settle by re-deriving it cleanly via the standard grid model. Index each of the positions by a pair with (block number, listed in the sequence order , so means block , ..., means block ) and (position within the block, increasing). Assign to the entry at the value . As increases (moving right across blocks in sequence order) the block contributes a smaller base value , while within a fixed , increasing increases .
- A strictly increasing subsequence in value, read in increasing sequence-position order, needs both index coordinates constrained: if two terms have the same , then increasing gives increasing , so we can increase within a block — length up to within one block. If we move to a later block (larger ), the base value drops by per step, more than the maximum possible gain of from varying within the new block, so values must decrease when increases. Hence an increasing subsequence must stay within a single block, giving length .
- A strictly decreasing subsequence must, symmetrically, either move to a strictly larger (since within one block values only increase with , so decreases can't happen for fixed ), giving at most one term per value of , hence length .
This matches the theorem's roles with and swapped from the sloppy pass above; to align exactly with the theorem statement (no increasing subsequence of length , no decreasing of length ), take blocks each of size as originally set up, and read the bound as: increasing subsequences have length and decreasing subsequences have length . To match the theorem's naming exactly, simply relabel: build the array with blocks of size instead. Concretely, partition into blocks of size , list the blocks in decreasing value order, each block increasing internally; then by the argument above, increasing subsequences (constrained to a single block of size ) have length at most , and decreasing subsequences (at most one term per block, blocks) have length at most . This is a sequence of exactly distinct integers with no increasing subsequence of length and no decreasing subsequence of length , proving sharpness.
∎Worked examples
Example 1 (monotone subsequences, asymmetric ). Take , , so . The theorem guarantees that any distinct reals contain an increasing subsequence of length or a decreasing subsequence of length . Test it on the concrete sequence
Compute at each position (longest increasing run ending there, longest decreasing run ending there):
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
|---|---|---|---|---|---|---|---|
| 8 | 2 | 9 | 4 | 11 | 3 | 1 | |
| 1 | 1 | 2 | 2 | 3 | 2 | 1 | |
| 1 | 2 | 1 | 2 | 1 | 3 | 4 |
All seven pairs are indeed distinct: . The largest is (achieved at , subsequence ), which is an increasing run of length — not yet length . The largest is , achieved at : chasing the decreasing chain backward from , we find ... we need a decreasing chain ending at , so read values that are decreasing as position increases towards : (pos 3) (pos 4)? No — build it correctly: a decreasing subsequence ending at position with value needs earlier larger values in decreasing order. Check : positions , values , all strictly decreasing and index-increasing — length . This matches , confirming the guaranteed alternative (decreasing subsequence of length ) with room to spare.
Example 2 (Ramsey-flavored: same number of acquaintances). Claim: at any gathering of people, where "acquainted" is a symmetric, irreflexive relation (nobody is acquainted with themselves, and acquaintance is mutual), there exist two people with exactly the same number of acquaintances present at the gathering. Proof. Each person's number of acquaintances (their degree within this group) is an integer in , giving possible values and people — pigeonhole does not immediately bite, since objects into boxes need not collide. The refinement: the values and cannot both occur among the people. If some person has degree , then is acquainted with everyone else, so every other person has degree , ruling out degree for anyone. Conversely if some person has degree , is acquainted with no one, so no other person can be acquainted with but could still reach at most acquaintances among the remaining people other than and themselves, ruling out degree . Either way, the set of achieved degree values is a subset of that misses at least one of , hence has size at most . Now we have people whose degrees lie in a set of at most possible values: by pigeonhole (function formulation, ), two people share the same degree. Concretely, at a party of people, suppose the acquaintance graph is: Alice–Bob, Alice–Carol, Bob–Carol, Dave–Eve, Dave–Frank, Eve–Frank (two disjoint triangles). Degrees: Alice , Bob , Carol, Dave, Eve, Frank — indeed everyone ties at degree , an extreme instance of the guaranteed collision, illustrating that the coincidence can be far more dramatic than the bare minimum "at least two."
The hypothesis that the are pairwise distinct is essential; if repeats are allowed and "increasing/decreasing" is read strictly, the theorem can fail. Take , so , and the theorem would claim: any real numbers contain a strictly increasing subsequence of length or a strictly decreasing subsequence of length . Consider the sequence — two equal, non-distinct terms. There is no strictly increasing pair (since ) and no strictly decreasing pair (since ), so both conclusions fail, even though terms were given. The proof breaks exactly at the injectivity claim: with for , neither nor holds, so the case analysis used to show has no case to apply, and indeed here , so the labels collide without producing any monotone run. This confirms distinctness is not a cosmetic simplification but a load-bearing hypothesis.
Let be a positive integer and let with . Then contains two distinct elements such that .
Every positive integer can be written uniquely as with and odd; call the odd part of , written . For , the odd part is an odd number in , a set of exactly odd numbers. Define by . The domain has elements and the codomain has elements, so by the Pigeonhole Principle (function formulation) is not injective: there exist distinct with for some common odd . Write and with (they must differ, since and both share the same odd part , forcing different powers of ). Without loss of generality ; then
and since is a positive integer, .
∎Worked instance. Let , so , and pick the -element set — instead choose a genuinely adversarial-looking : , which has . Compute odd parts: , , , , , , . The odd parts used are — indeed repeats (from and ) and repeats (from and ), while there are only possible odd values available for chosen integers, forcing at least one collision as predicted. From the collision at odd part : and , so — exactly the divisibility pair guaranteed by the theorem. Note a second pair also appears (, , so ), illustrating that the theorem guarantees at least one pair, though in practice more may occur.
Scope, edge cases & common traps
| Situation | What happens | Why |
|---|---|---|
| Sequence length exactly | Erdős–Szekeres conclusion can fail | Sharpness construction realizes exactly terms with no long monotone run |
| Repeated values allowed | Theorem as stated (strict monotonicity) can fail | see counterexample above; injectivity of breaks |
| with (not ) | Divisibility conclusion can fail | Take , all odd parts distinct and no element divides another since ratios are |
| Acquaintance relation not required symmetric | "Two people share a degree" argument breaks | Degree bound and the / exclusion both use symmetry (mutual acquaintance) |
| in the acquaintance theorem | Vacuous / theorem requires | With one person there is no pair to compare, and the degree set argument needs at least two people to make "share a degree" meaningful |
The mathematician behind it
Origins · 1 minPaul Erdős and how this was discovered
Paul Erdős was one of the most prolific mathematicians in history, publishing across combinatorics, number theory, set theory, and probability, and famously living an almost fully itinerant life devoted entirely to mathematical collaboration.
Why does inventing a labeling function count as a legitimate proof technique rather than a trick?
Because it reduces an existence question about a complicated combinatorial object to a counting fact about a much simpler auxiliary set, and every step of the reduction is fully justified logically. In the Erdős–Szekeres proof, the labeling is defined unambiguously from the sequence, its injectivity is proved by direct case analysis with no gaps, and the final contradiction follows from a precise counting inequality. Nothing is assumed about which label values occur — only that too many objects cannot inject into too few possible labels. This is the same logical content as the plain pigeonhole principle; the "invention" is choosing labels cleverly, not weakening the rigor of the argument.
Is the bound in the Erdős–Szekeres theorem the best possible, or just a convenient sufficient bound?
It is exactly best possible, not merely convenient. The theorem proves existence for terms, and the accompanying construction exhibits a specific sequence of exactly distinct terms with no increasing subsequence of length and no decreasing subsequence of length . Having both halves — the existence proof and the matching extremal example — is what makes the bound sharp rather than just an upper estimate; no smaller number of terms than can force the stated conclusion.
Does the acquaintance/degree theorem require the group to be a graph in the formal sense?
Yes, implicitly: "acquainted" must be modeled as a simple graph, meaning the relation is symmetric (if knows then knows ) and irreflexive (nobody is counted as acquainted with themselves). These are exactly the graph-theoretic assumptions needed for "degree" to be a well-defined integer in and for the / exclusion argument to work. If acquaintance were allowed to be asymmetric (a directed relation, as in one-way social media follows), the argument needs separate treatment of in-degree and out-degree, and the clean conclusion need not hold in the same form.
How does the odd-part labeling in the divisibility theorem generalize?
The same idea generalizes to more refined multiplicative invariants: instead of splitting off all factors of , one can split off all factors of any fixed prime, or use -adic valuation more finely to prove chains of divisibility of any specified length exist once the set is large enough relative to the range, via repeated pigeonhole on refined label sets. This style of argument is a basic building block in elementary number theory for proving that dense-enough subsets of must contain multiplicative or divisibility structure, echoing themes that recur in sieve methods and in combinatorial number theory more broadly.
Can the Erdős–Szekeres theorem be extended beyond sequences of real numbers?
Yes, the same proof technique (invented labels tracking longest monotone runs) works verbatim for any sequence of distinct elements from a totally ordered set, since the only properties used are trichotomy (for any two distinct elements, exactly one of holds) and transitivity of the order. It does not directly extend to partially ordered sets without modification, since two incomparable elements would break the case analysis used to show injectivity of the labeling; extensions to posets exist but require additional combinatorial machinery beyond the scope of the basic theorem.
Why is the "boxes too few for objects" framing more useful here than just checking examples?
Checking finitely many examples can never establish a universal existence claim across all sequences, all seating arrangements of acquaintances, or all subsets of integers, because there are infinitely many (or combinatorially explosively many) instances to check. The pigeonhole framing instead gives a single short argument valid for every instance simultaneously: it isolates the exact numerical threshold (like , or ) at which a counting obstruction becomes unavoidable, and the matching extremal constructions confirm that threshold cannot be improved. This is what separates a rigorously sharp existence theorem from an empirical pattern noticed in a handful of examples.