Lctur 7 Homwork #7: 2.2.1, 2.2.2, 2.2.3 (hnd in c nd d), Misc: Givn: M, NFA Prov: (q,xy) * (p,y) iff (q,x) * (p,) (follow proof don in clss tody) Lst tim: introducd our first computtionl modl th DFA. Tody w'll xpnd on th DFA modl. This xpnsion will not incrs th powr of th modl, ut will incrs th xprssivnss of th modl. Wht r w dding? Nondtrminism - i.., whn in givn stt, might l to slct from svrl trnsitions for givn input symol. For xmpl. ()* ()* Not: if thr is no trnsition spcifid for prticulr symol out of stt, th impliction is tht th trnsition would to "dd stt". Also Not: ccptnc is dfind s follows - string w Σ* is ccptd y NFA iff thr is som wy to gt to finl stt from th strt stt. Why introduc nondtrminism?
1) quivlnt to DFA 2) ut provids dditionl rprsnttionl flxiility And w'll llow vn mor flxiility in NFAs: 1) -trnsitions 2) trnsitions on strings rthr thn on symols An xmpl. Exrcis. Giv n NFA to rcogniz rls (rcll xrcis for DFAs). Df. A nondtrministic finit utomton (NFA or NDFA) is quintupl M = (K, Σ, Δ, s, F), whr K is finit st of stts Σ is n lpht s K is th strt stt F K is th st of finl stts Δ is th trnsition rltion, finit sust of K x Σ* x K (q,u,p) Δ iff u Σ* nd q u p W'll lrgly l to us th sm nottion nd dfinitions s for, ut w nd to mk fw modifictions: is "yilds in on stp"
(q,w) (q 1,w 1 ) iff w = uw 1 nd (q,u,q 1 ) Δ. * is th rflxiv, trnsitiv closur of w Σ* is ccptd iff (s,w) * (q,) nd q F. Not: tht th stt t ny point is dtrmind y wht's n rd - you cn't look hd. And thr is only limitd mmory of wht's n rd (just lik DFA). Lmm. Lt M = (K, Σ, Δ, s, F) NFA; q, r K x, y Σ* Thn (q, xy) * (r,) if, for som p K (q,x) * (p,) nd (p,y) * (r,). W will prov this y induction on th lngth of * in (q,x) * (p,), i.., on th numr of stps in th computtion. Bsis. Lt (q,x) * (p,) in 0 stps. Thn q = p, nd x =. So (q, xy) = (p, y) = (p,y) * (r,) Induction Stp. Assum (q,x) * (p,) nd (p,y) * (r,) (q, xy) * (r,), whn (q,x) * (p,) in < n stps. Now considr (q,x) * (p,) nd (p,y) * (r,), whr (q,x) * (p,) in n stps. Thn (q,x) = (q,ux 1 ) (q 1,x 1 ) * (p,), whr x = ux 1 (q,u,q 1 ) Δ (q 1, x 1 ) * (p,) in (n-1) stps
But thn (q 1,x 1 y) * (r,), y th induction hypothsis. So (q,xy) = (q,ux 1 y) (q 1,x 1 y) * (r,). Not tht th following is strongr vrsion tht holds for DFAs: Givn (p,y) * (r,) (q,xy) * (r,) iff (q,x) * (p,). Now, lt's show tht NFAs = DFAs. W'll sy tht two finit utomt M1 nd M2 r quivlnt iff L(M1) = L(M2). Thm. For ch NFA, thr is n quivlnt DFA. Proof will procd y construction. Tht is, w will show how to turn n NFA into DFA. To do this, w nd to: (1) limint trnsitions on. (2) limint trnsitions on strings of lngth > 1. (3) dd trnsitions to hv ctions for ll symols in givn stt. (4) limint multipl trnsitions from 1 stt. (2) is sy - just "strtch" th NFA y dding stts. Exmpl., q0 q1 q4 q2 q3
coms, p q0 q1 q4 q2 q3 (of cours, w'd nd to prov tht th "strtchd" NFA is quiv to th originl, ut it's firly ovious) Bsiclly, if (q,u,q 1 ) Δ, nd u > 1, thn w cn writ u = u1u2...un. To "strtch" th NFA, w dd trnsitions to Δ: (q,u1,p1), (p1,u2,p2),..., (pn-1,un,q 1 ). Lt's cll th initil NFA M = (K, Σ, Δ, s, F), nd th strtchd NFA M 1 = (K 1, Σ, Δ 1, s 1, F 1 ). Now, for th rmindr of th proof: W will viw th NFA s follows: t ny point in tim, it cn in mny stts t onc. Exmpl cont'd. On input, it cn in ny of {q0, q1, q2, q4} W cn viw this s singl stt in DFA. Th id is tht w'r uilding "multi-stts". Now, wht r susqunt stts? Anything tht cn rchd from on of ths on givn input symol. So, if th nxt symol wr "": {q0, q1, p, q3} Bsiclly, th DFA is simulting ll movs of th NFA simultnously.
Now, for w formliz this, lt's look t trnsitions on - ths nd to considrd spcilly. Dfin th stts tht r rchl from stt q on no input: E(q) = {p K 1 : (q,) * (p,)} or E(q) = {p K 1 : (q,w) * (p,w)} In our Exmpl. E(q0) = {q0, q1} E(q1) = {q1} E(q2) = {q2} E(q3) = {q3, q4} E(q4) = {q4} E(p) = {p} Bfor giving th forml construction, lt s tk ths ids nd complt th construction of DFA from th NFA ov: S" = {q0, q1} δ"(s", ) = E(q0) E(p) = {q0, q1, p} = t1 δ"(s", ) = E(q0) E(q2) = {q0, q1, q2} = t2 δ"(t1, ) = E(q0) E(p) = {q0, q1, p} = t1 δ"(t1, ) = E(q0) E(q2) E(q4)= {q0, q1, q2, q4} = t3 (FINAL STATE) δ"(t2, ) = E(q0) E(p) E(q3) = {q0, q1, p, q3, q4} = t4 (FINAL) δ"(t2, ) = E(q0) E(q2) = {q0, q1, q2} = t2 δ"(t3, ) = E(q0) E(p) E(q3) = {q0, q1, p, q3, q4} = t4 δ"(t3, ) = E(q0) E(q2) = {q0, q1, q2} = t2 δ"(t4, ) = E(q0) E(p) E(q3) = {q0, q1, p, q3, q4} = t4 δ"(t4, ) = E(q0) E(q2) E(q4) = {q0, q1, q2, q4} = t3
t1 t3 t2 t4