Finite Automata With � -T ransition s Allo w to b e a lab el on arcs. � � Nothing else c hanges: acceptance of w is still the existence of a path from the start state to an accepting state with lab el w . ✦ But � can app ear on arcs, and means the empt y string (i.e., no visible con tribution to w ). Example 0 Start 1 � q r s 0 � 1 � 001 is accepted b y the path q ; s; r ; q ; r ; s , with lab el 0 � 01 � = 001. Eliminati on of � -T ransitions � -transitions are a con v enience, but do not increase the p o w er of F A's. T o eliminate � -transitions: 1. Compute the transitiv e closure of the arcs � only . ✦ Example: � q r s � ! f q g ; ! f r s g ; ! f r s g . q r ; s ; 2. If a state can reac h state b y � -arcs, and p q there is a transition from to on input q r a (not � ), then add a transition from to on p r input a . 3. Mak e state an accepting state if can reac h p p some accepting state b y � -arcs. q 4. Remo v e all � -transitions. 1
Example 0 Start 1 q r s 0,1 0,1 Regular Expressions An algebraic equiv alen t to �nite automata. � Used in man y places as a language for describing simple but useful patterns in text. Op erators and Op erands If E is a regular expression, then L ( E ) denotes the language that E stands for. Expressions are built as follo ws: � An op erand can b e: 1. A v ariable, standing for a language. 2. A sym b ol, standing for itself as a set of strings , i.e., stands for the language f a g a (formally , L ( a ) = f a g ). 3. � , standing for f � g (a language). 4. ; , standing for ; (the empt y language). � The op erators are: 1. +, standing for union. L ( E + ) = L ( E ) [ F L ( F ). 2. Juxtap osition (i.e., no op erator sym b ol, as in xy to mean x � y ) to stand for c onc atenation . L ( E F ) = L ( E ) L ( F ), where the concatenation of languages L f xy j g . and M is x is in L and y is in M � � � � 3. to represen t closur e . L ( E � ) = L ( E ) , f � g [ [ [ [ � � � where L � = L LL LLL . � P aren theses ma y b e used to alter grouping, � whic h b y default is (highest precedence), then concatenation, then union (lo w est precedence). 2
Examples � L ( 001 ) = f 001 g . � � L 0 + 10 � ) = f 0 ; 1 ; 10 ; 100 ; 100 0 ; : : : g . � � � � � � L 0 ( 0 + 1 ) = the set of strings of 0's and 1's, of ev en length, suc h that ev ery o dd p osition has a 0. Equiv alence of F A Languages and RE Languages � W e'll sho w an NF A with � -transitions can accept the language for a RE. � Then, w e sho w a RE can describ e the language of a DF A (same construction w orks for an NF A). � The languages accepted b y DF A, NF A, � -NF A, RE are called the r e gular languages. RE to � -NF A � Key idea: construction of an � -NF A with one accepting state is b y induction on the heigh t of the expression tree for the RE. � Pictures of the basis and inductiv e constructions are in the course reader. Example W e'll go o v er the general construction in class and � � � w ork the example of 0 ( 0 + ) . 1 F A-to-RE Construction Tw o algorithms: 1. : giv es smaller expression, in State elimination general, and easier to apply . Co v ered in course reader. 2. A simple, inductiv e construction, whic h w e'll do here (also in reader). � Let b e a F A with states 1 ; 2 ; n . A : : : ; ( k ) � Let b e a RE whose language is the set of R ij lab els of paths that go from state to state i j without an y state n um b ered p assing thr ough ab o v e . k � Construction, and the pro of that the expressions for these RE's are correct, are inductions on k . Basis : k = 0. P ath can't go through any states. 3
� Th us, path is either an arc or the n ull path (a single no de). (0) � If i 6 = j , then R is the sum of all sym b ols ij a suc h that A has a transition from i to j on ( ; sym b ol a if none). � If = , then add to ab o v e. i j � Induction : Assume w e ha v e correctly dev elop ed ( k � 1) ( k ) expressions for the R 's. Then for the R 's: ( k ) ( k � 1) ( k � 1) ( k � 1) ( k � 1) � R = R + R ( R ) � R ij ij ik k k k j : A path from to that go es Pr o of it works i j through no state higher than either: k 1. Nev er go es through k , in whic h case the path's ( k � 1) lab el is (b y the IH) in the language of , R ij or 2. Go es through k one or more times. In this case: ( k � 1) ✦ R con tains the p ortion of the path ik that go es from to for the �rst time. i k ( k � 1) ✦ ( R ) con tains the p ortion of the path � k k (p ossibly empt y) from the �rst visit to k the last. ( k � 1) ✦ R con tains the p ortion of the path k j from the last k visit to j . Final step : The RE for the en tire F A is the sum ( n ) (union) of the RE's R , where i is the start state ij and j is one of the accepting states. � Note that sup erscript ( n ) represen ts no restriction on the path at all, since is the n highest-n um b ered state. Example The follo wing is the \clamping" automaton, with states named b y in tegers: 0,1 0 Start 1 1 3 1 2 0 Some basis expressions: (0) � = � . R 11 4
(0) � = 1 . R 12 (0) � R = � + 0 + 1 . 22 (0) � R = 1 . 31 (0) (0) � ; . R = R = 32 21 Tw o inductiv e examples: (1) (0) (0) (0) (0) � R = R + R ( R ) � R = ; + 1 � � 1 = 11 . 32 32 31 11 12 ✦ Uses algebr aic laws : � � = � ; R� = �R = R ( � is the iden tit y for con tatenation); ; ; ( ; + R = R + = R is the iden tit y for union). (1) (0) (0) (0) (0) � R = R + R ( R ) � R = � + 0 + 1 + 22 22 21 11 12 ; � � 1 = � + 0 + 1 . ✦ Additional algebraic la w used: ; R = R ; = ; ( ; is the annihilator for concatenation). 5
Recommend
More recommend