Snick snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman,...

62
snick snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    1

Transcript of Snick snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman,...

Page 1: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

snick

snack

CPSC 121: Models of Computation2011 Winter Term 1

Revisiting Induction

Steve Wolfman, based on work by Patrice Belleville and others

1

Page 2: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Outline

• Prereqs and Learning Goals• Problems and Discussion

– Introductions– Odd Numbers– Horse Colours– CS Induction: Duplicate Detection, Binary

Search, MergeSort– More examples

• Next Lecture Notes

2

Page 3: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Learning Goals: Pre-Class

By the start of class, you should be able to:– Given a theorem to prove and the insight into

how to break the problem down in terms of smaller problems, write out the skeleton of an inductive proof including: the base case(s) that need to be proven, the induction hypothesis, and the inductive step that needs to be proven.

3

Page 4: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Learning Goals: In-Class

By the end of this unit, you should be able to:– Formally prove properties of the non-negative

integers (or a subset like integers larger than 3) that have appropriate self-referential structure—including both equalities and inequalities—using either weak or strong induction as needed.

– Critique formal inductive proofs to determine whether they are valid and where the error(s) lie if they are invalid.

4

Page 5: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Online Quiz Notes: New Problem

Imagine that your country's postal system only issues 3 cent and 7 cent stamps. Prove by induction that it is possible to pay for postage using only these stamps for any amount n cents, where n is at least 12.

We will use n=12 as one of our base cases. (“We pay 12 cents with four 3 cent stamps”.)

5

Page 6: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Extra Base Cases?

Our inductive step says that for “sufficiently large” n, we can make n cents of postage by making n-3 cents of postage and then using a three cent stamp.What additional base case (if any) do we need?a. n = 6b. n = 13c. n = n-3d. no additional base casese. more than one additional base case

6

Page 7: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

n ?

Our inductive step says that for “sufficiently large” n, we can make n cents of postage by making n-3 cents of postage and then using a three cent stamp. We use n=12, n=13, and n=14 as base cases.How large must n be for the inductive step?a. n 12b. n 13c. n 14d. n 15e. none of these

7

Page 8: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Extra Base Cases?Version 2

Our inductive step says that for “sufficiently large” n, we can make n cents of postage by making n-1 cents of postage and then doing one of: take out two 7c stamps and add five 3c stamps or (if there are fewer than two 7c stamps), take out two 3c stamps and add a 7c stamp.What additional base case (if any) do we need?a. n = 6b. n = 13c. n = n-1d. no additional base casese. more than one additional base case

8

Page 9: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

n ?Version 2

Our inductive step says that for “sufficiently large” n, we can make n cents of postage by making n-1 cents of postage and then doing one of: take out two 7c stamps and add five 3c stamps or (if there are fewer than two 7c stamps), take out two 3c stamps and add a 7c stamp.We use n=12 as our only base case.How large must n be for the inductive step?a. n 12b. n 13c. n 14d. n 15e. none of these

9

Page 10: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Outline

• Prereqs and Learning Goals• Problems and Discussion

– Introductions– Odd Numbers– Horse Colours– CS Induction: Duplicate Detection, Binary

Search, MergeSort– More examples

• Next Lecture Notes

10

Page 11: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Worked Problem: How Many Introductions?

Problem: n people would like to introduce themselves to each other. How many introductions does it take?

For 2 people?

For 3 people?

For 4 people?

For 5 people?

For n people?Sound familiar?

Let’s prove it.11

Page 12: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Worked Problem: How Many Introductions?

Induction can feel very abstract. Let’s do the first few steps concretely…

For 1 person?

Given the number for 1, for 2?

Given the number for 2, for 3?12

Page 13: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Worked Problem: How Many Introductions?

Let’s let I(n) be the number of introductions required for a group of n people…

I(1)? 0 introductions.

Given I(k-1), what’s I(k)?a. I(k-1) + 1b. I(k-1) * (k-1)c. I(k-1) + 2(k – 1)d. I(k-1) + 2ke. None of these

13

My turn!

Let’s work through the intuition and then use it to fill in the pattern!

Page 14: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Finishing the Intuition: How Many Introductions?

I(k) = I(k-1) + 2(k-1)

= (k-1)((k-1)-1) + 2(k-1)

= (k-1)(k-2) + 2(k-1)

= k2 – 3k + 2 + 2k – 2

= k2 – k

= k(k-1)

14

My turn!

Let’s use this to fill in our pattern!

Page 15: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Formally…

Definition: When two people greet each other, we count that as two introductions. Let I(k) be the number of introductions it takes for a group of size k to introduce themselves. (I(.) is not a predicate; it’s a function!)

