Download Course Description

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Mathematics and art wikipedia , lookup

Philosophy of mathematics wikipedia , lookup

History of mathematics wikipedia , lookup

List of important publications in mathematics wikipedia , lookup

Addition wikipedia , lookup

Foundations of mathematics wikipedia , lookup

Georg Cantor's first set theory article wikipedia , lookup

Fermat's Last Theorem wikipedia , lookup

Non-standard analysis wikipedia , lookup

Laws of Form wikipedia , lookup

Four color theorem wikipedia , lookup

Peano axioms wikipedia , lookup

Non-standard calculus wikipedia , lookup

Theorem wikipedia , lookup

Wiles's proof of Fermat's Last Theorem wikipedia , lookup

Fundamental theorem of algebra wikipedia , lookup

Brouwer–Hilbert controversy wikipedia , lookup

Mathematical proof wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Transcript
Department of Computer Science
University of Karachi
BSCS-411 — Discrete Mathematics (Mathematical Induction) — Week 6
Mathematical Induction
• A powerful, rigorous technique for proving that a predicate P(n) is true
for every natural number n, no matter how large.
• Essentially a “domino effect” principle.
• Based on a predicate-logic inference rule:
P(0)
“The First Principle
n0 (P(n)P(n+1))
of Mathematical Induction”
n0 P(n)
Validity of Induction
Proof that k0 P(k) is a valid consequent:
Given any k0, the 2nd antecedent
n0 (P(n)P(n+1)) trivially implies that
n0 (n<k)(P(n)P(n+1)), i.e., that (P(0)P(1))  (P(1)P(2))  … 
(P(k1)P(k)). Repeatedly applying the hypothetical syllogism rule to
adjacent implications in this list k−1 times then gives us P(0)P(k); which
together with P(0) (antecedent #1) and modus ponens gives us P(k). Thus
k0 P(k). ■
The Well-Ordering Property
• Another way to prove the validity of the inductive inference rule is by
using the well-ordering property, which says that:
– Every non-empty set of non-negative integers has a minimum
(smallest) element.
–  SN : mS : nS : mn
• This implies that {n|P(n)} (if non-empty) has a min. element m, but
then the assumption that P(m−1)P((m−1)+1) would be contradicted.
Outline of an Inductive Proof
• Let us say we want to prove n P(n)…
– Do the base case (or basis step): Prove P(0).
– Do the inductive step: Prove n P(n)P(n+1).
• E.g. you could use a direct proof, as follows:
• Let nN, assume P(n). (inductive hypothesis)
• Now, under this assumption, prove P(n+1).
– The inductive inference rule then gives us
n P(n).
Week 6
(Mathematical Induction)
Page 1
Generalizing Induction
• Rule can also be used to prove nc P(n) for a given constant cZ,
where maybe c0.
– In this circumstance, the base case is to prove P(c) rather than
P(0), and the inductive step is to prove nc (P(n)P(n+1)).
• Induction can also be used to prove
nc P(an) for any arbitrary series {an}.
• Can reduce these to the form already shown.
Second Principle of Induction
• Characterized by another inference rule:
P(0)
n0: (0kn P(k))  P(n+1)
n0: P(n)
• The only difference between this and the 1st principle is that the
inductive step here makes use of the fact that P(k) is true for all smaller
numbers k<n+1, not just for k=n.
Induction Example (1st principle)
• Prove that the sum of the first n odd positive integers is n2. That is,
n
prove:
2
n  1 :  (2i  1)  n
i 1
• Proof by induction.
– Base case: Let n=1. The sum of the first 1 odd positive integer is 1
which equals 12.
• Inductive step: Prove n1: P(n)P(n+1).
– Let n1, assume P(n), and prove P(n+1).
 n

(
2
i

1
)

(
2
i

1
)

  (2(n  1)  1)

i 1
 i 1

 n 2  2n  1
n 1
 (n  1) 2
Another Induction Example
• Prove that n>0, n<2n. Let P(n)=(n<2n)
– Base case: P(1)=(1<21)=(1<2)=T.
Week 6
(Mathematical Induction)
Page 2
– Inductive step: For n>0, prove P(n)P(n+1).
• Assuming n<2n, prove n+1 < 2n+1.
• Note n + 1 < 2n + 1 (by inductive hypothesis)
< 2n + 2n (because 1<2=22022n-1= 2n)
= 2n (1+1) = 2n2 = 2n+1
• So n + 1 < 2n+1, and we’re done.
Example of Second Principle
• Show that every n>1 can be written as a product p1p2…ps of some series
of s prime numbers.
– Let P(n)=“n has that property”
• Base case: n=2, let s=1, p1=2.
• Inductive step: Let n2. Assume 2kn: P(k).
Consider n+1. If it’s prime, let s=1, p1=n+1.
Else n+1=ab, where 1<an and 1<bn.
Then a=p1p2…pt and b=q1q2…qu. Then we have that n+1 = p1p2…pt
q1q2…qu, a product of s=t+u primes.
Another 2nd Principle Example
• Prove that every amount of postage of 12 cents or more can be formed
using just 4-cent and 5-cent stamps. P(n)=“n can be…”
• Base case: 12=3(4), 13=2(4)+1(5), 14=1(4)+2(5), 15=3(5), so
12n15, P(n).
• Inductive step: Let n15, assume
12kn P(k). Note 12n3n, so P(n3), so add a 4-cent stamp to get
postage for n+1.
More Examples:
Example 0: The ATM Machine
Suppose an ATM machine has only two dollar and five dollar bills. You can
type in the amount you want, and it will figure out how to divide things up
into the proper number of two's and five's.
Claim. The ATM machine can generate any output amount n  4.
Proof: By induction on n.
Base case: n = 4. 2 two's, done.
Induction step: suppose the machine can already handle n  4 dollars. To
produce n + 1 dollars, we proceed as follows.
Week 6
(Mathematical Induction)
Page 3
Case 1: The n dollar output contains a five. Then we can replace the five by 3
two's to get n + 1 dollars.
Case 2: The n dollar output contains only two's.
Since n  4, there must be at least 2 two's. Remove 2, and replace them by 1
five.
Example 1: A Sum Formula
Theorem. For any positive integer n, 1 + 2 + ... + n = n(n+1)/2.
Proof. (Proof by Mathematical Induction) Let's let P(n) be the statement "1 +
2 + ... + n = n (n+1)/2." (The idea is that P(n) should be an assertion that for
any n is verifiably either true or false.) The proof will now proceed in two
steps: the initial step and the inductive step.
Initial Step. We must verify that P(1) is True. P(1) asserts "1 = 1(2)/2", which
is clearly true. So we are done with the initial step.
Inductive Step. Here we must prove the following assertion: "If there is a k
such that P(k) is true, then (for this same k) P(k+1) is true." Thus, we assume
there is a k such that 1 + 2 + ... + k = k (k+1)/2. (We call this the inductive
assumption.) We must prove, for this same k, the formula 1 + 2 + ... + k +
(k+1) = (k+1)(k+2)/2.
This is not too hard: Suppose for some integer k > 0, P(k) is true, then we
have



