CS1010: Theory of Computation Lorenzo De Stefani Fall 2019 Lecture 9: Turning Machine Variants
CS1010:TheoryofComputation
LorenzoDeStefaniFall2019
Lecture9:TurningMachineVariants
Outline
• VariantsofTuringMachine• StayPutTM• Multitape TM• Non-DeterministicTM• Enumerators
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 1
FromSipser Chapter3.2
VariantsofTuringMachines
• WesawonlyafewvariantsofFAandPDA– Deterministicandnon-deterministic
• TherearemanyvariantsofTuringMachines–Mainlybecausetheyareallequivalent,sothatmakesthingsmoreconvenientwithoutreallychanginganything
– Thisshouldnotbesurprising,sincewealreadystatedthataTuringMachinecancomputeanythingthatiscomputable
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 2
“Stayput”TMVariantThebasicTMmodelmustmovethetapeheadleftorrightaftereachstep.• Wemaywanttheheadtostay putinthesameposition.Isthevariantthathasthiscapabilityequivalent toourcurrentTMmodel?– Twomachinesareequivalentiftheyrecognizethesamelanguage
– Toshowthattwomodelsareequivalent,weonlyneedtoshowthatonecansimulateanother
• Proof:wecanconvertanyTMwiththe“stayput”featuretoonewithoutitbyaddingtwotransitions:move“right”then“left”
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 3
MultiTape TMs
Amultitape TuringmachineisanordinaryTMwithmultipletapes:– Eachtapehasitsownheadforreadingandwriting– Initiallytape1hasinputstringandrestareblank– Thetransitionfunctionallowsreading,writing,andmovingtheheadsonsomeoralltapessimultaneously
– ItisaconvenientextensionofTMs(extratapesactasscratchpaperortemporarymemoryspace)
– Havingmultipletapesdoesnotaddpower.
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 4
EquivalencebetweenTMandMultiTM
Weshowhowtoconvertamultitape TMMwithktapestoanequivalentsingle-tapeTMS– SsimulatesthektapesofMusingasingletape– Suses“#”asadelimitertoseparatethecontentsofthektapes
– Smarksthelocationofthekheadsbyputtingadotabovetheappropriatesymbols.(Intheslidesweusethecolorredinstead)
– Youcanthinkofdottedsymbolsasspecialtapeonlysymbols
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 5
• 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
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
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
• Thiscanbedoneusing3tapes:– onetapeforinput
• INPUTTAPE– onetapeforhandlingcurrentbranch,
• NONDETERMINISTICTAPE– onetapefortrackingpositionincomputationtree
• WORKTAPE• ButwepreviouslydiscussesthatTMandMultiTMareequivalent!
EquivalenceTM&NondeterministicTM
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 9
Enumerators
AnenumeratorEisaTMwithaprinter attached– TheTMcansendstringstobeoutputtotheprinter– Theinputtapeisinitiallyblank– ThelanguageenumeratedbyEisthecollectionofstringsprintedout
– Emaynothaltandprintoutinfinitenumbersofstrings
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 10
EquivalenceofTMandEnumerators
• IfanenumeratorEenumeratesalanguageAthenaTMMrecognizesit–WewanttobuildarecognizerMusingourenumeratorE
–M=“Oninputw”• RunE.EverytimeEoutputsastringcompareittow.• IfweverappearsintheoutputofE,accept.
– ClearlyMacceptsanystringenumeratedbyE
Theorem:AlanguageisTuring-recognizableifandonlyifsomeenumeratorenumeratesit
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 11
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
EquivalencewithOtherModels• WecanthinkofmanyvariantsofTMsomeofwhichmayappearverydifferent– Allhaveunlimitedaccesstounlimitedmemory– Allmodelswiththisfeatureturnouttobeequivalentassumingtheycanperformfiniteworkinonestep
• TMsareuniversalmodelofcomputation– Theclassesofalgorithmsaresameindependentofspecificmodelofcomputation
• Thisimpliesthatallprogramminglanguagesareequivalent– Forexample,assumingbasicconstructscanwriteacompilerforanylanguagewithanyotherlanguage
10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 13