To prove: I(n) = n(n-1).

15

Page 16: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Finishing the Intuition: How Many Introductions?

I(k) = I(k-1) + 2(k-1)

= (k-1)((k-1)-1) + 2(k-1)

= (k-1)(k-2) + 2(k-1)

= k2 – 3k + 2 + 2k – 2

= k2 – k

= k(k-1)

16

My turn!

Def’ns: Two people greet: two intros. I(k) is the # of intros for a group of size k to intro themselves.

To prove: I(n) = n(n-1) for all groups of at least one person.

Page 17: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

A Pattern For Induction

P(n) is ______________.

Theorem: P(n) is true for all n _______.

Proof: We proceed by induction on n.

Base Case(s) (P(.) is true for _______): Prove each base case via your other techniques.

Inductive Step (if P(.) is true for ________________, then P(n) is true, for n > ____________):

WLOG, let n be greater than ____________.

Assume P(.) is true for __________________.

Break P(n) down in terms of the smaller case(s).

The smaller cases are true, by assumption.

Build back up to show that P(n) is true.

This completes our induction proof. QED17

Page 18: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Introductions Proof

P(n) is ______________.

18

Page 19: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Introductions Proof

P(n) is I(n) = n(n-1).

Theorem: P(n) is true for all n _______.

19

Page 20: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Introductions Proof

P(n) is I(n) = n(n-1).

Theorem: P(n) is true for all n 1.

Proof: We proceed by induction on n.

Base Case(s) (P(.) is true for _______): Prove each base case via your other techniques.

20

Page 21: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Introductions Proof

P(n) is I(n) = n(n-1).

Theorem: P(n) is true for all n 1.

Proof: We proceed by induction on n.

Base Case(s) : a “group” of one person takes no introductions . I(1) = 0 = 1(1-1).

Inductive Step (if P(.) is true for ________________, then P(n) is true, for n > ____________):

21

Page 22: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Introductions Proof

P(n) is I(n) = n(n-1).

Theorem: P(n) is true for all n 1.

Proof: We proceed by induction on n.

Base Case(s) : a “group” of one person takes no introductions . I(1) = 0 = 1(1-1).

Inductive Step:

WLOG, let n be an integer greater than 1.

Assume I(k-1) = (k-1)((k-1)-1).

Break P(n) down in terms of the smaller case(s).

The smaller cases are true, by assumption.

Build back up to show that P(n) is true.

This completes our induction proof. QED22

Page 23: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Introductions Proof Complete

P(n) is I(n) = n(n-1).

Theorem: P(n) is true for all n 1.

Proof: We proceed by induction on n.

Base Case(s) : a “group” of one person takes no introductions . I(1) = 0 = 1(1-1).

Inductive Step:

WLOG, let n be an integer greater than 1.

Assume I(k-1) = (k-1)((k-1)-1) = (k-1)(k-2).

I(k) = I(k-1) + 2(k-1)

= (k-1)(k-2) + 2(k-1)

= k2 – 3k + 2 + 2k – 2

= k2 – k

= k(k-1)

This completes our induction proof. QED23

Page 24: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Outline

• Prereqs and Learning Goals• Induction as a Formal Argument Form• Problems and Discussion

– Introductions– Odd Numbers– Horse Colours– CS Induction: Duplicate Detection, Binary

Search, MergeSort– More examples

• Next Lecture Notes

24

Page 25: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Historical Problem: Sum of Odd Numbers

Problem: What is the sum of the first n odd numbers?

First, find the pattern. Then, prove it’s correct.

The first 1 odd number?

The first 2 odd numbers?

The first 3 odd numbers?

The first n odd numbers?Historical note: Francesco Maurolico made the first

recorded use of induction in 1575 to prove this theorem!25

Page 26: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Sum of Odd Numbers:Insight

Problem: Prove that the sum of the first n odd numbers is n2.

How can we break the sum of the first, second, …, nth odd number up in terms of a simpler sum of odd numbers?

26

Page 27: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Sum of Odd Numbers:Insight

Problem: Prove that the sum of the first n odd numbers is n2.

The sum of the first n odd numbers is the sum of the first n-1 odd numbers plus the nth odd number.

27

Page 28: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Historical Problem: Sum of Odd Numbers

Now, how do we prove it? We need...

Property: For all positive integers n... ?

Base Case: Establish for n=?

Inductive Hypothesis: Assume... ?

Inductive Step: To prove... ?

28

Page 29: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Historical Problem: Sum of Odd Numbers

Property:

