20

Let $F = \{⟨M⟩:\text{M is a TM which stops for every input in at most 50 steps}\}$. I need to decide whether F is decidable or recursively enumerable. I think it's decidable, but I don't know how to prove it.

My thoughts

This "50 steps" part immediate turns the R sign for me. If it was for specific input it would be decidable. However, here it's for every input. Checking it for infinite inputs makes me think that the problem is co-RE, i.e. its complement is acceptable.

Perhaps, I can check the configurations and see that all configurations after 50 steps don't lead to accept state- how do I do that?

user1868607
  • 2,224
  • 14
  • 23
Jozef
  • 1,727
  • 4
  • 14
  • 22

2 Answers2

22

Let's consider the more general problem of machines which stop after at most $N$ steps, for some $N \geqslant 1$. (The following is a substantial simplifcation of a previous version of this answer, but is effectively equivalent.)

As swegi remarks in an earlier response, if the machine stops after at most $N$ steps, then only the cells $0,1,\ldots,N-1$ on the tape are significant. Then it suffices to simulate the machine $M$ on all input strings of the form $x \in \Sigma^N$, of which there are a finite number.

  • If any of these simulations fail to enter a halting state by the $N^{\text{th}}\:\!$ transition, this indicates that any input string starting with $x$ is one for which the machine does not stop within the first $N$ steps.
  • If all of these simulations halt by the $N^{\text{th}}\:\!$ transition, then $M$ halts within $N$ steps on all inputs of any length (of which the substring of length $N$ is all that it ever acts on).
Niel de Beaudrap
  • 4,241
  • 1
  • 18
  • 32
6

If $M$ stops in no more than 50 steps, than the positions $M$ can reach on the normally infinite tape are limited. Thus the infinite tape can be simulated by a finite one. This means that the tape can be simulated by a finite automaton. It follows that a turing machine $M$ that stops in no more than 50 steps is bisimilar to some finite automaton $M'$.

Let $Q$ be the set of states of $M$, $F \subset Q$ the set of accepting states and $\Gamma$ be the alphabet. Then we build the set of states $Q'$ of $M'$ as follows: $Q' = \{ \langle n, q, s, p, a\rangle \, | n \in \{0,...,50\} \, q \in Q, s \in \Gamma, p \in \{-50,...,50\}, a \equiv q \in F\}$ where $p$ is the position of the read/write head above the tape. We can restrict the position to $\{-50,...,50\}$ because the number of allowed computing steps limits the number of reachable positions.

Having a state $\langle n, q, s, p, a\rangle$ of the finite automaton $M'$ then means that we are at state $q$ of the original automaton, with $s$ on the tape at position $p$ where also the read/write head is positioned, after the $n$-th computing step. The state is an accepting one if $a \equiv true$.

Transforming the transition relation of a concrete turing machine is a little more work but not necessary for the original question, because it is enough to show that the state space is finite (and thus we can just test each input with a length of at most 50 symbols on each such automaton). The idea is to build a new transition relation that goes from a state $\langle n, q, s, p, a \rangle$ to a state $\langle n+1, q', s', p', a'\rangle$ in the $n$-th computing step iff the transition $\langle q, s, p\rangle \rightarrow \langle q', s', p'\rangle$ was in the original transition relation.

swegi
  • 163
  • 5