5

Prove that the language Loop Turning Machine = { < M > | M is a TM that loops on all inputs} is recognizable.

I feel like $M$ would never halt. To make $M$ recognizable it needs to accept or reject. Do I need to establish a decider?

EDIT:

Can I say that a halting Turing Machine $M$ is a machine for which exists a word $w$ such that $M$ halts on $w$? This makes the language recognizable but the machine may go on forever if executed.

Yawn
  • 111
  • 1
  • 3
  • 8

4 Answers4

6

$L$ isn't recognizable. We'll first establish a couple of preliminary results

I. $\overline{L}$ is recognizable

The complement of $L$, $$ \overline{L}=\{\langle M\rangle\mid M \text{ halts on at least one input}\} $$ is recognizable. Define a recognizer TM as follows:

R(<M>) =
   for n = 1, 2, 3, ...
      for each x in {x_1, x_2, ... , x_n}   // in some canonical order
         run M on x for one move
         if M halts
            return accept

It should be clear that $R$ accepts all and only those $\langle M \rangle$ for which $\langle M \rangle\in \overline{L}$ and so $\overline{L}$ is recognizable. Now if $L$ were also recognizable, then we could use the two recognizers to make decider for $L$, which brings us to our second result.

II. L is undecidable

If $L$ were decidable, then $\overline{L}$ would also be, and conversely. If that were the case, we could define a reduction from the known undecidable language $$ HALT = \{(\langle M\rangle \mid M \text{ halts on input }w\} $$ to $\overline{L}$ by the mapping $$ (\langle M\rangle, w)\rightarrow M_w $$ where, as babou has already noted,

M_w(y) =
   erase the input y
   write w on the input tape
   simulate M on w

Now observe that $M$ halts on $w$ $\Longleftrightarrow$ $M_w$ halts (on every input $y$, in fact) $\Longleftrightarrow$ $M_w\in \overline{L}$. In summary, if $L$ were decidable, then we could $L$'s decider (reversing the roles of accept and reject) to decide the halting problem, a contradiction.


Now we can show that $L$ is not recognizable. If it were, then, using (I) we could conclude that $L$ was decidable, a contradiction to result (II).

Rick Decker
  • 15,016
  • 5
  • 43
  • 54
3

Note: obviously, here, "loops" must be understood as "does not halt".

Consider a machine $M$ and an input $w$. From that you can build a machine $M_w$ that, given any input, will just erase this input, replace it by $w$, and then will simply mimic $M$ on input $w$. Obviously $M$ loops on input $w$ iff $M_w$ loops on all inputs.

If the language $L_{\bar h}$ is recognizable, then we have a semi-decision procedure to know whether $M_w$ loops, hence whether $M$ loops on $w$. Since we also have a semi-decision procedure to check whether $M$ halts on $w$, by simply running it, we have a decision procedure for $M$ running on input $w$. This being true for any $M$ and any $w$, we have solved the halting problem.

So there seem to be a good chance that $L_{\bar h}$ might be there incognito. (I mean $L_{\bar h}$ is not recognizable)

babou
  • 19,645
  • 43
  • 77
2

Here's a different proof that this language isn't recognizable, this time using self-referential TMs and the recursion theorem.

Suppose that your language is recognizable. Let $R$ be a recognizer for it. We'll assume that $R$ never rejects - we can do this by replacing any rejecting states of $R$ with states that loop infinitely. Therefore, if we run $R$ on a TM encoding $\langle M \rangle$, then $R$ accepts if $M$ loops on all inputs and $R$ loops of $M$ halts on any input.

So consider this self-referential TM:

$M$ = "On input $w$:

Use the recursion theorem to obtain $\langle M \rangle$.

Run $R$ on $\langle M \rangle$.

If $R$ accepts, accept $w$."

Now, either $M$ always loops or $M$ halts at least once. If $M$ always loops, then $R$ will accept $\langle M \rangle$, causing $M$ to halt - a contradiction! Otherwise, $M$ halts at least once. But that means that $R$ will loop on $\langle M \rangle$, causing $M$ to always loop - a contradiction!

The only bad assumption we made is that we had a recognizer for $L$, so our assumption was wrong and $L$ is not recognizable.

Hope this helps!

Rick Decker
  • 15,016
  • 5
  • 43
  • 54
templatetypedef
  • 9,302
  • 1
  • 32
  • 62
1

A machine that necessarily loops (for all inputs) is a machine whose final states (accepting or rejecting) are unreachable.

There are two kinds of machines that behave this way: those that use a finite amount of tape (and repeat configurations forever), and those that don't. Encodings of the first kind form a language that is recognizable: you just have to keep track of the recurrence of configurations.

If you combine these two types of machines in one class, any language of their encodings will not be recognizable - as the other answers have shown.

For further discussion, check out this other question: Does a never-halting machine always loop?

André Souza Lemos
  • 3,296
  • 1
  • 16
  • 30