q 2 q q1 q δ a b c λ REGULAR LANGUAGES (14 POINTS) Problem 1 (6 points) For the following NFA (Sudkamp) Solution 1 a) The transition function for M - PDF

Description
DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 REGULAR LANGUAGES (4 POINTS) Prolem (6 points) For the following NFA

Please download to get full document.

View again

of 8
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information
Category:

Environment

Publish on:

Views: 33 | Pages: 8

Extension: PDF | Download: 0

Share
Transcript
DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 REGULAR LANGUAGES (4 POINTS) Prolem (6 points) For the following NFA (Sudkmp) 0 λ ) Write the trnsition funtion nd extended trnsition funtion (with λ trnsitions) ) Convert the NFA to DFA Solution ) The trnsition funtion for M δ λ 0 0 {,, } } { } } { { The extended trnsition funtion with λ trnsitions t 0 0 {,, } { } { } {, } DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 ) Conversion of the NFA to DFA We find the orresponding DFA y suset onstrution lgorithm: { 0 } { 0,, } { 0 } { 0 } { } { } { 0,, } { 0,, } A { 0} B { 0,, } { 0,, } { }, {, } C { 0,, } { } {, } { } { } { } { } { } E, { } D {, } { } {, } { } {, } {, } DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 Prolem (4 points) Minimize the following utomton (Sudkmp) A B D C E Solution From the trnsition tle elow C, D, E re indistinguishle: The miniml DFA is: A B D B C C E D D E D E E D A B CDE B CDE CDE CDE CDE A B CDE, 3 DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 Prolem 3 (4 points) Prove y using Pumping lemm tht the following lnguge is not regulr (Linz): L = { n l n is n integrl multipleof l} Solution 3 We use the Pumping lemm s follows. Assume (y ontrdition) tht L is regulr. From Pumping lemm, m suh tht w L, w m, x, y, z xy m, y = k 0, w = xyz nd xy i z L i 0. Let w = xyz = m m L (m = m) Sine xy m, xy m y = k Consider xy z L (m+k) m L n (m+k) = n m (y definition of L) ut k m m = m m+k m+m = m! n (m+k) = n m whih is ontrdition L is not regulr CONTEXT FREE LANGUAGES (4 POINTS) Prolem 4 (4 points) Is the following lnguge ontext free? Justify your nswer. If it is CFL, give grmmr. Otherwise prove tht the lnguge is not CF using the pumping lemm. (Chen) L = { n m n m} Solution 4 Yes, it hs the CFL with the following grmmr: n m m n n m m n S AS S S λ A A S S B S S λ B B S AS S B S S λ A A B B. 4 DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 Prolem 5 (6 points) The PDA is given y the following grph: (Sipser), λ,λ λ 0 λ, λ $ λ, λ λ λ, λ λ λ,$ λ 3 λ, λ λ λ,$ λ 4 5 6, λ,λ λ, λ Solution 5 ) Wht lnguge is epted y the utomton? ) Test run on the strings nd. ) The lnguge is: L ={ i j k i, j, k 0 nd i = j or i = k} ) Test run on the strings nd. Stte String Stk Stte String Stk 0 λ 0 λ $ $ $ $ $ $ $ 4 $ $ 5 $ $ 5 $ 3 λ 5 λ $ 3 λ λ 6 λ λ Aepted! Aepted! 5 DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 Prolem 6 (4 points) Whih of the following lnguges is ontext free? Justify! If ontext free onstrut CFG or PDA, if not use Pumping lemm. m n p r ) L= { d m+ n+ p= r; mnpr,,, 0} with the lphet Σ = {,,, d}. ) L= k k { k 0} with the lphet Σ = {, }. Solution 6 ) Context free. Grmmr: S Sd A A Ad B B Bd λ ) Not ontext free. Pumping lemm, see Leture 0, p.3. 6 DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 RECURSIVELY ENUMERABLE LANGUAGES ( POINTS) Prolem 7 (4 points) Is the funtion g(x) primitive reursive? If yes, define it s primitive reursive funtion (you n use si primitive reursive funtions from the ourse). (Slling) x g(x) Solution 7 Funtion g(x) is primitive reursive. From the funtion tle we see tht for even x it returns x+ nd for odd x it gives (x+)/. Thus, we n define g s follows: g(0) = g(x) = if (even(x), f(x), h(x)) f(x) = su (x) h(x)= uotient (su(x),) Prolem 8 (4 points) How does the following TM work? Tre the exeution of this mhine on three input strings (Krsnogor). # #, R 0 0 #,R 0 0, R, R # #,L 0 #,L 3 0 0, L, L #,R 0 0, R, R p # #, R # #, R #,L 5 # #,L 4 Solution 8: This is Turing Mhine tht reognizes plindromes over the lphet {0,}. For exmple fm() = yes, fm(00)= yes, fm(00)= yes, ut fm(0)= no The tions rried out y the mhine re:. Serh the first symol. Rememer the first symol nd go to the end of string 3. Delete the lst symol if it is the sme s the one rememered 4. If there is only one symol, the string is epted. 7 DVA35 Forml Lnguges, Automt nd Theory of Computtion, Mälrdlen University Shool of Innovtion, Design nd Engineering, Finl exm 8 Jn 03 Test run Proessing string 0 # 0 0# ## # # ## ##p# hlts nd epts Proessing string 0 # 0 0# ## 5 0# ##0 5 # ## 4 0# hlts nd fils Proessing string 00 # 0 00# ## 5 00# ##0 5 0 ##0 5 0# ##00 5 # ##00 5 # ##00 4 # ##0 3 0## ##0 3 0## ## 3 00## # 3 #00## ## 0 00## ### 0## ### 0## ###0 ## ### 0## ### 3 ### ## 3 #### ### 0 ### #### 5 ### ### 4 #### ####p### hlts nd epts Prolem 9 (4 points) Is the lnguge L deidle? Justify your nswer! (Hoproft) ) L = { M L(M) is infinite nd M is n ritrry DFA }. ) L = { M L(M) is infinite nd M is n ritrry TM } Solution 9: ) DECIDABLE. It is enough to hek if M ontins ny loops, whih n e done in finitely meny steps. ) UNDECIDABLE. Follows from Rie s theorem: Any nontrivil property of the lnguge reognized y Turing mhine is undeidle. The property of eing infinite Turing reognizle lnguge is nontrivil s not ll Turing reognizle lnguges hve tht property. Referenes Sudkmp, Lnguges nd Mhines, Addison Wesley 998 Sipser Mihel, Introdution to the Theory of Computtion, PWS 997 Linz Peter, An Introdution to Forml Lnguges nd Automt, Jones & Brtlett, 006 Slling: Formell språk, utomter oh eräkningr 00 Hoproft, Motwni, Ullmn, Introdution to Automt Theory, Lnguges, nd Computtion, Addison Wesley 00 8
Related Search
Similar documents
View more...
We Need Your Support
Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

Thanks to everyone for your continued support.

No, Thanks