2 u 1 v 2 t 1 pro ving the inductiv e step if and only if
play

= 2( u + ) 1. v = 2 t 1, pro ving the inductiv e - PDF document

Inductiv e Pro ofs Pro v e a statemen t ( X ) ab out a family of ob jects S (e.g., in tegers, trees) in t w o parts: X 1. Basis : Pro v e for one or sev eral small v alues of X directly . 2. : Assume


  1. Inductiv e Pro ofs Pro v e a statemen t ( X ) ab out a family of ob jects S (e.g., in tegers, trees) in t w o parts: X 1. Basis : Pro v e for one or sev eral small v alues of X directly . 2. : Assume ( Y ) for \smaller Inductive step S Y than" ; pro v e ( X ) using that assumption. X S Example A binary tree with lea v es has 2 n � 1 no des. n � F ormally , S ( T ): if T is a binary tree with n lea v es, then T has 2 n � 1 no des. � Induction is on the = n um b er of no des of size . T Basis : If T has 1 leaf, it is a one-no de tree. 1 = 2 � 1 � 1 so OK. : Assume ( U ) for trees with few er Induction S no des than . In particular, assume for the T subtrees of T . � m ust b e a ro ot plus t w o subtrees and . T U V � If U and V ha v e u and v lea v es, resp ectiv ely , and T has t lea v es, then u + v = t . � By the inductiv e h yp othesis, and ha v e U V 2 u � 1 and 2 v � 1 no des, resp ectiv ely . � Then T has 1 + (2 u � 1) + (2 v � 1) no des. ✦ = 2( u + ) � 1. v ✦ = 2 t � 1, pro ving the inductiv e step. If-And-Only-If Pro ofs Often, a statemen t w e need to pro v e is of the form \ X if and only if Y ." W e are then required to do t w o things: 1. Pro v e the : Assume and pro v e . if-p art Y X 2. Pro v e the only-if-p art : Assume X , pro v e Y . Remem b er: � The if and only-if parts are of eac h c onverses other. � One part, sa y \if X then Y ," sa ys nothing ab out whether is true when is false. Y X � An equiv alen t form to \if X then Y " is \if not Y then not X "; the latter is the c ontr ap ositive of the former. 1

  2. Equiv alence of Sets Man y imp ortan t facts in language theory are of the form that t w o sets of strings, describ ed in t w o di�eren t w a ys, are really the same set. T o pro v e sets S and T are the same, pro v e: � is in if and only if is in . That is: x S x T ✦ Assume is in ; pro v e is in . x S x T ✦ Assume is in ; pro v e is in . x T x S Example: Balanced P aren theses Here are t w o w a ys that w e can de�ne \balanced paren theses": 1. Gr ammatic al ly : a) The empt y string � is balanced. b) If w is balanced, then ( w ) is balanced. c) If w and x are balanced, then so is w x . 2. : is balanced if and only if: By Sc anning w a) has an equal n um b er of left and righ t w paren theses. b) Ev ery pre�x of has at least as man y w left as righ t paren theses. � Call these GB and SB prop erties, resp ectiv ely . � Theorem: a string of paren theses is GB if w and only if it is SB. If An induction on j w j (length of w ). Assume w is SB; pro v e it is GB. Basis : If w = � (length = 0), then w is GB b y rule (a). � Notice that w e do not ev en ha v e to address the question of whether � is SB (it is, ho w ev er). Induction : Supp ose the statemen t \SB implies GB" is true for strings shorter than w . 1. Case 1: w is not � , but has no nonempt y pre�x that has an equal n um b er of ( and ). Then w m ust b egin with ( and end with ); i.e., w = ( x ). ✦ x m ust b e SB (wh y?). ✦ By the IH, x is GB. ✦ By rule (b), ( x ) is GB; but ( x ) = w , so w is GB. 2

  3. 2. Case 2: = , where is the shortest, w xy x nonempt y pre�x of w with an equal n um b er of ( and ), and y 6 = � . ✦ x and y are b oth SB (wh y)? ✦ By the IH, x and y are GB. ✦ w is GB b y rule (c). Only-If An induction on j w j . Assume w is GB; pro v e it is SB. Basis : w = � . Clearly w ob eys the conditions for b eing SB. : Assume \GB implies SB" for strings Induction shorter than , and assume 6 = � . w w 1. Case 1: is GB b ecause of rule (b); i.e., = w w ( x ) and is GB. x ✦ b y the IH, is SB. x ✦ Since has equal n um b ers of ('s and )'s, x so do es ( x ). ✦ Since has no pre�x with more ('s than x )'s, so do es ( x ). 2. Case 2: w is not � and is GB b ecause of rule (c); i.e., w = xy , and x and y are GB. ✦ By the IH, x and y are SB. ✦ (Aside) T ric kier than it lo oks: w e ha v e to argue that neither x nor y could b e � , b ecause if one w ere, the other w ould b e w , and this rule application could not b e the one that �rst sho ws w to b e GB. ✦ has equal n um b ers of ('s and )'s xy b ecause and b oth do. x y ✦ If had a pre�x with more )'s than ('s, w that pre�x w ould either b e a pre�x of (con tradicting the fact that has no x x suc h pre�x) or it w ould b e follo w ed b y x a pre�x of (con tradicting the fact that y y also has no suc h pre�x). ✦ (Aside) Ab o v e is an example of pr o of by c ontr adiction . W e assumed our conclusion ab out w w as false and sho w ed it w ould imply something that w e kno w is false. 3

  4. Languages � A lphab et = �nite set of sym b ols, e.g., f 0 ; 1 g ( binary alphab et) or ASCI I. � String = �nite sequence of sym b ols c hosen from some alphab et, e.g., 01101 or abracadabra . � = set of strings c hosen from some L anguage alphab et. ✦ Subtle p oin t: the language ma y b e in�nite, but there is some �nite set of sym b ols of whic h all its strings are comp osed. Example; Languages � The set of all binary strings consisting of some n um b er of 0's follo w ed b y an equal n um b er of 1's; that is, f �; 01 ; 0011 ; 00 0111 ; : : : g . � C (the set of compilable C programs). � English. Finite Automata An imp ortan t w a y to describ e certain simple, but highly useful languages called \regular languages." � A graph with a �nite n um b er of no des, called states . � Arcs are lab eled with one or more sym b ols from some alphab et. � One state is designated the start state or initial state . � Some states are �nal states or ac c epting states . � The language of the F A is the set of strings that lab el paths that go from the start state to some accepting state. Example � Belo w F A scans HTML do cumen ts, lo oking for a list of what could b e title-author pairs, p erhaps in a reading list for some literature course. � It accepts whenev er it �nds the end of a list item. 4

  5. � In an application, the strings that matc hed the title (b efore ' ) and author (after) ' by w ould b e stored in a table of title-author pairs b eing accum ulated. an y non-tag Start < OL > , < UL > < LI > 1 2 3 space 4 b 5 < LI > y 6 space 9 8 7 < /OL > , < /UL > < /LI > an y non-tag 5

Recommend


More recommend