# Is there a more general proof for the halting problem?

Note:If this question is better suited for a different site, please tell me in the comments.

Summary:Is there a proof for the impossibility of the halting problem that doesn't involve calling it on itself.

The impossibility of the halting problem is demonstrated in most computer science courses in the following proof.

function does_halt(function){
if function.doesfinish{
return true
else{return false}

{
while(true){}
}
}


As shown above, the does_halt function is supposed to return true if the function does not enter an infinite loop, and false otherwise.

But the proof demonstrates that the function cannot give a correct answer, because the function will finish if does_halt returns false, and will never finish if does_halt returns true.

This proof however requires the use of does_halt in the tested function.This is perfectly legitimate as a proof, but doesn't say much about other cases.

Is there an established proof for the impossibility of the halting problem that doesn't call it on itself?And if not, could a halting function that worked on all functions that don't include a halting function within them theoretically be written?

• Does the proof on Wikipedia do what you want? It is at en.wikipedia.org/wiki/Halting_problem#Sketch_of_proof . That proof does not use the recursion theorem - the program $e$ there does not know its own index and does not assume that the halting function is computable (for a contradiction). Knowing whether that proof meets the question here will help answer it. – Carl Mummert Jul 15 '14 at 0:54
• The wikipedia proof is a rewritten version of the proof I have shown above and still relies on a call to the halting function from within the test case. – David Greydanus Jul 15 '14 at 0:58
• That is not the case; the Wikipedia proof uses an arbitrary computable function $f$, not the halting function $h$ (which is not computable). Also, the function paradox() above knows its own index, which it passes to does_halt() ; this requires the recursion theorem to formalize. The Wikipedia proof does not use the recursion theorem. – Carl Mummert Jul 15 '14 at 0:58
• Yes, Carl is correct, @DavidGreydanus – Thomas Andrews Jul 15 '14 at 1:02
• Upon further inspection I see the difference.Thanks for the reference @CarlMummert – David Greydanus Jul 15 '14 at 1:29

The usual proofs I've seen use a diagonal argument. First, enumerate computably all programs, $\phi_e$, and then to define:

$$f(e)=\left\{\begin{matrix}\phi_e(e)+1 &\text{if }\phi_e(e)\downarrow\\ 0&\text{otherwise} \end{matrix}\right.$$

This is computable, because we can determine whether $\phi_e(e)\downarrow$ - that is, whether computing $\phi_e(e)$ halts.

But $f$ is not equal to any $\phi_e$, and $\phi_e$ was an enumeration of all programs.

This is why lots of books talk about "universal Turing machines." There is a Turing machine, $U$, which takes two inputs, $e,x$ and computes $\phi_e(x)$, where $e$ is interpreted as program code for a Turing machine.

So to compute the above $f(e)$, we try to determine if $U(e,e)$ halts, and if it does...

My favorite version of the proof uses the idea from the old funny paradox, "The smallest natural number that cannot be described in 100 words or less." (This language paradox is hard to make rigorous, so it isn't a real paradox.)

But what if I could write a program, P, that takes an integer $n$ and says, "Find the smallest natural number that is not the output of a program of length $n$ or less with input of value $n$ or less?"

Then I'd have a real paradox, because if this program $P$ had length $N$, then what would happen when if I passed $N$ into it?

Now, if I can solve the halting problem, I can write $P$. I list all programs of length $n$ or less on all values of length $n$ or less, and, if they don't halt, I skip them, otherwise, I run them and enumerate the output value, keeping track. Then, after all that, I have a huge number of values, but I can still, with infinite memory, figure out the smallest positive integer which is not output by the program.

This still requires the existence of a universal program.

A universal program is essentially like writing an interpreter in the same language - writing Ruby in Ruby or C in C or Java in Java. Essentially, whatever machine you are using to model computation can be "emulated" inside itself.