cs1010: theory of computation · – if you had to list the elements of a dfa what would they be?...
TRANSCRIPT
![Page 1: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/1.jpg)
CS1010:TheoryofComputation
LorenzoDeStefaniFall2019
Lecture11:DecidabilityandLanguages
![Page 2: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/2.jpg)
LimitationsofAlgorithmicSolvability
• Inthispartoftheclassweinvestigatethepowerofalgorithmstosolveproblems– Somecanbesolvedalgorithmicallyandsomecannot
• Whydowestudyunsolvability?– Importantguideline
• Ifaproblemisunsolvablesearchingforanalgorithmicsolutionisawasteoftime
• Perhapstheproblemcanbesimplified– Gainunderstandingoncomputabilityanditslimits– Firststeptowardscomplexitycharacterization
• Firstweascertainwhetherthereisanalgorithmicsolutionandthenwestudywhetherthereisan“efficient”(polynomial-time)one
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 1
![Page 3: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/3.jpg)
Outline
• Decidablelanguages• Regularlanguagesaredecidable• Context-freelanguagesaredecidable• Languageshierarchy
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 2
FromSipserChapter4.1
![Page 4: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/4.jpg)
DecidableLanguages
• Westartwithproblemsthataredecidable– Wefirstlookatproblemsconcerningregularlanguagesandthenthoseforcontext-freelanguages
• …eventuallywewillmovetoproblemsconcerningTuringMachinesandshowthatsomeproblemsarenotdecidable!
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 3
![Page 5: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/5.jpg)
DecidableProblemsforRegularLanguages
• Weconsideralgorithmsfortesting– whetherafiniteautomatonacceptsastring– whetherthelanguageofafiniteautomatonisempty– whethertwofiniteautomataareequivalent
• Werepresenttheproblemsaslanguages(notFAs)– LetADFA={(B,w)|BisaDFAthatacceptsstringw}– TheproblemoftestingwhetheraDFABacceptsaspecificinputwisthesameastestingwhether(B,w)isamemberofthelanguageADFA.
– IfyouhadtolisttheelementsofADFAwhatwouldtheybe?• Allthepairs(Automata,string)suchthat“string”isacceptedby“automata”
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Showingthatthelanguageisdecidableisthesamethingasshowingthatthecomputationalproblemoftestingacceptanceisdecidable
4
![Page 6: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/6.jpg)
ADFAisaDecidableLanguage
ProofIdea:ConstructaTuringMachineMthatdecidesADFAM=Oninput(<B>,w),whereBisaDFAandwisastring:
1. SimulateBoninputw2. Ifthesimulationendsinanacceptstate,thenaccept;else
reject
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani
Theorem:ADFAisadecidablelanguage
5
![Page 7: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/7.jpg)
OutlineofProof• MmusttakeBasinput,encodedasastring,andthensimulateit
– ThealgorithmforsimulatinganyDFAmustbeembodiedintheTM’sstatetransitions
– Givenacurrentstateandinputsymbol,scanthetapefortheencodedtransitionfunctionandthenusethatinfotodeterminenewstate
• TheactualproofdescribeshowaTMsimulatesaDFA– CanassumeBisrepresentedbyits5componentsandthenwehavew
• NotethattheTMmustbeabletohandleanyDFA• Keeptrackofcurrentstateandpositioninwbywritingonthetape• Initiallycurrentstateisq0andcurrentpositionisleftmostsymbolofw
– Thestatesandpositionareupdatedusingthetransitionfunctionδ• TMM’sδnotthesameasDFAB’sδàthelatterisencodedastheinput
– WhenMfinishesprocessing,acceptifinanacceptstate;elsereject.Theimplementationwillmakeitclearthatwillcompleteinfinitetime.
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 6
![Page 8: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/8.jpg)
ANFAisaDecidableLanguage
ProofIdea:– BecausewehaveprovendecidabilityforDFAs,allweneedto
doisconverttheNFAtoaDFA.Oninput(B,w)whereBisanNFAandwisastring
1. ConvertNFABtoanequivalentDFAC,usingtheprocedureforconversiongiveninTheorem1.39
2. RunTMMoninput(C,w)usingthetheoremwejustproved3. IfMaccepts,thenaccept;elsereject
– RunningTMMinstep2meansincorporatingMintothedesignofNasasubroutine
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 7
![Page 9: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/9.jpg)
ComputingwhetheraDFAacceptsanyString
• EDFA={<A>|AisaDFAandL(A)=∅)isadecidablelanguage• Proof:
– ADFAacceptssomestringifandonlyifitispossibletoreachtheacceptstatefromthestartstate.Howcanwecheckthis?
– Wecanuseamarkingalgorithmsimilartotheoneusedtodecidethelanguageofconnectedgraphs.
– T=Oninput(A)whereAisaDFA:1. MarkthestartstateofA2. Repeatuntilnonewstatesgetmarked:
3. Markanystatethathasatransitioncomingintoitfromanystatealreadymarked
4. Ifnoacceptstateismarked,accept;otherwisereject
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 8
![Page 10: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/10.jpg)
EQDFAisaDecidableLanguage• EQDFA={(A,B)|AandBareDFAsandL(A)=L(B)}• Proofidea
– ConstructaDFACfromAandB,whereCacceptsonlythosestringsacceptedbyeitherAorBbutnotboth(symmetricdifference)• IfAandBacceptthesamelanguage,thenCwillacceptnothingandwe
canusethepreviousproof(forEDFA)tocheckforthis.• So,theproofis:
– F=Oninput(A,B)whereAandBareDFAs:1. ConstructDFACthatisthesymmetricdifferenceofAandB
(detailsonhowtodothisonnextslide)2. RunTMTfromtheprooffromlastslideoninput(C)3. IfTaccepts(sym.diff=∅)thenaccept.IfTrejectsthenreject
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 9
![Page 11: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/11.jpg)
HowtoConstructC
L(C)=(L(A)∩L(B))∪(L(A)∩L(B))– Weusedproofsbyconstructionthatregularlanguagesareclosedunder∪,∩,andcomplement
– WecanusethoseconstructionstoconstructaFAthatacceptsL(C)• Weneverprovedregularlanguagesareclosedunder∩!
L(A) L(B)
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 10
![Page 12: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/12.jpg)
RegularLanguagesClosedunderIntersection
IfLandMareregularlanguages,thensoisL∩M• Proof:LetAandBbeDFAswhoseregularlanguagesareLandM,respectively
– ConstructC,the“productautomation”ofAandB– CtracksthestatesinAandB(justlikewhenwedidtheproofofunionwithoutusingNFAs)
– MakethefinalstatesofCbethepairsconsistingoffinalstatesofbothAandB• IntheunioncasewethefinalstateanystatewithafinalstateinAorB
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 11
![Page 13: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/13.jpg)
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 12
![Page 14: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/14.jpg)
ACFGisaDecidableLanguageProofIdea:– ForCFGGandstringwwewanttodecidewhetherGgeneratesw.
– OneideaistouseGtogothroughallderivations.Thiswillnotwork,why?• ThismethodabestwillyieldaTMthatisarecognizer,notadecider.• Cangenerateinfinitestringsandifnotinthelanguage,willneverknowit.
– Canweusetheinformationonthelengthofw?– Astringwoflengthnwillhaveaderivationthatuses2n-1stepsiftheCFGisin
Chomsky-NormalForm.• FirstconverttoChomsky-NormalForm• Thenlistallderivationsoflength2n-1steps.Ifanygeneratesw,thenaccept,elsereject.
• Thisisavariantofbreadthfirstsearch,butinsteadofextendedthedepth1atatimeweallowittogo2n-1atatime.Aslongasfinitedepthextension,weareokay
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 13
![Page 15: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/15.jpg)
ECFGisaDecidableLanguage
• ECFG={<G>|GisaCFGandL(G)=∅)isadecidablelanguage
• Whatisthe“bruteforceapproach”?– Tryallpossiblestringsw.Willthiswork?
• Thenumberisnotbounded,sothiswouldnotbedecidable• Instead,thinkofthisasagraphproblemwhereyouwanttoknowifyoucanreachastringofterminalsfromthestartstate• Doyouthinkitiseasiertoworkforwardorbackwards?• Answer:backwards
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 14
![Page 16: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/16.jpg)
ECFGisaDecidableLanguage(cont)
ProofIdea:– Canthestartvariablegenerateastringofterminals?– Determineforeachvariableifitcangenerateanystringofterminalsandifso,markit
– Keepworkingbackwardssothatiftheright-sideofanyrulehasonlymarkeditems,thenmarktheLHS• Forexample,ifXàYZandYandZaremarked,thenmarkX• IfyoumarkS,thendone;ifnothingelsetomarkandSnotmarked,thenreject
• Youstartbymarkingallterminalsymbols
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 15
![Page 17: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/17.jpg)
EQCFGisnotaDecidableLanguage
• WecannotreusethesamereasoningusedtoshowthatEQDFAisadecidablelanguagesinceCFGsarenotclosedundercomplementandintersection
• Asitturnsout,EQCFGisnotdecidable!
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 16
![Page 18: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/18.jpg)
EveryContext-FreeLanguageisDecidable
• WepreviouslyshowedACFGisdecidable.• WewanttoknowifA,whichisaCFL,isdecidable.– AwillhavesomeCFGGthatgeneratesit– WhenweprovedthatACFGisdecidable,weconstructedaTMSthatwouldtellusifanyCFGacceptsaparticularinputw.
– NowweusethisTMandrunitoninput<G,w>andifitaccepts,weaccept,andifitrejects,wereject.
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 17
![Page 19: CS1010: Theory of Computation · – If you had to list the elements of A DFA what would they be? • All the pairs (Automata, string) such that “string” is accepted by “automata”](https://reader034.vdocument.in/reader034/viewer/2022042612/5f4124a5c58d6059873d2d6e/html5/thumbnails/19.jpg)
HierarchyofClassesofLanguages
Regular
Context-Free
Decidable
Turing-recognizable
• WeprovedRegular⊆Context-freesincewecanconvertaFAintoaCFG
• WejustprovedthateveryContext-freelanguageisdecidable
• FromthedefinitionsinChapter3itisclearthateveryDecidablelanguageistriviallyTuring-recognizable.
• NoteveryTuring-recognizablelanguageisDecidable!
10/10/19 Theory of Computation - Fall'19
Lorenzo De Stefani 18