The Pigeonhole Principle

Take 13 people at a party. Must two of them share a birth month? This is a concrete instance of a deceptively simple idea. If you distribute enough objects into few enough containers, some container must receive more than one object. The Pigeonhole Principle turns this everyday observation into a precise combinatorial tool. Its power lies in the gap between how obvious it sounds and how sharp its conclusions are. The principle matters because it proves existence without constructing anything. It never tells you which pigeonhole is crowded, only that one must be. This non-constructive flavor makes it indispensable across combinatorics, number theory, analysis, and computer science. Whenever a counting mismatch between a domain and codomain is unavoidable, the pigeonhole principle converts that mismatch into a guaranteed collision, coincidence, or repetition. The big picture is that the principle is really a statement about Functions between finite sets. A function f:N→Kf: N \to K with ∣N∣>∣K∣|N| > |K| cannot be injective. Some two inputs must share an output. Once you see it this way, applications multiply. Sequences must repeat a residue mod nn. Subsets must share a sum. Points must fall close together in a partitioned region. The principle is a single sentence, but its instantiations range widely. They span from a two-line party trick to deep results like Dirichlet's approximation theorem. This article gives the precise statement of both the basic and generalized pigeonhole principle. It includes a complete proof from first principles using the Sum and Product Rules. It also offers two fully worked non-trivial examples. It takes a careful look at what happens when hypotheses are dropped. Finally, it surveys where the idea resurfaces in mathematics and computing.

Key takeaways
  • The Pigeonhole Principle says nn objects in kk boxes with n>kn > k forces some box to hold ≥2\ge 2 objects.
  • The generalized version: nn objects in kk boxes forces some box to hold ≥⌈n/k⌉\ge \lceil n/k \rceil objects.
  • It is equivalent to the statement that a function from a larger finite set to a smaller one cannot be injective.
  • The proof is by contrapositive/contradiction and uses only the Sum Rule for counting.
  • It is a purely existential tool: it never identifies which box or which objects collide.
  • Key idea: counting a mismatch between set sizes is enough to force a collision, with no further information needed.

Where this lives today

In number theory, the pigeonhole principle underlies Dirichlet's approximation theorem: for any irrational α\alpha and any NN, there exist integers p,qp,q with 1≤q≤N1 \le q \le N and ∣α−p/q∣<1/(qN)|\alpha - p/q| < 1/(qN), proved by partitioning [0,1)[0,1) into NN subintervals and pigeonholing the fractional parts {qα}\{q\alpha\} for q=0,…,Nq = 0,\dots,N. In computer science, hash table collision analysis, the impossibility of perfect lossless compression for all inputs, and lower bounds in data structures all rest on pigeonhole counting: if a hash function maps more keys than table slots, collisions are unavoidable, and no compression algorithm can shrink every possible input string without some inputs growing, since there are strictly more short strings than shorter ones. In cryptography, the principle bounds the security of hash functions against collision resistance: any hash function with output space of size kk must have a collision among any k+1k+1 distinct inputs, motivating the birthday-attack style analysis of hash collision probabilities. In combinatorics and graph theory, it is the seed of Ramsey theory: in any graph on 66 vertices, pigeonhole-style degree-counting forces a monochromatic triangle in any red/blue edge coloring, the simplest nontrivial Ramsey number R(3,3)=6R(3,3)=6. In analysis and probability, discretizing continuous ranges into finitely many bins and pigeonholing sample points into them is a recurring technique for proving existence of clusters, recurrence, or bounded gaps (e.g., in ergodic theory and the study of equidistribution).

Ask the tutor: How do I choose the right "boxes" when the pigeonhole setup isn't obvious from the problem statement?

DefinitionThe Pigeonhole Principle

Let NN and KK be finite sets with a function f:N→Kf : N \to K assigning each element of NN (the "objects" or "pigeons") to an element of KK (the "boxes" or "pigeonholes").

Basic form. If ∣N∣>∣K∣|N| > |K|, then ff is not injective: there exist distinct a,b∈Na, b \in N with a≠ba \neq b and f(a)=f(b)f(a) = f(b).

Generalized form. If ∣N∣=n|N| = n and ∣K∣=k|K| = k with k≥1k \ge 1, then there exists y∈Ky \in K such that

∣f−1(y)∣  ≥  ⌈nk⌉.|f^{-1}(y)| \;\ge\; \left\lceil \frac{n}{k} \right\rceil.

