Pigeonhole Principle

Introduction

The pigeonhole principle is one of the simplest yet most powerful tools in combinatorics. Its statement is almost trivial: if you have more pigeons than pigeonholes and each pigeon must go into a hole, then at least one hole contains more than one pigeon. Yet this elementary observation leads to surprisingly deep results across mathematics.

The principle, also known as Dirichlet's box principle, was formalized by Peter Gustav Lejeune Dirichlet in 1834 1834. It provides existence proofs—showing that certain configurations must exist—without constructing them explicitly. This makes it invaluable when direct construction is difficult or impossible.

Applications range from number theory and combinatorics to computer science and everyday reasoning. The principle appears in proofs about rational approximations, graph coloring, data compression, and countless other areas.

Statement of the Principle

Simple Form

If n+1 n plus 1 or more objects are placed into n n boxes, then at least one box contains two or more objects.

If |A|>|B| the absolute value of A is greater than the absolute value of B, then no injection ƒ:A→B f with hook colon A right arrow B exists.

Equivalently: if ƒ:A→B f with hook colon A right arrow B and |A|>|B| the absolute value of A is greater than the absolute value of B, then ƒ f with hook is not injective (one-to-one), meaning some element of B B is hit by at least two elements of A A.

Generalized Form

If n n objects are placed into k k boxes, then at least one box contains at least ⌈n/k⌉ ceiling of n divided by k objects.

At least on box has ≥[n/k] is greater than or equal to open bracket n divided by k close bracket objects.

This follows from the simple form: if every box had fewer than ⌈n/k⌉ ceiling of n divided by k objects, the total would be at most
k⋅([n/k]−1)<n k times open paren open bracket n divided by k close bracket minus 1 close paren is less than n, a contradiction.

Strong Form

If n1+n2+⋯+nk−k+1 n sub 1 plus n sub 2 plus dot dot dot plus n sub k minus k plus 1 objects are placed into k k boxes, then either box 1 1 contains at least n1 n sub 1 objects, or box 2 2 contains at least n2 n sub 2 objects, … dot dot dot, or box k k contains at least nk n sub k objects.

The simple form is the special case where all ni=2 n sub i equals 2.

Basic Examples

Example 1: Birthdays

In any group of 367 367 people, at least two share a birthday (ignoring leap years). Here the pigeons are people (367 367) and the holes are days of the year (366 366).

More strongly: in a group of 23 23 people, the probability that two share a birthday exceeds 50 50%. This is the famous birthday paradox.

Example 2: Hair Count

The average human head has about 150000 150000 hairs, and no one has more than 500000 500000. In a city of 1 1 million people, at least two people have exactly the same number of hairs on their head.

Pigeons: 1 1,000000 000000 people. Holes: 500001 500001 possible hair counts (0 0 to 500000 500000). Since 1000000 1000000 > 500001 500001, at least two people share a hair count.

Example 3: Socks in the Dark

A drawer contains red and blue socks. What is the minimum number of socks you must draw (without looking) to guarantee a matching pair?

Answer: 3 3 socks. With 2 2 colors and 3 3 socks, at least two must be the same color. By the pigeonhole principle with k=2 k equals 2 holes and n=3 n equals 3 objects, [3/2]=2 open bracket 3 divided by 2 close bracket equals 2 socks must share a color.

Applications in Number Theory

Divisibility Result

Among any n+1 n plus 1 integers, at least two have the same remainder when divided by n n.

There are only n n possible remainders: 0,1,2,…,n−1 0 comma 1 comma 2 comma dot dot dot comma n minus 1. With n+1 n plus 1 integers and n n remainders, two integers must share a remainder, so their difference is divisible by n n.

Subsequence Sum Divisibility

Given any n n integers, some nonempty subset has a sum divisible by n n.

Consider the partial sums S0=0,S1=a1, S sub 0 equals 0 comma S sub 1 equals a sub 1 comma S2=a1+a2,…, S sub 2 equals a sub 1 plus a sub 2 comma dot dot dot comma Sn=a1+⋯+an S sub n equals a sub 1 plus dot dot dot plus a sub n.
These n+1 n plus 1 sums have remainders modulo n n from the set {0,1,…,n−1} the set 0 comma 1 comma dot dot dot comma n minus 1.

If any Si S sub i has remainder 0 0, we are done. Otherwise, by pigeonhole, two partial sums Si S sub i and Sj S sub j (with i<j i is less than j) have the same remainder. Then Sj−Si=ai+1+⋯+aj S sub j minus S sub i equals a sub i plus 1 plus dot dot dot plus a sub j is divisible by n n.

Dirichlet's Approximation Theorem

