You are on page 1of 13
218 Theory of Computation 2.5, EQUIVALENCE OF DFA AND NFA (i). Asevery DFA san NFA, thé class of languages accepted by NFA’s includes the class of languages accepted by DF‘A’s. (ii) DFA can simulate NFA. (iil) Forevery NFA, there exist an equivalent DFA. Theorem For every NFA, there exists a DFA which simulates the behavior of NFA. If Lis the set accepted by NFA, then there exists a DFA which also accepts L. ’ Proof Let M=(Q, 5, 94, F, 8) be NFA accepting L we cofistruct DFA M' = (Q', 5, g,!, F', 8"), where @) — Q'=2° (power set of Q) (any state in Q' is denoted by [4y. 9,5 -+--9] Where Jy Gop - JE QD Gi) 4 = [9] (iii) Fis set of final states. . Before defining 8, lét us look at the construction of Q','g,! and F'. Mis initially at g,. On application of an input symbol say a, M can reach any of the states in 5g. 2). To describe M, just after application of the input symbol a, we require all the possible states that Mcan reach after the application of a, So, M’, has to remember all these possible states at any instant of time. AsM (NFA) starts with inital state 4 99 is defined as [g,]: InM! (DFA) the final state (F') can be subset of Q containing all final states of F. Now.we define By, Ip ee Gs A) = BQ 2) V BQ) 4) a 8 (Qua) equivalently, — 59) 9-9, = Pp PP) Sand only if 519, 9 he = Dy Pym P) ee Proof by Induction Input string x BG D= [2 Ipod) - ; 3 ifand only if : - i 5G P= (92 Gap G} Z eas) a : Scanned with CamScanner Finile Automata 249 mae Basis" ‘The result is trivial if string length is Oi.c, fe}=0 \ since g,! = [g].* must bee induction : Pdi Indueti : oe es ‘Suppose the hypothesis is true for inputs of length m. - Let xa be a string of length m+1 witha in E. Then 84g), x2) =816"9,), 2) By induction hypothesis BG." Dive ifand only if 89,4) = (PyPpom By definition of BP Pye a) ™ ifand only if Thus 8(q,',24) = [rrp fend ontyi . : Sfend only if - word ie 3 - ton we . which establishes the inductive hypothesis. ww Thus L(M)=L™M') Que , ample 2.17 Construct the DFA equivalent to the NFA M=((gi,9,}s {0,1}, 8, 4 (q,)) and 8 is defined as: Bee Tnputs 9 i States oa =) a van | oad | 4) ; (a ze Sr t : Qte- welt lane G1 2% (gn) es e ae pi 0 eee ras Scanned with CamScanner 2.20 Theory of Compttation Solution : DFA M! = (Q', {0,1}, 8, [g,], F') accepting L(M) as follows: Q'=22 (all subsets of Q={9.9,)), Vr, Ps ge ab Lah L490) Sah = la) since 5(q,.1)= (9,} 51CG}0)= fy 9, | since 8(9,,0)= {449} 5'(G,.0) => since 5(9,,0)= Slg I= [94 9) since 8(Gy.1) = {9.94} 8'(19¢9)10) = [dq 4) | since 5 ({9q4,), 0) i =8 (90) 8 (9,0) = (p95) V {9} = (G00) S474) = [24.9] since 8 (gq), 1) , =B (dg V5 (Gul) AY (909) = {907} DFA transition table is : Tnputs v 1 fad | [49] fal wi | | wad Uau.4) | Lae 9d} Coad Set of final states of M’ = ([9,], [qm%)) States Exainple 2.18 Construct a DFA equivalent to M=({45,9,}, (0,1) 8 95, {4,}) where 5 is given as: : Scanned with CamScanner Finite Automata 2.21 Solution : DFA M! = Q', 5,8), gy’. F’), where () the subset of the states’ {gy 9,) is Q i.e. (6 [g,) 91), oad) Gi) [q,] is initial state i) [g,] and {q, 4) are the final states, since these are the only states containing {final state in NFA). (iv) Bis defined as: 5'({9,),0) = [4 since 8 (0) = {90} BUg dD =lg)s since B dy!) = (4) BCG IO= Ig) since 8 (Gy1)= (a) BGAN) = [dog since 8 yl) = (gy 4) since (4,,9,] is a new state, it has to be defined. 2 BCqy7h0) = 5449} . = 8 (qy0) V8 (9,0) = (a) Y (91) = (oH) = (09) BXlgeqh = 8 Udon) 1) = BGI) V5 Gy!) = (9) U (Goo) = {90 0} = Wo 9 : DFA transition table is : : Example 2.19 Construct a DFA for the given NFA M=({9y 4+9.}s (2, 5), 8, go. {,}) where 8 is given as: qo. \A% 4) % {ach a o Scanned with CamScanner Solution: We construct M! (Q', {4b), [gh 84 F)” Q contains all fubeats of Olt wo) ?P a (00h Eb fas Uoypd (tah (4 41h [4904597 BLqeha) = [4) since 8 (dq) = (4094) 5'([9))0) = [4], since 5 (gb) = (9,) 5((9,),4) = 4, since 8 (7,4) => 5X(C9,15) = [994] since 8 (9,6) = {994} : ” since we'have new state [g,,9,), we have to find its transitions: fo~ “ee Bgy9,), 2) = 8((qy9,}, 4) j 8 gya) V5 (gy) . = (495) ¥ (90) = (dont = [9091 * BYE 99) 5) = 8 (gy), 0) 8 (yb) V5 (9,6) = (Vg) = 9» 9) : = (a) Since [g,, 9,] is a new state, its transition has to be defined. 2 L9G) = 8 (99), 4) = 8 (4ya)U5 (9a) = {qo} V 19} = (gh = al - 59.42), 5) = 5 ({9y9,}, 5) 5 (9,6) 5 (Gyb) : ot AD) Y (oa) . mp ati thoy 2 = (Gea) * 2 i = (ga) * Scanned with CamScanner Finite Automata DFA transition table is = inputs States —F b 7 | aa | i | 8 | ead faa) | (oad | (v9) fap9) | (ae) (9091) ‘The final state in DFA is F¥= ((g,), [ay93)) since it contains q, which is final state int NPA Example 2.20 . Construct a DFA for the given NFA M= {95-9 Inn Go)» (0, 1s 5, do (43})s where B is States Inputs 7 I Ge Tae Gl] (0d n (a) (a) L {a} (9) % % {a} Solution : We construct M'= (Q!, {0,1}, 8! [gah an equivalent DPA which accepts L(M) Q contains all subsets of Q = (6, Lagh Lah (as) {95} [44h [44h [dues [992s [qr Qyh [49° 9ph [Gos 44> Fab» [Ir 4) [9 93) [4o9n,99} (4°99) & oe 51a) © = [dog SLA) ~ (29) Hh) = Lah since 5 (4g!) = (9) 5'la69)0) = 8(f4959) = 5 (40) V8 0,0) = (499) ¥ (4) ee 5 {90993} = [409%] » Bed. = Be IID - 5B Gp V3 My!) eh {9} Vg) \ 0 Scanned with CamScanner 224 Theory of Comput = (94) ° = (9) la.4,9,1,0) Hew won Beda) = 5'4099p I) 0) = 5 9, 9449), 0) 5 (40) 085 (0) U5 (4,0) {90091} U (9) 0 {a5} {90 Gis 4a» 95) 0 Ma» 95) 8 (140 4G) 1) 8 (91) 48 (9,1) V8 (g,,1) (96) Y {9} L {g,) {9 993) (90 94) 5 (0 G1» dy» 93)2 0) 8 (90) 8 (g,,0) V8 G,,0) US (9,0) {09,3 V (9) V (9) v (9) = (90 9 Ind) " B49 95h 1) = 8400995), 0) (Iv 4» 9) 8 (bd dys By Ghs 1) 8 (451) 8 Gul) U5 (G51) U5 (1) {90} V9} Y {9,) (9) {4 Fa» 95) [9% G0 G) = 5 (£4 9%} 0) 5 (4,0) V5 (4,0) 5 (9,,0) {I 94) Y {9} VO} = (de Id) 89044) (» 94) 5 ({90 9» GY) 5 (gy 1) V5 G1) 5 (gy1) (90) Uta) 4 (92h {9 9 93) [40° 91» 9a) Scanned with CamScanner 2.25 Finité Automata a DFA transition table is : i Inputs States e a a - td | Goad ta) ae @: ( (a9) |} Wodrdd | load) : a Z [9 9»9) | lo Iv In 91] (0% I] Le ip (4993) | In 4a) | (90 90) y yY 5 | eG | [oe I Te 95} | [or Io ry a oN The final states are A® P= [gy 9 95] M4 [4 Iv I» M9) wre Dp a 2.6 Finite Automata with e-moves . E ‘The NFA can be extended to include traniitions on emptyinput e. 2.6.1 Definition of NFA with ¢-moves The NFA with e nioves is defined by 5 tuple (or) quintuple as si 8, gu. F) with all components as before and 8 : Qx (U(E}) (2%) ‘The intention is that 5 (g, a) will consists of all states p such that there is a transition labeled ‘a’ from q to p,-where a is cither or any symbol in 5. ce ee rly as NFA, except 8. (Q, Example 2.21 ¥ siset 3p be esi ws nite autorhata with & moves \w ® i : wey * c wv a ©. of © ‘The transition diagram of the NFA accepts the language consistin, followed ky any number of 1’s followed by any number of 2’s, g of any number of 0's with arcs labeled 0, 0, €, €, 2. For example, te string w= 02 i atcepted by the NFA along the path—¢ fe 44.4 10 Zor Tor Ti» Va» Js 2.6.2 Epsilon Closures ‘We extend the transition function 6 to a fimetion 2 : ee §!QxX* 42% such that 4 i ¢ id slates Pp such that we can go from q to p along a path labeled w, also inch fine, leo) wil be Constructing § it will be important to compute the set of states Tee eet labeled. sing e- transitions oly. We use ¢- CLOSURE(g) i ‘eachable fiom a given sta “is a pallvivom q top labeled ¢. {@) to denote the set ofl vertices p suet thatthe, Scanned with CamScanner 2.26 Theory of Computation (i) Let P be set of states, (ii) Then e- CLOSURE (P) = Ue -CLOSURE(g) me Example 2.22 Construct the trahsition table and e-CLOSURE for the Figure given in the previous page. Solution: _ (The e~ CLOSURE (9) = (9955 a) e» the path consisting of g, alone is a path from q, to g,with all arcs labeled ¢, The path from g, to g, labeled e shows that g, is in'e- CLOSURE (q,) and path 9, 99, shows q, is in ¢ - CLOSURE (q,). Similary . Hs 8-CLOSURE (9,) = (4.4) a e-CLOSURE (4,)= (9,) . (oe 2.6.3: ‘Transition function and language of e-NFA " ‘The transition function {is defined ast § (4 : . nel °) © § @e=e,GLostme (@: Gi) For win D*, and a in _ § (Gwe) = CLOSURE 0, lace Boi ht ae Fam pind(.0) i) 5 Ra)= {Y,5(G0) 4 A Gy) § Rms YG.) avy vwvyvuvVv Vv VeVvesweeseehsermUmUmDFlmUmDUD® ‘The language accepted by NFA with ¢ - move is defined as: 3 » LOM) = (wf (q,3») coniains a stat in F) Scanned with CamScanner Finite Automata Example 2.23 Consider the NFA given below and find 5(9,, 01) 4 Solution : Baye) = e-CLOSURE ()* ( ) -O Thus (qq0) =#-CLOSURE (6(Fq. 899) "Se CLOSURE (8 (£9059 92)» 0)) = e-CLOSURE(8(9,.0)V5(9,,0)U 8p) = e-CLOSURE (tg,}U (4) U (4) = ¢-CLOSURE ({9,}) = (dy 94) ftom equation | “Then 5(qy01) = 6-CLOSURE (8 (6(4y 0)!)) + SE-CLOSURE 6 ((994 02} 0) = -CLOSURE(5(91)J5(9 10 5 p1))- = e-CLOSURE ($V {9,) V (4) = 6-CLOSURE ((9,)) = {qj-4,) (because from q,,0n &-transition we can reach q, and also remain ing, itself) 4 t «Since 8(g,) 01) = {4 4.) Which contain final state {g,) itis an accepted string. 2.7 “EQUIVALENCE OF NFA’S WITH. AND WITHOUT ¢ - MOVES ‘Theorem IfL is accepted by NFA with e-transitions, than Lis accepted by an NFA without e-transitions. ‘Proof "Let M=(Q, 5, 8, gy F) be an NFA with ¢ - transitions. Construct M! which is NFA without ¢ - - transition. 5 MS (Q,5, 54,9 F!) where Fl = FU {g,} ife-CLOSURE (q,) contains a state of F. ‘F otherivise Scanned with CamScanner Theory of Computztion fi 2.28 i i \ By induction : t and § are same Sand are different Let x be any string - By) = § (Gy) ‘This statement is not truc if x=e because (gy #)= {gg} and § Go ®) = & CLOSURE (q,) Basis step Lx] = 1 x isa symbol whose value is a 8'Gu2) = § (ya) (because by definition of § ) Induction step let x= wa where ais in E. 5'(qy. a) = 8! (By, W), a) = B(§ Gy), 4) = 8! (p, a) [because by inductive hypothesis Gy MS (Jo) = PSY] Now we must show that 8G, a)= § Oy wa) But ei sie.a) = ,2,8!(.0)= 2,8(02) = § (§ G9) = § (oa) =§ (>) Hence 8'Gp* § Mo) re 2.24 Fxample e-moves from NFA Construct a NFA without elt ee 4 Scanned with CamScanner Thoory.of Computation Finite Automata SURE (4)* (47) LetM = (CE, 998; F) be NFA with etansition M! = (Q,5, 9, 51, F#) be NEA without e+ eas : Ce gates) Az (wes G8) =e CLOSURE Gd (sii ~ BQH) » § (969) * =eCLOSURE 6 (§ (940.0) 23 Dros =e CLOSURE (6 ((29,)» 0) els = e-CLOSURE((4,09-5(6,0) 3 =e-CLOSURE ((9,)V{4)) oe ina + =e-CLOSURE (g)) ye a fi ep (because of D) » = ©-CLOSURE (6 (§ (9»-®)1)) a Ey 4, . i? iD = e-CLOSURE (6 ((49))» )) : =£-CLOSURE(5(q_1 84) gree _“OCLOSURE HY (5) e e-CLOSURE (9,) aol ; : from q, on eitcan g6t0 g, only) 00) > 5,0). = FG), Ms =e-CLOSURE (5 (§ (@y #)9)) i] @ = fsPLOSURE 6 (la) 0) ay ota osunstea,00 e ules =-CLOSURE (#) Lo + ‘ ao” BG) = § Ge) af vn =eCLOSURE (6 (§ (9,8).1)) ap 0? we 6 po “CLOSURE (a1) ae Ds eats or 204 A LcrosurE 6G.) vy ache e a =c-CLOSURE (9,) a @ eo Pinwnhe BD De 0h ; Nee : EON cw Scanned with CamScanner ieury vb Compurauon ‘Transition diagram and table is as follow: . ss SOLVED PROBLEMS : F 1, Construct a DFA equivalent to the given NFA M = ({p,g,r-5}, (0:1), 8p, {s}) where dis > sivenas: . 3 > Mylution : We construct DFA M'= (Q', E, 8, p, F'), where Q' = 2° DB - 5. 0)= ah since (0,0 a} oo Sag! my. 8) = Ip) since 5 (ip), =}: Since [p,q] is new state, we have to find its transitions on ‘0’ and 1” A spa): )=(th.g}, 0-3.) USED - = gu (r} = tp.gr} =o) > strait = 6.4), = 80.1) U8) 2 * = 9)Ut)= b= BA Since [p.g.7) & [p,r] are new states, we have to find its transitions. DB scrqrio = tar). =B.NUVEENVEED - = 2 S = wave tars) Scanned with CamScanner

You might also like