That is, some box contains at least ⌈n/k⌉\lceil n/k \rceil objects. The basic form is the special case k≥1k \ge 1, n=k+1n = k+1, since ⌈(k+1)/k⌉=2\lceil (k+1)/k \rceil = 2.

Intuition

Picture kk labeled boxes drawn as bins on a number line, and nn pigeons that must each land in exactly one bin. If you have strictly more pigeons than bins, the "average occupancy" per bin exceeds 11, and since occupancy counts are whole numbers, some bin must round that average up rather than down. This is the entire mechanism: averages of integers that are not themselves integers force some term above the average. The generalized principle sharpens this averaging idea. If nn pigeons fill kk boxes, the average number of pigeons per box is n/kn/k. It is impossible for every box to hold strictly fewer than n/kn/k objects on average without violating the total count — so some box must reach at least ⌈n/k⌉\lceil n/k \rceil. The ceiling appears precisely because box occupancy must be an integer, and n/kn/k need not be.

Figure
13 pigeons distributed into 12 monthly boxes: one box must hold ≥ 2
13 people, 12 birth months: n = 13 > k = 12 J F M A M J* J A S O N D ⌈13/12⌉ = 2 forces a collision — here in the marked box The principle guarantees a collision exists; it does not predict which box.

Central theorem

TheoremGeneralized Pigeonhole Principle

Let n,kn, k be positive integers, let NN be a finite set with ∣N∣=n|N| = n, let KK be a finite set with ∣K∣=k|K| = k, and let f:N→Kf : N \to K be any function. Then there exists y∈Ky \in K such that

∣f−1(y)∣≥⌈nk⌉.|f^{-1}(y)| \ge \left\lceil \frac{n}{k} \right\rceil.

In particular (taking n=k+1n = k+1), if n>kn > k then ff is not injective.

Proof

We argue by contradiction, a standard technique for existence statements phrased as "there exists an object with property PP."

Setup. Write K={y1,y2,…,yk}K = \{y_1, y_2, \dots, y_k\}, and for each i∈{1,…,k}i \in \{1,\dots,k\} let

Ai=f−1(yi)={x∈N:f(x)=yi}.A_i = f^{-1}(y_i) = \{x \in N : f(x) = y_i\}.

Since ff is a function with domain NN, every x∈Nx \in N has exactly one value f(x)∈Kf(x) \in K, so xx belongs to exactly one AiA_i (namely ii with yi=f(x)y_i = f(x)). Hence the sets A1,…,AkA_1, \dots, A_k are pairwise disjoint and their union is all of NN: they form a partition of NN.

Applying the Sum Rule. By the Sum and Product Rules (specifically the Sum Rule for a partition into disjoint blocks), the size of a finite set equals the sum of the sizes of the blocks in any partition of it:

n=∣N∣=∑i=1k∣Ai∣.n = |N| = \sum_{i=1}^{k} |A_i|.

This is not an assumption; it follows because each element of NN is counted in exactly one AiA_i, so summing ∣Ai∣|A_i| over ii counts every element of NN exactly once, giving the total nn.

Suppose for contradiction that the conclusion fails: suppose that for every ii,

∣Ai∣≤⌈nk⌉−1.|A_i| \le \left\lceil \frac{n}{k} \right\rceil - 1.

Since ∣Ai∣|A_i| is an integer and ⌈n/k⌉\lceil n/k \rceil is by definition the least integer ≥n/k\ge n/k, the integer ⌈n/k⌉−1\lceil n/k \rceil - 1 is the greatest integer strictly less than ⌈n/k⌉\lceil n/k \rceil, hence

⌈n/k⌉−1<nk\lceil n/k \rceil - 1 < \frac{n}{k}

is false in general — instead we must be careful and argue directly with the defining property of the ceiling function: ⌈n/k⌉−1\lceil n/k \rceil - 1 is an integer strictly less than ⌈n/k⌉\lceil n/k \rceil, and by minimality of the ceiling, any integer strictly less than ⌈n/k⌉\lceil n/k \rceil is strictly less than n/kn/k or equal to it only if n/kn/k is not an integer strictly between them — to avoid this delicacy we instead bound directly: Since ⌈n/k⌉\lceil n/k \rceil is the smallest integer greater than or equal to n/kn/k, the integer ⌈n/k⌉−1\lceil n/k\rceil - 1 is strictly less than n/kn/k whenever n/kn/k is not an integer, and equals n/k−1<n/kn/k - 1 < n/k whenever n/kn/k is an integer. In both cases,

