COMP3010: Algorithm Theory and Design

Daniel Sutantyo,  Department of Computing, Macquarie University

2.1 Mathematical Induction

Introduction

2.1 - Induction

  • We are going to use induction a few times in COMP3010
  • I assume that you have done induction in the past (DMTH137 or DMTH237 or high school), but let's go through a quick refresher
  • You can skip or just skim this video if you're already good with induction

References

  • You can refer to your DMTH237 textbook: Discrete Mathematics and Its Applications (7th Ed) by Kenneth H. Rosen, Chapter 5
  • I also like 'How to Prove It' by Daniel J. Velleman

Deduction and Induction

2.1 - Induction

  • Deductive reasoning:
    • Go from the general case to a specific case (if you have a general rule for the population, it will apply to the individual)
      • e.g.
        • Everyone who has a driver's license is 16 years or older.
        • Tom has a driver's license.
        • Tom must be 16 years or older
  • Inductive reasoning:
    • Go from the specific case to draw conclusion about the general case
      • e.g.
        • All the tests for COMP3010 have been easy so far
        • The final exam must also be easy

Deduction and Induction

2.1 - Induction

  • Inductive reasoning, prime numbers:
    • 3 is a prime
    • 5 is a prime
    • 7 is a prime
    • so all odd numbers must be a prime
    • or all prime numbers are odd?

Deduction and Induction

2.1 - Induction

  • Inductive reasoning, divisors of 60:
    • 1 divides 60
    • 2 divides 60
    • 3 divides 60
    • 4 divides 60
    • 5 divides 60
    • 6 divides 60
    • all numbers must divide 60!

Deduction and Induction

2.1 - Induction

  • Inductive reasoning is different to mathematical induction
  • Mathematical induction is a method to prove something, so it is actually deductive
  • Alfred has COVID
  • Anna has COVID
  • Alex has COVID
  • Amy has COVID
  • Adam has COVID
     
  • Everyone whose name starts with A has COVID
  • Alfred has COVID and had dinner with Anna
  • Anna has COVID and had dinner with Alex
  • Alex has COVID and had dinner with Amy
  • Amy has COVID and had dinner with Adam
  • Adam has COVID
     
  • If x contracted COVID and has dinner with y, then y will also get COVID

Mathematical Induction

2.1 - Induction

  • You are given a statement to prove, involving n 
  • For example, show that \[1 + 2 + 3 + \cdots + n = \frac{n(n+1)}{2}\] 
  • Can you just do:

\(1= \frac{1(1+1)}{2}\)

\(1+2 =  \frac{2(2+1)}{2}\)

\(1+2+3 =  \frac{3(3+1)}{2}\)

\( 1+2+3 +4=  \frac{4(4+1)}{2}\)

Mathematical Induction

2.1 - Induction

  • More generally, I'm giving you a statement P(n), and I want you to prove that P(n) is true for all n > 0
  • You can't just show
    • P(1) is correct
    • P(2) is correct
    • P(3) is correct
    • so P(n) is correct for all n > 0
  • Unfortunately many students somehow think that this is induction is (inductive reasoning, maybe, but definitely not mathematical induction)

Mathematical Induction