1 + 2 + ... + k = k(k+1) / 2
1 + 2 + ... + k + (k+1) = k(k+1) / 2 + (k+1)
1 + 2 + ... + k + (k+1) = k(k+1) / 2 + (k+1) = (k(k+1) + 2 (k+1)) / 2 =
(k+1)(k+2) / 2.
 1 + 2 + ... + (k+1) = (k+1)(k+1+1) / 2.
So P(k+1) is also true. Hence theorem is valid for all n.
NOTE:
1-Mathematical induction is a form of proof based on a logical principle
technically known as the well-ordering principle. Here is an informal
statement of the principle:
If something is ever going to happen at all, there will be an instant when it
happens for the first time.
2-The fact that one can use mathematical induction to prove the rule gives no
indication about how the rule was found in the first place.
Week 6
(Mathematical Induction)
Page 4
Example 2: Summing Squares
Consider the problem of finding a closed formula for the sum of the first n
squares (a closed formula, as opposed to a recurrence f(0) = 0, f(n) = f(n-1) +
n2, n > 0). By direct trial one might find the following:
This suggests a general rule:
But the trial procedure that we used to guess the rule is different from the
procedure that is needed to prove it.
The sum of squares formula can be proved by mathematical induction, which
is left as an Exercise.
A Divisibility Proof
Prove that 3 | (22n – 1) for all n > 0.
Basis: For n = 1, 22n – 1= 22 – 1 = 3, so 3|3.
Inductive step: By inductive hypothesis, assume that 3 | (22k – 1) for some
positive k. We must show that 3 | (22(k+1) – 1). Now
Therefore, 3 | (22(k+1) – 1).
Q.E.D.
An Inequality Proof
Prove that
Week 6
2n + 1 < 2n
n 
3.
(Mathematical Induction)
Page 5
Basis: n=3. 6+1 < 8.
Inductive step: By inductive hypothesis, assume 2k + 1 < 2 k
must show that
k

