f all 1998 f ormal language theory dr r bo y er w eek f
play

F all 1998 F ormal Language Theory Dr. R. Bo y er W eek - PDF document

F all 1998 F ormal Language Theory Dr. R. Bo y er W eek F our: Equiv alence b et w een Finite Automata and Regular Expressions e -mo 1. Example of Con v ersion of NF A with v es with a DF A W e consider


  1. F all 1998 F ormal Language Theory Dr. R. Bo y er W eek F our: Equiv alence b et w een Finite Automata and Regular Expressions e -mo 1. Example of Con v ersion of NF A with v es with a DF A W e consider the NF A M = ( Q; � ; � ; q ; f q g ) ; where Q = f q ; q ; q ; q ; q g ; 0 3 0 1 2 3 4 with t w o letter alphab et � = f a; b g ; and with one accepting state f q g and 3 � is giv en b y the follo wing table: NF A T ransitions Computation of e -closures state a b e states e -closure 0 1 - 2 q f q ; q ; q ; q g 0 0 1 2 3 1 - - 3 q f q ; q g 1 1 3 2 4 - 1 q f q ; q ; q g 2 1 2 3 3 - 4 - q f q g 3 3 4 1 - 3 q f q ; q g 4 3 4 Computation of the states and transitions of the equiv alen t DF A: Since the original NF A has initial state f 0 g ; the corresp onding DF A has initial state whic h is its e -closure: E (0) = f 0 ; 1 ; 2 ; 3 g 1

  2. We ek F our : : : : : Equivalenc e b etwe en A utomata and R e gular Expr essions DF A T ransitions set of states a b f 0 ; 1 ; 2 ; 3 g E (1) [ E (2) = f 1 ; 3 ; 4 g E (4) = f 3 ; 4 g f 1 ; 3 ; 4 g E (1) = f 1 ; 3 g E (4) = f 3 ; 4 g f 3 ; 4 g E (1) = f 1 ; 3 g E (4) = f 3 ; 4 g f 1 ; 3 g ; E (4) = f 3 ; 4 g ; ; ; The accepting states are an y sets of states that con tain an accepting state of the original NF A. So, the accepting sets of the equiv alen t DF A are f 0 ; 1 ; 2 ; 3 g ; f 1 ; 3 ; 4 g ; f 3 ; 4 g and f 1 ; 3 g : 2. Prop osition. Let r b e a regular expression. Then there exists a NF A that accepts L ( r ) : The construction using induction on the n um b er of op erators in r : It is con v enien t to normalize the t yp e of NF A used in the construction. W e require that the NF A has one �nal state and no transitions out of this unique �nal state. It is easy to v erify that this do es not restrict the languages that will b e recognized. Base Case: r con tains zero op erators. Then either r = ; or r = � 2 � : F or r = ; ; the NF A has t w o states q and q ; where q is the start state and q f f 0 0 2

  3. We ek F our : : : : : Equivalenc e b etwe en A utomata and R e gular Expr essions is the accepting state. There is no edge connecting them. F or r = � ; again there are t w o states q and q as b efore. There is one edge connecting them f 0 lab eled with the letter � : The induction h yp othesis is that the result holds for all regular expressions with k op erators or less. No w, assume r is a regular expression con taining k + 1 op erators. There are three cases to consider. r = r [ r : Case One: 1 2 W e �rst state the construction informally . Then r = L ( M ), where M has 1 1 1 initial state q and unique accepting state f ; and r = L ( M ), where M 1 1 2 2 2 has initial state q and unique accepting state f : Then NF A that accepts the 2 2 union r will ha v e initial state q and unique accepting state f ; further there 0 0 are e -transitions from q to b oth initial states q and q and e -transitions 0 1 2 from the �nal states f and f to f : 1 2 0 In detail, let the NF A's b e giv en as M = ( Q ; � ; � ; q ; f f g ) and M = 1 1 1 1 1 1 2 ( Q ; � ; � ; q ; f f g ) where Q \ Q = ; : 2 2 2 2 2 1 2 W e create a new initial state q and a new �nal state f : T ak e M = ( Q [ 0 0 1 Q [ f q ; f g ; � [ S ; � ; q ; f f g ) ; where 2 0 0 1 2 0 0 �( q ; e ) = f q ; q g ; 0 1 2 2 n f f g ; 2 [ f e g ; �( q ; a ) = � ( q ; a ) ; q Q a � 1 1 1 1 �( q ; a ) = � ( q ; a ) ; q 2 Q n f f g ; a 2 � [ f e g ; 2 2 1 2 f f g �( f ; e ) = �( f ; e ) = 1 2 0 3

  4. We ek F our : : : : : Equivalenc e b etwe en A utomata and R e gular Expr essions r = r � r : Case Tw o: 1 2 Let M and M b e as ab o v e. Informally , the NF A that accepts r is obtained 1 2 b y connecting the �nal state of M to the initial state of M : More precisely , 1 2 M = ( Q [ Q ; � [ S ; � ; q ; f f g ) ; where 1 2 1 2 1 2 �( q ; a ) = � ( q ; a ) ; q 2 Q n f f g ; a 2 � [ f e g ; 1 1 1 1 f q g ; �( f ; e ) = 1 2 �( q ; a ) = � ( q ; a ) ; q 2 Q n f f g ; a 2 � [ f e g ; 2 2 2 2 r = ( r ) � : Case Three: 1 Let the NF A M = ( Q [ f q ; f g ; � ; � ; q ; f f g ) ; where 1 0 0 0 0 �( q ; e ) = f q ; f g ; 0 1 0 �( f ; e ) = f q ; f g ; 1 1 0 2 2 �( q ; a ) = � ( q ; a ) ; q Q ; a � 1 1 1 � [ 3. Example. W e apply the ab o v e construction to r = 0 1 � 1 : The class of languages accepted b y DF A's are closed under 4. Prop osition. the follo wing op erations: (1) union, concatenation, Kleene star; (2) complemen tation; 4

  5. We ek F our : : : : : Equivalenc e b etwe en A utomata and R e gular Expr essions (3) in tersection. Note: w e shall presen t t w o di�eren t constructions for in tersection. The �rst will b e somewhat implicit and mak es use of (2) while the second construction will use the cross pro duct of automata. Let M = ( Q ; � ; � ; s ; F ) and M = ( Q ; � ; � ; s ; F ) : Then w e let 1 1 1 1 1 2 2 2 2 2 � M = ( Q Q ; � ; � ; ( s ; s ) ; F ) 1 2 1 2 where 0 0 0 � (( q ; q ) ; a ) = ( � ( q ; a ) ; � ( q ; a )) ; q 2 Q ; q 2 Q ; a 2 � ; 1 1 2 � f ( f 0 2 0 2 g : F = F F = ; f ) : f F ; f F 1 2 1 2 The idea of the cross pro duct construction is that a computation in M actu- ally will trace out the computation in the t w o mac hines M and M sim ulta- 1 2 neously . � [ � Note: if the collection of accepting states is c hanged to ( F Q ) ( Q F ) ; 1 2 1 2 then M w ould accept the union L ( M ) [ L ( M ) : So, this construction will 1 2 pro duce a DF A that accepts the union rather than a NF A. 5. There are algorithms to answ er the follo wing questions ab out DF A's: (1) giv en w 2 � � ; is w 2 L ( M )? (2) Is L ( M ) = ; ? 5

  6. We ek F our : : : : : Equivalenc e b etwe en A utomata and R e gular Expr essions (3) Is L ( M ) = � � ? (4) Giv en t w o DF A's M and M ; is L ( M ) � L ( M )? 1 2 1 2 (5) Giv en t w o DF A's M and M ; is L ( M ) = L ( M )? 1 2 1 2 Pro of. If L = L ( M ) ; where M is a DF A, then L is a regular language; 6. Prop osition. that is, there is a regular expression r suc h that L = L ( r ) : W e shall study t w o constructions for this corresp ondence. The �rst is a graph based algorithm that builds up the regular expression as no des are deleted from the state diagram. The second is a metho d analogous to solving a linear system of equations. T o presen t the graph orien ted algorithm, w e need to in tro duce an ev en more general notion of NF A. It will ha v e the expanded prop ert y that its edges ma y 2 b e lab eled b y regular expressions, not simply b y a � or e: W e will denote this new class of automata b y GNF A. Next, w e describ e ho w a string w is accepted. No w, in an usual NF A, the mac hine matc hes an input sym b ol with an edge lab el in order to mak e a mo v e. F or a GNF A, the automaton will consume, p erhaps, more than one sym b ol in order to mak e the next mo v e. It will consume a substring that b elongs to the regular language whic h is denoted b y the edge lab el. F or a tec hnical normalization reason, w e shall assume that the GNF A M has a start state s that has NO edge coming in to it and that M has a unique 6

Recommend


More recommend