2.1 - Induction

  • In learning proof by induction you were probably told to do certain steps (it's very procedural), and it's easy for students to just know what to do, without knowing why they're doing it 
  • Remember that in mathematical induction, your main goal is this:
    • if you tell me that A is true, then I can prove that B is also true
    • if P(n) is true, then P(n+1) is also true

Mathematical Induction

2.1 - Induction

For example

  • You tell me that for an integer \(k\)
    • \(1 + 2 + 3 + \cdots + k = \frac{k(k+1)}{2}\)
  • Can I show that
    • \(1 + 2 + 3 + \cdots + k + (k+1) = \frac{(k+1)(k+2)}{2}\)
  • Why?
    • because this means \(1 + 2 + \cdots + n = \frac{n(n+1)}{2}\) (the general formula)
  • This is your main goal in a proof by induction

Mathematical Induction

2.1 - Induction

  • Let's try this:
    • we know \(1 + 2 + 3 + \cdots + k = \frac{k(k+1)}{2}\)
    • add \((k+1)\) on both sides
      • \[\begin{aligned}1 + 2 + 3 + \cdots + k + (k+1) &= \frac{k(k+1)}{2} + (k+1)\\&=\frac{k(k+1)+2k+2}{2}\\&=\frac{k^2+3k+2}{2}\\&=\frac{(k+1)(k+2)}{2}\end{aligned}\]

Mathematical Induction

2.1 - Induction

  • So now we know that \(1 + 2 + \cdots + n = \frac{n(n+1)}{2}\), but what is \(n\) here?
  • Remember that we showed that if this is true for \(k\), then it is also true for \((k+1)\), but we never really said what \(k\) can be
  • So let's try \(k = 5\)
    • 1+2+3+4+5 =  15
    • 5 (5+1) / 2 = 15
  • It works for \(k = 5\), so it must also works for \(k=6\), and so on
    • Why? 
    • because I only add \((k+1)\) to both sides and the formula is still correct

Mathematical Induction

2.1 - Induction

  • One more time:
    • we are proving that if a statement is true for \(k\), then it will also be true for \(k+1\)
    • we show that it's true for 1
      • so it must follow that it's true for 2 (we don't have to show this)
      • so it must follow that it's true for 3 (we don't have to show this)
      • so it must follow that it's true for 4 (we don't have to show this)
      • we don't have to show all this because we proved this for \(k\) and \((k+1)\) 

Writing the proof

2.1 - Induction

  • In learning induction, we were normally told to do:
    • base case (prove the statement is true for n = 1)
    • induction step 
      • assume the statement is true for n = k
      • prove that if the statement is true for n = k, then it's also true for n = k + 1
  • What I did it in this video is to flip that, and say that the final thing (proving the link between k and k+1) is the thing that you do first
    • hopefully you understand why we pick n = k
    • don't do this, please maintain the normal structure (i.e. start with the base case)

Mathematical Induction

2.1 - Induction

  • What about this 'assume the statement is true for n=k' business?
    • assume, because we don't know if the statement is true or not
    • I have to start somewhere in order to prove the link,
      • so I'm going to assume that it's true for k,
      • then I use it to prove the statement is true for k+1
    • because we are just assuming it, we call this statement the 'induction hypothesis', as in, we hypothesise that it is true for k

Mathematical Induction

2.1 - Induction

  • Show that \(1+2+3+\cdot+n = \displaystyle\frac{n(n+1)}{2}\) for all \(n \ge 1\)
     
    • Base case: show that the statement is true for \(n=1\)
      • if \(n = 1\) then


         
      • LHS = RHS, thus the property is true for \(n=1\)

 

LHS :

\[ 1\]

\[\frac{1(1+1)}{2} = 1\]

RHS :

Mathematical Induction

2.1 - Induction

  • Induction step
    • induction hypothesis: assume that the statement is true for \(n = k\), that is we assume

\[1+2+\cdots + k = \frac{k(k+1)}{2}  \text{for some $k \ge 1, k \in \mathbb N$}\]

Mathematical Induction

2.1 - Induction

  • Induction step (continued)
    • now prove that if the property holds for \(n =k\), then it also holds for \(n =k+1\)
    • that is, we have to prove that
      \[ 1+2+3+\cdots+k+1 = \frac{(k+1)(k+2)}{2}\]
    • proof:

\[1+2+3+\cdots+(k+1) = (k+1) + (1+2+3+\cdots+k)\]

\[= (k+1) + \frac{k(k+1)}{2} \]

\[= \frac{2k+2 + k^2 + k}{2} = \frac{k^2 +3k + 2}{2}\]

