{
  "id": "pigeonhole-principle",
  "title": "Pigeonhole Principle",
  "lang": "en",
  "source_lang": "en",
  "summary": "The pigeonhole principle states that placing more objects than containers into those containers forces at least one container to hold more than one object.",
  "category": "mathematics",
  "subcategory": "discrete-logic",
  "type": "concept",
  "aliases": [
    "Dirichlet's principle",
    "Dirichlet's box principle",
    "Drawer principle"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/pigeonhole-principle/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/pigeonhole-principle/",
      "json": "https://aiwiki.page/zh/pigeonhole-principle.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "The pigeonhole principle is a basic counting principle in combinatorics: if more than \\(n\\) objects are assigned to \\(n\\) containers, at least one container receives at least two objects. The containers, traditionally called pigeonholes, may represent physical spaces, categories, numerical remainders, or any other classification. Although elementary, the principle is a powerful tool for proving that repetitions, coincidences, or particular configurations must exist."
    },
    {
      "heading": "Statement and proof",
      "text": "For any positive integer \\(n\\), if \\(n+1\\) objects are placed into \\(n\\) boxes, some box contains at least two objects.\n\nA proof by contradiction establishes the claim immediately. Suppose every box contained at most one object. The total number of objects would then be at most \\(n\\), contradicting the presence of \\(n+1\\) objects.\n\nThe objects need not be identical, the boxes need not have physical boundaries, and some boxes may be empty. What matters is that every object is assigned to exactly one box.\n\nIn the language of set theory, if \\(A\\) and \\(B\\) are finite sets with\n\n\\[|A|>|B|,\\]\n\nthen no function \\(f:A\\to B\\) can be an injection. There must be distinct elements \\(a_1,a_2\\in A\\) such that\n\n\\[f(a_1)=f(a_2).\\]\n\nHere, \\(|A|\\) denotes the cardinality of \\(A\\). This formulation expresses the principle without the metaphor of objects and boxes."
    },
    {
      "heading": "Generalized forms",
      "text": "A guaranteed occupancy\n\nIf \\(N\\) objects are distributed among \\(k\\) boxes, where \\(N\\geq 0\\) and \\(k\\geq 1\\), then some box contains at least\n\n\\[\\left\\lceil\\frac{N}{k}\\right\\rceil\\]\n\nobjects. The ceiling denotes the least integer greater than or equal to its argument.\n\nTo prove this, let \\(m=\\lceil N/k\\rceil\\). If every box contained at most \\(m-1\\) objects, the total would be at most\n\n\\[k(m-1)<N,\\]\n\na contradiction.\n\nEquivalently, for positive integers \\(k\\) and \\(r\\), placing\n\n\\[k(r-1)+1\\]\n\nobjects into \\(k\\) boxes guarantees that at least one box contains \\(r\\) objects. This threshold is sharp: \\(k(r-1)\\) objects can be distributed with exactly \\(r-1\\) objects in every box.\n\nThe minimum-occupancy counterpart is also useful: at least one box contains at most\n\n\\[\\left\\lfloor\\frac{N}{k}\\right\\rfloor\\]\n\nobjects, where the floor is the greatest integer not exceeding its argument. Both statements reflect the fact that the average occupancy is \\(N/k\\).\n\nUnequal capacities\n\nSuppose box \\(i\\) has a nonnegative integer capacity \\(c_i\\). If\n\n\\[N>\\sum_{i=1}^{k}c_i,\\]\n\nthen some box receives more objects than its capacity.\n\nThis form is useful when the categories have different allowable sizes. Its proof is the same counting argument: respecting every capacity would bound the total by their sum."
    },
    {
      "heading": "How the principle is applied",
      "text": "The main difficulty in a pigeonhole argument is usually not the final counting step but the choice of boxes. A typical application proceeds by:\n\n- Identifying the objects being counted.\n- Assigning every object to one category.\n- Showing that there are too many objects for all categories to remain below a specified occupancy.\n- Translating the forced coincidence into the desired conclusion.\n\nThe boxes may be remainder classes, intervals, possible outputs of a computation, or possible values of a numerical property. A useful choice makes sharing a box imply something mathematically significant.\n\nFor example, among 13 people, at least two were born in the same month: the people are the objects and the 12 months are the boxes. More generally, among 37 people, at least four share a birth month."
    },
    {
      "heading": "Applications in number theory",
      "text": "Equal remainders\n\nIn modular arithmetic, division by a positive integer \\(m\\) produces one of \\(m\\) possible remainders:\n\n\\[0,1,\\ldots,m-1.\\]\n\nTherefore, among any \\(m+1\\) integers, two have the same remainder modulo \\(m\\). Their difference is divisible by \\(m\\).\n\nThis elementary observation underlies many arguments in number theory. The integers themselves may be arbitrarily large; only their finitely many remainder classes matter.\n\nA consecutive sum divisible by \\(n\\)\n\nGiven any sequence of \\(n\\) integers\n\n\\[a_1,a_2,\\ldots,a_n,\\]\n\nthere is a nonempty consecutive block whose sum is divisible by \\(n\\).\n\nDefine the \\(n+1\\) partial sums\n\n\\[S_0=0,\\qquad S_j=a_1+\\cdots+a_j\\quad(1\\leq j\\leq n).\\]\n\nThere are only \\(n\\) remainder classes modulo \\(n\\), so two partial sums, say \\(S_i\\) and \\(S_j\\) with \\(i<j\\), have the same remainder. Hence\n\n\\[S_j-S_i=a_{i+1}+\\cdots+a_j\\]\n\nis divisible by \\(n\\).\n\nIncluding the initial sum \\(S_0=0\\) makes the proof cover, in one argument, blocks beginning with \\(a_1\\) and blocks beginning later.\n\nRational approximation\n\nThe principle also gives an elementary approximation result. For any real number \\(\\alpha\\) and positive integer \\(Q\\), there exist integers \\(p\\) and \\(q\\), with \\(1\\leq q\\leq Q\\), such that\n\n\\[\\left|\\alpha-\\frac pq\\right|<\\frac{1}{qQ}.\\]\n\nConsider the fractional parts of\n\n\\[0,\\alpha,2\\alpha,\\ldots,Q\\alpha.\\]\n\nDivide \\([0,1)\\) into \\(Q\\) half-open intervals of length \\(1/Q\\). Two of the \\(Q+1\\) fractional parts lie in the same interval, so their difference has absolute value less than \\(1/Q\\). Subtracting the corresponding multiples of \\(\\alpha\\) gives\n\n\\[|q\\alpha-p|<\\frac1Q\\]\n\nfor suitable integers \\(p\\) and \\(q\\). Division by \\(q\\) gives the result. This is a standard form of Dirichlet's approximation theorem."
    },
    {
      "heading": "Applications in geometry and graph theory",
      "text": "In geometry, subdividing a region creates boxes whose dimensions control the distance between points.\n\nFor example, among any five points in a square of side length \\(1\\), two are at Euclidean distance at most\n\n\\[\\frac{\\sqrt2}{2}.\\]\n\nDivide the square into four squares of side length \\(1/2\\), using a fixed convention to assign boundary points to one region. Two points must occupy the same region. Their distance cannot exceed that region's diagonal, \\(\\sqrt2/2\\).\n\nIn graph theory, the principle proves that every finite simple undirected graph with at least two vertices has two vertices of equal degree. For a graph with \\(n\\) vertices, the apparent possible degrees are\n\n\\[0,1,\\ldots,n-1.\\]\n\nHowever, degrees \\(0\\) and \\(n-1\\) cannot both occur: a vertex adjacent to every other vertex cannot coexist with an isolated vertex. Thus at most \\(n-1\\) degree values are available for \\(n\\) vertices, forcing a repetition.\n\nThis example illustrates an important technique: structural constraints can reduce the number of available boxes below the initially apparent count."
    },
    {
      "heading": "Computing and information limits",
      "text": "In computer science, a function mapping a larger finite input set into a smaller output set must map some distinct inputs to the same output. Such an event is called a collision. For example, a hash function with \\(b\\)-bit outputs has only \\(2^b\\) possible output values. If its input domain contains more than \\(2^b\\) elements, collisions necessarily exist.\n\nThe same counting argument limits lossless compression. There are \\(2^n\\) binary strings of length \\(n\\), but only\n\n\\[1+2+\\cdots+2^{n-1}=2^n-1\\]\n\nbinary strings of length strictly less than \\(n\\), including the empty string. A lossless encoding must assign distinct inputs distinct representations. Consequently, no encoding can shorten every \\(n\\)-bit string while preserving recoverability from the representation alone.\n\nThese are existence and impossibility results, not efficiency claims. Proving that a collision exists does not establish that it can be found quickly."
    },
    {
      "heading": "Infinite versions and limitations",
      "text": "An infinite set partitioned into finitely many classes must have at least one infinite class. Otherwise, every class would be finite, and their finite union would also be finite. This statement is often called the infinite pigeonhole principle.\n\nThe requirement of finitely many classes matters. Infinitely many objects can be assigned to infinitely many boxes with exactly one object per box. Likewise, infinite sets do not obey every finite intuition: an infinite set can have the same cardinality as a proper subset of itself. For instance, \\(n\\mapsto n+1\\) injectively maps the nonnegative integers onto the positive integers.\n\nThe finite principle also does not require probability or random assignment. Its conclusions hold for every permitted arrangement. Conversely, it does not ordinarily identify which objects coincide or how many coincidences occur beyond the stated bound. Stronger conclusions require additional information about the distribution or structure of the objects."
    },
    {
      "heading": "Historical terminology",
      "text": "The principle is closely associated with the nineteenth-century mathematician Peter Gustav Lejeune Dirichlet, who used it in number theory. The names Dirichlet's box principle and drawer principle emphasize the same allocation argument as the English expression pigeonhole principle.\n\nThe shorter name Dirichlet's principle is ambiguous: it also refers to a distinct variational principle concerning harmonic functions and boundary-value problems. “Pigeonhole principle” or “Dirichlet's box principle” avoids that ambiguity."
    }
  ],
  "links": [
    "combinatorics",
    "integer",
    "proof-by-contradiction",
    "set-theory",
    "mathematical-function",
    "injective-function",
    "cardinality",
    "modular-arithmetic",
    "number-theory",
    "real-number",
    "geometry",
    "euclidean-distance",
    "graph-theory",
    "computer-science",
    "hash-function",
    "subset",
    "probability"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}