Presentation is loading. Please wait.

Presentation is loading. Please wait.

Halting Problem Introduction to Computing Science and Programming I.

Similar presentations


Presentation on theme: "Halting Problem Introduction to Computing Science and Programming I."— Presentation transcript:

1 Halting Problem Introduction to Computing Science and Programming I

2 Alan Turing Alan Turing 1912-1954 Alan Turing 1912-1954 “Father” of modern computing science “Father” of modern computing science 1936 1936 Turing Machine Turing Machine Church-Turing thesis Church-Turing thesis Halting Problem Halting Problem 1950: Turing Test 1950: Turing Test

3 Turing Machine A Turing machine is a very simple theoretical “computer” with a couple basic elements. A Turing machine is a very simple theoretical “computer” with a couple basic elements. An infinitely long tape broken up into cells that can each store a single symbol from a finite set of symbols An infinitely long tape broken up into cells that can each store a single symbol from a finite set of symbols A head that can read or write one symbol at a time from the tape A head that can read or write one symbol at a time from the tape A state diagram that tells the head what to do, move left/right, print a symbol A state diagram that tells the head what to do, move left/right, print a symbol

4 Church-Turing Thesis This thesis proves has to do with comparing what problems can be solved by different types of computer. This thesis proves has to do with comparing what problems can be solved by different types of computer. It proves that a Turing Machine could theoretically be created that can do anything any digital computer can do. It proves that a Turing Machine could theoretically be created that can do anything any digital computer can do.

5 Halting Problem An important question of computing science is “Are there problems that cannot be solved?” An important question of computing science is “Are there problems that cannot be solved?” There are, and probably the most famous of these is the halting problem described by Turing. There are, and probably the most famous of these is the halting problem described by Turing. He was thinking in terms of Turing machines (there were no computers), but it is easy to extend the idea. He was thinking in terms of Turing machines (there were no computers), but it is easy to extend the idea.

6 Halting Problem Halting problem Halting problem Can we write a program that will look at any computer program and its input and decide if the program will halt (not run infinitely)? Can we write a program that will look at any computer program and its input and decide if the program will halt (not run infinitely)? A practical solution might be to run the program and if it halts you have your answer. If after a given amount of time it doesn’t halt, guess that it won’t halt. However, you wouldn’t know if the program would eventually halt. A practical solution might be to run the program and if it halts you have your answer. If after a given amount of time it doesn’t halt, guess that it won’t halt. However, you wouldn’t know if the program would eventually halt.

7 Halting Problem As it turns out the problem is undecidable. As it turns out the problem is undecidable. For a problem to be undecidable you just have to prove that there is one case it can’t produce an answer for. For a problem to be undecidable you just have to prove that there is one case it can’t produce an answer for. The case that Turing came up with that can never be solved involves giving a program itself as input. The case that Turing came up with that can never be solved involves giving a program itself as input.

8 Halting Problem Let’s assume we’re given a function halts(prog,input) that is supposed to tell us if the program prog will halt if given the input. The function will return True if it halts, False otherwise. Let’s assume we’re given a function halts(prog,input) that is supposed to tell us if the program prog will halt if given the input. The function will return True if it halts, False otherwise.

9 Halting Problem Using the halts function the following program can be written that reads in a program, given as a filename) from the user. It then calls the halts function to decide if the program will halt given itself as input. Using the halts function the following program can be written that reads in a program, given as a filename) from the user. It then calls the halts function to decide if the program will halt given itself as input. prog = raw_input("Program file name: ") if halts(prog, prog): while True: print "looping“ else: print "done"

10 Halting Problem It may not make sense to give a program itself as input, but that isn’t important here. It may not make sense to give a program itself as input, but that isn’t important here. What could happen? What could happen? If halts(prog,prog) returns True, that means the program will halt when given itself as input. However, in this case the program would go into an infinite loop. Therefore the program doesn’t halt. If halts(prog,prog) returns True, that means the program will halt when given itself as input. However, in this case the program would go into an infinite loop. Therefore the program doesn’t halt. If halts(prog,prog) returns False, that means that it wouldn’t halt, but in that case the program does halt. If halts(prog,prog) returns False, that means that it wouldn’t halt, but in that case the program does halt. This contradiction is unavoidable thus proving that the halting problem is undecidable. No function can always correctly decide if a program will halt. This contradiction is unavoidable thus proving that the halting problem is undecidable. No function can always correctly decide if a program will halt.

11 Turing Test The Turing test was formulated as a way to answer the question, “Can machines think?” The Turing test was formulated as a way to answer the question, “Can machines think?” The basic idea is that there is a sort of judge who converses with a computer and a person. However, this is indirect. The judge writes down questions and the computer and the person, who are hidden from the judge, return typewritten answers. If the judge couldn’t consistently identify which set of answers were from the person, than the computer could “think”. The basic idea is that there is a sort of judge who converses with a computer and a person. However, this is indirect. The judge writes down questions and the computer and the person, who are hidden from the judge, return typewritten answers. If the judge couldn’t consistently identify which set of answers were from the person, than the computer could “think”. Turing predicted that computers could pass this test with 30% of humans as the judge by the year 2000. Turing predicted that computers could pass this test with 30% of humans as the judge by the year 2000.


Download ppt "Halting Problem Introduction to Computing Science and Programming I."

Similar presentations


Ads by Google