For all positive integers n, the sum of the first n odd natural numbers is n2.

Basis Case: Establish for n=?

Inductive Hypothesis: Assume... ?

Inductive Step: To prove... ?

29

Page 30: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Historical Problem: Sum of Odd Numbers

Theorem: For all positive integers n, the sum of the first n odd natural numbers is n2.

Base Case:

Establish for n=1. The sum of the “first 1 odd natural numbers” is 1, which equals 12.

Inductive Hypothesis: Assume... ?Inductive Step: To prove... ?

30

Page 31: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Historical Problem: Sum of Odd Numbers

Theorem: For all positive integers n, the sum of the first n odd natural numbers is n2.

Base Case for n = 1

Inductive Hypothesis: For some arbitrary k > 1, assume the sum of the first k-1 odd natural numbers is (k-1)2

Inductive Step: To prove... ?

31

Page 32: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Historical Problem: Sum of Odd Numbers

32

(by the IH)

Page 33: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Outline

• Prereqs and Learning Goals• Induction as a Formal Argument Form• Problems and Discussion

– Introductions– Odd Numbers– Horse Colours– CS Induction: Duplicate Detection, Binary

Search, MergeSort– More examples

• Next Lecture Notes

33

Page 34: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Proof Critique

Theorem: All horses are the same colour.

See handout.

Problem: Critique the proof.

34

Page 35: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Proof Critique

Theorem: All horses are the same colour.See handout.

Proof critique: Is the proof valid? a.Yes, because each step follows irrefutably

from the previous steps.b.Yes, because the premises are false.c.Yes, but not for the reasons listed here.d.No, because the conclusion is false.e.No, but not for the reasons listed here.

35

Page 36: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Proof Critique

Theorem: All horses are the same colour.See handout.

Proof critique: Where is the error in the proof? a.The base case.b.The inductive hypothesis.c.The inductive step.d.None of these, but there must be an error.e.None of these, and there may be no error.

36

Page 37: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Proof Critique

Theorem: All horses are the same colour.

See handout.

Proof critique: Can the proof be fixed?

37

Page 38: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Outline

• Prereqs and Learning Goals• Induction as a Formal Argument Form• Problems and Discussion

– Introductions– Odd Numbers– Horse Colours– CS Induction: Duplicate Detection, Binary

Search, MergeSort– More examples

• Next Lecture Notes

38

Page 39: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Induction and Computer Science

How important is induction? Is it just for proving things about N?

Induction forms the basis of…– proofs of correctness and efficiency for many

algorithms: e.g., How long does it take to detect duplicates in a list of n inputs? Does binary search work?

– “recursive” algorithms: e.g., “merge sort”– “recursive data structures”: e.g., How big can a “tree” of

height n be?39

Page 40: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Detecting Duplicates

Problem: How long does it take to detect duplicates in a list of n Inputs?

Let’s assume the amount of “time” taken is proportional to the number of comparisons we make between numbers.

We could compare each element to each other element and see if they’re the same.

Sound familiar? We already know how long this takes!

Note: this isn’t the fastest algorithm!40

Page 41: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Binary Search Works

Problem: Prove that binary search works.

Binary search is when we search a sorted list by checking the middle element.

If it’s what we’re looking for, we’re done.

Otherwise, we “throw out” the part of the list we don’t need (e.g., the left half if the element we looked at was too small) and start over on what remains.

41

Page 42: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Sorting by “Merging”

Problem: sort a list of names.

Algorithm:1. If the list is of length 1, it’s sorted.

2. Otherwise:a) Divide the list in half (or as close as possible).

b) Sort each half using this algorithm.

c) Merge the sorted lists back together.

42

Page 43: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

The Merge Step

Problem: given two lists of names in sorted order, merge them into a single sorted list.

Merge(a,b):1. If a is empty, return b2. If b is empty, return a3. Otherwise, if the first element of b comes before the

first element of a, return a list with the first element of b at the front and the result of Merge(a, rest of b) as the rest

4. Otherwise, return a list with the first element of a at the front and the result of Merge(rest of a, b) as the rest.

43

Familiar?

Page 44: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Prove Merge works

44

Page 45: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Outline

• Prereqs and Learning Goals• Induction as a Formal Argument Form• Problems and Discussion

– Introductions– Odd Numbers– Horse Colours– CS Induction: Duplicate Detection, Binary

Search, MergeSort– More examples

• Next Lecture Notes

45

Page 46: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem:Prove that 2n < n!

Problem: prove that 2n < n!?

Note: is 2n < n!?46

Page 47: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Outline

