Recursion and induction
Recursion
A recursively defined function \(f\) needs two ingredients:
- a base, where the function value \(f(n)\) is defined, for some value of \(n\).
- a recursion, in which the computation of the function in \(n\) is explained with the help of the previous values smaller than \(n\).
For example, the sum
Or the product
Induction
Principle - Natural induction: suppose \(P(n)\) is a predicate for \(n \in \mathbb{Z}\), let \(b \in \mathbb{Z}\). If the following holds
- \(P(b)\) is true,
- for all \(k \in \mathbb{Z}\), \(k \geq b\) we have that \(P(k)\) implies \(P(k+1)\).
Then \(P(n)\) is true for all \(n \geq b\).
For example, we claim that \(\forall n \in \mathbb{N}\) we have
We first check the claim for \(n=1\):
Now suppose that for some \(k \in \mathbb{N}\)
Then by assumption
Hence if the claim holds for some \(k \in \mathbb{N}\) then it also holds for \(k+1\). The principle of natural induction implies now that \(\forall n \in \mathbb{N}\) we have
Principle - Strong induction: suppose \(P(n)\) is a predicate for \(n \in \mathbb{Z}\), let \(b \in \mathbb{Z}\). If the following holds
- \(P(b)\) is true,
- for all \(k \in \mathbb{Z}\) we have that \(P(b), P(b+1), \dots, P(k-1)\) and \(P(k)\) together imply \(P(k+1)\).
Then \(P(n)\) is true for all \(n \geq b\).
For example, we claim for the recursion
that \(a_n\) is odd \(\forall n \in \mathbb{N}\).
We first check the claim for for \(n=1\) and \(n=2\), from the definition of the recursion it may be observed that the it is true.
Now suppose that for some \(i \in \{1, \dots, k\}\) \(a_i\) is odd.
Then by assumption
so \(a_{k+1}\) is odd.