1 / 15

Section 1.5: Intractable problems

Section 1.5: Intractable problems. The Halting Problem. Animation overview. In this animation you will be shown what The Halting Problem is. You will see: what it means to say if a program halts (terminates) examples of programs that do and do not halt.

tender
Télécharger la présentation

Section 1.5: Intractable problems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Section 1.5: Intractable problems The Halting Problem

  2. Animation overview In this animation you will be shown what The Halting Problem is. You will see: • what it means to say if a program halts (terminates) • examples of programs that do and do not halt. You will then be shown a proof that it is not possible to write a program that is able to take any other program and say if that program will halt or not.

  3. When you run a program, it will do one of two things: • It will run for a while and then halt (stop). • It will run forever (i.e. it will never halt). The second of these is not usually a good thing – you would normally want your program to terminate.

  4. Here is an example of a program Here is an example of a program that runs for a while and then that never stops: halts: program printNumbers2 program printNumbers1 X 1 ß X 0 repeat ß repeat print (X) print (X) X X +2 ß until X = 6 X X +2 ß until X = 6 print (X) print (X) end end What will this program do when it runs? What will this program do when it runs? When this program runs it will print the numbers 1, 3 , 5 , 7, 9, etc... no When this program runs it will print matter how long this program runs, the numbers 0, 2, 4, 6. for it will never stop as X never becomes equal to 6. It has got stuck in an infinite loop.

  5. Explanation It is fairly easy to tell that the second program will not terminate as it is a fairly simple program. Most programs are far more complex and you cannot tell by just looking at the code if it will terminate or not. One way of trying to find out if a program terminates or not is to run the program and see. If the program stops running after a while, you know that the program does terminate. The problem with this though is that if the program has not terminated you have no way of knowing if the program does not terminate, or if it has just not terminated yet (if you leave it running for another second it may terminate).

  6. Alan Turing – proof by contradiction

  7. True …it will return a value of True as printNumbers1 is a program that does halt.

  8. False …it will return a value of False as printNumbers2 is a program that doesn’t halt.

  9. If the program reaches this while loop, it will get stuck in an infinite loop, as x is always going to be less than 1 If a program goes into an infinite loop, it does not halt (terminate)

  10. Conclusion

More Related