⌈nk⌉−1<nk.\left\lceil \frac{n}{k} \right\rceil - 1 < \frac{n}{k}.

(This is exactly the characterizing inequality of the ceiling: ⌈x⌉−1<x≤⌈x⌉\lceil x \rceil - 1 < x \le \lceil x \rceil for all real xx, applied to x=n/kx = n/k.) Therefore, under our contradiction hypothesis, for every ii,

∣Ai∣≤⌈nk⌉−1<nk.|A_i| \le \left\lceil \frac{n}{k} \right\rceil - 1 < \frac{n}{k}.

Summing over all kk boxes:

n=∑i=1k∣Ai∣<∑i=1knk=k⋅nk=n.n = \sum_{i=1}^k |A_i| < \sum_{i=1}^k \frac{n}{k} = k \cdot \frac{n}{k} = n.

This gives n<nn < n, a contradiction.

Conclusion. The assumption that every ∣Ai∣≤⌈n/k⌉−1|A_i| \le \lceil n/k \rceil - 1 is false. Hence some ii has ∣Ai∣≥⌈n/k⌉|A_i| \ge \lceil n/k \rceil, i.e., there exists y=yi∈Ky = y_i \in K with ∣f−1(y)∣≥⌈n/k⌉|f^{-1}(y)| \ge \lceil n/k \rceil, as claimed.

Basic form as a corollary. If n=k+1>kn = k+1 > k, then ⌈n/k⌉=⌈(k+1)/k⌉=2\lceil n/k \rceil = \lceil (k+1)/k \rceil = 2 since 1<(k+1)/k≤21 < (k+1)/k \le 2 for k≥1k \ge 1 (equality (k+1)/k=2(k+1)/k = 2 only when k=1k=1, and otherwise (k+1)/k(k+1)/k lies strictly between 11 and 22; either way the ceiling is 22). So some y∈Ky \in K has ∣f−1(y)∣≥2|f^{-1}(y)| \ge 2, meaning at least two distinct elements a≠ba \neq b of NN map to the same yy, i.e., f(a)=f(b)f(a) = f(b) with a≠ba \ne b — precisely the failure of injectivity. This completes the proof for both forms. ■\blacksquare

∎
CorollaryContrapositive form

If f:N→Kf: N \to K is injective, then ∣N∣≤∣K∣|N| \le |K|. Equivalently, an injective function from a finite set into a finite set cannot increase cardinality.

Proof

This is the logical contrapositive of the basic form: the basic form states "∣N∣>∣K∣  ⟹  f|N| > |K| \implies f not injective," whose contrapositive is "ff injective   ⟹  ∣N∣≤∣K∣\implies |N| \le |K|." Contraposition is a valid inference rule (a statement and its contrapositive are logically equivalent), so no new proof is required beyond the theorem above.

∎

Worked examples

Example 1 (Non-uniform box sizes forcing a specific count). A librarian has 100100 books to shelve into 99 labeled bins by Dewey category. Show that some bin receives at least 1212 books, and exhibit that 1212 is the best bound the principle can guarantee (i.e., it is achievable that no bin receives more than 1212). Solution. Here n=100n = 100, k=9k = 9. Compute

⌈1009⌉=⌈11.111…⌉=12.\left\lceil \frac{100}{9} \right\rceil = \left\lceil 11.111\ldots \right\rceil = 12.

By the Generalized Pigeonhole Principle, some bin holds at least 1212 books. To see this bound is tight, exhibit a distribution matching it: put 44 books in one bin and 1212 in each of the other 88 bins:

4+12×8=4+96=100.4 + 12 \times 8 = 4 + 96 = 100.

This uses exactly 100100 books, no bin exceeds 1212, and one bin (in fact several) attains exactly 1212. So the guaranteed bound 1212 cannot be improved to 1313 in general — the theorem's conclusion is sharp. (Note the theorem never claims every bin reaches 1212; it only asserts some bin does, and here the extremal example shows the guarantee cannot be strengthened.)

Example 2 (A number-theoretic collision via injectivity failure, asymmetric inputs). Show that among any 77 distinct integers chosen from {1,2,…,12}\{1, 2, \dots, 12\}, two of them sum to 1313. Solution. Partition {1,…,12}\{1, \dots, 12\} into 66 unordered pairs each summing to 1313:

{1,12},{2,11},{3,10},{4,9},{5,8},{6,7}.\{1,12\}, \{2,11\}, \{3,10\}, \{4,9\}, \{5,8\}, \{6,7\}.

