0% found this document useful (0 votes)
78 views16 pages

Lecture 7 - Induction-And-Recursion PDF

1. Mathematical induction and recursion are techniques for proving statements about positive integers or recursively defining functions. 2. Mathematical induction involves two steps: a basis step to verify the statement is true for n=1, and an inductive step to assume the statement is true for n=k and prove it is true for n=k+1. 3. Recursion defines a function using a basis case and recursive rule relating the function value to prior values. Recursive definitions and structural induction are useful for proving properties of recursively defined objects.

Uploaded by

Migi Alucrad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views16 pages

Lecture 7 - Induction-And-Recursion PDF

1. Mathematical induction and recursion are techniques for proving statements about positive integers or recursively defining functions. 2. Mathematical induction involves two steps: a basis step to verify the statement is true for n=1, and an inductive step to assume the statement is true for n=k and prove it is true for n=k+1. 3. Recursion defines a function using a basis case and recursive rule relating the function value to prior values. Recursive definitions and structural induction are useful for proving properties of recursively defined objects.

Uploaded by

Migi Alucrad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

INDUCTION AND

RECURSION
Lecture 7 - Ch. 4
4. Introduction
2

 Any mathematical statements assert that a property is


true for all positive integers
 Examples: for every positive integer n:
 n! <= nn
 n3 -n is divisible by 3
a set with n elements has 2n subsets
𝑛(𝑛 + 1 )
 the sum of the first n positive integers is
2
This chapter goal is to understand the mathematical induction,
and how it is used to prove results of this kind
4.1 Mathematical Induction
3

 Mathematical Induction is used to show


that P(n) is true for every positive integer
n.
 Example:
Suppose we have an infinite ladder, and
we want to know whether we can reach
every step on the ladder. We know two
things
1. We can reach the first rung of the
ladder.
2. If we can reach a particular rung of the
ladder, then we can reach the next rung.
4.1 Mathematical Induction
4

PRINCIPLE OF MATHEMATICAL INDUCTION


To prove that P(n) is true for all positive integers n, where P(n) is a
propositional function, we complete two steps.
1. BASIS STEP: We verify that P(1) is true.
2. INDUCTIVE STEP: We show that the conditional statement P(k) →P(k+1) is
true for all positive integers k.
 The assumption that P(k) is true is called the inductive hypothesis.
 To complete the inductive step of a proof using the principle of mathematical
induction, we assume that P(k) is true for an arbitrary positive integer k and
show that under this assumption, P(k+1) must also be true.

The proof technique is stated as [P(1)Λ (∀ k(P(k) →P(k+1) )] → ∀ n P(n)


where the domain is the set of positive integers
4.1 Mathematical Induction
Example 1
5

n(n  1)
Show that if n is a positive integer, then 1  2  ...  n 
Solution: 2
1(1  1)
BASIS STEP: because P(1)=1 (LHS), =1 (RHS). Thus, P(1) is true
INDUCTIVE STEP: 2
a) Assume P(k) is true for an arbitrary positive integer k. That is, we assume that
k (k  1)
P(k)= 1  2  ...  k 
2
b) Under assumption (a), it must be shown that P(k+1) is true, i.e.:
(k  1)[(k  1)  1] (k  1)(k  2)
P(k+1)= 1  2  ...  k  (k  1)  
2 2
c) Comparing LHS in (a) and (b), we add k+1 to both sides of the equation in P(k)
k (k  1) k (k  1)  2(k  1) (k  1)(k  2)
P(k)+k+1=1  2  ...  k  (k  1)   (k  1)  
=P(k+1) 2 2 2
This shows that P(k+1) is true under the assumption that P(k) is true. 5
4.1 Mathematical Induction
Example 2:
6

For all nonnegative integers n. Use mathematical induction to show that: 1 + 2 + 22


+· · ·+2n = 2n+1 − 1
Solution:
BASIS STEP: because P(0)= 20 = 1 (LHS), 21 − 1 =1 (RHS). Thus, P(1) is true
INDUCTIVE STEP:
a) Assume P(k) is true for an arbitrary positive integer k. That is, we assume that
P(k)= 1 + 2 + 22 +· · ·+2k = 2k+1 − 1

b) Under assumption (a), it must be shown that P(k+1) is true, i.e.:


P(k+1)=1 + 2 + 22 +· · ·+2k + 2k+1 = 2(k+1)+1 − 1 = 2k+2 − 1

c) Comparing LHS in (a) and (b), we add 2k+1 to both sides of the equation in P(k)
P(k)+ 2k+1 = 1 + 2 + 22 +· · ·+2k + 2k+1 = (2k+1 − 1) + 2k+1
= 2 · 2k+1 − 1 = 2k+2 − 1 =P(k+1)
This shows that P(k+1) is true under the assumption that P(k) is true.
4.2 Strong Induction
7

PRINCIPLE OF STRONG INDUCTION


To prove that P(n) is true for all positive integers n, where P(n) is a propositional
function, we complete two steps:
1. BASIS STEP : We verify that the proposition P(1) is true.
2. INDUCTIVE STEP: We show that the conditional statement
[P(1) /\ P(2) /\ . . . /\ P(k)]  P(k + 1) is true for all positive integers k.

