Lecture Notes on Halting Problem and Reductions | CS 422, Study notes of Algorithms and Programming

Material Type: Notes; Professor: Kowalczyk; Class: Algorithms Design And Analysis; Subject: Computer Science; University: Northern Michigan University; Term: Winter 2008;

Typology: Study notes

Pre 2010

Uploaded on 08/01/2009

koofers-user-0ou
koofers-user-0ou 🇺🇸

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Algorithm Design and Analysis 4/3/2008
Lecture 31: Halting problem and reductions
Instructor: Mike Kowalczyk
1 Halting problem
Consider the function programHalts in Halt.java. Is it possible to write a correct implementation?
After several attempts, it appears to be impossible, but can we prove it? Assuming that we have
a correct implementation of programHalts, then we could also write the method thisProgramHalts,
and then write our main program to do the opposite of whatever our program supposedly was going
to do. Intuitively, such a function would allow us to predict the future outcome of our program as
it is still running! Let’s reason this more carefully:
If the program Halt.java halts, then the if statment evaluates to true, and then the program
infinite loops, so Halt.java doesn’t halt. But if the program Halt.java doesn’t halt, then the else
statment will execute, and the program will halt. Thus, we have a contradiction and our assumption
that the method programHalts could be written is false. So we conclude that there is no algorithm
that can always determine whether or not any given program halts on any given input.
A decision problem with this property that no algorithm solves it in general is called an unde-
cidable problem. So the halting problem is an example. Calculating the Kolmogorov complexity of
a given string is another example of an undecidable problem.
Does nondeterminism help? If we used a nondeterministic machine, could we solve an undecid-
able problem? A deterministic machine (such as an NMU laptop) can simulate a nondeterministic
machine, it just takes lots of time. Therefore, even a nondeterministic machine cannot solve the
halting problem.
Note that it is possible to solve the halting problem for specific cases, but not in general. An
interesting question to ask yourself is: “Is it possible to solve the halting problem if we only restrict
inputs to problems other than the same program itself?”, which throws a slight monkey wrench in
our proof technique above.
2 Reductions
A reduction, informally, is a way solving a problem using another. Example: getting to Chicago
from Marquette reduces to the problem of finding a map. It also reduces to loading up Google
maps, which in turn reduces to the problem of finding a computer with an Internet connection and
a browser. We will use reductions to relate the complexity of different problems.
1

Partial preview of the text

Download Lecture Notes on Halting Problem and Reductions | CS 422 and more Study notes Algorithms and Programming in PDF only on Docsity!

Algorithm Design and Analysis 4/3/

Lecture 31: Halting problem and reductions

Instructor: Mike Kowalczyk

1 Halting problem

Consider the function programHalts in Halt.java. Is it possible to write a correct implementation? After several attempts, it appears to be impossible, but can we prove it? Assuming that we have a correct implementation of programHalts, then we could also write the method thisProgramHalts, and then write our main program to do the opposite of whatever our program supposedly was going to do. Intuitively, such a function would allow us to predict the future outcome of our program as it is still running! Let’s reason this more carefully: If the program Halt.java halts, then the if statment evaluates to true, and then the program infinite loops, so Halt.java doesn’t halt. But if the program Halt.java doesn’t halt, then the else statment will execute, and the program will halt. Thus, we have a contradiction and our assumption that the method programHalts could be written is false. So we conclude that there is no algorithm that can always determine whether or not any given program halts on any given input. A decision problem with this property that no algorithm solves it in general is called an unde- cidable problem. So the halting problem is an example. Calculating the Kolmogorov complexity of a given string is another example of an undecidable problem. Does nondeterminism help? If we used a nondeterministic machine, could we solve an undecid- able problem? A deterministic machine (such as an NMU laptop) can simulate a nondeterministic machine, it just takes lots of time. Therefore, even a nondeterministic machine cannot solve the halting problem. Note that it is possible to solve the halting problem for specific cases, but not in general. An interesting question to ask yourself is: “Is it possible to solve the halting problem if we only restrict inputs to problems other than the same program itself?”, which throws a slight monkey wrench in our proof technique above.

2 Reductions

A reduction, informally, is a way solving a problem using another. Example: getting to Chicago from Marquette reduces to the problem of finding a map. It also reduces to loading up Google maps, which in turn reduces to the problem of finding a computer with an Internet connection and a browser. We will use reductions to relate the complexity of different problems.