• Prereqs and Learning Goals• Induction as a Formal Argument Form• Problems and Discussion

– Introductions– Odd Numbers– Horse Colours– CS Induction: Duplicate Detection, Binary

Search, MergeSort– More examples

• Next Lecture Notes

47

Page 48: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Learning Goals: In-Class

By the end of this unit, you should be able to:– Formally prove properties of the non-negative

integers (or a subset like integers larger than 3) that have appropriate self-referential structure—including both equalities and inequalities—using either weak or strong induction as needed.

– Critique formal inductive proofs to determine whether they are valid and where the error(s) lie if they are invalid.

48

Page 49: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

snick

snack

Extra Slides

49

Page 50: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem: Proof Critique

Theorem: All integers ≥ 2 are even.

Problem: Critique the proof. Is it valid? If not, why not? Can it be fixed, and how?

50

Page 51: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Problem:Sum of a Geometric Series

Problem: What is the sum of the first n terms of the form ai, if a is a real number between 0 and 1? (Note: we mean terms 0 through n.)

Note: we’re looking for

Can we use induction over the real numbers between 0 and 1?

1

11

a

an

51

Page 52: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Induction: a Domino Effect

A proof by induction is like toppling a chain of dominoes.

Let’s say I tell you:– the first domino in the chain toppled– for every domino in the chain, if the domino

before it toppled, then the domino itself toppled

Did all the dominoes in the chain topple?

52

Page 53: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Formal (Weak) Induction

A formal induction proof follows the same pattern. To prove some property P(.) applies to all positive integers n, we prove:

The first domino topples.

If one domino topples…

Then the next one topples.

P(0) is true.

[For arbitrary k] If P(k) is true...

Then P(k+1) is also true.

Typically, we prove the second step by antecedent assumption/direct proof.

53

Page 54: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Form of an Induction Proof

Theorem: some property that depends on n

Basis step: show that a small case works

Inductive Hypothesis: Assume your property holds for n=k where k ≥ your basis step.

Inductive Step: Under this assumption, you need to prove that your property holds for n=k+1.

54

Page 55: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Side Note: Practical Induction

That’s how you formally write out the proof, but how do you figure out the proof?

Start at the inductive step!

55

Page 56: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Side Note: Practical Induction

Look at a “big” problem (of size n).

Figure out how to break it down into smaller pieces.

Assume those smaller pieces work. That will end up as your inductive hypothesis.

Figure out which problems cannot be broken down (usually small ones!). Those will end up as your basis step(s).

56

Page 57: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Proof

Base case: A group of size 1 takes 0 intros. (Because there are no pairs.)

Note: we talked about induction to prove properties for the non-negative integers, but it can be more general.57

Page 58: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Proof (Continued)

Inductive step, to prove: If a group of size k-1 takes (k-1)((k-1)-1) intros, then a group of size k takes k(k-1) intros.

Assume size (k-1) takes (k-1)((k-1)-1) or (k-1)(k-2) intros (the Inductive Hypothesis)

...

58

Page 59: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Proof (Continued)

Inductive step, continued: A group of size k, where k > 0, is a group of size k-1 plus one person. Imagine size k-1 group has completed introductions. That took (k-1)(k-2) intros by the IH. Add one more person to the group, and that person must greet all k-1 other people, for a total of (k-1)(k-2) + 2(k-1) introductions.

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

QED: if k-1 takes (k-1)(k-2), k takes k(k-1).

59

Page 60: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Proof (Completed)

Base case: A group of size 1 takes 0 intros. (See proof above.)

Inductive step: If a group of size k-1 takes (k-1)(k-2) intros, then a group of size k takes k(k-1) intros. (See proof above.)

QED.

From these two we could (but don’t have to) crank out a proof for any n that a group of size n requires n(n-1) introductions.

60

Page 61: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Form of a Strong Induction Proof

Theorem: some property that depends on n

Basis step: show that one or more small cases (as needed) work

Inductive Hypothesis: Assume your property holds for any n = i where your basis step ≤ i < k and k is an integer > your basis step.

Inductive Step: Under this assumption, you need to prove that your property holds for n = k.

Hint: there’s really no difference. Just assume what you need in order to break the problem into smaller pieces.

61

Page 62: Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Revisiting Induction Steve Wolfman, based on work by Patrice Belleville and others 1.

Side Note: “Strong Induction”

We’ve used weak induction: basis step (n = a) plus “if it works for n then it works for n+1”.

In strong induction, we use: basis step plus “if it works for all a i < k then it works for k”.

Can we still build our individual proofs (for n = 1, n = 2, n = 3, ...) from that?

62