Discrete Mathematics
Proof by induction, the pigeonhole principle, and solving recurrences — the reasoning toolkit of computer science.
Discrete mathematics studies structures that come in distinct, separate pieces — integers, statements, steps of an algorithm — rather than continuous quantities. It supplies the proof techniques that let us claim an algorithm is correct for every input, not just the cases we tested.
The visualizer below shows induction as a chain of dominoes. The base case pushes the first domino; the inductive step guarantees each domino topples the next. Turn either ingredient off and watch the proof break.
Base case holds and each domino knocks the next, so every P(k) is true — that is a complete proof by induction.
Proof by induction
To prove a statement holds for every natural number , induction needs two parts:
- Base case: show is true.
- Inductive step: assume (the inductive hypothesis) and prove .
Together they cover every like falling dominoes. For example, to prove : the base case gives , and assuming ,
which is exactly . Induction is how we prove loops and recursive functions work for inputs of any size.
The pigeonhole principle
If you put pigeons into holes, some hole holds at least two pigeons. Stated plainly: if items go into boxes and , at least one box gets more than one item. It sounds trivial but proves surprising facts — for instance, in any group of 13 people, two share a birth month, and any hash table with more keys than buckets must have a collision. More generally, some box holds at least items.
Solving recurrences
A recurrence defines a value in terms of smaller cases — exactly how recursive algorithms describe their own cost. Merge sort, for example, satisfies
Unrolling it builds a tree: each level does total work across its subproblems, and there are levels, giving . Other patterns: unrolls to , while explodes to . Recognizing a recurrence’s shape is how you read an algorithm’s running time straight off its structure.
Why it matters for CS
Induction proves that recursive algorithms and loop invariants are correct for all inputs. The pigeonhole principle bounds what is possible — collisions, duplicates, worst cases. Solving recurrences turns a recursive definition into a concrete complexity like . These three tools are how computer scientists reason rigorously instead of merely testing.
References
Takeaways
- Induction proves for all via a base case plus an inductive step — the domino chain.
- The pigeonhole principle forces a collision whenever items outnumber boxes.
- Unrolling a recurrence into a tree reveals an algorithm’s running time, like for .