## Pigeonhole Principles

Pigeonhole Principle (PP):
    If some pigeons are in some pigeonholes,
    and there are fewer pigeonholes than there are pigeons,
    then some pigeonhole must contain at least two pigeons.

// The "pigeons" and "pigeonholes" can be abstract!

Example:
    If there are 367 people in a room,
    there must be two who share a common birthday.

# Interlude: maps and numbers

$f : X --> Y$ map between finite sets.

For $y\in Y$, $f^{-1}(y) =$ "fibre of $f$ over $y$" $= \{ x | f(x) = y \}$.

Recall:
    ***) $f$ is _surjective_ aka _onto_,
    written $f : X -->> Y$,
    if for all $y \in Y$, $| f^{-1}(y) | >= 1$

    ** $f$ is _injective_ aka \underline{1-1},
    written $f : X (-> Y$,
    if for all $y \in Y$, $| f^{-1}(y) | <= 1$

    ** $f$ is _bijective_ aka \underline{a (1-1) correspondence} aka _invertible_,
    written $f : X -~-> Y$,
    if $f$ is both injective and surjective,
    i.e. if for all $y \in Y$, $| f^{-1}(y) | = 1$

    *e)*

Remark:
    If $f$ is
    ***) injective then $|X| <= |Y|$ (Pigeonhole principle)
    ** surjective then $|X| >= |Y|$
    ** bijective then $|X| = |Y|$
    *e)*

# Applications of the Pigeonhole principle

Example:
    If I take 13 coins,
    divide them into 9 piles, placed in a row,
    then there will be a group of neighbouring piles within the row
    such that there are exactly 4 coins in the group.
(Generally: $n$ coins, $m$ piles; must be $k$ coins in a contiguous group if
    :	$n+k < 2*m$
    (this isn't sharp))
Proof:
    Let $a_i :=$ number of coins in first $i$ piles, $1 <= i <= 9$.
    Consider the 18 numbers
    :	$a_1, a_2, ..., a_9, a_1+4, a_2+4, ..., a_9+4$.
    Since $1 <= a_i <= 13$, these numbers are all between 1 and 17.
    So by the PP, two must be equal.

    Since no two $a_i$ are equal (since the piles are non-empty),
    and similarly no two $a_i+4$ are equal,
    we must have $a_i = a_j+4$ for some $i$,$j$.

    So $a_i - a_j = 4$,
    so 4 is the sum of the sizes of the piles after $i$ and up to $j$,
    namely piles $i+1,...,j$.

Example:
    Using as many coins as I want,
    I make a row of $k$ piles.
    Then there is a group of neighbouring piles
    such that the number of coins in the group is divisible by $k$.
Proof:
    Let $a_1,...,a_k$ be as above.
    
    Let $r_i$ be the remainder on dividing $a_i$ by $k$.
    If any $r_i=0$, we're done.
    Else, $0 < r_i < k$,
    so by the PP, two remainders are equal,
    $r_i = r_j$.
    But then $a_i - a_j$ is divisible by 7, and we conclude as in the previous
    example.


# Packed Pigeonhole Principle

Packed Pigeonhole Principle (PPP):
    If there are more than $k*n$ pigeons in $n$ pigeonholes,
    then some pigeonhole contains more than $k$ pigeons.
(Note: "Packed" is not standard terminology. This principle is commonly
referred to as the pigeonhole principle. Brualdi calls something slightly more
general (but less pleasing) the "strong pigeonhole principle", but I don't
think we need to cover it)

Example:
    If $a_1,...,a_{n^2+1}$ is a sequence of $n^2 + 1$ real numbers,
    there is a subsequence of length $n+1$ which is monotonic, i.e. is either
    (nonstrictly) increasing or (nonstrictly) decreasing.
Proof:
    Suppose there is no increasing subsequence of length $n+1$.

    Let $l_i$ be the length of the longest increasing subsequence starting with
    $a_i$. So $1 <= l_i <= n$.

    So by the PPP, $n+1$ of these $n^2+1$ numbers are equal;
    say $l_{i_1} = ... = l_{i_{n+1}}$.

    Now suppose $a_{i_j} < a_{i_{j+1}}$.
    Then we can extend the longest increasing subsequence starting with
    $a_{i_{j+1}}$ to a longer one starting with $a_{i_j}$, by prepending $a_{i_j}$.
    This contradicts $l_{i_j} = l_{i_{j+1}}$.

    So $(a_{i_j})_j$ is a decreasing sequence of length $n+1$.

Abstract version:
    If $f : X -->> Y$ is a surjection,
    and if all fibres are of size at most $k$,
    :   i.e. $| f^{-1}(y) | <= k$ for all $y$,
    then $|X| <= k|Y|$.

Remark (Division principle, map form):
    If $f : X -->> Y$ is a surjection,
    and if all fibres have size exactly $k$,
    :   i.e. $| f^{-1}(y) | = k$ for all $y$,
    then $|X| = k|Y|$.

    (Proof: partition $X$ according to the value of $f$, apply division principle)

Averaging principle:
    Given integers $a_1,...,a_n$,
    some $a_i$ is at least the average,
    :	$a_i >= (a_1+...+a_n)/n$
    (Note the average might not be an integer!)

Packed Pigeonhole follows from averaging:
    if there are more than $k*n$ pigeons,
    then the average number of pigeons per pigeonhole is more than k;
    some pigeonhole has at least the average number of pigeons,
    so has more than $k$ pigeons.

Example:
    Discs (p.75)
