Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Mathematical Induction Proofs in Computer Science, Papers of Computer Science

An explanation of mathematical induction and its applications in proving statements about algorithms and abstract data types. It covers the first and second principles of mathematical induction, examples of induction proofs, and common pitfalls to avoid. The document also includes an exercise for the reader to prove a statement about a recursively defined function using strong induction.

Typology: Papers

Pre 2010

Uploaded on 08/19/2009

koofers-user-3jg
koofers-user-3jg 🇺🇸

10 documents

1 / 9

Toggle sidebar

Related documents


Partial preview of the text

Download Mathematical Induction Proofs in Computer Science and more Papers Computer Science in PDF only on Docsity! CMPS 101 Algorithms and Abstract Data Types Summer 2006 Induction Proofs Let )(nP be a propositional function, i.e. P is a function whose domain is (some subset of) the set of integers and whose codomain is the set {True, False}. Informally, this means )(nP is a sentence, statement, or assertion whose truth or falsity depends on the integer n. Mathematical Induction is a proof technique which can be used to prove statements of the form )(:0 nPnn  (“for all n greater than or equal to 0n , )(nP is true”), where 0n is a fixed integer. A proof by Mathematical Induction contains two steps: I. Base Step: Prove directly that the proposition )( 0nP is true. IIa. Induction Step: Prove ))1()((:0  nPnPnn . To do this pick an arbitrary 0nn  , and assume for this n that )(nP is true. Then show as a consequence that )1( nP is true. The statement )(nP is often called the induction hypothesis, since it is what is assumed in the induction step. When I and II are complete we conclude that )(nP is true for all 0nn  . Induction is sometimes explained in terms of a domino analogy. Consider an infinite set of dominos which are lined up and ready to fall. Each domino is labeled by a positive integer, starting with 0n . (It is often the case that 10 n , which we assume here for the sake of definiteness). Let )(nP be the assertion: “the nth domino falls”. First prove )1(P , i.e. “the first domino falls”, then prove ))1()((: 1  nPnPn which says “if any particular domino falls, then the next domino must also fall”. When this is done we may conclude )(:1 nPn  , “all dominos fall”. There are a number of variations on the induction step. The first is just a reparametrization of IIa. IIb. Induction Step: Prove ))()1((:0 nPnPnn  Let 0nn  , assume )1( nP is true, then prove )(nP is true. Forms IIa and IIb are said to be based on the first principle of mathematical induction. The validity of this principle is proved in the appendix of this handout. Another important variation is called the second principle of mathematical induction, or strong induction. IIc. Induction Step: Prove ))1())( :((:0  nPkPnknn Let 0nn  , assume for all k in the range nkn 0 that )(kP is true. Then prove as a consequence that )1( nP is true. In this case the term induction hypothesis refers to the stronger assumption: )( : kPnk  . The strong induction form is often reparametrized as in IIb: IId. Induction Step: Prove ))())(:((:0 nPkPnknn  Let 0nn  , assume for all k in the range nkn 0 , that )(kP is true, then prove as a consequence that )(nP is true. In this case the induction hypothesis is )( : kPnk  . 1 In terms of the Domino analogy, the strong induction form IId says we must show: (I) the first domino falls, and (II) for any n, if all dominos up to but not including the thn domino fall, then the thn domino falls. From (I) and (II) we may conclude that all dominos fall. Strong Induction is most often parameterized as in IId, and form IIc is uncommon. We present here a number of examples of IIa, IIb, and IId. Example 1 Prove that for all 1n : 6 )12)(1( 2 1    nnn i n i Proof: Let )(nP be the boxed equation above. We begin the induction at 10 n . I. Base step Clearly 6 )112()11(1 1 1 1 2  i i , showing that )1(P is true. IIa. Induction Step Let 1n and assume )(nP is true. That is, for this particular value of n, the boxed equation holds. Then 22 1 2 1 1 )1(      nii n i n i 2)1( 6 )12)(1(    n nnn (by the induction hypothesis) 6 )1(6)12)(1( 2  nnnn     6 1)1(21)1()1(   nnn (by some algebra) showing that )1( nP is true. We conclude that )(nP is true for all 1n . /// When writing an induction proof, always state the induction hypothesis explicitly. Also make note of the point in the proof where the induction hypothesis is used. Example 2 Let Rx  and 1x . Show that for all 0n : 1 1 1 0       x x x n i n i Proof: Here we will use form IIb. Again let )(nP be the boxed equation. We begin the induction at 00 n . I. Base step 1 1 1 0 0 0     x x xx i i , showing that )1(P is true. IIb. Induction Step Let 0n and assume that )1( nP is true, i.e. assume for this particular n that: 1 11 0      x x x n i n i . Then 2 element subset of V. Two vertices that are joined by an edge are said to be adjacent, and an edge is said to be incident with it’s two end vertices. Two edges are said to be adjacent if they are incident with a common end vertex. Thus in the example below: vertex 1 is adjacent to vertex 4, vertex 2 is incident with edge 26, and edge 45 is adjacent to edge 53. 1 2 3 4 5 6 V {1, 2, 3, 4, 5, 6} E {12, 14, 23, 24, 25, 26, 35, 36, 45, 56} Let Vyx , . An x-y path in G is a sequence of vertices starting with x and ending with y, in which each consecutive pair of vertices are adjacent. We require that all vertices other than x and y be distinct. If yx  , i.e. if the initial and terminal vertices in a path are identical, then the path is called a cycle. The length of a path is the number of edges traversed by the sequence. In the above example we have: A 1-6 path of length 5: 1, 2, 4, 5, 3, 6 A 1-6 path of length 3: 1, 4, 5, 6 Another 1-6 path of length 3: 1, 2, 3, 6 A cycle of length 6: 1, 2, 6, 3, 5, 4, 1 A cycle of length 3: 6, 2, 5, 6 A graph is said to be connected if it contains an x-y path for every Vyx , , otherwise it is called disconnected. The example above is clearly connected, while the following example is disconnected. 1 2 3 4 5 6 7 8 9 V {1, 2, 3, 4, 5, 6, 7, 8, 9} E {12, 15, 25, 26, 56, 37, 38, 78, 49} A subgraph of a graph G is a graph H in which )()( GVHV  , and )()( GEHE  . In the above example ({1, 2, 5}, {12, 15, 25}) is a connected subgraph, while ({2, 3, 6, 7}, {26, 37}) is a disconnected subgraph. A subgraph H is called a connected component of G if it is (i) connected, and (ii) maximal with respect to property (i), i.e. any other subgraph of G that contains H is disconnected. The above example clearly has three connected components: ({1, 2, 5, 6}, {12, 15, 25, 26, 56}), ({3, 7, 8}, {37, 38, 78}), and ({4, 9}, {49}). Obviously a graph is connected if and only if it has exactly one connected component. A graph G is called acyclic if it contains no cycles. A tree is a graph that is both connected and acyclic. The connected components of an acyclic graph are obviously trees. For this reason an acyclic graph is sometimes called a forest. The following graph is a forest with three connected components. 5 Observe that the number of vertices in each tree in this forest is one less that the number of vertices. This is true for all trees, as we now show. Example 5 For all 1n , if T is a tree on n vertices, then T contains 1n edges. Proof: Let )(nP be the boxed statement above. We begin at 10 n , and use the strong induction form IId. I. Base step If T has just one vertex, then it can have no edges, since in the definition of a graph, each edge must have distinct end vertices. Therefore )1(P holds. IId. Induction Step Let 1n and assume for all k in the range nk 1 , that )(kP is true, i.e. for any such k, all trees on k vertices contain 1k edges. Now let T be a tree on n vertices, pick any edge e in T, and remove it. The removal of e splits T into two subtrees, each having fewer than n vertices. (This follows from some elementary facts about graphs which we omit for the sake of brevity.) Suppose for the sake of definiteness that the two subtrees have 1k and 2k vertices, respectively. Since no vertices were removed, we must have nkk  21 . By our inductive hypothesis, these two subtrees have 11 k and 12 k edges, respectively. Upon replacing the edge e, we see that the number of edges originally in T must have been 111)1()1( 2121  nkkkk , as required. By the second principle of mathematical induction, all trees on n vertices have 1n edges. /// Induction Fallacies The next three examples illustrate some pitfalls to be avoided when constructing induction proofs. The result in Example A was proved correctly in Example 5. Here we give an invalid proof of the same fact that illustrates an argument which some authors have called “the induction trap”. Example A For all 1n , if T is a tree on n vertices then T has 1n edges. Proof: (Invalid) Base Step: If 1n then T has no edges, since each edge must have distinct end vertices. Induction Step: Let 1n and let T be a tree on n vertices. Assume that T has 1n edges. Add a new vertex and join it to T with a new edge. To be precise, the new edge has the new vertex at one end, and the other end can be any existing vertex in T. The resulting graph has 1n vertices and n edges, and is clearly a tree since connectedness is maintained and no cycles were created. By the principle of mathematical induction, all trees on n vertices have 1n edges. 6 First note that the base step is identical to that in Example 5, and is correct. For the induction step, the argument attempts to follow IIa, but does not do so. In this example )(nP is of the form )()( nBnA  where )(nA is the statement “T is a tree on n vertices”, and )(nB is “T has 1n edges”. The induction step should therefore be to prove, for all 1n , that )1()(  nPnP , i.e. ))1()1(())()((  nBnAnBnA . To prove this, we should assume )()( nBnA  , then assume )1( nA , then show as a consequence that )1( nB is true. In other words we should:  Assume all trees on n vertices have 1n edges  Assume T has 1n vertices  Show as a consequence that T has n edges The argument did not follow this format however. Instead it does the following.  Assume T has n vertices  Assume T has 1n edges  Construct a new tree from T having 1n vertices and n edges Therefore the argument was not a proof by induction. Some students would nevertheless hold that the argument is still valid, even though it is not a true induction proof. The next example shows convincingly that it cannot be valid. Example B For all 1n , if G is a connected graph on n vertices, then G has 1n edges. (False!) We notice right away that the above statement is false, since the graph below provides an elementary counter-example. But consider the following “proof” in light of Example A. Proof: (Invalid) Base Step: If 1n then G has no edges, since each edge must have distinct end vertices. Induction Step: Let 1n and let G be a connected graph on n vertices. Assume that G has 1n edges. Add a new vertex and join it to G with a new edge. The resulting graph has 1n vertices and n edges, and is clearly connected. By the principle of mathematical induction, all connected graphs on n vertices have 1n edges. Observe that Example B follows the format of Example A exactly. Thus if A is valid, so must B be valid. But the assertion “proved” in B is false! Therefore B cannot be a valid argument, and so neither is A. Example C All horses are of the same color. Proof: (Invalid) We prove that for all 1n : if S is a set of n horses, then all horses in S have the same color. The result follows on letting S be the set of all horses. Let )(nP be the boxed statement, and proceed by induction on n. Base Step: Let 1n . Obviously if S is a set consisting of just one horse, then all horses in S must have the same color. Thus )1(P is true. 7
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved