You are on page 1of 5

CD5560FormalLanguages,AutomataandTheoryofComputation,MlardalenUniversitySchoolofInnovation,DesignandEngineering, Finalexam20Jan2012Solutionhints

RegularLanguages(14points)
Problem1(6points)MinimizethefollowingautomatonM

ShowthattheresultingDFAisminimal.

Solution:
WeapplytheStateReductionbySetPartitioningalgorithm(srskiljandealgoritmen)(Lecture4page71). Minimalautomatonis:

TheaboveDFAisminimalbecausepairsofstatesaredistinguishable:

qB qC

1 qA qB

CD5560FormalLanguages,AutomataandTheoryofComputation,MlardalenUniversitySchoolofInnovation,DesignandEngineering, Finalexam20Jan2012Solutionhints

Problem2(4points)

a) ConvertthefollowingNFAintoRegularGrammar:

Answer WeapplythealgorithmexplainedinF4,startingwithpage151.

S aA A abS b

b) Does the expression ((0+1)(0+1)*)*00(0+1)* denote the language of strings w such that w has at least onepairofconsecutivezeros?Justifyyouranswerclearly! Answer YES.Hereiswhy:xx*representsoneormorexs.Thus(0+1)(0+1)*representsstrings,eachoneofwhichis eithera0ora1.Sothisisallstringsofzerosandonesoflength1orgreater.Butwhenyouapply*tothis expression,youarenowincludingmakingtheexpression((0+1)(0+1)*)*thesameas(0+1)*.Sothe expressionasawholerepresentsanystringthatconsistsof0sand1switha00somewhereinit. Problem3(4points)ProvebyusingPumpinglemmathatthefollowinglanguageisnotregular:

L = { a n b m c k | n = m + k or m = n + k}
Answer Usingthepumpinglemmatoprovethatthelanguageisnotregular: Letw=a2kbkck.NotethatwLbecauseitsatisfiesthefirstcondition(n=m+k).(Donotgetconfusedbythe twodifferentusesofthevariablenamek.)Thenyisap,forsomenonzerop.Pumpinonce.Theresultingstring isa2k+pbkck.ItisnotinLbecauseitsatisfiesneitheroftheconditionsformembershipinL, as2k+pk+k,andk2k+p+k.Thus, Lisnotregular.

CD5560FormalLanguages,AutomataandTheoryofComputation,MlardalenUniversitySchoolofInnovation,DesignandEngineering, Finalexam20Jan2012Solutionhints

ContextFreeLanguages(14points)
Problem4(5points)Constructcontextfreegrammarstoacceptthefollowinglanguages. a. L = {w | = { a, b} and w is odd} b. L = {a b a b | n, j 0}
n j j n

Answer a. b.

S A| A S |

where = { a, b}

S aSb | X

X bXa |
Problem5(5points)DescribethefollowingPDA.Testrun.Whatlanguageisacceptedbytheautomaton?

Answer

L = {a i b j c k i, j , k 0 and i = j or i = k ) }

Problem6(4points)Isthefollowinglanguagecontextfree?Justifyyouranswer.IfitisCF,giveagrammaror anautomaton.OtherwiseprovethatthelanguageisnotCFusingthepumpinglemma.

L = {a i b j c k i, j , k 0 and j > max (i, k ) }

CD5560FormalLanguages,AutomataandTheoryofComputation,MlardalenUniversitySchoolofInnovation,DesignandEngineering, Finalexam20Jan2012Solutionhints

Answer Thelanguageisnotcontextfree.Weproveitusingthepumpinglemma.Letmbethepumpinglength fromthepumpinglemmaandwechoosethestringw=uvxyz=ambm+1cm.(Accordingtopumpinglemma alsouvmxymzisinLform0.) Letthepart1ofthestringcontainalltheas,part2allthebs,andpart3containallthecs. Ifeithervorygoacrossnumberedparts,pumpuponce.TheresultingstringwillnotbeinLbecauseit willnotfollowtheformofthelanguage.Weconsidertheremainingcases: (1,1):Pumpuponce.Thisincreasesthenumberofasandthusthemaxofthenumberofasandcs.But thenumberofbsisunchangedsoitisnolongergreaterthanthatmaximum. (2,2):Pumpdownonce.Themaxnumberofasandcsisunchanged.Butthenumberofbsisdecreased andsoitisnolongergreaterthanthatmaximum. (3,3):Sameargumentas(1,1)butincreasesthenumberofcs. (1,2).(2,3):Pumpdownonce.Themaxnumberofasandcsisunchanged.Butthenumberofbsis decreasedandsoitisnolongergreaterthanthatmaximum. (1,3):Notpossiblesince|vxy|mustbelessthanorequaltom. Thismeansthatlanguagedoesnotsatisfypumpinglemma

RecursivelyEnumerableLanguages(12points)
Problem7(6points) HowdoesthefollowingTMwork?Doesitaccepttheinputstring?TracetheexecutionofthisTuringmachine ontheinputstring.

CD5560FormalLanguages,AutomataandTheoryofComputation,MlardalenUniversitySchoolofInnovation,DesignandEngineering, Finalexam20Jan2012Solutionhints

Answer TMstartsfromthefirstsymbolintheinputaabbcc.Thestringgetsacceptedandtapecontains
n n n xxyyzz##.TMacceptsthelanguage L = {a b c n 1 }

Problem8(6points)Proveeachofthefollowinglanguagesdecidableorundecidable!

a) {(< M 1 >, (< M 2 >) | L( M 1 ) L ( M 2 ) = } ? Answer Undecidable.Thisisanontrivialpropertyoflanguages,soRice'sTheoremapplies. b) {(< M 1 >, (< M 2 >) | L( M 1 ) L ( M 2 ) = } ? Answer Undecidable.WegiveareductionfromETM(emptylanguageTM). Supposethecontrary,thatthislanguageisdecidable.LetTbeaTuringmachinethatdecidesit. ThenwecanconstructaTuringmachineTdecidingETM,thatbehavesasfollowsoninput<M>. (1)SimulateToninput<M,M>,whereMisaTuringmachinerecognizingtheemptylanguage. (2)AcceptifandonlyifTaccepts. SupposethatMacceptstheemptylanguage.ThenTaccepts<M,M>,andsoTaccepts. Ontheotherhand,supposethatMacceptssomestring.ThenTrejects<M,M>,andsoTrejects. Thus,TdecidesETM.
c) IsL(M)infiniteifMisanarbitraryDFA?

Decidable.AnarbitraryDFAisafinitemachine.Wecaninspectthecodingofthemachineandseeif thereareloopswhichmakethelanguageinfinite.
References LinzPeter,AnIntroductiontoFormalLanguagesandAutomata,Jones&Bartlett,2006 RichElaine,Automata,ComputabilityandComplexity:TheoryandApplications,PrenticeHall,2007 Sudkamp,LanguagesandMachines,AddisonWesley1998 SipserMichael,IntroductiontotheTheoryofComputation,PWS1997 Hopcroft,Motwani,Ullman,IntroductiontoAutomataTheory,Languages,andComputation,A.Wesley2001

You might also like