Induction Proof

Download Report

Transcript Induction Proof

Induction Proof
Well-ordering
A set S is well ordered if every subset has a least element.

[0, 1] is not well ordered since (0,1] has no least element.
Examples:
 N is well ordered (under the  relation).
 Any coutably infinite set can be well ordered.


Z can be well ordered but it is not well ordered under the
 relation.


The least element in a subset is determined by a bijection (list)
which exists from N to the countably infinite set.
Z has no smallest element.
The set of finite strings over an alphabet using
lexicographic ordering is well ordered.
Mathematical Induction
Let P(x) be a predicate over a well ordered set S.
In the case that S = N, the natural numbers, the
principle has the following form.
P(0)
P(n)  P(n +1)
x P(x)
The hypotheses are
H1: P(0)
(Basis Step)
 H2: P(n)  P(n +1) for n arbitrary. (Induction Step)

How It Works
First, prove that the predicate is true for the smallest
element of the set S (0 if S = N).
 Then, show if it is true for an element (n if S=N) implies
it is true for the “next” element in the set (n + 1 if S=N).
Meaning
 Knowing it is true for the first element means it must be
true for the element following the first or the second
element
 Knowing it is true for the second element implies it is
true for the third and so forth.
 Therefore, induction is equivalent to modus ponens
applied an countable number of times!!

Outline of Induction Proof
 State
what P(n) is.
 Basis:

Prove that P(0) is true.
 Induction

Assume that P(n) is true, for an arbitrary n.
 Induction

hypothesis:
step:
Prove that P(n+1) is true, using P(n). (Usually, direct
proof)
Example
n
Prove: i = n(n +1)/2
i=0
In logical notation we wish to show
n
n [ i = n(n +1)/2 ]
i=0
n
Hence, P(n) is [ i] = n(n +1)/2
i=0
Basis:
Prove H1: P(0): 0=0(0 +1)/2
Induction Hypotheses:
Assume P(n) is true for n arbitrary.
Now use this and anything else you know to establish that P(n+1)
must be true.
Example
Induction step: Write down the assertion P (n+1)
P(n + 1) is the assertion 
n+1
i = (n+1)((n +1)+1)/2
i=0
n+1

i=0
n
i =  i +n+1
i=0
= n(n +1)/2 + n+1
(from induction hypothesis)
= (n(n +1) + 2(n+1) )/ 2
= (n+1)(n+2)/ 2
= (n+1)((n +1)+1)/2
Q.E.D.
More General Rule
 Suppose
we wish to prove for some specific
integer k x [xk P(x)]
 Now we merely change the basis step to P(k) and
continue.
Example
Prove 3n + 5 is in O(n2).
Definition: f(n) is in O(g(n)) if there are constants c>0
and k such that f(n)cg(n) for n  k.
Proof:
We must find C and k such that 3n + 5  Cn2 for n  k (or
n > k-1).
If we try C = 1, then the assertion is not true until k = 5.
Hence we prove by induction that 3n + 5  n2 for all n  5.
The assertion becomes n[n  5 3n + 5  n2 ]
and the predicate P(n) is 3n + 5  n2.
Example
Basis step:
P(5): 35 + 5 = 20 (5)2 .
Induction hypothesis:
Assume P(n): 3n +5 n2 is true for arbitrary n.
Induction step: Prove P(n+1): 3(n +1)+5 (n +1)2
From 3n +5 n2 , we have (3n +5) +3 n2 +3.
Now we must show that n2 + 3 (n + 1)2 = n2 + 2n + 1
which is true iff 3 2n + 1
which is true iff n 1.
But we have already restricted n 5 so n 1 must hold.
That is, n[n 53n +5 n2 ], i.e. 3n + 5 is in O(n2).
Q.E.D.
Double Qualifier
 In
doubly quantified assertions of the form
mn[P(m,n)]
 we
often assume m (or n ) is arbitrary to
eliminate a quantifier and prove the remaining
result using induction.
Strong Induction
H1: P(0)
H2: P(0)  P(1)  ... P(n)  P(n +1)
xP(x)
The two rules are equivalent but sometimes the
second is easier to apply.
Example
For any integer n>1, n can be written as a product of
primes.
Proof:
Let P(n) be the predicate n can be written as a product of
primes.
Basis:
P(2): 2 can be written as a product of 2, which is a prime.
Induction hypothesis:
For any integer kn, k can be written as a product of
primes.
Example
Induction step:
Prove n+1 can be written as a product of primes.
 If n+1 is a prime, then it can be written as a product of
itself only (by def. of primes).
 If n+1 is not a prime, then there exist integers p and q
such that pq=n+1 (by def. of primes) and p and q are
less than n+1.
Since p and q are less than n+1, p and q can be written
as products of primes (by induction hypothesis).
Thus, n+1 can be written as a product of primes that
make p and q.
Q.E.D.
Recursive or Inductive Definitions
 Basis

step
For sets
 State

