Proofs, Induction and Recursion Basic Proof Techniques Mathematical Induction Recursive Functions...
-
Upload
logan-patrick -
Category
Documents
-
view
307 -
download
4
Transcript of Proofs, Induction and Recursion Basic Proof Techniques Mathematical Induction Recursive Functions...
Proofs, Induction and Proofs, Induction and RecursionRecursion
Basic Proof TechniquesBasic Proof TechniquesMathematical InductionMathematical InductionRecursive Functions and Recursive Functions and
Recurrence RelationsRecurrence Relations
Basic Proof TechniquesBasic Proof Techniques
Mathematical proofs all have their basis in Mathematical proofs all have their basis in formal logic.formal logic.
There are some basic techniques for There are some basic techniques for proving things, on the basis of different proving things, on the basis of different logical truths.logical truths.
Why are proofs really necessary? Because Why are proofs really necessary? Because intuition and guessing don't always work.intuition and guessing don't always work. nn! < ! < nn22 for all integers. True for for all integers. True for n = n = 1, 1, n = n = 2,2,
and and n = n = 33, but is it really true? How about , but is it really true? How about nn = 4 = 4? ?
Basic Proof TechniquesBasic Proof Techniques
There are more integers than there are even There are more integers than there are even integers.integers.
Intuition tells us that this must be true.Intuition tells us that this must be true. But, if you give me an integer, I can come back But, if you give me an integer, I can come back
with a unique even integer every time!with a unique even integer every time! So there are no more integers than even So there are no more integers than even
integers.integers. That's why we need to prove things.That's why we need to prove things.
Basic Proof TechniquesBasic Proof Techniques
Luckily for you, you will seldom be called Luckily for you, you will seldom be called upon to prove anything in this course (or upon to prove anything in this course (or any other courses at FDU)any other courses at FDU)
Unluckily for you, you DO need to Unluckily for you, you DO need to understand why proofs work, what they understand why proofs work, what they mean and how they are formulated.mean and how they are formulated.
Basic Proof TechniquesBasic Proof Techniques
Exhaustive proofExhaustive proof not usually effective because it is, of course, not usually effective because it is, of course,
exhausting.exhausting.• Prove that the set Prove that the set {{aa, , bb, , cc, , dd}} has 16 subsets. has 16 subsets.
• {}, {{}, {aa}, {}, {bb}, {}, {cc}, {}, {dd}, {}, {aa, , bb}, {}, {aa, , cc}, {}, {aa, , dd}, {}, {bb, , cc}, }, {{bb, , dd}, {}, {cc, , dd}, {}, {aa, , bb, , cc}, {}, {aa, , bb, , dd}, {}, {aa, , cc, , dd}, {}, {bb, , cc, , dd}, }, {{aa, , bb, , cc, , dd} }
• That's 16. Imagine having to prove that a set with That's 16. Imagine having to prove that a set with 10 elements has 1024 subsets!10 elements has 1024 subsets!
Basic Proof TechniquesBasic Proof Techniques
DirectDirect proofproof use basic mechanisms of deduction. use basic mechanisms of deduction. examples are any of the proofs we saw in the examples are any of the proofs we saw in the
previous weeks' lectures.previous weeks' lectures. Can be very difficult.Can be very difficult.
Basic Proof TechniquesBasic Proof Techniques
ContrapositionContraposition instead of proving the statement itself, which instead of proving the statement itself, which
might be hard to do, prove the contrapositive. might be hard to do, prove the contrapositive. Instead of Instead of ppqq, prove , prove qq''pp''
ExampleExample:: Prove that in the universe of Prove that in the universe of integers, if integers, if nn22 is odd, then is odd, then nn is odd.is odd.
ContrapositiveContrapositive: Prove that if: Prove that if nn is even, then is even, then nn22 is even. is even.
Assume that Assume that nn is even.is even. n n = 2 = 2kk nn22 = 4 = 4kk2 2 = 2(2= 2(2kk22)) which, by definition, is even. which, by definition, is even.
Basic Proof TechniquesBasic Proof Techniques
ContradictionContradiction Show that if we assume what we want to prove Show that if we assume what we want to prove
is false, then we must arrive at a contradiction.is false, then we must arrive at a contradiction. Show that can not be represented as a Show that can not be represented as a
fraction.fraction.• Suppose is represented by the fractionSuppose is represented by the fraction pp//qq which is which is
in lowest terms. That is, the greatest common in lowest terms. That is, the greatest common divisor of divisor of pp and and qq is is 11 ( (gcdgcd((p, qp, q) = 1) = 1). ).
• If If gcdgcd((p, qp, q) = 1,) = 1, then then gcdgcd((pp22, q, q22) = 1) = 1• But if But if pp//qq = , then = , then pp22//qq2 2 = = 22 and so and so gcdgcd((pp22 , ,qq22) = 2.) = 2.
2
2
2
Basic Proof TechniquesBasic Proof Techniques
ContradictionContradiction Show that if we assume what we want to prove is Show that if we assume what we want to prove is
false, then we must arrive at a contradiction.false, then we must arrive at a contradiction. Show that if Show that if x + x = xx + x = x, then , then x =x = 0 0..
• Suppose that Suppose that x + x = xx + x = x for some for some xx ≠ 0 ≠ 0• 2x = x2x = x, , xx ≠ 0 ≠ 0• Dividing both sides byDividing both sides by xx (allowable since (allowable since xx ≠ 0 ≠ 0) we get ) we get
that 2 = 1.that 2 = 1.• Contradiction!Contradiction!• Therefore if Therefore if x + x = xx + x = x, then , then xx = 0 = 0..
Basic Proof TechniquesBasic Proof Techniques
ContradictionContradiction Show that the set of real numbers is Show that the set of real numbers is
uncountable (i.e. – that you can not start uncountable (i.e. – that you can not start listing all the real numbers in such a way that listing all the real numbers in such a way that every real number will eventually appear in every real number will eventually appear in such a list. Such a proof by contradiction is such a list. Such a proof by contradiction is called called DiagonalizationDiagonalization..
We will prove this by contradiction and see We will prove this by contradiction and see why it's called diagonalization.why it's called diagonalization.
Basic Proof TechniquesBasic Proof Techniques
ContradictionContradiction Suppose we could create a list of real numbers Suppose we could create a list of real numbers
such that every real number will eventually such that every real number will eventually appear. It would look like:appear. It would look like:
Some number is missing from this list!!!!Some number is missing from this list!!!!
• 00 ..aa0000aa0101aa0202aa0303aa0404aa05 …………. 05 …………. aa00n ............................n ............................
• 11 ..aa1010aa1111aa1212aa1313aa1414aa15 …………. 15 …………. aa11n ............................n ............................
• 22 ..aa2020aa2121aa2222aa2323aa2424aa25 …………. 25 …………. aa22n ............................n ............................
..
..
.. ..
• nn ..aann00aann11aann22aann33aann44aann5 …………. 5 …………. aann ............................nn ............................
Basic Proof TechniquesBasic Proof Techniques ContradictionContradiction
Suppose such a list can be made. It would look Suppose such a list can be made. It would look like:like:
Now, consider the numberNow, consider the number . .aa0000aa1111aa2222aa3333aa4444aa5555 …………. …………. aann ............................nn ............................
• 00 ..aa0000aa0101aa0202aa0303aa0404aa05 …………. 05 …………. aa00n ............................n ............................
• 11 ..aa1010aa1111aa1212aa1313aa1414aa15 …………. 15 …………. aa11n ............................n ............................
• 22 ..aa2020aa2121aa2222aa2323aa2424aa25 …………. 25 …………. aa22n ............................n ............................
..
..
.. ..
• nn ..aann00aann11aann22aann33aann44aann5 …… 5 …… aannnn ............................ ............................
Basic Proof TechniquesBasic Proof Techniques ContradictionContradiction
Now consider the number created by changing Now consider the number created by changing each digit to another digit (for example 0 each digit to another digit (for example 0 becomes a 1, 1 becomes a 2. etc.becomes a 1, 1 becomes a 2. etc.
. .a'a'0000a'a'1111a'a'2222a'a'3333a'a'4444a'a'5555 …………. …………. a'a'nn ..................nn ..................
where where a'a'nn nn ≠ ≠ aannnn for allfor all nn
Basic Proof TechniquesBasic Proof Techniques ContradictionContradiction
..a'a'0000a'a'1111a'a'2222a'a'3333a'a'4444a'a'5555 …………. …………. a'a'nn ..................nn ..................
This number is not in the list!!!!!This number is not in the list!!!!!
Contradiction. Therefore it can't be done.Contradiction. Therefore it can't be done.
• 00 ..aa0000aa0101aa0202aa0303aa0404aa05 …………. 05 …………. aa00n ............................n ............................
• 11 ..aa1010aa1111aa1212aa1313aa1414aa15 …………. 15 …………. aa11n ............................n ............................
• 22 ..aa2020aa2121aa2222aa2323aa2424aa25 …………. 25 …………. aa22n ............................n ............................
..
..
.. ..
• nn ..aann00aann11aann22aann33aann44aann5 …………. 5 …………. aann ............................nn ............................
Basic Proof TechniquesBasic Proof Techniques
SerendipitySerendipity In a tennis tournament, players are eliminated In a tennis tournament, players are eliminated
round by round because only the winner goes round by round because only the winner goes to the next round until there is a final round in to the next round until there is a final round in which the winner gets the trophy.which the winner gets the trophy.
If there are If there are nn players, prove that there are players, prove that there are exactly exactly nn – 1 – 1 games played. games played.
Everyone except the champion loses exactly 1 Everyone except the champion loses exactly 1 game.game.
There are There are n – n – 11 non-champions. non-champions. There are There are n – n – 11 games. games.
Mathematical InductionMathematical Induction
Based on creating a one to one correspondence Based on creating a one to one correspondence with the integers and showing that it is true forwith the integers and showing that it is true for the basisthe basis: Simplest possible case (usually : Simplest possible case (usually nn = 1 = 1)) the assumptionthe assumption: assuming it is true for : assuming it is true for somesome nn ≥ 1≥ 1
the statement is true.the statement is true. the inductionthe induction: and then showing it is true for : and then showing it is true for n +n + 1 1, ,
wherewhere nn is the number from the basis is the number from the basis
Mathematical InductionMathematical Induction
Since it is true for the basis it is true for the next Since it is true for the basis it is true for the next higher number, and then the next higher, and so on. higher number, and then the next higher, and so on. That is, if the first domino is knocked over, all of That is, if the first domino is knocked over, all of them will fallthem will fall..
Mathematical InductionMathematical Induction
Show that the sum of the first Show that the sum of the first nn integers integers equalsequals n
k
n nk
1
( 1)2
For non-mathematiciansFor non-mathematicians
If you're not a mathematician, an If you're not a mathematician, an expression likeexpression like
might seem a bit scary.might seem a bit scary. Let's explain it. It's really not so bad.Let's explain it. It's really not so bad.
n
k
k 2
1
For non-mathematiciansFor non-mathematicians
First of all, the expressionFirst of all, the expression
stands for "add up the squares (stands for "add up the squares (kk22) of all the ) of all the numbers from 1 to numbers from 1 to nn."."
1 + 4 + 9 + 16 + 25 + … + (1 + 4 + 9 + 16 + 25 + … + (nn – – 11))22 + + nn22
n
k
k 2
1
For non-mathematiciansFor non-mathematicians
For example, the expressionFor example, the expression
stands for add up the squares (stands for add up the squares (kk22) of all the ) of all the numbers from 1 to 8.numbers from 1 to 8.
1 + 4 + 9 + 16 + 25 + 36 + 49 + 641 + 4 + 9 + 16 + 25 + 36 + 49 + 64
k
k8
2
1
Mathematical InductionMathematical Induction
Show that the sum of the first Show that the sum of the first nn integers integers equalsequals
BasisBasis: When : When n = n = 11, ,
HypothesisHypothesis::Assume thatAssume that
InductionInduction: Show that : Show that
n
k
n nk some n
1
( 1), for 1
2
k
k1
1
1(1 1) 1(2)1
2 2
n
k
n nk n
1
1
( 1)( 2),for the from the hypothesis
2
n
k
n nk
1
( 1)2
Mathematical InductionMathematical Induction
n n
k k
n nk k n n
1
1 1
( 1)( 1) ( 1)
2
n
k
n nk for the n from the hypothesis
1
1
( 1)( 2),
2
n n n n n n n( 1) 2( 1) ( 2)( 1) ( 1)( 2)2 2 2
Therefore, sinceTherefore, since the result is in the proper form the result is in the proper form forfor nn + 1 + 1, by Mathematical Induction, it is true , by Mathematical Induction, it is true for for allall nn > 0. > 0.
Mathematical InductionMathematical Induction
Now I will prove that all marbles in the Now I will prove that all marbles in the world are the same color.world are the same color. Proof by induction: (on bags containing Proof by induction: (on bags containing nn
marbles collected at random)marbles collected at random)• BasisBasis: For all bags containing 1 marble, clearly all : For all bags containing 1 marble, clearly all
the marbles in any of these bags is of the same the marbles in any of these bags is of the same color, trivially.color, trivially.
• HypothesisHypothesis: Assume that for : Assume that for somesome nn, all the , all the marbles in any bag containing marbles in any bag containing nn marbles will be of marbles will be of the same color.the same color.
Mathematical InductionMathematical Induction
• HypothesisHypothesis: Assume that for : Assume that for somesome nn, all the , all the marbles in any bag containing marbles in any bag containing nn marbles will be of marbles will be of the same color.the same color.
• InductionInduction: I will now show that for any bag : I will now show that for any bag containing containing nn + 1 + 1 marbles, all the marbles in the bag marbles, all the marbles in the bag are of the same color.are of the same color.
All Marbles Are The Same ColorAll Marbles Are The Same Color
Consider any bag Consider any bag containing containing n + n + 11
marblesmarblesthe bag now has the bag now has nn
marblesmarblesremove a marble from remove a marble from
the bagthe bagby the hypothesis, all the by the hypothesis, all the marbles in this bag of marbles in this bag of nn
marbles are the same colormarbles are the same color
remove one of those remove one of those same-colored same-colored
marbles and put marbles and put that first marble that first marble
back inback inn marbles, all the n marbles, all the same colorsame color
bring back that same-bring back that same-colored marblecolored marble
n+n+11 marbles all the marbles all the same colorsame color
QEDQED
Weak Induction vs. Strong Weak Induction vs. Strong InductionInduction
The type of inductive proofs we have The type of inductive proofs we have seen are often called proof by seen are often called proof by strong strong inductioninduction (or the (or the first principle of first principle of inductioninduction).).
There is another type of induction There is another type of induction called called weak inductionweak induction (or (or the second the second principle of inductionprinciple of induction.).)
Weak Induction vs. Strong Weak Induction vs. Strong InductionInduction
Proof by weak induction is the same as Proof by weak induction is the same as proof by strong induction, except that proof by strong induction, except that we change the hypothesis step.we change the hypothesis step.
Instead of assuming the statement true Instead of assuming the statement true for some for some nn ≥≥ the basis value the basis value, we assume , we assume the statement true the statement true for for allall values up to and including that values up to and including that n n ≥≥ the basis value the basis value
Weak InductionWeak Induction
Prove that a fence with Prove that a fence with nn posts has posts has n – n – 11 sections for any sections for any n n ≥ 1.≥ 1. BasisBasis: any fence with 1 post has no sections. : any fence with 1 post has no sections.
any fence with 2 posts has one section.any fence with 2 posts has one section. HypothesisHypothesis: Assume that any fence with at most : Assume that any fence with at most
nn posts, for some posts, for some nn ≥ 1.≥ 1. InductionInduction: Take any fence with : Take any fence with nn + 1 + 1 posts. posts.
Take out one section anywhere. You now have Take out one section anywhere. You now have two fences, one with two fences, one with kk posts and the other with posts and the other with and and n – kn – k + 1 + 1 posts. posts.
Weak InductionWeak Induction
Prove that a fence with Prove that a fence with nn posts has posts has n – n – 11 sections for any sections for any n n ≥ 1.≥ 1. InductionInduction (continued): Obviously both k (continued): Obviously both k
and and nn – k– k + 1 + 1 are less than are less than nn. So one fence . So one fence has has kk – 1 – 1 sections and the other has sections and the other has n – kn – k sections yielding a total of sections yielding a total of n n – 1– 1 sections. sections.
Now restore the missing section. You Now restore the missing section. You have one fence with have one fence with n n – 1 + 1 = – 1 + 1 = nn sections. sections.
Therefore the fence with Therefore the fence with n n + 1+ 1 posts has posts has nn sections. QEDsections. QED
RecursionRecursion
Recursive definitions.Recursive definitions. A A recursive definitionrecursive definition is a definition with two is a definition with two
parts:parts:• A A basisbasis - some simple case. - some simple case.• A A recursive steprecursive step – where new items are defined in – where new items are defined in
terms of previous cases.terms of previous cases.
Example:Example: SS(1) = 2 (basis)(1) = 2 (basis) SS((nn) = 2) = 2SS((nn – 1) for – 1) for n n ≥≥ 2 2 This defines the set {2, 4, 8, 16, 32, …}This defines the set {2, 4, 8, 16, 32, …}
RecursionRecursion
The Fibonacci numbers:The Fibonacci numbers: FF(1) = 1 and (1) = 1 and FF(2) = 1 (basis)(2) = 1 (basis) FF((nn) = ) = FF((nn – 2) + – 2) + FF((nn – 1) for – 1) for n n >> 2 2 This defines the set {1, 1, 2, 3, 5, 8, 13, 21, …}This defines the set {1, 1, 2, 3, 5, 8, 13, 21, …}
Note that the previous example could have Note that the previous example could have been defined by been defined by S S = {2= {2nn | n | n >= 1} >= 1}
The Fibonacci numbers are always defined The Fibonacci numbers are always defined recursively.recursively.
RecursionRecursion
A A binary treebinary tree is is a graph that has no nodes (basis)a graph that has no nodes (basis) a graph with a node that points in the left a graph with a node that points in the left
direction to a binary tree (called the left direction to a binary tree (called the left subtree) and in the right direction to a binary subtree) and in the right direction to a binary tree (called the right subtree). tree (called the right subtree).
RecursionRecursion
A A well-formed formula well-formed formula ((wffwff)) in propositional in propositional logic islogic is Any statement letter, or one of the contants Any statement letter, or one of the contants TT
and and FF (representing true and false.) (representing true and false.) If If PP and and QQ are are wffwff's, then so are ('s, then so are (PP QQ), (), (PP QQ), ),
((PP → → QQ), (), (PP ↔ ↔ QQ), and (), and (P'P'). ).
RecursionRecursion
Recursively defined operations:Recursively defined operations: For example, exponentiation, an, can be defined For example, exponentiation, an, can be defined
asas• aa00 = 1 = 1
• aann = = aann – 1– 1, for , for nn ≥≥ 1 1
Recursion and AlgorithmsRecursion and Algorithms
We often find it more convenient to We often find it more convenient to define things recursively because it is define things recursively because it is easier to develop algorithms for such easier to develop algorithms for such objects by using objects by using recursive algorithmsrecursive algorithms..
Consider the earlier definition of a Consider the earlier definition of a binary tree. How do we compute the binary tree. How do we compute the number of nodes in a given binary number of nodes in a given binary tree?tree?
Recursion and AlgorithmsRecursion and Algorithms
ifif (T.is_empty()) (T.is_empty()) // (no nodes)// (no nodes) T.node_count() = 0;T.node_count() = 0;elseelse
T.node_count() = T.node_count() = T.left_subtree().node_count() T.left_subtree().node_count() + T.left_subtree().node_count; + T.left_subtree().node_count;
Recursion and Mathematical Recursion and Mathematical InductionInduction
Recursive definitions lend themselves Recursive definitions lend themselves to proof by Mathematical Induction.to proof by Mathematical Induction.
Prove that the Fibonacci number Prove that the Fibonacci number FF((nn) < 2) < 2nn forfor nn ≥ 1.≥ 1. BasisBasis: consider when n = 1. : consider when n = 1. FF(1)(1) = 1, = 1,
which is clearly less than 2which is clearly less than 211 = 2. = 2. HypothesisHypothesis: assume that : assume that FF((kk) < 2) < 2kk for all for all
values less than values less than nn some some nn ≥ 1.≥ 1. Note that we will be using Note that we will be using weak weak
induction.induction.
Recursion and Mathematical Recursion and Mathematical InductionInduction
InductionInduction: Consider now : Consider now FF((nn + 1) + 1) where where n is the number from the hypothesis.n is the number from the hypothesis.
We know that We know that FF((nn + 1) = + 1) = FF((nn) + ) + FF((nn – 1). – 1). But by the hypothesis But by the hypothesis FF((nn) < 2) < 2nn and and
FF((nn-1) < 2-1) < 2nn-1-1.. So So FF((nn + 1) < 2 + 1) < 2nn + 2 + 2nn-1-1.. But But 22nn + 2 + 2nn-1 -1 < 2< 2nn + 2 + 2nn which is equal to which is equal to
2222nn which in turn is equal to which in turn is equal to 22nn++1.1.
So So FF((nn + 1) < 2 + 1) < 2nn+1+1. QED. QED