/
Introduction Introduction

Introduction - PDF document

cheryl-pisano
cheryl-pisano . @cheryl-pisano
Follow
346 views
Uploaded On 2015-08-04

Introduction - PPT Presentation

TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 2 of 12 Back FullScreen Close Quit 351 Introduction Someproblemsareunsolvable Weretalkingabout importantandinterestingproblems pr ID: 99924

TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 2 of 12 Back FullScreen Close Quit 35.1. Introduction  Someproblemsareunsolvable.  We'retalkingabout { importantandinterestingproblems { pr

Share:

Link:

Embed:

Download Presentation from below link

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.


Presentation Transcript

Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 2 of 12 Back FullScreen Close Quit 35.1. Introduction  Someproblemsareunsolvable.  We'retalkingabout { importantandinterestingproblems, { precisely-de nedproblems(notvagueproblemssuchas`composeapoemontopicT')forwhich { nomatterhowcleverweare, { nomatterhowmuchexecutiontime,memory,etc.weallowthereisprovablynoalgorithmtosolvetheproblem.  Ourterminology:computableandnon-computable.  Herearesomeexamplesofnon-computableproblemsthatwebrushedupagainstearlierinthemodule: { TilingProblemsfortheintegergrid(lecture1); { TakeinaprogramP;returnYESifPwilleverperformadivisionbyzero,elsereturnNO(lecture10); { TakeinaprogramP;returnanadequatesetoftestdataforprogramP(lecture10); { Takeinaproblemspeci cationPSandaprogramP;returnaproofthatPsolvesPS(ifitdoessolveit),elsereturnfail(lectures10&22).  Butwe'regoingtolook rstatthemostfamousofallnon-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:=x�2;g  E.g.AsolutiontotheHaltingProblemshouldreturnNOwhengiventhepreviousprogramandinputx=12.  Question:Whycan'twesimplyrunPonxandseewhathappens? 35.2.2. Preliminaries  WewillprovethattheHaltingProblemisnon-computable.  Wewanttoprove: ThereisnoMOCCAprogramwhich,uponacceptinganypairhP;xicon-sistingofthetextofalegalMOCCAprogramPandastringofsymbolsx,terminatesaftersome niteamountoftime,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,Impossentersanin niteloop.  IfHPreturnedNO,Impossterminates(theoutputbeingunimportant). Introduction TheHaltingProblem ModuleHomePage TitlePage JJ II J I Page 8 of 12 Back FullScreen Close Quit  WewillnowshowthatImpossisalogicalimpossibility.  Speci cally,wewillshowthatthereisacertaininputonwhichImposscannotter-minate,butitalsocannotnotterminate!  TheinputthatcausestheproblemisImpossitself!  We'llspellouttwocases { We'llsupposeImpossappliedtoitselfdoesterminate. { Thenwe'llsupposeImpossappliedtoitselfdoesnotterminate.  SupposeImposs,whengivenitselfasinput,doesterminate.  Whathappens?TwocopiesofImpossaremade.ThesearefedtoHP,whichreturnsananswer.Ittellsus,inthiscase,whetherImpossterminatesonImposs.Weareassumingthatitdoes.SoHPwouldreturnYES.However,atthispoint,weenterthein niteloop,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).