def fun(a):
if a ==0:
return 1
return 2 * fun(a-1)
Claim: fun(\(n\)) = \(2^n\)
How to prove?
Induction: Proof methodology where we show that $\forall n \in \mathbb{N}, P(n)$
Prove $P(x)$ is true because $P(n\le x)$ is true
More specifically: $P(0) \land P(0) \Rightarrow P(1) \land P(1) \Rightarrow P(2) \land \dots$
Basically a way we can prove recursion works
Dominoes, or ladders
There are always two things
There are always two things
What can be concluded?
Weak Induction: A way we can prove $\forall x \in \mathbb{Z}^{\ge n_0}, P(x)$ because $P(n_0) \land P(x) \Rightarrow P(x+1)$ and $n_0 \in \mathbb{Z}^{\ge 0}$
Weak Induction: A way we can prove $\forall x \in \mathbb{Z}^{\ge n_0}, P(x)$ because $P(n_0) \land P(x) \Rightarrow P(x+1)$ and $n_0 \in \mathbb{Z}^{\ge 0}$
We want to prove 2 things
Term: Inductive Hypothesis: for some arbitrary $ k \ge n_0, P(k)$
def fun(a):
if a ==0:
return 1
return 2 * fun(a-1)
\[ f(x) = \begin{cases} 1 & x = 0 \\ 2f(x-1) & x \ge 1 \end{cases} \]
\[ f(x) = \begin{cases} 1 & x = 0 \\ 2f(x-1) & x \ge 1 \end{cases} \]
$\forall x \in \mathbb{Z}^{\ge 0},f(x) = 2^x$
$\forall n \in \mathbb{Z}^{\ge 3}, 2n+1 < 2^n$
$\forall n \in \mathbb{Z}^{\ge 1},\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$
$P(x) = \sum_{i=1}^{n} i = \frac{n(n=1)}{2}, n_0 = 1$
\[ f(x) = \begin{cases} 3 & n = 0 \\ 5(f(x-1)) + 8 & n \ge 1 \end{cases} \]
$\forall x \in \mathbb{Z}^{\ge 0},f(x) \equiv 3 (\text{ mod }4)$
$\forall n \in \mathbb{Z}^{\ge 4},2^n - n^2 \ge 0$