3. We
. Now
Therefore, 2(k+1) + 1 < 2k+1 Q.E.D.
A Sequence
For the sequence
prove that
Basis: n=1.
.
,
.
Inductive step: By inductive hypothesis, assume
must show that
Therefore,
Q.E.D.
. We
.
.
Note:- This problem suggests an alternative way of solving recurrences. But
this is valid for few simple cases. If you can guess a pattern (e.g. by giving
different values of the index variable in the given recurrence and then
observing if you see an emerging pattern), and the pattern can be proved by
using the principle of mathematical induction you are done, else your guess
was wrong!
Week 6
(Mathematical Induction)
Page 6
Executrices:
1- Summing Cubes
Prove by using the techniques of mathematical induction
2- Prove by using the techniques of mathematical induction that for each
nonnegative integer
2(n+2) + 3(2n+1) is divisible by 7.
3- By using the Principle of Induction prove that
n
n  1 :  i * i!  (n  1)!1
i 1
Theorem: If a set S has n elements, then its power set P(S) has 2n elements.
Proof: The theorem is proved by induction on n. The first case is n = 0. If S
has 0 elements, then S is empty, so S = Ø. Now the empty set has only one
subset, namely itself, so P(Ø) = 1 = 20. This proves the first case.
For the inductive case, we assume P(S) has 2n elements whenever S has n
elements and n is equal to or less than k. Suppose S has k + 1 elements.
Choose an element t in S and let R = S - {t}. Then R has exactly k elements.
By the inductive hypothesis, P(R) = 2k.
Now we count the subsets of S. If A is a subset of S, either A contains t or it
does not. If A does not contain t, then A is a subset of R; we know there are
exactly 2k such subsets.
If A does contain t, then B = A - {t} does not, so B is a subset of R. Since
there are exactly 2k such subsets B, and since A = B union {t} is formed by
just taking one of these subsets of R and tossing in t, there are exactly 2 k
subsets A containing t. Thus the total number of subsets of S is 2k + 2k = 2·2k
= 2k+1. This proves the inductive step.
To summarize: the steps in a proof by mathematical induction are:
Week 6
(Mathematical Induction)
Page 7
1. State clearly that you are going to do an inductive proof using the
variable n, or whatever the indexing variable is.
2. Identify the first value of n for which p(n) is supposed to be true (usually
this is n = 0 or 1).
3. Prove the first case (often this is easy, or even trivial, so don't be
surprised if there's not much to do in this step.)
4. State the inductive hypothesis carefully (as above: "we assume P(S) has
2n elements whenever S has n elements and n is equal to or less than k").
5. Prove the inductive step p(k + 1) using the inductive hypothesis.
Recursive Definitions
• In induction, we prove all members of an infinite set satisfy some
predicate P by:
– proving the truth of the predicate for larger members in terms of
that of smaller members.
• In recursive definitions, we similarly define a function, a predicate, a set,
or a more complex structure over an infinite domain (universe of
discourse) by:
– defining the function, predicate value, set membership, or structure
of larger elements in terms of those of smaller ones.
• In structural induction, we inductively prove properties of recursivelydefined objects in a way that parallels the objects’ own recursive
definitions.
Recursively Defined Functions
• Simplest case: One way to define a function f:NS (for any set S) or
series an=f(n) is to:
– Define f(0).
– For n>0, define f(n) in terms of f(0),…,f(n−1).
• E.g.: Define the series an :≡ 2n recursively:
– Let a0 :≡ 1.
– For n>0, let an :≡ 2an-1.
Another Example
• Suppose we define f(n) for all nN recursively by:
– Let f(0)=3
– For all nN, let f(n+1)=2f(n)+3
• What are the values of the following?
– f(1)=9
f(2)=21
f(3)=45
f(4)=93
Week 6
(Mathematical Induction)
Page 8
Recursive definition of Factorial
• Give an inductive (recursive) definition of the factorial function,
F(n) :≡ n! :≡ ∏1≤i≤n i = 12…n.
– Base case: F(0) :≡ 1
– Recursive part: F(n) :≡ n  F(n−1).
• F(1)=1
• F(2)=2
• F(3)=6
More Easy Examples
• Write down recursive definitions for:
i+n (i integer, n natural) using only s(i) = i+1.
a·n (a real, n natural) using only addition
an (a real, n natural) using only multiplication
∑0≤i≤n ai (for an arbitrary series of numbers { ai })
∏0≤i≤n ai (for an arbitrary series of numbers { ai })
∩0≤i≤n Si (for an arbitrary series of sets {Si})
The Fibonacci Series
•
The Fibonacci series fn≥0 is a famous series defined by:
f0 :≡ 0, f1 :≡ 1, fn≥2 :≡ fn−1 + fn−2
So that f2 = f1 + f0 = 1+0=1, f3 = f2 + f1 = 1+1=2, f4 = 3 f5 = 5 f6 = 8 etc.
We can use the recursive definition of the Fibonacci numbers to prove many
properties of these numbers. Few properties are given below by means of
theorms:
Theorem: fn < 2n, for all nN.
Proof: By induction.
Base cases:
f0 = 0 < 2 0 = 1
f1 = 1 < 2 1 = 2
Inductive step: Use 2nd principle of induction
(strong induction). Assume k<n, fk < 2k.
Then fn = fn−1 + fn−2 is
< 2n−1 + 2n−2 < 2n−1 + 2n−1 = 2n.
Theorem. For all integers n ≥ 3, fn > αn−2, where α = (1+51/2)/2 ≈ 1.61803.
Proof. (Using strong induction.)
Week 6
(Mathematical Induction)
Page 9
–Let P(n) = (fn > αn−2).
–Base cases: For n=3, note that α < 2 = f3.
For n=4, α2 = (1+2·51/2+5)/4
= (3+51/2)/2 ≈ 2.61803 < 3 = f4.
Inductive step: For k≥4, assume P(j) for 3≤j≤k, prove P(k+1). Note α2
= α+1. Thus, αk−1 = (α+1)αk−3 = αk−2 + αk−3. By inductive hypothesis, fk−1
> αk−3 and fk > αk−2. So, fk+1 = fk + fk−1 > αk−2 + αk−3 = αk−1. Thus P(k+1).■
Lamé’s Theorem
Theorem: a,bN, a≥b>0, the number of steps in Euclid’s algorithm to find
gcd(a,b) is ≤ 5k, where k = log10 b+1 is the number of decimal digits in b.
–Thus, Euclid’s algorithm is linear time in the number of digits in b.
Proof:
–Uses the Fibonacci sequence!
Consider the sequence of division-algorithm equations used in Euclid’s
algorithm: (here a = r0, b = r1, and gcd(a,b)=rn)
r 0 = r 1q 1 + r 2
with 0 ≤ r2 < r1
r 1 = r 2q 2 + r 3
with 0 ≤ r3 < r2
…
rn−2 = rn−1qn−1 + rn
with 0 ≤ rn < rn−1
rn−1 = rnqn + rn+1
with rn+1 = 0 (terminate)
So the number of divisions (iterations) is n. Now Consider
•Since r0 ≥ r1 > r2 > … > rn, each quotient qi ≡ ri−1/ri ≥ 1.
•Since rn−1 = rnqn and rn−1 > rn, qn ≥ 2.
•So we have the following relations between r and f:
r n ≥ 1 = f2
rn−1 ≥ 2rn ≥ 2f2 = f3
rn−2 ≥ rn−1 + rn ≥ f2 + f3 = f4
…
r2 ≥ r3 + r4 ≥ fn−1 + fn−2 = fn
b = r1 ≥ r2 + r3 ≥ fn + fn−1 = fn+1.
•Thus, if n>2 divisions are used, then b ≥ fn+1 > αn−1.
–Thus, log10 b > log10(αn−1) = (n−1)log10 α ≈ (n−1)0.208 > (n−1)/5.
–If b has k decimal digits, then log10 b < k, so n−1 < 5k, so n ≤ 5k.
Week 6
(Mathematical Induction)
Page 10
This finishes the proof.
Recursively Defined Sets
• An infinite set S may be defined recursively, by giving:
– A small finite set of base elements of S.
– A rule for constructing new elements of S from previously
established elements.
– Implicitly, S has no other elements but these.
• Example: Let 3S, and let x+yS if x,yS.
What is S?
The Set of All Strings
• Given an alphabet Σ, the set Σ* of all strings over Σ can be recursively
defined by:
ε  Σ* (ε :≡ “”, the empty string)
w  Σ*  x  Σ → wx  Σ*
Structural Induction
 Proving something about a recursively defined object using an inductive
proof whose structure mirrors the object’s definition.
 Example problem: Let 3S, and let x+yS if x,yS. Show that S =
{nZ+| (3|n)} (the set of positive multiples of 3).
Theorem: Let 3S, and let x+yS if x,yS. Let A = {nZ+| (3|n)}. Then
A=S.
Proof: We show that AS and SA.
– To show AS, show [nZ+  (3|n)]→ nS.
• Inductive proof. Let P(n) :≡ nS. Induction over positive
multiples of 3. Base case: n=3, thus 3S by def’n. of S.
Inductive step: Given P(n), prove P(n+3). By inductive hyp.,
nS, and 3S, so by def’n of S, n+3S.
– To show SA: let nS, show nA.
• Structural inductive proof. Let P(n):≡nA. Two cases:
n=3 (base case), which is in A, or n=x+y (recursive step). We
know x and y are positive, since neither rule generates
negative numbers. So, x<n and y<n, and so we know x and y
are in A, by strong inductive hypothesis. Since 3|x and 3|y,
we have 3|(x+y), thus x+y  A.
Recursive Algorithms
Week 6
(Mathematical Induction)
Page 11
• Recursive definitions can be used to describe algorithms as well as
functions and sets.
• Example: A procedure to compute an.
procedure power(a≠0: real, nN)
if n = 0 then return 1
else return a · power(a, n−1)
Efficiency of Recursive Algorithms
• The time complexity of a recursive algorithm may depend critically on
the number of recursive calls it makes.
• Example: Modular exponentiation to a power n can take log(n) time if
done right, but linear time if done slightly differently.
– Task: Compute bn mod m, where
m≥2, n≥0, and 1≤b<m.
Algorithm 1- Uses the fact that bn = b·bn−1 and that x·y mod m =
x·(y mod m) mod m. (Prove the latter theorem at home.)
procedure mpower(b≥1,n≥0,m>b N)
{Returns bn mod m.}
if n=0 then return 1 else
return (b·mpower(b, n−1, m)) mod m
Note this algorithm takes Θ(n) steps!
Algorithm 2 - Uses the fact that b2k = bk·2 = (bk)2.
procedure mpower(b,n,m) {same signature}
if n=0 then return 1
else if 2|n then
return mpower(b,n/2,m)2 mod m
else return (b.mpower(b,n−1,m)) mod m
What is its time complexity?
Θ(log n) steps!
{]
A Slight Variation
Nearly identical but takes Θ(n) time instead!
procedure mpower(b,n,m) {same signature}
if n=0 then return 1
else if 2|n then
return (mpower(b,n/2,m)·
mpower(b,n/2,m)) mod m
else return (b.mpower(b,n−1,m)) mod m
The number of recursive calls made is critical!
Week 6
(Mathematical Induction)
Page 12
Recursive Euclid’s Algorithm
procedure gcd(a,bN)
if a = 0 then return b
else return gcd(b mod a, a)
• Note recursive algorithms are often simpler to code than iterative ones…
• However, they can consume more stack space, if your compiler is not smart
enough.
Week 6
(Mathematical Induction)
Page 13