The Connection to Recursion

Induction is the proof technique that mirrors recursion. If you can write a recursive algorithm, you can structure an inductive proof with the same shape. The domino analogy is standard: if the first domino falls, and each domino knocks over the next, then every domino falls. But the real insight for CS is that induction and recursion are two sides of the same coin. Recursion breaks a problem down; induction builds a proof up. Same structure, different direction.

Note

Induction is not optional in CS. It’s the primary method for proving algorithm correctness, verifying loop invariants, and establishing properties of recursive data structures. If you’re uncomfortable with induction, you’ll hit a wall the moment a course asks you to prove something works rather than just implement it.

Weak (Simple) Induction

To prove a statement holds for all :

  1. Base case: Show is true.
  2. Inductive step: Assume for an arbitrary (the inductive hypothesis), and prove .

By the well-ordering principle of the natural numbers, this suffices: every is reachable from by repeated successor steps.

Example

Sum formula. Prove for all .

Base case (): . True.

Inductive step: Assume . Then: which is the formula with . QED.

Strong Induction

The inductive hypothesis is strengthened: assume for all , then prove . This is equivalent in power to weak induction but often simplifies proofs where the recursive step depends on cases smaller than but not necessarily itself.

Example

Every integer is a product of primes.

Base case (): is prime, so it’s trivially a product of primes.

Inductive step: Assume every integer with is a product of primes. Consider . If it’s prime, done. If not, then where . By the strong IH, both and are products of primes, so is as well. QED.

Tip

Use strong induction whenever your recursive structure doesn’t just depend on the “previous” case. Divide-and-conquer algorithms (merge sort splits in half, not just peeling off one element) naturally call for strong induction in their correctness proofs.

Structural Induction

This generalizes induction to recursively defined structures: trees, lists, formulas, ASTs. Instead of inducting on an integer, you induct on the structure of the data:

  1. Base case: Prove for each base constructor (e.g., empty list, leaf node).
  2. Inductive step: For each recursive constructor, assume holds for all sub-structures and prove for the constructed whole.

This directly mirrors how recursive functions process algebraic data types. If you’ve written a recursive function over a tree, you’ve already done structural induction informally. The proof has exactly the same shape as the code.

Example

Binary tree leaf bound. Prove: for any binary tree , the number of leaves , where is the node count.

Base case: A single-node tree has , , and . True.

Inductive step: Suppose has root with subtrees and . By the IH, and . Since and , the bound follows by algebra.

When to Use Which Form

FormUse when…
Weak inductionThe step from to only needs
Strong inductionThe step needs for arbitrary (e.g., optimal substructure arguments)
Structural inductionThe domain is a recursive data type, not integers

CS Proof Patterns

Loop invariants. Induction on iteration count proves that a loop maintains a property. The base case is the state before the first iteration; the step shows that if the invariant holds at iteration , it holds at . This is how you prove that a while loop in an algorithm actually computes what you claim it does.

Algorithm correctness. For divide-and-conquer or recursive algorithms, strong induction on input size shows that if the algorithm is correct on all inputs smaller than , it is correct on input .

Recurrence verification. You have a recurrence and a claimed closed form. Substitute and induct to verify it. This is the “guess and check” approach that complements the master theorem.

Warning

Common mistakes in induction proofs:

  • Forgetting to verify the base case. Without it, the proof is vacuous. You can “prove” anything by induction if you skip the base case.
  • Using in the proof of : that’s circular reasoning, not induction.
  • Choosing the wrong inductive variable (e.g., inducting on when the recursion decreases a different quantity).
  • Off-by-one errors in the base case that leave a gap between the base and the first application of the inductive step.

Tip

When stuck on an induction proof, write the recursive algorithm first. The base case of the algorithm is the base case of the proof. The recursive calls correspond to applications of the inductive hypothesis. Match the proof structure to the code structure and it usually clicks.

  • Recursion - induction is the proof technique that mirrors recursive computation
  • Recurrence Relations - induction verifies closed-form solutions to recurrences
  • Graph Theory - many graph proofs proceed by induction on vertices or edges
  • Discrete Probability - inductive arguments establish properties of random processes