induction and recursion
play

Induction and Recursion CMPS/MATH 2170: Discrete Mathematics - PowerPoint PPT Presentation

Induction and Recursion CMPS/MATH 2170: Discrete Mathematics Outline Mathematical induction (5.1) Strong induction (5.2) Recursive definitions (5.3) Recurrence Relations (8.1) Principle of Mathematical Induction Want to know


  1. Induction and Recursion CMPS/MATH 2170: Discrete Mathematics

  2. Outline • Mathematical induction (5.1) • Strong induction (5.2) • Recursive definitions (5.3) • Recurrence Relations (8.1)

  3. Principle of Mathematical Induction • Want to know if we can reach every step on a infinite ladder • Suppose we know two things • We can reach the first rung of the ladder • If we can reach a particular rung of the ladder, then we can reach the next rung • Can we conclude that we can reach every rung?

  4. Mathematical Induction • Want to show: ∀𝑜 ∈ ℤ % : 𝑄 𝑜 Proof by induction on 𝑜 • Base case: verify that 𝑄(1) is true • Inductive step: show that 𝑄 𝑙 → 𝑄 𝑙 + 1 for any 𝑙 ∈ ℤ % Inductive hypothesis: Assume 𝑄(𝑙) is true Want to prove 𝑄 𝑙 + 1 is true

  5. Examples of Mathematical Induction Ex.1: Sums of Arithmetic Progressions 1 = 𝑜(𝑜 + 1) ∀𝑜 ∈ ℤ % : / 𝑗 2 234 Ex.2: Sums of Geometric Progressions 1 = 𝑑 1%4 − 1 ∀𝑜 ∈ ℕ: / 𝑑 2 where 𝑑 ≠ 1 𝑑 − 1 239

  6. More about Mathematical Induction 𝑄(1) • Why Mathematical Induction is valid? ∀𝑙 ∈ ℤ % : 𝑄 𝑙 → 𝑄 𝑙 + 1 • Implied by the Weak Ordering Property: ∀𝑜 ∈ ℤ % : 𝑄 𝑜 ∴ “Every nonempty subset of ℤ % has a least element” • Pros • Can be used to prove a wide variety of “forall” conjectures • Easy to follow • Cons • Cannot be used to find new theorems • Lack of insight

  7. More Examples Ex. 3: Prove 𝑜 = < 2 1 for all integers 𝑜 > 4 Ex. 4: Prove that a finite set with 𝑜 elements has 2 1 subsets Ex. 5: Prove that every amount of postage of 12 cents or more can be formed using just 4-cent and 5-cent stamps.

  8. Mathematical Induction • Want to prove 𝑄 𝑜 is true for 𝑜 = 𝑐, 𝑐 + 1, 𝑐 + 2, … , where 𝑐 ∈ ℤ Proof by induction on 𝑜 : • Base case: verify that 𝑄(𝑐) is true • Inductive step: show that 𝑄 𝑙 → 𝑄 𝑙 + 1 for any 𝑙 = 𝑐, 𝑐 + 1, 𝑐 + 2, …

  9. Outline • Mathematical induction (5.1) • Strong induction (5.2) • Recursive definitions (5.3) • Recurrence Relations (8.1)

  10. Strong Induction • Want to prove: ∀𝑜 ∈ ℤ % : 𝑄 𝑜 Proof by (weak) induction on 𝑜 : • Base case: verify that 𝑄(1) is true • Inductive step: show that 𝑄 𝑙 → 𝑄 𝑙 + 1 for any 𝑙 ∈ ℤ % Proof by strong induction on 𝑜 : • Base case: verify that 𝑄(1) is true • Inductive step: show that [𝑄 1 ∧ 𝑄 2 ∧ … ∧ 𝑄 𝑙 ] → 𝑄 𝑙 + 1 for any 𝑙 ∈ ℤ %

  11. Strong Induction • A more general form of strong induction • Base step: verify that 𝑄 𝑐 , 𝑄 𝑐 + 1 , … 𝑄(𝑐 + 𝑘) are true • Inductive step: Assume [𝑄 𝑐 ∧ 𝑄 𝑐 + 1 ∧ … ∧ 𝑄 𝑙 ] is true, prove 𝑄 𝑙 + 1 is true for every integer 𝑙 ≥ 𝑐 + 𝑘

  12. � Examples of Strong Induction Fibonacci Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, … 𝑔 9 = 0, 𝑔 4 = 1, Initial conditions 𝑔 1 = 𝑔 1K4 + 𝑔 1K= , 𝑜 ≥ 2 Recurrence relation This is called a recursive definition 1 ≤ 2 1 for all 𝑜 ≥ 0 Ex.1: 𝑔 1 > 𝛽 1K= for any 𝑜 ≥ 3 where 𝛽 = (1 + Ex. 2: 𝑔 5 )/2 wikipedia

  13. Outline • Mathematical induction (5.1) • Strong induction (5.2) • Recursive definitions (5.3) • Recurrence Relations (8.1)

  14. Recursively Defined Sequences • Fibonacci Sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, … 𝑔 9 = 0, 𝑔 4 = 1, Initial conditions 𝑔 1 = 𝑔 1K4 + 𝑔 1K= , 𝑜 ≥ 2 Recurrence relation • A sequence of powers of 2: 1, 2, 4, 8, 16, 32 … An explicit formula: 𝑏 1 = 2 1 , 𝑜 ≥ 0 A recursive definition: Initial condition 𝑏 9 = 2 9 , 𝑏 1 = 2𝑏 1K4 , 𝑜 ≥ 1 Recurrence relation

  15. Recursively Defined Functions • A recursive definition of 𝑔: ℕ → 𝐵 , ℕ = {0,1,2, 3 … } • Base step: specify 𝑔 0 • Recursive step: s pecify 𝑔 𝑜 in terms of 𝑔 0 , 𝑔 1 , … , 𝑔(𝑜 − 1) , for any 𝑜 ≥ 1 • Ex.1: Give a recursive definition of 𝑔 𝑜 = 𝑜! 1 • Ex.2: Give a recursive definition of 𝑔 𝑜 = ∑ 𝑏 2 , where 𝑏 2 2∈ℕ is a given 239 sequence

  16. Recursively Defined Sets • Consider a set 𝑇 ⊆ ℤ % recursively defined by • Base step: 3 ∈ 𝑇 • Recursive step: if 𝑦 ∈ 𝑇 and 𝑧 ∈ 𝑇, then 𝑦 + 𝑧 ∈ 𝑇 • Show that the set 𝑇 is the set of all positive integers divided by 3 • 𝐵 = 𝑜 ∈ ℤ % : 3 𝑜 • 𝐵 ⊆ 𝑇 : prove by mathematical induction • 𝑇 ⊆ 𝐵 : prove by structural induction

  17. Structural induction • Want to prove a result for a recursively defined set • Base step: show that the result holds for all base cases in the recursive definition • Inductive step: show that if the statement is true for each of the elements used to construct new elements in the recursive step, the result holds for the new elements

  18. Outline • Mathematical induction (5.1) • Strong induction (5.2) • Recursive definitions (5.3) • Recurrence Relations (8.1)

  19. The Tower of Hanoi Task: Move the stack of disks from peg 1 to peg 3 subject to the following rules: • Move one disk at a time • Only the uppermost disk on a stack can be moved • No disk can be placed on top of a smaller disk Question: how many steps are needed?

  20. The Tower of Hanoi By André Karwath aka Aka - Own work, CC BY-SA 2.5, https://commons.wikimedia.org/w/index.php?curid=85401

  21. The Tower of Hanoi 𝐼 1K4 𝑜 − 1 disks • 𝐼 1 - number of moves needed to solve the 1 move Tower of Hanoi with 𝑜 disks • Divide & Conquer 𝐼 4 = 1 𝐼 1 = 2𝐼 1K4 + 1, 𝑜 ≥ 2 𝐼 1K4 Recurrence relation • How to find an explicit formula for 𝐼 1 ? • Expand the recurrence iteratively and then make a conjecture: 𝐼 1 = 2 1 − 1 • 2 64 − 1 seconds ≈ 585 billion years • Proof by mathematical induction

Recommend


More recommend