cpsc 121 models of computation
play

CPSC 121: Models of Computation Module 9: Proof Techniques (part 2) - PowerPoint PPT Presentation

CPSC 121: Models of Computation Module 9: Proof Techniques (part 2) Mathematical Induction Module 9: Announcements Assignment #5 is due Wednesday November 28 th at 19:00. Pre-class quiz #10 is tentatively due on Wednesday November 21 st at


  1. CPSC 121: Models of Computation Module 9: Proof Techniques (part 2) Mathematical Induction

  2. Module 9: Announcements Assignment #5 is due Wednesday November 28 th at 19:00. Pre-class quiz #10 is tentatively due on Wednesday November 21 st at 19:00. Textbook sections: Epp, 4th edition: 6.1, 7.1 Epp, 3rd edition: 5.1, 6.1 Rosen, 6th edition: 2.1, 2.3 up to the top of page 136. Rosen, 7th edition: 2.1, 2.3 down to the bottom of page 141. CPSC 121 – 2018W T1 2

  3. Module 9: Mathematical Induction By the start of class, you should be able to Convert sequences to and from explicit formulas that describe the sequence. Convert sums to and from summation/Σ notation. Convert products to and from product/π notation. Manipulate formulas in summation/product notation by adjusting their bounds, merging or splitting summations/products, and factoring out values. CPSC 121 – 2018W T1 3

  4. Module 9: Mathematical Induction Pre-class quiz #9 Well done overall. You had a bit more trouble (77% avg) on the questions about the coin-changing induction proof. We will discuss induction proofs at length and do a lot of examples. Being comfortable with summations is important not only for CPSC 121, but for following courses too! As usual, we will revisit the open-ended question shortly. CPSC 121 – 2018W T1 4

  5. Module 9: Mathematical Induction If you haven’t already done so, read the rest of the chapters on mathematical induction (Epp4, 5.2 to 5.4, etc). After this reading, you will be able to: Given a theorem to prove stated in terms of its induction variable (i.e., usually, in terms of n), 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. CPSC 121 – 2018W T1 5

  6. Module 9: Mathematical Induction By the end of this module, you should be able to: Establish properties of self-referential structures using inductive proofs that naturally build on those self-references. Critique formal inductive proofs to determine whether they are valid and where the error(s) lie if they are invalid. Prove properties of the non-negative integers (or a subset) with appropriate self-referential structure using weak or strong induction as needed. CPSC 121 – 2018W T1 6

  7. Module 9: Mathematical Induction CPSC 121: the BIG questions: ? ? ? 1. How can we convince ourselves that an algorithm ? ? does what it's supposed to do? 2. How do we determine whether or not one algorithm ? ? is better than another one? ? ? ? Mathematical induction is a very very useful tool when proving the correctness or efficiency of an ? algorithm. ? ? ? We will see several examples of this. ? ? ? CPSC 121 – 2018W T1 7

  8. Module 9: Mathematical Induction Module Summary Example: single-elimination tournaments. Defining and validating mathematical induction. More examples where we can use induction. A slightly different type of induction. CPSC 121 – 2018W T1 8

  9. Module 9.1: Single-elimination tournaments Problem: single-elimination tournament Teams play one another in pairs The winner of each pair advances to the next round Los Angeles Vancouver Toronto St. Louis Pittsburgh New York Isl. Montréal Buffalo Round 2 CPSC 121 – 2018W T1 9

  10. Module 9.1: Single-elimination tournaments Question: if we have n rounds of playoffs, how many teams can participate? a) n b) 2n c) n 2 d) 2 n e) None of the above. ▷ CPSC 121 – 2018W T1 10

  11. Module 9.1: Single-elimination tournaments How can we prove this result formally? We will use a technique called mathematical induction. We will convince ourselves that it is a valid proof technique. Many theorems involve summations, so it is important to be comfortable manipulating them. Hence the reading for pre-class quiz #9. CPSC 121 – 2018W T1 12

  12. Module 9.1: Single-elimination tournaments First we look at the following question instead: If t teams can participate in a playoff with n rounds, how many teams can participate in a playoff with n+1 rounds? a) t+1 b) 2t c) t 2 d) 2 t e) None of the above. ▷ CPSC 121 – 2018W T1 13

  13. Module 9.1: Single-elimination tournaments Proof (with holes): Consider an unspecified playoff with n rounds. Assume that We can think of a playoff with n+1 rounds as follows: Two playoffs with n rounds proceed in parallel. The two winners then Since each playoff with n rounds has CPSC 121 – 2018W T1 15

  14. Module 9.1: Single-elimination tournaments How do we use this to prove what we want? Recall Universal Modus Ponens: P(a) ∀ x ∈ D, P(x) → Q(x) \ Q(a) If we define P(t, n): Up to t teams can participate in a playoff with n rounds then we have proved + n + , P(t, n)→P(2t, n+1) ∀ t ∈ Z ∀ ∈ Z CPSC 121 – 2018W T1 16

  15. Module 9.1: Single-elimination tournaments So We know that only 2 teams can play with 1 round. This is P(2, 1). Given P(2, 1) + n + , P(t, n) → P(2t, n+1) ∀ t ∈ ∀ ∈ Z Z We can deduce: P(4, 2) CPSC 121 – 2018W T1 17

  16. Module 9.1: Single-elimination tournaments Given P(4, 2) ∀ t ∈ + n ∀ ∈ + , P(t, n) → P(2t, n+1) Z Z We can deduce: P(8, 3) Given P(8, 3) ∀ t ∈ + n ∀ ∈ + , P(t, n) → P(2t, n+1) Z Z We can deduce: P(16, 4) CPSC 121 – 2018W T1 18

  17. Module 9.1: Single-elimination tournaments Given P(16, 4) ∀ t ∈ + n ∀ ∈ + , P(t, n) → P(2t, n+1) Z Z We can deduce: P(32, 5) Etc... Therefore we can show that ∀ n ∈ + , P(2 n , n) Z CPSC 121 – 2018W T1 19

  18. Module 9.1: Single-elimination tournaments Another way to think about this: Given an unspecified positive integer n. To prove P(2 n+1 , n+1): First we prove P(2 n , n). Then we use the fact that ∀ t ∈ + n ∀ ∈ + , P(t, n) → P(2t, n+1) Z Z Hence induction is more or less the same as recursion! A fun example involving induction: http://www.youtube.com/watch?v=daRS98L9rHs&feature=related CPSC 121 – 2018W T1 20

  19. Module 9: Mathematical Induction Module Summary Example: single-elimination tournaments. Defining and validating mathematical induction. More examples where we can use induction. A slightly different type of induction. CPSC 121 – 2018W T1 21

  20. Module 9.2: Defining and validating M.I. Define Q(n) by: Q(n): P(2 n ,n) In the previous example, we proved Q(1) + , Q(n) → Q(n+1) ∀ n ∈ Z and deduced that ∀ n ∈ + , Q(n) Z Why is this a valid proof technique? CPSC 121 – 2018W T1 22

  21. Module 9.2: Defining and validating M.I. Theorem: + , Q(n) → Q(n+1)) → n + , Q(n) Q(1) ^ ( n ∀ ∈ Z ∀ ∈ Z Proof: We use a proof by contradiction. + , ∀ ∈ Suppose that the premises hold, but that n Z Q(n) is false. There is at least one value of n for which Q(n) does not hold. Let y be the smallest such value. Clearly y > 1, so ∈ + . y – 1 Z CPSC 121 – 2018W T1 23

  22. Module 9.2: Defining and validating M.I. Proof (continued): Because y is the smallest value for which Q(n) is + , Q(y - 1) is true. ∈ false, and y – 1 Z But then the 2 nd premise implies that Q(y) is true, a contradiction (since we assumed Q(y) was false). ∀ ∈ Therefore the conclusion must be true, that is n Z + , Q(n) holds. CPSC 121 – 2018W T1 24

  23. Module 9.2: Defining and validating M.I. So a proof by mathematical induction has One (or more) base case(s): Q(1) Usually very straightforward to prove. An induction step: ∀ n ∈ + , Q(n) → Q(n+1) OR n ∀ ∈ + , Q(n-1) → Q(n) Z Z We can use any proof technique we know for it. Usually a direct proof will work well. CPSC 121 – 2018W T1 25

  24. Module 9.2: Defining and validating M.I. How do we decide which base cases we need? Look at the induction step. Decide for which values of n it can be used to prove Q(n). The induction step might not be usable for some n: because it needs Q(some x < n) and x would be smaller than smallest n for which Q holds. because some mathematical steps only work for large enough values of n. If the induction step is not usable for n, then n needs to be a base case! CPSC 121 – 2018W T1 26

  25. Module 9: Mathematical Induction Module Summary Example: single-elimination tournaments. Defining and validating mathematical induction. More examples where we can use induction. A slightly different type of induction. CPSC 121 – 2018W T1 27

  26. Module 9.3: More induction examples Example 1: recall the exercises from our first class: Make group of 5 students. Then order each group from in order of day of birth by swapping pairs of adjacent students. We claimed the maximum number of swaps for n students is n(n-1)/2. CPSC 121 – 2018W T1 28

  27. Module 9.3: More induction examples How many swaps do we need? Suppose we place students from left to right. The students already placed are ordered by day of birth. We swap each new student with his/her neighbour until he/she is at the right place. The i th student may be swapped with all previous i-1 students. n − 1 So the total number of swaps is at most ∑ i i = 0 n − 1 i = n ( n − 1 ) Hence we need to prove that ∑ 2 i = 0 CPSC 121 – 2018W T1 29

Recommend


More recommend