TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 2 of 12 Back FullScreen Close Quit 351 Introduction Someproblemsareunsolvable Weretalkingabout importantandinterestingproblems pr ID: 99924
Download Pdf The PPT/PDF document "Introduction" 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.
Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 2 of 12 Back FullScreen Close Quit 35.1. Introduction Someproblemsareunsolvable. We'retalkingabout { importantandinterestingproblems, { precisely-denedproblems(notvagueproblemssuchas`composeapoemontopicT')forwhich { nomatterhowcleverweare, { nomatterhowmuchexecutiontime,memory,etc.weallowthereisprovablynoalgorithmtosolvetheproblem. Ourterminology:computableandnon-computable. Herearesomeexamplesofnon-computableproblemsthatwebrushedupagainstearlierinthemodule: { TilingProblemsfortheintegergrid(lecture1); { TakeinaprogramP;returnYESifPwilleverperformadivisionbyzero,elsereturnNO(lecture10); { TakeinaprogramP;returnanadequatesetoftestdataforprogramP(lecture10); { TakeinaproblemspecicationPSandaprogramP;returnaproofthatPsolvesPS(ifitdoessolveit),elsereturnfail(lectures10&22). Butwe'regoingtolookrstatthemostfamousofallnon-computableproblems,theHaltingProblem. Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 3 of 12 Back FullScreen Close Quit 35.2. TheHaltingProblem 35.2.1. WhatistheHaltingProblem? Aswehavediscussedpreviously,compilersdetecterrorsinprograms(priortotrans-latingthesourceprogramintoatargetprogram).Inparticular,theydetecterrorsinthesyntaxandthestaticsemantics.Theycannot,ingeneral,detecterrorsinthedynamicsemantics.Thereisagoodreasonforthis:it'simpossible.TheHalt-ingProblemisoneoftheproblemswemightlikecompilerstosolve,butwhichnocompilercaneversolve. Itistraditionaltoexplainthisproblem(andcomputabilityingeneral)usingsome-thingcalledaTuringmachine.However,wewillexplainthistopicusingMOCCAprograms,whichisjustasgood.(Infact,wecoulduseJavaprograms,orCpro-grams,orPascalprograms,or...,andthesewouldbejustasgoodalso.)We'llcomebacktoTuringmachinesinafewlectures'time,andthat'swhenwecanshowthatusingMOCCA(orJava,etc.)isjustasgood. Thefollowingproblemisnon-computable: Problem35.1. TheHaltingProblemParameters:AMOCCAprogramP,andapotentialin-putxtoP.Returns:YESifPwouldhaveterminatedhadwerunitoninputx;NOotherwise.(WeareassumingthatPexpectsjustoneinputx.Againnothinghangsonthis.Indeed,ifPrequiresmorethanoneinput,wecanthinkofitastakinginasingleinput:theconcatenationoftheindividualinputs.) Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 4 of 12 Back FullScreen Close Quit E.g.AsolutiontotheHaltingProblemshouldreturnYESwhengiventhefollowingprogramandinputx=11: whilex6=1fx:=x2;g E.g.AsolutiontotheHaltingProblemshouldreturnNOwhengiventhepreviousprogramandinputx=12. Question:Whycan'twesimplyrunPonxandseewhathappens? 35.2.2. Preliminaries WewillprovethattheHaltingProblemisnon-computable. Wewanttoprove: ThereisnoMOCCAprogramwhich,uponacceptinganypairhP;xicon-sistingofthetextofalegalMOCCAprogramPandastringofsymbolsx,terminatesaftersomeniteamountoftime,andoutputsYESifPhaltswhenrunoninputxandNOifPdoesnothaltwhenrunoninputx. Akeyobservationisthatsuchaprogram,ifitexists,mustworkforeverypairhP;xi.And,ofcourse,suchaprogram,ifitexists,isitselfalegalMOCCAprogram,soithastoworkonitself. Weshallprovethenonexistenceofsuchaprogrambycontradiction. Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 7 of 12 Back FullScreen Close Quit Here'sImpossagaininamoretextualform: Algorithm:Imposs(Q)ans:=HP(Q;Q);ifans=YESfwhiletruefggelsefreturnwhatever;g Andhere'sanexplanationofprogramImpossinwords. { ImpossisaMOCCAprogramwhichtakesinasingleinput,Q,whichitselfshouldbethetextofaMOCCAprogram. { ImpossbeginsbymakingacopyofQ. { ImpossthencallsHP.RecallthatHPexpectstwoinputs,sowhenImpossactivatesHP,itsuppliesthetwocopiesofQ. { HPmusteventuallyreturneitherYES(i.e.programQdoesterminateforinputQ)orNO(i.e.programQdoesnotterminateforinputQ). { Impossreactsasfollows: IfHPreturnedYES,Impossentersaninniteloop. IfHPreturnedNO,Impossterminates(theoutputbeingunimportant). Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 8 of 12 Back FullScreen Close Quit WewillnowshowthatImpossisalogicalimpossibility. Specically,wewillshowthatthereisacertaininputonwhichImposscannotter-minate,butitalsocannotnotterminate! TheinputthatcausestheproblemisImpossitself! We'llspellouttwocases { We'llsupposeImpossappliedtoitselfdoesterminate. { Thenwe'llsupposeImpossappliedtoitselfdoesnotterminate. SupposeImposs,whengivenitselfasinput,doesterminate. Whathappens?TwocopiesofImpossaremade.ThesearefedtoHP,whichreturnsananswer.Ittellsus,inthiscase,whetherImpossterminatesonImposs.Weareassumingthatitdoes.SoHPwouldreturnYES.However,atthispoint,weentertheinniteloop,soImpossneverterminates. Butthismeansthat,whenweassumethatImpossdoesterminateonImposs,thenImpossdoesnotterminateonImposs! Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 10 of 12 Back FullScreen Close Quit Fromthesetwocases,wehavefoundthat { Imposscannotterminatewhenrunonitself,and { Imposscannotnotterminatewhenrunonitself!SomethingisverywrongwithImposs. ButImposswasconstructedquitelegally.So,theonlypartofImpossthatcanbeheldresponsibleisHP. WeconcludethataprogramHP,solvingtheHaltingProblem,simplycannotexist. (HowmuchdidthisdependonMOCCA?Notatall.) Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 11 of 12 Back FullScreen Close Quit Acknowledgements Thistreatmentismostlybasedon[ Har92 ].Iacknowledgealsothein uenceofAchimJung'sModelsofComputationcoursenotes[ Jun ].ClipArt(ofheadwithbomb)licensedfromtheClipArtGalleryonDiscoverySchool.com. Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 12 of 12 Back FullScreen Close Quit References [Har92] D.Harel.Algorithmics:TheSpiritofComputing.Addison-Wesley,2ndedition,1992. [Jun] A.Jung.ModelsofComputation(CourseNotes).