lecture induction2 6up

Post on 02-Oct-2015

4 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

NM MBBHDFBFV DBDS

TRANSCRIPT

  • CS311H: Discrete Mathematics

    Mathematical Induction

    Isl Dillig

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 1/26

    Announcements

    I Homework 5 out today

    I Due next Thursday (Oct 30)

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 2/26

    Review: Strong Induction

    I Base case same as regular induction, different in inductive step

    I Regular induction: assume P(k) holds and prove P(k + 1)

    I Strong induction: assume P(1),P(2), ..,P(k); prove P(k + 1)

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 3/26

    Example

    I Prove that every integer n 12 can be written asn = 4a + 5b for some non-negative integers a, b.

    I Proof by strong induction on n and consider 4 base cases

    I Base case 1 (n=12): 12 = 3 4 + 0 5

    I Base case 2 (n=13): 13 = 2 4 + 1 5

    I Base case 3 (n=14): 14 = 1 4 + 2 5

    I Base case 4 (n=15): 15 = 0 4 + 3 5

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 4/26

    Example, cont.

    Prove that every integer n 12 can be written as n = 4a + 5b forsome non-negative integers a, b.

    I Inductive hypothesis: Suppose every 12 i k can bewritten as i = 4a + 5b.

    I Inductive step: We want to show k + 1 can also be writtenthis way for k + 1 16

    I Observe: k + 1 = (k 3) + 4

    I By the inductive hypothesis, k 3 = 4a + 5b for some a, bbecause k 3 12

    I But then, k + 1 can be written as 4(a + 1) + 5b

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 5/26

    Matchstick Example

    I The Matchstick game: There are two piles with same numberof matches initially

    I Two players take turns removing any positive number ofmatches from one of the two piles

    I Player who removes the last match wins the game

    I Prove: Second player always has a winning strategy.

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 6/26

    1

  • Matchstick Proof

    I P(n): Player 2 has winning strategy if initially n matches ineach pile

    I Base case:

    I Induction: Assume j .1 j k P(j ); show P(k + 1)

    I Inductive hypothesis:

    I Prove Player 2 wins if each pile contains k + 1 matches

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 7/26

    Matchstick Proof, cont.

    I Case 1: Player 1 takes k + 1 matches from one of the piles.

    I What is winning strategy for player 2

    I Case 2: Player 1 takes r matches from one pile, where1 r k

    I Now, player 2 takes r matches from other pile

    I Now, the inductive hypothesis applies player 2 has winningstrategy for rest of the game

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 8/26

    The Horse Paradox

    I Easy to make subtle errors when trying to prove things byinduction pay attention to details!

    I Consider the statement: All horses have the same color

    I What is wrong with the following bogus proof of thisstatement?

    I P(n) : A collection of n horses have the same color

    I Base case: P(1) X

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 9/26

    Bogus Proof, cont.

    I Induction: Assume P(k); prove P(k + 1)

    I Consider a collection of k + 1 horses: h1, h2, . . . , hk+1

    I By IH, h1, h2, . . . , hk have the same color; let this color be c

    I By IH, h2, . . . , hk+1 have same color; call this color c

    I Since h2 has color c and c, we have c = c

    I Thus, h1, h2, . . . , hk+1 also have same color

    I Whats the fallacy?

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 10/26

    Recursive Definitions

    I Should be familiar with recursive functions from programming:

    public int fact(int n) {

    if(n

  • Recursively Defined Functions

    I Just like sequences, functions can also be defined recursively

    I Example:

    f (0) = 3f (n + 1) = 2f (n) + 3 (n 1)

    I What is f (1)?

    I What is f (2)?

    I What is f (3)?

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 13/26

    Recursive Definition Examples

    I Consider f (n) = 2n + 1 where n is non-negative integer

    I Whats a recursive definition for f ?

    I Consider the sequence 1, 4, 9, 16, . . .

    I What is a recursive definition for this sequence?

    I Recursive definition of function defined as f (n) =n

    i=1i?

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 14/26

    Recursive Definitions of Important Functions

    I Some important functions/sequences defined recursively

    I Factorial function:

    f (1) = 1f (n) = n f (n 1) (n 2)

    I Fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21, . . .

    a1 = 1a2 = 1an = an1 + an2 (n 3)

    I Just like there can be multiple bases cases in inductive proofs,there can be multiple base cases in recursive definitions

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 15/26

    Inductive Proofs for Recursively Defined Structures

    I Recursive definitions and inductive proofs are very similar

    I Natural to use induction to prove properties about recursivelydefined structures (sequences, functions etc.)

    I Consider the recursive definition:

    f (0) = 1f (n) = f (n 1) + 2

    I Prove that f (n) = 2n + 1

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 16/26

    Example

    I Let fn denote the nth element of the Fibonacci sequence

    I Prove: For n 3, fn > n2 where = 1+5

    2

    I Proof is by strong induction on n with two base cases

    I Intuition 1: Definition of fn has two base cases

    I Intuition 2: Recursive step uses fn1, fn2 strong induction

    I Base case 1 (n=3): f3 = 2, and < 2, thus f3 >

    I Base case 2 (n=4): f4 = 3 and 2 =(3+5)

    2 < 3

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 17/26

    Example, cont.

    Prove: For n 3, fn > n2 where = 1+5

    2

    I Inductive step: Assuming property holds for fi where3 i k , need to show fk+1 > k1

    I First, rewrite k1 as 2k3

    I 2 is equal to 1 + because:

    2 =

    (1 +

    5

    2

    )2=

    5 + 3

    2= + 1

    I Thus, k1 = (+ 1)(k3) = k2 + k3

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 18/26

    3

  • Example, cont.

    I k1 = k2 + k3

    I By recursive definition, we know fk+1 = fk + fk1

    I Furthermore, by inductive hypothesis:

    fk > k2 fk1 > k3

    I Therefore, fk+1 > k2 + k3 = k1

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 19/26

    Recursively Defined Sets and Structures

    I We saw how to define functions and sequences recursively

    I We can also define sets and other data structures recursively

    I Example: Consider the set S defined as:

    3 SIf x S and y S , then x + y S

    I What is the set S defined as above?

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 20/26

    More Examples

    I Give a recursive definition of the set E of all even integers:

    I Base case:

    I Recursive step:

    I Give a recursive definition of N, the set of all natural numbers:

    I Base case:

    I Recursive step:

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 21/26

    Strings and Alphabets

    I Recursive definitions play important role in study of strings

    I Strings are defined over an alphabet

    I Example: 1 = {a, b}

    I Example: 2 = {0}

    I Examples of strings over 1: a, b, aa, ab, ba, bb, . . .

    I Set of all strings formed from forms language called

    I 2 = {, 0, 00, 000, . . .}

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 22/26

    Recursive Definition of Strings

    I The language has natural recursive definition:

    I Base case: (empty string)

    I Recursive step: If w and x , then wx

    I Since is the empty string, s = s

    I Consider the alphabet = {0, 1}

    I How is the string 1 formed according to this definition?

    I How is 10 formed?

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 23/26

    Recursive Definitions of String Operations

    I Many operations on strings can be defined recursively.

    I Consider function l(w) which yields length of string w

    I Example: Give recursive definition of l(w)

    I Base case:

    I Recursive step:

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 24/26

    4

  • Another Example

    I The reverse of a string s is s written backwards.

    I Example: Reverse of abc is bca

    I Give a recursive definition of the reverse(s) operation

    I Base case:

    I Recursive step:

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 25/26

    Palindromes

    I A palindrome is a string that reads the same forwards andbackwards

    I Examples: mom, dad, abba, Madam Im Adam, . . .

    I Give a recursive definition of the set P of all palindromes overthe alphabet = {a, b}

    I Base cases:

    I Recursive step:

    Isl Dillig, CS311H: Discrete Mathematics Mathematical Induction 26/26

    5

top related