They provide a precise formal de64257nition of what it means for a function to be computable Many other de64257nitions of computation have been proposed over the years for example one could try to formalize precisely what it means to run a program ID: 33534
Download Pdf The PPT/PDF document "Introduction to Algorithms Notes on Turi..." 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.
NotethataTuringmachineisnotpreventedfromoverwritingtherightmostsymbolonitstapeormovingtotherightofit.Infact,thiscapabilityisnecessaryinorderforTuringmachinestoperformcomputationsthatrequiremorespacethanisgivenintheiroriginalinputstring.HavingdenedthespecicationofaTuringmachine,wemustnowpindownadenitionofhowtheyoperate.Thishasbeeninformallydescribedabove,butit'stimetomakeitformal.ThatbeginswithformallydeningthecongurationoftheTuringmachineatanytime(thestateofitstape,aswellasthemachine'sownstateanditspositiononthetape)andtherulesforhowitscongurationchangesovertime.Denition2.Thesetisthesetofallnitesequencesofelementsof.Whenanelementofisdenotedbyalettersuchasx,thentheelementsofthesequencexaredenotedbyx0;x1;x2;:::;xn1,wherenisthelengthofx.Thelengthofxisdenotedbyjxj.AcongurationofaTuringmachineisanorderedtriple(x;q;k)2KN,wherexdenotesthestringonthetape,qdenotesthemachine'scurrentstate,andkdenotesthepositionofthemachineonthetape.Thestringxisrequiredtobeginwith.andendwitht.Thepositionkisrequiredtosatisfy0kjxj.IfMisaTuringmachineand(x;q;k)isitscongurationatanypointintime,thenitsconguration(x0;q0;k0)atthefollowingpointintimeisdeterminedasfollows.Let(p;;d)=(q;xk):Thestringx0isobtainedfromxbychangingxkto,andalsoappendingttotheendofx,ifk=jxj1.Thenewstateq0isequaltop,andthenewpositionk0isequaltok1;k+1;orkaccordingtowhetherdis ;!;or,respectively.Weexpressthisrelationbetween(x;q;k)and(x0;q0;k0)bywriting(x;q;k)M!(x0;q0;k0):AcomputationofaTuringmachineisasequenceofcongurations(xi;qi;ki),whereirunsfrom0toT(allowingforthecaseT=1)thatsatises:Themachinestartsinavalidstartingconguration,meaningthatq0=sandk0=0.Eachpairofconsecutivecongurationsrepresentsavalidtransition,i.e.for0iT,itisthecasethat(xi;qi;ki)M!(xi+1;qi+1;ki+1).IfT=1,wesaythatthecomputationdoesnothalt.IfT1,werequirethatqT2fhalt,yes,nogandwesaythatthecomputationhalts.IfqT=yes(respectively,qT=no)wesaythatthecomputationoutputs\yes"(respectively,outputs\no").IfqT=haltthentheoutputofthecomputationisdenedtobethestringobtainedbyremoving.andtfromthestartandendofxT.Inallthreecases,theoutputofthecomputationisdenotedbyM(x),wherexistheinput,i.e.thestringx0withouttheinitial.andnalt.Ifthecomputationdoesnothalt,thenitsoutputisundenedandwewriteM(x)=%. Theupshotofthisdiscussionisthatonemuststandardizeoneitherasingly-inniteordoubly-innitetape,forthesakeofmakingaprecisedenition,butthechoicehasnoeectonthecomputationalpowerofthemodelthatiseventuallydened.AswegothroughtheotherpartsofthedenitionofTuringmachines,wewillencountermanyotherexamplesofthisphenomenon:detailsthatmustbestandardizedforthesakeofprecision,butwheretheprecisechoiceofdenitionhasnobearingonthedistinctionbetweencomputableanduncomputable. a1totheinputusingasubroutineverysimilartoExample1.We'llrefertothestatesinthatsubroutineasprepend::s;prepend::r;prepend::`:Example3.Wecancomputethebinarypre-cedessorfunctioninroughlythesameway.Wemusttakecaretodenethevalueofthepre-decessorfunctionwhenitsinputisthenum-ber0,sincewehaven'tyetspeciedhownega-tivenumbersshouldberepresentedonaTuringmachine'stapeusingthealphabetf.;t;0;1g.Ratherthanspecifyaconventionforrepresent-ingnegativenumbers,wewillsimplydenethevalueofthepredecessorfunctiontobe0whenitsinputis0.Also,forconvenience,wewillallowtheoutputofthebinarypredecessorfunctiontohaveanynumberofinitialcopiesofthedigit0. (q;)q state symbol direction s . z . ! z 0 z 0 !z 1 r 1 !z t t t r 0 r 0 !r 1 r 1 !r t ` t ` 0 ` 1 ` 1 t 0 t 0 t 0 t 1 t 1 t . halt . Ourprogramtocomputethebinarypredecessorofnthusbeginswithatesttoseeifnisequalto0.Themachinemovestotheright,remaininginstatezunlessitseesthedigit1.Ifitreachestheendofitsinputinstatez,thenitsimplyrewindstothebeginningofthetape.Otherwise,itdecrementstheinputinmuchthesamewaythattheprecedingexampleincrementedit:inthiscaseweusestate`tochangethetrailing0'sto1'suntilweencountertherightmost1,andthenweenterstatettorewindtothebeginningofthetape.2.1PseudocodeforTuringmachinesTransformingevensimplealgorithmsintoTuringmachinestatetransitiondiagramscanbeanunbearablycumbersomeprocess.Itisevenmoreunbearabletoreadastatetransitiondiagramandtrytodeduceaplain-Englishdescriptionofwhatthealgorithmaccomplishes.Itisdesirabletoexpresshigher-levelspecicationsofTuringmachinesusingpseudocode.Ofcourse,thewholepointofdeningTuringmachinesistogetawayfromtheinformalnotionof\algorithm"asexempliedbypseudocode.Inthissectionwewilldiscussastraight-forward,directtechniquefortransformingacertaintypeofpseudocodeintoTuringmachinestatediagrams.Thepseudocodetowhichthistransformationappliesmustsatisfythefollowingrestrictions:1.Theprogramhasanite,predenednumberofvariables.2.Eachvariablecantakeonlyanite,predenedsetofpossiblevalues.3.Recursivefunctioncallsarenotallowed.Theword\predened"abovemeans,\speciedbytheprogram,notdependingontheinput."Notethatthisisreallyquiterestrictive.Forexample,ourpseudocodeisnotallowedtousepointerstolocationsonthetape.(Suchvariablescouldnotbelimitedtoapredenednitesetofvalues.)Integer-valuedvariablesaresimilarlyolimits,unlesstherearepredenedlowerandupperboundsonthevaluesofsaidvariables.Givenpseudocodethatmeetstheaboverestrictions,itisstraightforwardtotransformitintoanactualTuringmachine.SupposethatthepseudocodehasLlinesandnvariablesv1;:::;vn.For1inletVidenotethepredenednitesetofvaluesforvi.Thestatesetofthe numbersjj;jj+1;:::;jj+jKj1(withjjrepresentingthestartingstates)andthatfhalt,yes,nog[f ;!;gconsistsofthenumbersjj+jKj;:::;jj+jKj+5:Now,thedescriptionofTuringmachineMisdenedtobeanitestringinthealphabetf0,1,`(',`)',`,'g,determinedasfollows.M=m;n;12:::Nwheremisthenumberjjinbinary,nisthenumberjKjinbinary,andeachof1;:::;Nisastringencodingoneofthetransitionrulesthatmakeupthemachine'stransitionfunction.Eachsuchruleisencodedusingastringi=(q;;p;;d)whereeachofthevepartsq;;p;;disastringinf0;1g`encodinganelementof[K[fhalt,yes,nog[f ;!;gasdescribedabove.ThepresenceofiinthedescriptionofMindicatesthatwhenMisinstateqandreadingsymbol,thenittransitionsintostatep,writessymbol,andmovesindirectiond.Inotherwords,thestringi=(q;;p;;d)inthedescriptionofMindicatesthat(q;)=(p;;d):3.2DenitionofauniversalTuringmachineAuniversalTuringmachineisaTuringmachineUwithalphabetf0,1,`(',`)',`,',`;'g.Ittakesaninputoftheform.M;xt,whereMisavaliddescriptionofaTuringmachineandxisastringinthealphabetofM,encodedusing`-bitblocksasdescribedearlier.(Ifitsinputfailstomatchthisspecication,theuniversalTuringmachineUisallowedtobehavearbitrarily.)ThecomputationofU,giveninput.M;xt,hasthesameterminationstatus|haltinginstate\halt",\yes",or\no",orneverhalting|asthecomputationofMoninputx.Further-more,ifMhaltsoninputx(and,consequently,Uhaltsoninput.M;xt)thenthestringonU'stapeatthetimeithaltsisequaltothestringonM'stapeatthetimeithalts,againtranslatedintobinaryusing`-bitblocksasspeciedabove.ItisfarfromobviousthatauniversalTuringmachineexists.Inparticular,suchamachinemusthaveanitenumberofstates,yetitmustbeabletosimulateacomputationperformedbyaTuringmachinewithamuchgreaternumberofstates.InSection3.4wewilldescribehowtoconstructauniversalTuringmachine.First,itishelpfultoextendthedenitionofTuringmachinestoallowmultipletapes.Afterdescribingthisextensionwewillindicatehowamulti-tapeTuringmachinecanbesimulatedbyasingle-tapemachine(atthecostofaslowerrunningtime).3.3Multi-tapeTuringmachinesAmulti-tapeTuringmachinewithktapesisdenedinnearlythesamewayasaconventionalsingle-tapeTuringmachine,exceptthatitstoreskstringssimultaneously,maintainsapositionineachofthekstrings,updatesthesekpositionsindependently(i.e.itcanmoveleftinonestringwhilemovingrightinanother),anditsstatechangesarebasedontheentirek-tupleofsymbolsthatitreadsatanypointintime.Moreformally,ak-tapeTuringmachinehasanitealphabetandstatesetKasbefore,butitstransitionfunctionis:Kk!(K[fhalt,yes,nog)(f ;!;g)k; Algorithm1Simulationofmulti-tapeTuringmachineMbysingle-tapeTuringmachineM. 1:q s//Initializestate.2:repeat3://Simulationround4://First,ndoutwhatsymbolsMisseeing.5:repeat6:Moverightwithoutchangingcontentsofstring.7:fori=1;:::;kdo8:ifith agatcurrentlocationequals1then9:i ithsymbolatcurrentlocation.10:endif11:endfor12:untilMreachest13:repeat14:Moveleftwithoutchangingcontentsofstring.15:untilMreaches.16://Now,1;:::;kstoretheksymbolsthatMisseeing.17://EvaluatestatetransitionfunctionformachineM.18:q0;(01;d1);(02;d2);:::;(0k;dk) (q;1;:::;k)19:fori=1;:::;kdo20://Phasei21:repeat22:Moverightwithoutchangingthecontentsofthestring.23:untilalocationwhoseith agis1isreached.24:Changetheithsymbolatthislocationto0i.25:ifdi= then26:Changeith agto0atthislocation.27:Moveonestepleft28:Changeith agto1.29:elseifdi=!then30:Changeith agto0atthislocation.31:Moveonestepright.32:Changeith agto1.33:endif34:repeat35:Moveleftwithoutchangingthecontentsofthestring.36:untilthesymbol.isreached.37:endfor38:q q039:untilq2fhalt;yes;nog40://Ifthesimulationreachesthisline,q2fhalt;yes;nog:41:ifq=yesthen42:Transitionto\yes"state.43:elseifq=nothen44:Transitionto\no"state.45:else46:Transitionto\halt"state.47:endif identicaltothe`-bitstringonitsstatetapeandisidenticaltothe`-bitstringonitsworkingtape.Thesecomparisonsareperformedonebitatatime,andifeitherofthecomparisonsfails,thenUrewindsitsstatetapecursorbacktothe.anditrewindsitsworkingtapecursorbacktothecommathatmarkeditslocationatthestartofthisiterationofthemainloop.ItthenmovesitsdescriptiontapecursorforwardtothedescriptionofthenextruleinM'stransitionfunction.Whenitnallyencountersapair(q;)thatmatchesitscurrentstatetapeandworkingtape,thenitmovesforwardtoreadthecorresponding(p;;d),anditcopiespontothestatetape,ontotheworkingtape,andthenmovesitsworkingtapecursorinthedirectionspeciedbyd.Finally,toendthisiterationofthemainloop,itrewindsthecursorsonitsdescriptiontapeandstatetapebacktotheleftmostposition.ItisworthmentioningthattheuseofvetapesintheuniversalTuringmachineisoverkill.Inparticular,thereisnoneedtosavetheinput.M;xtonaseparateread-onlyinputtape.Aswehaveseen,theinputtapeisneverusedaftertheendoftheinitializationstage.Thus,forexample,wecanskiptheinitializationstepofcopyingthedescriptionofMfromtheinputtapetothedescriptiontape;instead,aftertheinitializationnishes,wecantreattheinputtapehenceforwardasifitwerethedescriptiontape. Algorithm2UniversalTuringmachine,initialization. 1://CopythetransitionfunctionofMfromtheinputtapetothedescriptiontape.2:Moverightpasttherstandsecondcommasontheinputtape.3:whilenotreading';'oninputtapedo4:Readinputtapesymbol,copytodescriptiontape,moverightonbothtapes.5:endwhile6://Now,writetheidentiersofthehaltingstatesandthe\directionofmotionsymbols"onthespecialtape.7:Movetostartofinputtape.8:Usingbinaryadditionsubroutine,writem+ninbinaryonworkingtape.9:fori=0;1;2;3;4;5do10:Onspecialtape,writebinaryrepresentationofm+n+i,followedby';'.11://Thisdoesn'trequirestoringm+ninmemory,becauseit'sstoredontheworkingtape.12:endfor13://Copytheinputstringxontotheworkingtape,insertingcommasbetweeneach`-bitblock.14:Writem+n+6inbinaryonthestatetape.//Inordertostorethevalueof`.15:Startingfromleftedgeofinputtape,moverightuntil';'isreached.16:Movetoleftedgeofworkingtapeandstatetape.17:Moveonesteprightonstatetape.18:repeat19:whilestatetapesymbolisnottdo20:Moverightoninputtape,workingtape,andstatetape.21:Copysymbolfrominputtapetoworkingtape.22:endwhile23:Write','onworkingtape.24:Rewindtoleftedgeofstatetape,thenmoveonestepright.25:untilinputtapesymbolist26:Copymfrominputtapetostatetape.27://Donewithinitialization! 4UndecidableproblemsInthissectionwewillseethatthereexistcomputationalproblemsthataretoodiculttobesolvedbyanyTuringmachine.SinceTuringmachinesareuniversalenoughtorepresentanyalgorithmrunningonadeterministiccomputer,thismeansthereareproblemstoodiculttobesolvedbyanyalgorithm.4.1DenitionsTobepreciseaboutthenotionofwhatwemeanby\computationalproblems"andwhatitmeansforaTuringmachineto\solve"aproblem,wedeneproblemsintermsoflanguages,whichcorrespondtodecisionproblemswithayes/noanswer.Wedenetwonotionsof\solving"aproblemspeciedbyalanguageL.Therstofthesedenitions(\decidingL")correspondstowhatweusuallymeanwhenwespeakofsolvingacomputationalproblem,i.e.terminatingandoutputtingacorrectyes/noanswer.Theseconddenition(\acceptingL")isa\one-sided"denition:iftheansweris\yes",themachinemusthaltandprovidethisanswerafteraniteamountoftime;iftheansweris\no",themachineneednoteverhaltandprovidethisanswer.Finally,wegivesomedenitionsthatapplytocomputationalproblemswherethegoalistooutputastringratherthanjustasimpleyes/noanswer.Denition3.Let0=nf.;tg:AlanguageisanysetofstringsL0.SupposeMisaTuringmachineandLisalanguage.1.MdecidesLifeverycomputationofMhaltsinthe\yes"or\no"state,andListhesetofstringsoccurringinstartingcongurationsthatleadtothe\yes"state.2.LisdecidableifthereisamachineMthatdecidesL.3.MacceptsLifListhesetofstringsoccurringinstartingcongurationsthatleadMtohaltinthe\yes"state.4.LisrecursivelyenumerableifthereisamachineMthatacceptsL.5.Mcomputesagivenfunctionf:0!0ifeverycomputationofMhalts,andforallx20,thecomputationwithstartingconguration(.xt;s;0)endsinconguration(.f(x)tt;halt;0);wherettdenotesanysequenceofoneormorerepetitionsofthesymbolt.6.fisacomputablefunctionifthereisaTuringmachineMthatcomputesf.4.2UndecidabilityviacountingOnesimpleexplanationfortheexistenceofundecidablelanguagesisviaacountingargument:therearesimplytoomanylanguages,andnotenoughTuringmachinestodecidethemall!Thiscanbeformalizedusingthedistinctionbetweencountableanduncountablesets.Denition4.Aninnitesetiscountableifandonlyifthereisaone-to-onecorrespondencebetweenitselementsandthenaturalnumbers.Otherwiseitissaidtobeuncountable.Lemma1.Ifisanitesettheniscountable. Proof.ThesetoflanguagesLisuncountablebyLemmas1and2.ThesetofTuringmachineswithalphabetiscountablebecauseeachsuchTuringmachinehasadescriptionwhichisanite-lengthstringofsymbolsinthealphabetf0,1,`(',`)',`,'g.ThereforetherearestrictlymorelanguagesthenthereareTuringmachines,sotherearelanguagesthatarenotacceptedbyanyTuringmachine. 4.3UndecidabilityviadiagonalizationTheproofofTheorem3isquiteunsatisfyingbecauseitdoesnotprovideanyexampleofaninterestinglanguagethatisnotrecursivelyenumerable.Inthissectionwewillrepeatthe\diag-onalargument"fromtheproofofTheorem2,thistimeinthecontextofTuringmachinesandlanguages,toobtainamoreinterestingexampleofasetthatisnotrecursivelyenumerable.Denition5.ForaTuringmachineM,wedeneL(M)tobethesetofallstringsacceptedbyM:L(M)=fxjMhaltsandoutputs\yes"oninputxg:Supposeisanitealphabet,andsupposewehavespeciedamappingfromf0,1,`(',`)',`,'gtostringsofsomexedlengthin,sothateachTuringmachinehasadescriptioninobtainedbytakingitsstandarddescription,usingtomapeachsymbolto,andconcatenatingtheresultingsequenceofstrings.Foreveryx2wewillnowdenealanguageL(x)0asfollows.IfxisthedescriptionofaTuringmachineMthenL(x)=L(M);otherwise,L(x)=;:WearenowinapositiontorepeatthediagonalconstructionfromtheproofofTheorem2.Consideraninnitetwo-dimensionaltablewhoserowsandcolumnsareindexedbyelementsof0. x0x1x2x3... L(x0) 0100...L(x1) 1101...L(x2) 0010...L(x3) 1011...... ............Denition6.ThediagonallanguageD0isdenedbyD=fx20jx62L(x)g:Theorem4.ThediagonallanguageDisnotrecursivelyenumerable.Proof.TheproofisexactlythesameastheproofofTheorem2.Assume,bywayofcontradiction,thatD=L(x)forsomex.Eitherx2Dorx62Dandweobtainacontradictioninbothcases.Ifx2Dthenthisviolatesthefactthatx62L(x)forallx2D.Ifx62Dthenthisviolatesthefactthatx2L(x)forallx62D. Corollary5.ThereexistsalanguageLthatisrecursivelyenumerablebutitscomplementisnot.Proof.LetLbethecomplementofthediagonallanguageD.ATuringmachineMthatacceptsLcanbedescribedasfollows:giveninputx,constructthestringx;xandrunauniversalTuringmachineonthisinput.ItisclearfromthedenitionofLthatL=L(M),soLisrecursivelyenumerable.Wehavealreadyseenthatitscomplement,D,isnotrecursivelyenumerable. 4.5Rice'sTheoremTheorem7showsthat,unfortunately,thereexistinterestinglanguagesthatarenotdecidable.Inparticular,thequestionofwhetheragivenTuringmachinehaltsonagiveninputisnotdecidable.Unfortunately,thesituationismuchworsethanthis!Ournexttheoremshowsthatessentiallyanynon-trivialpropertyofTuringmachinesisundecidable.(Actually,thisisanoverstatement;thetheoremwillshowthatanynon-trivialpropertyofthelanguagesacceptedbyTuringmachinesisundecidable.Non-trivialpropertiesoftheTuringmachineitself|e.g.,doesitrunformorethan100stepswhenpresentedwiththeinputstring.t|maybedecidable.)Denition8.LanguageL0isaTuringmachineI/Opropertyifitisthecasethatforallpairsx;y2suchthatL(x)=L(y),wehavex2L,y2L.WesaythatLisnon-trivialifbothofthesetsLand L=0nLarenonempty.Theorem8(Rice'sTheorem).IfLisanon-trivialTuringmachineI/Oproperty,thenLisundecidable.Proof.Consideranyx1suchthatL(x1)=;.Wecanassumewithoutlossofgeneralitythatx162L.Thereasonisthatalanguageisdecidableifandonlyifitscomplementisdecidable.Thus,ifx12LthenwecanreplaceLwith Landcontinuewiththerestofproof.Intheendwewillhaveproventhat LisundecidablefromwhichitfollowsthatLisalsoundecidable.SinceLisnon-trivial,thereisalsoastringx02L.Thisx0mustbeadescriptionofaTuringmachineM0.(Ifx0werenotaTuringmachinedescription,thenitwouldbethecasethatL(x0)=;=L(x1),andhencethatx062Lsincex162LandLisaTuringmachineI/Oproperty.)WearenowreadytoproveRice'sTheorembycontradiction.GivenaTuringmachineMLthatdecidesLwewillconstructaTuringmachineMHthatdecidesthehaltingproblem,incontradictiontoTheorem7.TheconstructionofMHisasfollows.OninputM;x,ittransformsthepairM;xintothedescriptionofanotherTuringmachineM,andthenitfeedsthisdescriptionintoML.ThedenitionofMisalittletricky.Oninputy,machineMdoesthefollowing.FirstitrunsMoninputx,withoutoverwritingthestringy.IfMeverhalts,theninsteadofhaltingMentersthesecondphaseofitsexecution,whichconsistsofrunningM0ony.(RecallthatM0isaTuringmachinewhosedescriptionx0belongstoL.)IfMneverhalts,thenMalsoneverhalts.ThiscompletestheconstructionofMH.Torecap,whenMHisgivenaninputM;xitrsttransformsthepairM;xintothedescriptionofarelatedTuringmachineM,thenitrunsMLontheinputconsistingofthedescriptionofManditoutputsthesameanswerthatMLoutputs.Therearetwothingswestillhavetoprove.1.ThefunctionthattakesthestringM;xandoutputsthedescriptionofMisacomputablefunction,i.e.thereisaTuringmachinethatcantransformM;xintothedescriptionofM.2.AssumingMLdecidesL,thenMHdecidesthehaltingproblem.Therstofthesefactsiselementarybuttedious.Mneedstohaveabunchofextrastatesthatappendaspecialsymbol(say,])totheendofitsinputandthenwriteoutthestringxafterthespecialsymbol,].ItalsohasthesamestatesasMwiththesametransitionfunction,withtwomodications:rst,thismodiedversionofMtreatsthesymbol]exactlyasifitwere..(ThisensuresthatMwillremainontherightsideofthetapeandwillnotmodifythecopyofythatsitstotheleftofthe]symbol.)Finally,wheneverMwouldhalt,themodiedversion 1.AswewillseeinSection5.1,ifthereisanondeterministicTuringmachinethatacceptslanguageLthenthereisalsoadeterministicTuringmachinethatacceptsL.Thus,ifoneignoresrunningtime,nondeterministicTuringmachineshavenomorepowerthandeterministicones.2.ThequestionofwhethernondeterministiccomputationcanbesimulateddeterministicallywithonlyapolynomialincreaseinrunningtimeisthePvs.NPquestion,perhapsthedeepestopenquestionincomputerscience.3.Nondeterminismcanfunctionasausefulabstractionforcomputationwithanuntrustedexternalsourceofadvice:thenondeterministicmachine'stransitionsareguidedbytheadvicefromtheexternalsource,butitremainsincontrolofthedecisionwhethertoacceptitsinputornot.5.1NondeterministicTuringmachinesanddeterministicveriersOneusefulwayoflookingatnondeterministiccomputationisbyrelatingittothenotionofaverierforalanguage.Denition10.Letbealanguagenotcontainingthesymbol`;'.AverierforalanguageL0isadeterministicTuringmachinewithalphabet[f;g,suchthatL=fxj9ys.t.V(x;y)=yesg:Wesometimesrefertothestringyintheverier'sinputastheevidence.WesaythatVisapolynomial-timeverierforLifVisaverierforLandthereexistsapolynomialfunctionpsuchthatforallx2LthereexistsaysuchthatV(x;y)outputs\yes"afteratmostp(jxj)steps.(Notethatifanysuchyexists,thenthereisonesuchysatisfyingjyjp(jxj),sincetherunningtimeboundpreventsVfromreadinganysymbolsofybeyondtherstp(jxj)symbols.)ThefollowingtheoremdetailsthecloserelationshipbetweennondeterministicTuringma-chinesanddeterministicveriers.Theorem9.ThefollowingthreepropertiesofalanguageLareequivalent.1.Lisrecursivelyenumerable,i.e.thereexistsadeterministicTuringmachinethatacceptsL.2.ThereexistsanondeterministicTuringmachinethatacceptsL.3.ThereexistsaverierforL.Proof.AdeterministicTuringmachinethatacceptsLisaspecialcaseofanondeterministicTuringmachinethatacceptsL,soitistrivialthat(1)imples(2).Toseethat(2)implies(3),supposethatMisanondeterministicTuringmachinethatacceptsL.ThetransitionrelationofMisanitesetof5-tuplesandwecannumbertheelementsofthissetas1;2;:::;KforsomeK.Theverier'sevidencewillbeastringyencodingasequenceofelementsoff1;:::;Kg,thesequenceoftransitionsthatMundergoesinacomputationthatleadstoacceptingx.TheverierVoperatesasfollows.Giveninputx;y,itsimulatesacomputationofMoninputx.Ineverystepofthesimulation,Vconsultstheevidencestringytoobtainthenexttransitionrule.Ifitisnotavalidtransitionruleforthecurrentconguration(forexamplebecauseitappliestoastateotherthanthecurrentstateofMinthesimulation)thenVinstantlyoutputs\no", otherwords,cnf-satisdenedinexactlythesamewayas3satexceptthataclauseisallowedtocontainanynumberofliterals.Itisclearthatcnf-satand3satbelongtoNP:averiermerelyneedstotakeaproposedtruthassignmentandgothrougheachclause,checkingthatatleastoneofitsliteralsissatisedbytheproposedassignment.Thereisaneasyreductionfromcnf-satto3sat.Supposewearegivenasatinstancewithvariablesx1;:::;xnandclausesC1;:::;Cm.ForeachclauseCjthatisadisjunctionofk(j)3literals,welet`1;:::;`k(j)betheliteralsinCjandwetransformCjintoaconjunctionofk(j)2clausesofsize3,asfollows.Firstwecreateauxiliaryvariableszj;1;:::;zj;k(j)3,thenwerepresentCjusingthefollowingconjunction:(`1_`2_zj;1)^( zj;1_`3_zj;2)^( zj;2_`4_zj;3)^( zj;3_`5_zj;4)^^( zj;k(j)3_`k(j)1_`k(j)):Itisanexercisetoseethatagiventruthassignmentofvariablesx1;:::;xnsatisesCjifandonlyifthereexistsatruthassignmentofzj;1;:::;zj;k(j)3that,whencombinedwiththegivenassignmentofx1;:::;xn,satisesalloftheclausesintheconjunctiongivenabove.Similarly,wecanuseauxiliaryvariablestoreplaceeachclausehavingk3literalswithaconjunctionofclauseshavingexactlythreeliterals.Specically,wetransformaclauseCjcontainingasingleliteral`1intotheconjunction(`1_zj_z0j)^(`1_ zj_z0j)^(`1_zj_ z0j)^(`1_ zj_ z0j);andwetransformaclauseCj=(`1_`2)intotheconjunction(`1_`2_zj)^(`1_`2_ zj):Onceagainitisanexercisetoseethatagiventruthassignmentofvariablesx1;:::;xnsatisesCjifandonlyifthereexistsatruthassignmentoftheauxiliaryvariablesthat,whencombinedwiththegivenassignmentofx1;:::;xn,satisesalloftheclausesintheconjunctionsgivenabove.TocompletetheproofoftheCook-LevinTheorem,wenowshowthateverylanguageinNPcanbereduced,inpolynomialtime,tocnf-sat.Theorem11.IfL20isinNPthenthereexistsapolynomial-timereductionfromLtocnf-sat.Proof.SupposeVisapolynomial-timeverierforLandpisapolynomialfunctionsuchthatforeveryx2LthereexistsysuchthatV(x;y)outputs\yes"afteratmostp(jxj)steps.ThecomputationofVcanbeexpressedusingarectangulartablewithp(jxj)rowsandcolumns,witheachrowrepresentingacongurationofV.Eachentryofthetableisanorderedpairin(K[fg),whereKisthestatesetofV.Themeaningofanentry(q;)intheithrowandjthcolumnofthetableisthatduringstepiofthecomputation,Vwasinstateq,visitinglocationj,andreadingsymbol.Iftheentryis(;)itmeansthatwasstoredatthatlocationduringstepi,butthelocationofVwaselsewhere.ToreduceLtocnf-sat,weuseasetofvariablesrepresentingthecontentsofthistableandasetofclausesassertingthatthetablerepresentsavalidcomputationofVthatendsinthe\yes"state.Thisissurprisinglyeasytodo.Foreachtableentry(i;j)where0i;jp(jxj),andeachpair(q;)2(K[fastg),wehaveaBooleanvariableuq;i;j.Theclausesaredenedasfollows.1.Theverierstartsinstatesontheleftsideofitstape.Thisisrepresentedbyaclauseconsistingofasingleliteral,us;.0;0.