These 66 pairs are pairwise disjoint and their union is {1,…,12}\{1,\dots,12\} — a genuine partition into k=6k = 6 blocks. Define ff on the chosen set NN of 77 integers by letting f(x)f(x) be the pair (block) containing xx; formally f:N→Kf: N \to K where KK is the set of 66 pairs and f(x)f(x) is the unique pair containing xx. Since ∣N∣=7>6=∣K∣|N| = 7 > 6 = |K|, the Pigeonhole Principle (basic form) guarantees ff is not injective: two distinct chosen integers a≠ba \ne b land in the same pair, i.e. f(a)=f(b)f(a) = f(b). But each pair {i,13−i}\{i, 13-i\} has only two elements, and if a≠ba \ne b both lie in the same pair, they must be exactly the two elements of that pair (a set of size 2 cannot contain three distinct elements a,b,a, b, and also the pair's own two members unless a,ba,b are those two members). Hence {a,b}={i,13−i}\{a,b\} = \{i, 13-i\} for some ii, so a+b=13a + b = 13. To confirm sharpness: choosing only 66 integers, e.g. {1,2,3,4,5,6}\{1,2,3,4,5,6\}, avoids any pair summing to 1313 (since {1,12},…\{1,12\},\dots each contribute at most one element from {1,…,6}\{1,\dots,6\}). This shows 77 is the minimal number of integers that forces the conclusion — the bound in the problem is exactly the pigeonhole threshold k+1=7k+1 = 7.

CounterexampleDropping finiteness of KK

The theorem requires KK to be finite. If KK is infinite, the conclusion can fail entirely, even with NN much larger than any finite "slice" of KK you might compare it to. Take N={1,2,…,1000}N = \{1, 2, \dots, 1000\} (so n=1000n = 1000) and K=Z+K = \mathbb{Z}^+ (the positive integers, an infinite set). Define f:N→Kf: N \to K by f(x)=xf(x) = x, the identity inclusion. This map is injective: f(a)=f(b)  ⟹  a=bf(a) = f(b) \implies a = b trivially. There is no collision anywhere, despite NN having 10001000 elements — because ∣K∣|K| is not a finite number to compare against, the hypothesis "∣N∣>∣K∣|N| > |K|" is not even meaningful (there is no finite ∣K∣|K|), and the entire mechanism of the proof collapses: the Sum Rule argument required summing ∣Ai∣|A_i| over finitely many boxes i=1,…,ki = 1, \dots, k, and with kk infinite there is no such finite sum to bound. This shows finiteness of the codomain KK (or at least finiteness of the number of boxes being counted) is not a technical nicety — it is load-bearing. The principle is a statement about finite partitions, and infinite pigeonholes simply have room for everyone.

Scope, edge cases & common traps

SituationWhat holdsWhat fails / caution
n≤kn \le kNo collision is forced; an injection may or may not existDo not assume a collision — check n>kn>k first
n>kn > k, both finiteCollision guaranteed (basic form)Principle gives existence, not which pigeons collide
Arbitrary n,k≥1n,k \ge 1 finiteSome box has ≥⌈n/k⌉\ge \lceil n/k\rceil (generalized form)⌈n/k⌉\lceil n/k \rceil, not n/kn/k rounded incorrectly — always take the ceiling, never floor
KK infinitePrinciple does not applySee counterexample above
Boxes defined by a partition not literally "boxes"Still valid — any partition of NN into kk disjoint blocks worksMust verify the blocks are disjoint and cover NN (a genuine partition)
Multiple valid partitions of the same problemDifferent partitions can give different (both correct) boundsChoosing a coarser partition (fewer kk) gives a weaker, still valid, bound; look for the finest useful partition

The mathematician behind it

Origins · 1 minPeter Gustav Lejeune Dirichlet and how this was discovered
PG
Peter Gustav Lejeune Dirichlet
1805–1859 · 19th-century Prussia/Germany, analytic number theory

Dirichlet is credited with the first systematic use of the pigeonhole principle in serious mathematics, applying it in number theory — for instance in his proof related to rational approximation of irrational numbers, now known as Dirichlet's approximation theorem. The principle is still sometimes called the Dirichletscher Schubfachschluss ("Dirichlet's drawer/box principle") in German mathematical tradition, reflecting his central role in elevating an intuitive observation into a rigorous proof technique used throughout number theory.

History
- 1834: Dirichlet applies the drawer/box argument in a number-theoretic proof, giving the principle its first prominent rigorous use.
- 1842: Dirichlet's approximation theorem is published, showing every irrational number has infinitely many good rational approximations, proved via a pigeonhole argument on fractional parts.
- Late 1800s: The term "pigeonhole principle" enters English mathematical usage, referencing literal pigeonhole desk compartments.
- 20th century: The principle becomes a standard tool in combinatorics textbooks and a staple of olympiad and computer science curricula.
- Present: Generalized and probabilistic versions (e.g., the probabilistic method, Ramsey theory) trace their combinatorial ancestry directly to this principle.
Does the pigeonhole principle tell us which box has multiple items?

No. The principle is purely existential: it guarantees some box must be overcrowded but gives no information about which box or which specific objects collide. The proof works by contradiction — assuming no box is crowded leads to a numerical contradiction — so it never constructs the colliding pair explicitly. In applications, you often need a separate, sometimes clever, argument or search to actually locate the collision, even though its existence is already certain. This non-constructive character is common to many existence proofs in combinatorics and is not a weakness of the technique, but a defining feature of what it can and cannot claim.

Is the pigeonhole principle the same as saying ∣N∣>∣K∣|N| > |K| implies no bijection exists?

Closely related but not identical in emphasis. If ∣N∣>∣K∣|N| > |K|, then indeed no bijection N→KN \to K can exist (bijections require equal cardinalities for finite sets), but the pigeonhole principle says something stronger and more specific: any function at all, injective or not, must have a repeated value somewhere. It is really a statement about the impossibility of injections in this cardinality regime, phrased in terms of forced collisions rather than merely the absence of a perfect one-to-one correspondence.

How is the ceiling function ⌈n/k⌉\lceil n/k \rceil justified rather than rounding normally?

The ceiling arises because box occupancy counts are non-negative integers, and the proof shows that assuming every box holds fewer than n/kn/k objects leads to a total strictly less than nn, a contradiction. The threshold "fewer than n/kn/k" translates precisely to "at most ⌈n/k⌉−1\lceil n/k\rceil - 1" for integers, by the defining property ⌈x⌉−1<x≤⌈x⌉\lceil x\rceil - 1 < x \le \lceil x \rceil. Ordinary rounding (to nearest) would not give a valid guaranteed lower bound; only the ceiling correctly captures "smallest integer not below the average."

Can the pigeonhole principle be applied to infinite sets at all?

The classical finite-box version, as stated here, strictly requires both NN and KK finite; the counterexample block shows the argument breaks completely when KK is infinite. However, there are genuinely infinite analogues, such as: if NN is infinite and partitioned into finitely many blocks, some block must be infinite (this follows from finite additivity failing for an all-finite partition of an infinite set). That is a different, though related, statement, and should not be confused with the finite generalized principle proved here.

What is the difference between the "basic" and "generalized" pigeonhole principle?

The basic form only concludes that some box has at least 22 objects, applicable whenever n>kn > k. The generalized form gives a quantitative lower bound, ⌈n/k⌉\lceil n/k \rceil, on the most-crowded box's occupancy for any nn and kk, not just n=k+1n = k+1. The basic form is literally the special case of the generalized one when n=k+1n = k+1, since ⌈(k+1)/k⌉=2\lceil (k+1)/k \rceil = 2. Most real applications, such as bounding shared birth months among large groups or forcing repeated remainders, use the generalized form to extract a specific numeric guarantee rather than just "a repeat exists."

Does choosing a different partition change the strength of the conclusion?

Yes, significantly. The pigeonhole principle's power depends entirely on how cleverly you choose the boxes (the partition of the codomain or an auxiliary set). A coarser partition (fewer, larger boxes) gives a weaker but still valid bound; a finer, well-chosen partition can extract a much sharper and more useful conclusion, as seen in Example 2 where pairing {i,13−i}\{i, 13-i\} was the crucial creative step. Much of the skill in applying this principle lies in designing the right boxes, not in the mechanical final step.

Where does the name "pigeonhole" come from?

The name references old writing-desk furniture with a grid of small open compartments, called "pigeonholes," originally used to sort mail or documents (and named by analogy to compartments in a dovecote used for pigeons). The mathematical metaphor imagines "pigeons" (objects) being placed into these "holes" (categories or boxes), so that too many pigeons and too few holes forces at least one hole to contain more than one pigeon. In German mathematical literature the same idea appears as the "Schubfachprinzip" (drawer principle), associated historically with Dirichlet's early rigorous use of the argument.

Before this