# Prove Halting on all Inputs is not in RE simulation

I don't understand why when proving if Halting on all inputs problem si not in RE using the complement of the halting problem, I have to take a turing machine and simulate the machine M(the machine that the halting problem receives as input) on w(the word received as input) for n steps.

Can somebody explain to me who is n and why do we need to simulate M for n steps? Why not only once?

For proving that halting on all inputs problem is not in RE, the complement of halting problem is used. Supposed we take M(w) as the turing machine used for halting problem, I get the next simulation:

M'= simulate M(w) for n steps; if M(w) halts, make it loop else, stop.

I don't understand why do I have to make M' simulate M(w) for N STEPS. Why can't I just simulate it one and that's it?

N stands for the length of the word. I don't understand the simulation for a number of steps. Why is that?

• Can you add a reference to the textbook you are using in the question? All users are not using the same textbook as you. Or you can copy the full or just the relevant text of that proof in the question. Jan 31, 2019 at 5:23
– Xyz
Jan 31, 2019 at 6:53
• Unless you explain the entire proof, it will be very hard to answer this question. We also don't know what $n$ stands for. Jan 31, 2019 at 7:32
• @YuvalFilmus I try my best to prove all the information, but that is all it was written..
– Xyz
Jan 31, 2019 at 8:26

What is the Halting on all inputs problem? It is the problem about the language $$TOTAL=\{⟨M⟩\mid M \text{ is a TM and }M\text{ halts on all inputs} \}.$$

What is the complement of the Halting problem? It is the problem about the language $$\overline{HALT}= \{⟨M, w⟩\mid M \text{ is a TM and }M\text{ does not halt on input } w\}.$$

Given a word $$⟨M, w⟩$$ where $$M$$ is a Turing machine and $$w$$ is a input word, how can we construct a new Turing machine in a way that is similar to/the same as how a Turing machine is described in $$TOTAL$$?

$$M'$$ = simulate $$M(w)$$ for $$n$$ steps; if $$M(w)$$ halts, make it loop else, stop.

The construction above is not clear as the meaning of $$n$$ is defined. Let us clarify that $$n$$ is the length of the input string. Here is a clear construction of $$M'$$, where $$|x|$$ is the length of $$x$$.

$$M' =$$ "On input string $$x$$, simulate $$M$$ with input $$w$$ as long as possible but for no more than $$|x|$$ steps. If the simulation ever halts, continue to loop forever; otherwise, halt."

Now you should be able to check that $$⟨M, w⟩\in\overline{HALT} \Longleftrightarrow M'\in TOTAL.$$

I don't understand why do I have to make M' simulate M(w) for N STEPS. Why can't I just simulate it one and that's it?

The "N" in "N STEPS" depends on the input to $$M'$$. It is a variable independent of $$M'$$.

• Let me see if I understood this correctly. It is like, when simulating M for M', you take just a finite part of the inputs w' and simulate M for them in order to see if M will halt or not and if M halts, then you make it loop so that the statement for TOTOAL(TOTOAL halts on all inputs) would be true?
– Xyz
Jan 31, 2019 at 9:30
• No. Given any input $w'$, $M'$ changes it to a number, $n$ using $E$. Then $M'$ simulates $M$ on input $w$ for $n$ steps. Note that $w'$ has nothing to do with $w$. (Hmm, I should have used $x$ instead of $w'$ to prevent relating $w$ to $w'$.) Jan 31, 2019 at 9:35
• And why is a number of steps needed? I mean, M(w) won't have the same behaviour everytime especially beacuse it's related to the same input w on and on?
– Xyz
Jan 31, 2019 at 9:48
• Please think from the following perspective first. How do you construct a Turing machine $M'$? You need to specify how $M'$ runs given any input $x$. Now how can you specify that? how? how? how? We have infinitely many such $x$. Jan 31, 2019 at 9:55
• Running $M'$ a certain number of times to see it's behaviour?
– Xyz
Jan 31, 2019 at 9:57