the basic building blocks (BBB's) of the set.
For functions
 State
the values of the function on the BBB’s.
 Inductive

or recursive step:
For sets
 Show
how to build new things from old with some
construction rules.

For functions
 Show
how to compute the value of a function on the new
things that can be built knowing the value on the old things.
Recursive or Inductive Definitions

Extremal clause:

For sets


For functions


If you can't build it with a finite number of applications of steps 1. and
2. then it isn't in the set.
A function defined on a recursively defined set does not require an
extremal clause.
Often omitted.
To prove something is in the set you must show how to
construct it with a finite number of applications of the
basis and inductive steps.
 To prove something is not in the set is often more
difficult.

Example
A recursive definition of N:
 Basis:

0 is in N (0 is the BBB).
 Induction:

if n is in N then so is n + 1 (how to build new objects
from old: “add one to an old object to get a new
one”).
 Extremal

clause:
If you can't construct it with a finite numberof
applications of the basis and induction, it is not in N.
Example
Given the recursive definition of N, we can give
recursive definitions of functions on N:
 f(0) =1


The initial condition or the value of the function on the BBB’s.
f(n+1)=(n+1)f(n)

The recurrence equation, how to define f on the new objects
based on its value on old objects.
f is the factorial function: f(n) = n!
 Note how it follows the recursive definition of N.


Proof of assertions about inductively defined objects
usually involves a proof by induction.
Proof guideline
 Prove
the assertion is true for the BBBs in the
basis step.
 Prove
that if the assertion is true for the old
objects it must be true for the new objects you
can build from the old objects.
 Conclude
objects.
the assertion must be true for all
Example
We define an inductively where n is in N.
Basis:
a0 = 1
Induction:
a(n+1) = ana
Theorem: m n [aman = am+n ]
Proof:
Since the powers of a have been defined inductively, we
must use a proof by induction somewhere. Get rid of the
first quantifier on m by Universal Instantiation:
Assume m is arbitrary.
Now prove, by induction, the remaining quantified
assertion
n [aman = am+n ]
Example
Basis step: Show it holds for n=0.
The left side becomes ama0 = am(1) = am. The right side
becomes am+0 = am.
Hence, the two sides are equal to the same value.
Induction hypothesis:
Assume the assertion is true for n: aman = am+n.
Induction step: Now show it is true for n+1
(aman+1=am+n+1).
aman+1 = am(ana) (by inductive step in the definition of an)
aman+1 = (aman )a (by associativity of multiplication)
aman+1 = am+na
(by the induction hypothesis)
aman+1 = am+n+1
(by inductive step in the definition of
n
Rooted Trees
The set of rooted trees, where a rooted tree consists of a set of
vertices containing a distinguished vertex called the root, and
edges connecting these vertices, can be defined recursively as
follows:
Basis step:
A single vertex r is a rooted tree.
Recursive step:
If T1, T2, …, Tn are rooted trees with roots r1, r2, …, rn ,
espectively, the graph form by starting with a root r, which is not
in any of T1, T2, …, Tn , and adding an edge from r to r1, r2, …, rn
is also a rooted tree.
Extended Binary Trees
The set of extended binary trees can be defined recursively as
follows:
Basis step:
The empty set is an extended binary tree.
Recursive step:
If T1 and T2 are extended binary trees, there is an extended binary
tree, denoted by T1T2, consisting of a root r together with edges
connecting the root to the root of the left subtree T1 and the right
subtree T2, when these trees are not empty.
Full Binary Trees
The set of full binary trees can be defined recursively as follows:
Basis step:
A single vertex r is a full binary tree.
Recursive step:
If T1 and T2 are full binary trees, there is an full binary tree,
denoted by T1T2, consisting of a root r together with edges
connecting the root to the root of the left subtree T1 and the right
subtree T2.
Height of Trees
The height of a full binary tree T, denoted by h(T), can be defined
as follows:
Basis step:
The height of a full binary tree T consisting of a single vertex r is
h(T)=0.
Recursive step:
If T1 and T2 are full binary trees, the height of a full binary tree T
= T1T2 is h(T)=1+max(h(T1), h(T2)).
2
0
1
0
Number of Nodes in a Full Binary Tree
Theorem: If T is a full binary tree, the number of nodes in T, denoted
by n(T), is not more than 2h(T)+1 -1.
Proof:
Basis step:
For a full binary tree T of height 0, T is consisted of one vertex.
Then, n(T)=1, and 2h(T)+1-1 =20+1-1=1. Thus, n(T) 2h(T)+1-1.
Induction hypothesis:
Assume n(T) 2h(T)+1-1 for any full binary tree T of the height less
than k.
Induction step:
If T1 and T2 are full binary trees of the height less than k, the
number of nodes in a full binary tree T = T1T2 is 1+n(T1)+n(T2).
Number of Nodes in a Full Binary Tree
n(T)
= 1+n(T1)+n(T2)
(from the construction of T)
 1 + (2h(T1)+1-1) + (2h(T2)+1-1) (from induction hypothesis)
1 + (2h(T1)+1-1) + (2h(T2)+1-1) = 2h(T1)+1+ 2h(T2)+1-1
 2max(2h(T1)+1, 2h(T2)+1) -1
2max(2h(T1)+1, 2h(T2)+1) -1
= 2(2 max(h(T1)+1, h(T2))+1) -1
= 22h(T) -1
= 2h(T)+1 -1
That is, n(T)  2h(T)+1 -1.
Q.E.D.