Nme nd St.ID#: CSE96 Prelim I Answer Key Spring 2017 (1) (24 pts.) Define A to e the lnguge of strings x {, } such tht x either egins with or ends with, ut not oth. Design DFA M such tht L(M) = A. A node-rc digrm tht shows the strt nd finl sttes clerly is good enough, plus the correctness of your M must e cler either from your theoreticl technique or from strtegic comments on how M works. Answer: First let us design DFA M 1 for the ends with property: strt 1 2 Now tke M 1 to e complementry mchine in which sttes 1 nd 2 re ccepting nd stte is not. We design M to hve two non-ccepting sttes s nd p plus copy of ech mchine, for 8 sttes in ll. At s, if the first chr of the input x is then we know it didn t strt with, so y the XOR we need x to end in. Since we lredy hve one, the rc goes to stte 2 of M 1, not stte 1. If x egins with n then we go to stte p. At p, if we then get we know gin tht x doesn t strt with, nd we re ctully in the sme sitution s when x egins with, so we go to stte 2 of M 1. If we get n t stte p, then tht s the second t the strt, so we shift mode into not wnting to end in. So we go to the strt stte 1 of the complementry mchine M 1. Tht completes M such tht L(M) = A nd lso its verifiction: p 1 2 strt s 1 2
The other good wy ws to drw second smll DFA M 2 such tht L(M 2 ) = ( ) nd then mke M to e the Crtesin product of M 1 nd M 2 using XOR. M 2 is in some wys simpler to drw thn M 1 ut it hs ded stte which techniclly mkes 4 sttes totl nd since the processing hs to go on even fter the prt is ded you cn t mke it ded stte for ll of M. So you re doing 4 Crtesin product which could mke you lile for 12 sttes, ut if you crry it out in n economicl s-needed mnner then you get the sme 8 sttes s ove. Let s cll the sttes of M 2 s s 2, q 2, r 2, d 2 to go with 1, 2, for M 1 s ove. With Crtesin lels, the sttes 1, 2, in the ove digrm ecome (1, d 2 ), (2, d 2 ), (, d 2 ) since they re pired with the ded stte of M 1. And s = (1, s 2 ) since it is the strt stte of oth mchines, nd p = (1, q 2 ). Then 1 = (1, r 2 ) nd since r 2 is nirvn stte of M 2, the remining lels re 2 = (2, r 2 ) nd = (, r 2 ). The finl sttes re (, d), (1, r 2 ), nd (2, r 2 ), eing the rechle sttes tht hve either from M 1 or r 2 from M 2, ut not oth. (2) (18 + + 6 = 27 pts.) Let N = (Q, Σ, δ, s, F ) e the NFA with Q = { 1, 2, }, Σ = {, }, s = 1, F = { }, nd δ given y the rcs (1, ɛ, ), (1,, 1), (1,, 2), (2,, 1), (2,, ), nd (,, 2), shown y: ɛ 1 2 () Clculte DFA M such tht L(M) = L(N) (no comments needed if the method is cler). () Find string x such tht N cn process x from 1 to ny one of its three sttes figurtively speking, such tht x lights up ll three sttes of N. (c) Are there strings w tht N cnnot process t ll, so tht N dies? Most in prticulr, cn w hve the form xz tht is, egin with your string x from prt () which turned ll sttes on? Answer: The ɛ-rc gives us Whenever 1, then lso nd in prticulr mkes the strt stte of the DFA e {1, } not just {1}. This is crucil ecuse ɛ elongs to L(N) ut we need the to recognize tht the strt stte of M is ccepting. Strting this wy lso lets us henceforth only hve to worry out triling ɛ s y the Romn soldier resoning in lecture. We cn thus mke tle tht is IMHO more useful thn wht the text does: δ ) = {1, 2, } δ (1, ) = (1, δ ) = {1, } δ (2, ) = {} (2, δ ) = δ (, ) = {2}. (, Doing redth-first serch from S = {1, } then gives us: (S, ) = δ (1, ) δ (, ) = {1, 2, } = {1, 2, } (S, ) = δ (1, ) δ (, ) = {2} = {2}.
Notice we lredy lit ll the lights on n. Since we got there on n, we utomticlly know tht ({1, 2, }, ) = {1, 2, }, ut this need not e true of ({1, 2, }, ). Indeed, we get ({1, 2, }, ) = δ (1, ) δ (2, ) δ (1, ) = {} {2} = {2, } only, which is wht egins the long decline nd ultimte fll of the Nondeterministic Empire. Soldiering on with redth-first serch, we need to expnd the new sttes {2} nd {2, }. We get: ({2}, ) = δ (2, ) = {1, } (ck to strt) ({2}, ) = δ (2, ) = {} (ut this counts s new) ({2, }, ) = δ (2, ) δ (, ) = {1, } = {1, } ({2, }, ) = δ (2, ) δ (, ) = {} {2} = {2, } (not new) ({}, ) = δ (, ) = (our 6th stte ut it s ded) ({}, ) = δ (, ) = {2} (not new). Since we utomticlly know (, ) = (, ) =, we re done we ve closed the mchine M. The finl sttes of M re everything with so we get: strt {1, } {1, 2, } {2, }, {2} {} Note we lredy nswered prt () with x =. For (c) note from the DFA digrm tht there is long nd tortuous pth from the ll-on stte {1, 2, } to the ded stte in five steps processing z =. This mkes xz = unprocessle y N. The shortest dying string from the strt is, ut hs the extr insult-plus-injury of first turning ll the sttes on. (Grding ws 4 points for w = ut xz = (or the equivlent) needed for the full 6 points.) () (5 5 = 25 pts.) Multiple Choice. Note the first three questions refer to the NFA N in prolem (2). 1. When we eliminte stte 2 from the NFA N in prolem (2), we need to updte which items involving only sttes 1 nd : () Just the two rcs in the digrm, (1,, 1) nd (1, ɛ, ). () Besides those two rcs, we need to dd self-loop (,, ), ut nothing from ck to 1. (c) Becuse stte 2 hs incoming nd outgoing rcs from oth 1 nd, we need to updte 2 2 = 4 entries. (d) Becuse of the ɛ-rc, we cn just comine the sttes 1 nd together, getting simple 1-stte GNFA fter eliminting stte 2.
Answer: (c). 2. Regrding the lnguges L 1,1 nd L 1, of N whether efore or fter eliminting stte 2 it doesn t mtter which of the following is true for this prticulr mchine? () L 1,1 L 1,. () L(N) = L 1,1 L 1,. (c) L 1,1 contins ( ), which simplifies to. (d) All of the ove. Answer: (d) All of the ove. Prt () comes ecuse of the ɛ-rrow it isn t true in generl nd () follows from tht nd the fct tht L(N) = L 1, y definition. When you crry out the step of of eliminting stte 2 ove, you get loop on s well s the originl loop on t stte 1. Since the -loop cn e simulted y two go-rounds of the -loop, which is nother wy of sying (), you cn just discrd it, which mens ( ) =. And ws lredy prt of L 1,1.. A vlid regulr expression for L(N) is: () ( ( ɛ)() ) (ɛ )(). () ( ) since stte 1 could e ccepting too. (c) ( ) since N ccepts ll even-length strings. (d) ( () ) (). Answer: Without going through the whole NFA-to-regesx exercise, we cn eliminte () ecuse ( ) is ll strings nd we know there re strings tht N rejects. And we cn eliminte (c) ecuse we found n odd-length string tht N ccepts (nd N doesn t ccept ll even-length strings nywy, it s fke news ). Tht leves () versus (d), oth of which look close. Well, the troule with (d) is tht the prt in the middle is mde mndtory, which rules out not only ɛ ut lso the ll-lights-on string s possiilities. Hence it s too strict. Item () hppens to e right ut there re unch of other right ones including tking the hint from 2(c) nd simplifying it to ( () ) (ɛ )(). 4. The symmetric difference of lnguge A with its complement à in Σ lwys equls: (). () { ɛ }. (c) A. (d) A no wit! Σ. Answer: Well, I intended to mke question whose nswer ws, ut this wsn t it correct is Σ. One might sy (d) ws closest ut CSE96 isn t horseshoes or tom oms, so ny nswer hd to e ccepted nd this ecme free 5 points. 5. For generl lnguge L, the reltion x L y when xy L is: () An equivlence reltion. () Reflexive nd symmetric, ut not trnsitive. (c) Symmetric, ut not reflexive or trnsitive. (d) Neither reflexive, symmetric, nor trnsitive (in generl).
Answer: Consider L = {, }. Since L hs no doule words, there is no string x such tht xx L, so x L x never hppens, so the reltion is s irreflexive s cn e. Nor is it symmetric, ecuse L ut not vice-vers (likewise L ut not vice-vers). This lredy torpedos (,,c) ut let s consider trnsitive : We hve L nd L, ut not L ecuse / L. So the nswer is (d). Very few got this; so mny sid () tht this ecme n instnce of ewring rosy expecttions in fvor of colf logic which is one of the ulterior messges of the course. [This, the xz prt of 2(c), prt (c) ove, nd getting prolem 4 exctly right were the min A-level points on the grding scheme, plus the points for comments/strtegy in prolem 1. In fct, prolem 1 hd scores verging 2- points lower thn expected, ut the freeie on (d) offset this so the difficulty tuning for the pre-set curve ws pretty-much on-trget.] (4) (24 pts.) Over Σ = {0, 1}, define L = { x : #00(x) = #10(x) }. Recll from Prolem Set 4 tht for ny u, x Σ, #u(x) is the numer of times u occurs s sustring of x, counting occurrences tht overlp. Prove vi the Myhill-Nerode technique tht L is not regulr lnguge. Answer: Tke S = (00), which is clerly infinite. Let ny x, y S (x y) e given. Then there re numers m, n 0 such tht x = (00) m nd y = (00) n. (We could lso postulte m < n without loss of generlity ut we won t need this.) Consider tking, ummm..., z = (10) m Then xz = (00) m (10) m which looks like it is in L, ut wit ecuse of the overlps string like w = (00) 2 (10) 2 = 00001010 hs #00(w) = #00(x) =, not 2, which #10(w). So we ctully need to tke z = (10) 2m 1 to mke xz L. Then yz = (00) n (10) 2m 1 nd since #00(yz) = 2n 1 2m 1 = #10(yz), we do get yz / L. Since x, y S re ritrry, S is PD for L, nd since S is infinite, L is not regulr y the Myhill-Nerode Theorem. Except there s one little niggle: tking S = (00) llows m = 0, ut wht does z = (10) 2m 1 ) men when m = 0? It sys (10) 1 ut we don t hve negtive powers of strings. If we stipulte tht it mens ɛ then we re still OK since then xz = ɛ ɛ = ɛ nd ɛ L. But we cn totlly void this onoxious edge cse y tking S = (00) + insted. Then we get m, n 1 nd the ove proof ecomes irtight. We cn lso tke S = 0 + = 00 (note tht 00 is not the sme s (00), which ws n unforseen error). Then when we let ny x, y S e given we get x = 0 m+1 nd y = 0 n+1 with n m. Then we cn exctly sy #00(x) = m nd tke z = (01) m fter ll. This ws nother completely-correct nswer given y severl. [Most, however, did the simple xz = (00) m (10) m thing nd fell victim to opticl ppernces to sy xz L, forgetting the overlps. This ws 4-point deduction, mitigted to if there ws some ttempt to justify with ecuse nd something tngile, not just sying xz L nd moving on. The A-level points were reckoned s on prolem 1, 2 on 2, 8 for (c) nd (e) not 10 ecuse 2 pts. prt credit ws given for nswering d on (c) nd 4 here, mking 17, ut I figured prolem 1 rought more ecuse it ws little longer thn comprle prolems in pst yers, so tht mde the usul 20 out of 100.] End of Exm