Recall Weak Induction
Goal: $\forall n \in \mathbb{Z}^{\ge 0}, \sum\limits_{i=1}^n i = \frac{n(n+1)}{2}$
Goal: $\forall n \in \mathbb{Z}^{\ge 0}, \sum\limits_{i=1}^n i = \frac{n(n+1)}{2}$
$P(0),P(1),P(2),\ldots$
Instead what if we proved:
$P(0),P(0) \Rightarrow P(1), P(1) \Rightarrow P(2), P(2) \Rightarrow P(3), \ldots$
Goal: $\forall n \in \mathbb{Z}^{\ge 0}, \sum\limits_{i=1}^n i = \frac{n(n+1)}{2}$
Instead what if we proved:
$P(0),P(0) \Rightarrow P(1), P(1) \Rightarrow P(2), P(2) \Rightarrow P(3), \ldots$
(If we generalize this: $P(0),P(k) \Rightarrow P(k+1), k\ge 0$)
Strong induction is slightly different
Strong induction is slightly different
public int strong(int n){
if(n==0) return 3;
if(n==1) return 4;
return -n + strong(n-1) + strong(n-2);
}
public int strong(int n){
if(n==0) return 3;
if(n==1) return 4;
return -n + strong(n-1) + strong(n-2);
}
claim: $\text{strong}(n) = n + 3$
public int strong(int n){
if(n==0) return 3;
if(n==1) return 4;
return -n + strong(n-1) + strong(n-2);
}
Weak induction would not work
strong$(n) \nRightarrow \text{ strong}(n+1)$
instead: strong$(n) \land \text{strong}(n -1) \Rightarrow \text{ strong}(n+1)$
strong$(n) \nRightarrow \text{ strong}(n+1)$
instead: $\text{strong}(n) \land \text{strong}(n -1) \Rightarrow \text{ strong}(n+1)$
Recall the weak induction assumption:$k \ge n_0, P(k)$
We need to modify for Strong: $\forall i, k \ge i \ge n_0, P(i)$
public int strong(int n){
if(n==0) return 3;
if(n==1) return 4;
return -n + strong(n-1) + strong(n-2);
}
\[ s(x) = \begin{cases} 3 & x = 0 \\ 4 & x = 1 \\ -n + s(x-1) + s(x-2) & x \ge 2 \end{cases} \]
\[ s(x) = \begin{cases} 3 & x = 0 \\ 4 & x = 1 \\ -x + s(x-1) + s(x-2) & x \ge 2 \end{cases} \]
Claim: s(x) = x + 3
\[ s(x) = \begin{cases} 3 & x = 0 \\ 4 & x = 1 \\ -x + s(x-1) + s(x-2) & x \ge 2 \end{cases} \]
Explicit Base cases
Not always obvious
Suppose I have 3¢ and 10¢ coins
Prove I can pay anything 18¢ or more
Question: How many Base Cases?
How many things we rely on?
Suppose I have 3¢ and 10¢ coins
18¢ = 3¢ + 3¢ + 3¢ + 3¢ + 3¢ + 3¢
19¢ = 10¢ + 3¢ + 3¢ + 3¢
20¢ = 10¢ + 10¢
21¢ = 18¢ + 3¢
22¢ = 19¢ + 3¢
23¢ = 20¢ + 3¢
3 Base cases: P(18), P(19), P(20)
Suppose I have 3¢ and 10¢ coins
3 Base cases: P(18), P(19), P(20)
$P(n) = P(n-3) + 3, n\ge 21$
$P(n+1) = P(n-2) + 3, n\ge 20$
Prove: All integers $\ge 2$ has a prime factor