Note:
When we use strong induction to prove that P (n) is true for all positive integers n ,
our inductive hypothesis is the assumption that P(j) is true for j = 1,2, ... , k. That
is, the inductive hypothesis includes all k statements P(1), P(2), ... , P(k). Because
we can use all k statements P(1), P(2), ... , P(k) to prove P(k + 1), rather than just
the statement P(k) as in a proof by mathematical induction, strong induction is a
more flexible proof technique.
4.2 Strong Induction
Example 1:
8

Show that if n is an integer greater than 1 , then n can be written as the


product of primes.
Solution:
BASIS STEP: because the first case is P(2)= 2 (prime#).Thus, P(2) is true
INDUCTIVE STEP:
a) The inductive hypothesis is the assumption that P(j) is true for all positive
integers 2 ≤ j ≤ k
b) We show that P(k+1) is true under assumption (a), that is, we must show
that k+1 is the product of primes. There are two cases to consider:
1. k+1 is prime  P (k+1) is true
2. k+1 is composite P (k+1)= a*b (2≤a≤b<k+1)
By the inductive hypothesis, both a and b can be written as the product of
primes. Thus, if k + 1 is composite, it can be written as the product of primes,
namely, those primes in the factorization of a and those in the factorization
of b.
4.2 Strong Induction
Example 2:
9

Use strong induction to show that if you can run one mile or two miles, and if you can always run
two more miles once you have run a specified number of miles, then you can run any number of
miles.
Solution:
BASIS STEP: because we are told we can run one mile, so P (1) is true

INDUCTIVE STEP:
a) The inductive hypothesis is the assumption that P(j) is true; which is we can run any number of
miles from 1 to k. [P(j) is true for all positive integers 1 ≤j ≤ k]
b) We show that P(k+1) is true under assumption (a), that is, we must show that we can run
k + 1 miles:
 If k = 1 , then we are already told that we can run two miles.
 If k > 1 , then the inductive hypothesis tells us that we can run k-1 miles, so we can run
(k-1) + 2 = k + 1 miles.
4.3 Recursive Definitions and Structural Induction
Introduction
10
4.3 Recursive Definitions and Structural Induction
11

 Sometimes it’s easier to define an object in terms of itself.


This process is called Recursion.
 Example:

The sequence of powers of 2: 1, 2, 4, 8, 16, 32, 64, 128, …


can be found by:
 Using the sequence given by the formula an = 2
n

for n = 0, 1, 2, …
 Or, using recursion:
1. Find first term of the sequence, namely, a0 = 1, then
2. find a term of the sequence from the previous one, namely,
an = 2an -1 , for n = 1, 2, ….
4.3 Recursive Definitions and Structural Induction
Recursively Defined Functions
12

 Use two steps to define a function with the set of nonnegative integers as its
domain:
BASIS STEP: Specify that value of the function at zero. (f(0))
RECURSIVE STEP: Give a rule for finding its value at an integer from its
values at smaller integers. (f(n)=g(n-1))
 Such a definition is called a recursive or inductive definition.
 Examples:
 Suppose that f is defined recursively by
f(0) = 3,
f(n) = 2f(n-1) + 3
Find f(1), f(2), f(3), and f(4).

Solution:
f(1) = 2f(0) + 3 = 2*3 + 3 = 9
f(2) = 2f(1) + 3 = 2*9 + 3 = 21
f(3) = 2f(2) + 3 = 2*21 + 3 = 45
f(4) = 2f(3) + 3 = 2*45 + 3 = 93
4.3 Recursive Definitions and Structural Induction
13

 Example1:
 Give an recursive definition of the factorial function f(n) = n! . Then find f(5)
Solution:
The recursive definition is:
 Basis Step: f(0) = 1
 Recursive Step: f(n) = (n)*f(n-1)

F(5) =5 F(4)
=5*4F(3)
=5*4*3 F(2)
=5 * 4 * 3 * 2F(1)
=5 * 4 * 3 * 2 * 1F(0)
=5*4*3*2*1*1
= 120
4.3 Recursive Definitions and Structural Induction
14

 Example2: n
 Give a recursive definition of . a
k 0
k

Solution:
n

a
k 0
k = a0 + a1 + a2 + a3 + … an
0

Basis Step: a
k 0
k  a0

Inductive Step:
𝑛 𝑛−1

෍ 𝑎𝑘 = ෍ 𝑎𝑘 + 𝑎𝑛
𝑘=0 𝑘=0
4.3 Recursive Definitions and Structural Induction
15

DEFINITION 1
The Fibonacci numbers, f0, f1, f2, …, are defined by the equations
Basis step: f0= 0, f1 =1
Recursive step: fn = fn-1 + fn-2
for n = 2, 3, 4, ….

 Example: Find the Fibonacci numbers f2, f3, f4, f5, and f6.
Solution:
f2 = f1 + f0 = 1 + 0 = 1,
f3 = f2 + f1 = 1 + 1 = 2,
f4 = f3 + f2 = 2 + 1 = 3,
f5 = f4 + f3 = 3 + 2 = 5,
f6 = f5 + f4 = 5 + 3 = 8.
 Example: Find the Fibonacci numbers f7.
Solution ?
4.3 Recursive Definitions and Structural Induction
16

f4

f3
f2 fn+1 -1 addition to find fn

f2
f1 f f0
1

(f5 -1) addition to find f4


f1 f0
= (5-1) = 4 additions

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy