Induction is one of our most powerful tools for proving things (e.g., correctness, runtime) about our algorithms, and it can be intimidating. To reduce the stress surrounding induction, we will present it as a step-by-step process you can follow when you don't know where to start or if you are stuck. With practice, you will understand the common patterns and become comfortable proving properties about the algorithms you develop.
Induction:
- The claim. Before we prove something, we need a clear statement about what we want to prove and what it means for an algorithm to be correct. Take sorting.
- The induction target. What are we running induction on? The target is a variable that is an integer that can correspond to all possible inputs. In many cases, it will be the size of the input.
- Base case.
- The inductive hypothesis. This is the thing that we will assume to be true. It is an additional fact that we can use to prove our claim true. BE CAREFUL that your inductive hypothesis does not inadvertently assume your claim is true. This is a common mistake, and it is worth taking a second to look back at your claim to be sure there is room between this assumption and your claim.
- The inductive step.
Claim:
Proof by induction on
Base case: When
Inductive hypothesis: Assume that
Inductive step: If
- Let
$n>4$ $2^n = 2 * 2^(n-1)$ - From the inductive hypothesis, we know that
$2^(n-1) < (n-1)!$ , which implies that$2^n < 2 * (n-1)!$ - Since we let
$n>4$ ,$2^n < n * (n-1)!$ - Since
$n! = n * (n-1)!$ we can reduce (4) to$2^n < n!$
By induction on
graph LR;
S--> 1 & 2;
1--> 2