/
CSCI  Formal Languages and Automata Theory Lecture  Th CSCI  Formal Languages and Automata Theory Lecture  Th

CSCI Formal Languages and Automata Theory Lecture Th - PDF document

tatyana-admore
tatyana-admore . @tatyana-admore
Follow
409 views
Uploaded On 2015-06-03

CSCI Formal Languages and Automata Theory Lecture Th - PPT Presentation

Which one of these DFAs is thebest one One answer to this question is to try to build a minimal DFA one with the smallest possible number of states But building a minimal DFA from scratch can be dicult Instead we will show a procedure that converts ID: 79228

Which one these

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "CSCI Formal Languages and Automata Theo..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

21.q1=qandq01=q0,2.qi+1=(qi;wi)andq0i+1=(q0i;wi),fori=1;:::;m�1,and3.Exactlyoneofthestatesqmandq0misinF.2CharacterizingminimalDFAsWenowdescribethemainfeatureofaminimalDFA.Theorem4.LetM=(Q;;;q0;F)beaDFA.ThenMisminimalifandonlyifeverystateofMisreachableandeverypairofstatesofMisdistinguishable.Toprovethistheorem,wehavetodotwothings:First,wehavetoshowthatifeverystateisreachableandeverypairofstatesofMisdistinguishable,thenMisminimal.Then,wehavetoshowthatifMisminimal,theneverystateisreachableandeverypairofstatesisdistinguishable.Lemma5.IfeverystateofMisreachableandeverypairofstatesofMisdistinguishable,thenMisminimal.Proofsketch.WeneedtoarguethatifeverystateofMisreachableandeverypairofstatesofMisdistinguishable,thenMisminimal,thatistherecanbenosmallerM0=(Q0;;0;q00;F0)(i.e.,onewithjQ0jjQj)forthesamelanguage.WewillassumesuchanM0existsandarguethatsomethingmustbewrongwithit.BecauseeverystateofMisreachable,foreverystateqi2Q,thereisastringwithatreachesqiinM.Bythepigeonholeprinciple,thereexistsareachablestateq0ofQ0andapairofstringswi;wj(wherewi6=wj)suchthatwireachesq0inM0andwjreachesq0inM0.Byassumption,qiandqjaredistinguishableinM,sothereexistsastringwthatdistinguishesthem.NowthinkwhathappenswhenwerunMonthestringswiwandwjw.Sinceqiandqjaredistinguishable,exactlyoneofwiwandwjwreachesanacceptingstateofM.Ontheotherhand,bothwiwandwjwreachthesamestateofM0.ThereforethelanguagesofMandM0mustbedi erent. Fortheotherdirection,weneedtoarguethatifMisminimal,theneverystateofMisreachableandeverypairofstatesofMisdistinguishable.Wewillreasonbycontradiction:IfeitherMhasastatethatisnotreachable,orMhasapairofstatesthatareindistinguishable,thenwewillshowthatMisnotminimal{itcanbemadesmaller.LetusstartbyseeingwhathappenswhenMhasanunreachablestate.Lemma6.IfMhasanunreachablestate,thenMisnotminimal.Proof.SupposeMhasastateqthatisnotreachable.LetM0betheDFAobtainedbyremovingallunreachablestatesfromM,togetherwiththeiroutgoingtransitions.ThatisM0=(Q0;;0;q0;F0)where1.ThestatesofM0are:Q0=fq:q2QandqisreachableinMg, 4classA,andona1-transition,everystatefromclassAmovestoclassB.Thesamethinghappenswiththeotherclasses.Sowecantaketogetherallthestatesfromthesameclass,mergethemtogetherintonew\megastates",andobtainasmallerDFA: Infact,thismergingofindistinguishablestatesinto\megastates"canalwaysbedoneinsuchaway.Thereasonisthatifapairofstatesqiandqjareindistinguishable,thenforeverya2,ri=(qi;a)andrj=(qj;a)mustalsobeindistinguishable:Forifriandrjcanbedistinguishedbyw,thenqiandqjcanbedistinguishedbyaw.Sotransitionsoutofindistinguishablestatespointintoindistinguishablestates.Withthisinmind,wecanproveLemma7.ProofofLemma7.AssumeMhasapairofdistinguishablestates.WewillshowhowtoconstructanequivalentDFAM0=(Q0;;0;q00;F0)withfewerstates.Todoso,wedividethestatesQofMintoindistinguishabilityclassesq00;q01;:::;q0m0.EachoftheseclassesrepresentsasubsetofstatesofMwhicharemutuallyindistinguishable.Wewillsaythatastateqisrepresentedbyitsindistinguishabilityclassq0.Wecanassumethatq0isrepresentedbyq00.SinceMhasatleasttwoindistinguishablestates,itfollowsthatm0jQj.WecannowdescribeM0:1.States:Q0=fq00;q01;:::;q0m0g,2.Transitions:Foreveryq02Q0anda2,ifq0representsq,then0(q0;a)represents(q;a).3.Acceptingstates:F0=fq0:Thestatesinclassq0areallinFg.Forthisde nitiontomakesense,wehavetoarguethatthetransitionsofM0arewellde ned:Ifqiandqjarebothrepresentedbythesamestate,weneedtoknowthatri=(qi;a)andrj=(qj;a)arebothrepresentedbythesamestate.Indeed,thismustbethecase:Ifriandrjarerepresentedbydi erentstates,thentheymustbedistinguishable|saybyw.Butthenqiandqjaredistinguishablebyaw,andthiscontradictsthefactthattheybelongtothesameindistinguishabilityclass.NowwecanarguethatL(M)=L(M0).Letw=w1:::wkbeanystring.SupposethatwhenwerunMoninputw,Mgoesthroughthestatesq0;q1;:::;qk,thatis,(qi;wi+1)=qi+1fori=0;:::;k�1.Thenonthesameinputw,M0willgothroughsomesequenceofstatesq00;q01;:::;q0k,whereq0iistherepresentativeofqi. 5Thelaststateq0kwillbeacceptingifandonlyifqkisaccepting:Ifqkisrejecting,thenq0kcontainsarejectingstatesoitisalsorejecting.Ontheotherhand,ifqkisaccepting,thensomustbealltheotherstatesrepresentedbyq0k(becausetheyareindistinguishable),soq0kisalsoaccepting.ItfollowsthatMacceptswifandonlyifM0acceptsw{soMandM0areequivalent.ButM0hasfewerstatesthanM. 4TheDFAminimizationalgorithmNowweunderstandwhatminimalDFAsmustlooklike:Alltheirstatesarereachable,andalltheirpairsofstatesaredistinguishable.Moreover,wesawthatifMisnotminimal,wecanmakeitsmallerbygroupingtogetherstatesintoindistinguishabilityclasses.Itremainstoseehowwecan ndtheseindistinguishabilityclassessystematically.Todoso,wemust rst gureoutwhichpairsofstatesofMareindistinguishable.Aneasiertaskisto ndthepairsthataredistinguishable.Todoso,wewilliterativelyupdatea\table"Xof(unordered)pairsofdistinguishablestates(q;q0)usingthefollowingrules:Initialization:RemoveallunreachablestatesofM.SetXtobeempty.Rule1:Ifqisacceptingandq0isrejecting,addthepair(q;q0)toX.Rule2:If(q;q0)isalreadyinXandr;r0isapairsuchthatq=(r;a)andq0=(r0;a)forsomea2,thenaddthepair(r;r0)toX.Weapplyrules1and2aslongasnewpairscanbeaddedtoXusingtheserules.Onceweare nished,Xwillcontainallpairsofdistinguishablestates.Allpairsofunmarkedstateswillbeindistinguishableandtheycanbemergedtogetherintoindis-tinguishableclasses.TheresultingDFAwillbeminimal.Letusexplainhowthisworksontheaboveexample.WestartwithanemptyX.ApplyingRule1,wecanaddallthepairs(q";q11);(q0;q11);(q1;q11);(q00;q11);(q01;q11),and(q10;q11)toX.Afterthisstep,X=f(q";q11);(q0;q11);(q1;q11);(q00;q11);(q01;q11);(q10;q11)g:NowwecanstartapplyingRule2.Forexample,(q1;q11)isalreadyinX,andweseethat(q";1)=q1,and(q1;1)=q11,sowealsoaddthepair(q";q1)toX.Similarly,wecanalsoincludethepairs(q0;q1),(q00;q1),(q10;q1),(q";q01),(q0;q01),(q00;q01),and(q10;q01).NowX=f(q";q11);(q0;q11);(q1;q11);(q00;q11);(q01;q11);(q10;q11);(q";q1);(q0;q1);(q00;q1);(q10;q1);(q";q01);(q0;q01);(q00;q01);(q10;q01)g:Atthispoint,thereisnothingmoretoaddusingRules1and2.TheonlypairsofstatesnotincludedinXarenowthoseinthelist(1).Thosearethepairsofindistinguishablestates.Aftermergingtogethertheindistinguishablestates,weobtaintheminimizedDFA.