Top Banner
CS1010: Theory of Computation Lorenzo De Stefani Fall 2019 Lecture 9: Turning Machine Variants
14

CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators

Jul 10, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS1010: Theory of Computation€¦ · Lecture 9: Turning Machine Variants. Outline •Variants of Turing Machine •Stay Put TM •MultitapeTM •Non-Deterministic TM •Enumerators

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

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

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

“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

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

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

• 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

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

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

• 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

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

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

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

EquivalencewithOtherModels• WecanthinkofmanyvariantsofTMsomeofwhichmayappearverydifferent– Allhaveunlimitedaccesstounlimitedmemory– Allmodelswiththisfeatureturnouttobeequivalentassumingtheycanperformfiniteworkinonestep

• TMsareuniversalmodelofcomputation– Theclassesofalgorithmsaresameindependentofspecificmodelofcomputation

• Thisimpliesthatallprogramminglanguagesareequivalent– Forexample,assumingbasicconstructscanwriteacompilerforanylanguagewithanyotherlanguage

10/8/19 TheoryofComputation- Fall'19LorenzoDeStefani 13