CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of...
Transcript of CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of...
![Page 1: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/1.jpg)
CS1010:TheoryofComputation
LorenzoDeStefaniFall2019
Lecture9:TurningMachineVariants
![Page 2: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/2.jpg)
Outline
• VariantsofTuringMachine• StayPutTM• Multitape TM• Non-DeterministicTM• Enumerators
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 1
FromSipser Chapter3.2
![Page 3: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/3.jpg)
VariantsofTuringMachines
• WesawonlyafewvariantsofFAandPDA– Deterministicandnon-deterministic
• TherearemanyvariantsofTuringMachines–Mainlybecausetheyareallequivalent,sothatmakesthingsmoreconvenientwithoutreallychanginganything
– Thisshouldnotbesurprising,sincewealreadystatedthataTuringMachinecancomputeanythingthatiscomputable
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 2
![Page 4: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/4.jpg)
“Stayput”TMVariantThebasicTMmodelmustmovethetapeheadleftorrightaftereachstep.• Wemaywanttheheadtostay putinthesameposition.Isthevariantthathasthiscapabilityequivalent toourcurrentTMmodel?– Twomachinesareequivalentiftheyrecognizethesamelanguage
– Toshowthattwomodelsareequivalent,weonlyneedtoshowthatonecansimulateanother
• Proof:wecanconvertanyTMwiththe“stayput”featuretoonewithoutitbyaddingtwotransitions:move“right”then“left”
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 3
![Page 5: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/5.jpg)
MultiTape TMs
Amultitape TuringmachineisanordinaryTMwithmultipletapes:– Eachtapehasitsownheadforreadingandwriting– Initiallytape1hasinputstringandrestareblank– Thetransitionfunctionallowsreading,writing,andmovingtheheadsonsomeoralltapessimultaneously
– ItisaconvenientextensionofTMs(extratapesactasscratchpaperortemporarymemoryspace)
– Havingmultipletapesdoesnotaddpower.
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 4
![Page 6: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/6.jpg)
EquivalencebetweenTMandMultiTM
Weshowhowtoconvertamultitape TMMwithktapestoanequivalentsingle-tapeTMS– SsimulatesthektapesofMusingasingletape– Suses“#”asadelimitertoseparatethecontentsofthektapes
– Smarksthelocationofthekheadsbyputtingadotabovetheappropriatesymbols.(Intheslidesweusethecolorredinstead)
– Youcanthinkofdottedsymbolsasspecialtapeonlysymbols
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 5
![Page 7: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/7.jpg)
• Oninputofw=w1,w2…,wn,Swilllooklike:#w1w2…wn#-#-#….#
• Tosimulateasinglemove,Sscansitstapefromthefirst#tothe(k+1)st #inordertodeterminethesymbolsunderthevirtualheads.TheSmakesasecondpasstoupdatetheheadsandcontentsbasedonM’stransitionfunction
• IfatanypointSmovesoneofthevirtualheadstotheright(resp.,left)ontoa#,thisactionmeansthatMhasmovedtheheadtoapreviouslyblankportionofthetape.Swriteablanksymbolontothiscellandshiftseverythingtotheright(resp.,left)ontheentiretapeoneunittotheright.
EquivalencebetweenTMandMultiTM
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 6
![Page 8: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/8.jpg)
ExampleofTMandMultiTM
M
0 | 1 | 0 | 1 | 0 | | | | |
a | a | a | | | | | | |
b | a | | | | | | | |
S # | 0 | 1 | 0 | 1 | 0 | # | a | a | a | # | b | a | # | | | |
• InMultitape case,redindicateswherethetapeheadislocated.• InSingletapecase,redindicatesthesymbolwithadotonit.
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 7
![Page 9: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/9.jpg)
Proofidea:simulateanynon-deterministicTMNwithadeterministicTMD• Dsimulatesallpossiblebranches ofN• Thinkofthebranchesasthecorrespondingdecisiontree
• Dexplorethistreeasitsimulatesitsbranches– Depth-firstsearch:D fullyexploresonebranchbeforegoingtothenext.• Badidea:Ifthatoneloopsforever,willnevereventrymostbranches.
– Breadth-firstsearch:Dsimulatesfirstalldecisionsatthesamelevel• Goodidea: guaranteesthatallbrancheswillbeexploredtoanyfinitedepthandhencewillacceptifanybranchaccepts.
– TheDTMwillacceptiftheNTMdoes
EquivalenceTM&NondeterministicTM
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 8
![Page 10: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/10.jpg)
• Thiscanbedoneusing3tapes:– onetapeforinput
• INPUTTAPE– onetapeforhandlingcurrentbranch,
• NONDETERMINISTICTAPE– onetapefortrackingpositionincomputationtree
• WORKTAPE• ButwepreviouslydiscussesthatTMandMultiTMareequivalent!
EquivalenceTM&NondeterministicTM
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 9
![Page 11: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/11.jpg)
Enumerators
AnenumeratorEisaTMwithaprinter attached– TheTMcansendstringstobeoutputtotheprinter– Theinputtapeisinitiallyblank– ThelanguageenumeratedbyEisthecollectionofstringsprintedout
– Emaynothaltandprintoutinfinitenumbersofstrings
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 10
![Page 12: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/12.jpg)
EquivalenceofTMandEnumerators
• IfanenumeratorEenumeratesalanguageAthenaTMMrecognizesit–WewanttobuildarecognizerMusingourenumeratorE
–M=“Oninputw”• RunE.EverytimeEoutputsastringcompareittow.• IfweverappearsintheoutputofE,accept.
– ClearlyMacceptsanystringenumeratedbyE
Theorem:AlanguageisTuring-recognizableifandonlyifsomeenumeratorenumeratesit
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 11
![Page 13: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/13.jpg)
EquivalenceofTMandEnumerators
IfaTMMrecognizesalanguageA,wecanconstructanenumeratorEforAasfollows:• Lets1,s2,s3,…bethelistofallpossiblestringsin∑*
• Fori =1,2,…– RunMfori stepsoneachinputs1,s2,…,si.– Ifastringisaccepted,thenprintit.
• Whydoweneedtoloopoveri?–Weneedtodobreadthfirstsearchsoeventuallygenerateeverythingwithoutgettinginaloop!
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 12
![Page 14: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators](https://reader033.fdocuments.net/reader033/viewer/2022042908/5f37dd43e7d4e348cd48c13f/html5/thumbnails/14.jpg)
EquivalencewithOtherModels• WecanthinkofmanyvariantsofTMsomeofwhichmayappearverydifferent– Allhaveunlimitedaccesstounlimitedmemory– Allmodelswiththisfeatureturnouttobeequivalentassumingtheycanperformfiniteworkinonestep
• TMsareuniversalmodelofcomputation– Theclassesofalgorithmsaresameindependentofspecificmodelofcomputation
• Thisimpliesthatallprogramminglanguagesareequivalent– Forexample,assumingbasicconstructscanwriteacompilerforanylanguagewithanyotherlanguage
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 13