\[= \frac{(k+1)(k+2)}{2}\]

(as required)

(from the induction hypothesis)

Induction hypothesis

2.1 - Induction

  • It may sound strange that we are assuming what we're trying to prove to be true
    • e.g. I want to prove that \(1 + 2 + \cdots + n = n(n+1)/2\)
      • so why did I assume \(1 + 2 + \cdots + k = k(k+1)/2\)
  • They are different!
    • I want to prove that \(1 + 2 + \cdots + n = n(n+1)/2\) is true for all \(n \ge 1\)
    • I assume \(1+2+\cdots+k = k(k+1)/2\) for ONE value of \(k\)

Induction hypothesis

2.1 - Induction

  • Can you get the induction hypothesis wrong? Yes!
  • Show that \(1 + 2 + \cdots + n = O(n)\)
  • Base case: if \(n = 1\), obviously \(1 = O(1)\)
  • Induction step:
    • Induction hypothesis:
       
    • want to show that:

\[\sum_{i=1}^{k+1} i = (k+1) + \sum_{i=1}^k i = O(k) + k+1 = O(k+1)\]

\[1+2 + \cdots + k = O(k)\]

\[1 + 2 + \cdots + k + (k+1) = O(k+1)\]

Induction hypothesis

2.1 - Induction

  • Can you get the induction hypothesis 'right' but the proof wrong? Yes
  • Show that all odd numbers \(n \ge 2\) are prime
  • Base case: n = 3 is prime
  • Induction step:
    • Induction hypothesis:
       
    • want to show that:

\(k\) is a prime number

\(k+2\) is a prime number

now what ... ?

More examples

2.1 - Induction

  • Show that 
  • Base case: if \(n = 1\)
    • LHS : 1
    • RHS : 1! = 1
    • so LHS = RHS, the statement is true for \(n = 1\)

\[\prod_{i=1}^n i = 1 \times 2 \times \cdots \times n =  n! \]

  • Induction step: 
    • Induction hypothesis: assume true for \(n = k\), i.e
       
    • we need to prove that

(this one is a bit silly because we are proving a definition)

\[\prod_{i=1}^k i = 1 \times 2 \times \cdots \times k =  k! \]

\[\prod_{i=1}^{k+1} i = 1 \times 2 \times \cdots \times k \times (k+1) =  (k+1)! \]

More examples

2.1 - Induction

  • Prove

\[ = (k+1) k! \]

\[\prod_{i=1}^{k+1} i = 1 \times 2 \times \cdots \times k \times (k+1) =  (k+1)! \]

\[\prod_{i=1}^{k+1} i = 1 \times 2 \times \cdots \times k \times (k+1) =  (k+1)\prod_{i=1}^{k+1} i  \]

(from the induction hypothesis)

\[ = (k+1)! \]

More examples

2.1 - Induction

  • Show that 
  • Base case: if \(n = 1\)
    • LHS : \(1 \times 1! = 1\)
    • RHS : \((1+1)! - 1 = 2 - 1 = 1\)
    • so LHS = RHS, the statement is true for \(n = 1\)

\[\sum_{i=1}^n (i \times i!) = (n+1)! - 1 \]

\[\sum_{i=1}^k (i \times i!) = (k+1)! - 1 \]

\[\sum_{i=1}^{k+1} (i \times i!) = (k+2)! - 1 \]

  • Induction step: 
    • Induction hypothesis: assume true for \(n = k\), i.e
       
    • we need to prove that

More examples

2.1 - Induction

\[\sum_{i=1}^{k+1} (i \times i!) = (k+1) \times (k+1)! + \sum_{i=1}^k (i \times i!) \]

\[= (k+1) \times (k+1)! + (k+1)! - 1\]

\[= (k+1)! ( k+1+1) - 1\]

\[= (k+2)(k+1)!  - 1\]

\[= (k+2)!  - 1\]

as required