For any real number α alpha and positive integer n n, there exist integers p p and q q with 1≤q≤n 1 is less than or equal to q is less than or equal to n such that:

|α−pq|<1q⁢n the absolute value of alpha minus p over q is less than 1 over q n

The proof uses the pigeonhole principle on the fractional parts of
0,α,2⁢α,…,n⁢α 0 comma alpha comma 2 alpha comma dot dot dot comma n alpha. These n+1 n plus 1 numbers lie in [0,1) the interval from 0 to 1 including 0 but not including 1, which we divide into n n intervals of length 1/n 1 divided by n. Two must fall in the same interval.

Applications in Combinatorics

Monotone Subsequences

Any sequence of n2+1 n squared plus 1 distinct real numbers contains either an increasing subsequence of length n+1 n plus 1 or a decreasing subsequence of length n+1 n plus 1.

Label each element with the length of the longest increasing subsequence starting from it. If all labels are at most n n, there are only n n possible labels for n2+1 n squared plus 1 elements. By pigeonhole, at least n+1 n plus 1 elements share the same label.

If these elements with the same label form an increasing subsequence, we get a contradiction. So they must form a decreasing subsequence of length n+1 n plus 1.

Ramsey-Type Results

In any 2 2-coloring of the edges of K6 K sub 6 (complete graph on 6 6 vertices), there exists a monochromatic triangle.

Consider any vertex v v. It has 5 5 edges, colored red or blue. By pigeonhole, at least 3 3 edges have the same color, say red. Let these connect v v to vertices a,b,c a comma b comma c.

If any edge among a,b,c a comma b comma c is red, we have a red triangle. If all edges among a,b,c a comma b comma c are blue, we have a blue triangle. Either way, a monochromatic triangle exists.

Applications in Computer Science

Hash Collisions

If a hash function maps n n items to m m buckets where n>m n is greater than m, at least one bucket must contain multiple items (a collision). This is why hash tables must handle collisions.

Data Compression Limits

No lossless compression algorithm can compress all files of length n n bits. There are 2n 2 to the n-th power possible inputs but only 2n−1 2 to the n-th power minus 1 possible outputs shorter than n n bits. By pigeonhole, two inputs must map to the same output, making decompression ambiguous.

Load Balancing

If n n tasks are distributed among k k servers, at least one server handles at least
⌈n/k⌉ ceiling of n divided by k tasks. This lower bound on maximum load is unavoidable regardless of the distribution strategy.

The Probabilistic Pigeonhole

The principle has a probabilistic analog: if n n items are randomly placed into k k boxes, the expected number of items in a box is n/k n divided by k. By linearity of expectation, at least one box must have at least the average ⌈n/k⌉ ceiling of n divided by k items.

This connects to the probabilistic method in combinatorics, which uses expected value arguments to prove existence results.

Connection to Other Concepts

The pigeonhole principle is a special case of cardinality arguments about finite sets. It formalizes the intuition that injections can only exist between sets of appropriate sizes.

In combinatorics, it underlies Ramsey theory, which studies conditions guaranteeing the existence of order in large structures. The friendship theorem and the Happy Ending Problem are examples.

In number theory, it provides approximation theorems (Dirichlet) and results about quadratic residues. In analysis, it appears in proofs about measure and cardinality.

In computer science, it explains fundamental limits on hashing, compression, and resource allocation. It also underlies the birthday attack in cryptography.

Summary

The pigeonhole principle states that if n+1 n plus 1 objects are placed into n n boxes, at least one box contains at least two objects. More generally, n n objects in k k boxes means some box has at least ⌈n/k⌉ ceiling of n divided by k objects.

Though simple, the principle has far-reaching applications. In number theory, it proves results about remainders, rational approximations (Dirichlet), and divisibility. In combinatorics, it establishes the existence of monotone subsequences and monochromatic subgraphs.

In computer science, it explains hash collisions, compression limits, and load balancing lower bounds. The principle provides existence proofs without explicit construction.

The power of the pigeonhole principle lies not in its statement but in identifying the right pigeons and holes for a given problem. Finding clever applications requires insight into the structure of the problem at hand.

The principle extends to infinite sets via cardinality comparisons. If there is no injection from A A to B B, then |A|>|B| the absolute value of A is greater than the absolute value of B. Cantor's diagonal argument, which proves the uncountability of the reals, is a sophisticated application of this idea.

Many competition mathematics problems rely on the pigeonhole principle. The key challenge is always the same: identify what the pigeons are, what the pigeonholes are, and why the count guarantees the desired conclusion.

Despite its elementary nature, the pigeonhole principle remains indispensable in modern mathematics and computer science. It reminds us that sometimes the simplest observations lead to the most profound results.