6

Procedure: Start a secondary TM in parallel with the first, but have the second perform exactly 1 step each 2 steps the first TM performs (i.e. it runs at half speed). If the second machine ever reaches the same configuration as the first, a loop was detected (obviously).

Claim: All infinite local loops in a TM can be detected in the above manner.

Local loop, in this context, refers to a machine running within a certain tape interval without ever stopping. To clarify, in particular this excludes any machines which extend the tape in any direction without bounds.

Has this been proven? I'm pretty sure I found this claim in a paper, I believe one of Marxen's, though I can't seem to find it.

mafu
  • 339
  • 1
  • 12

1 Answers1

7

This is Floyd's cycle finding algorithm, which is an efficient procedure for finding cycles. If you don't care about efficiency, you can use a big table which stores the different states the Turing machine has reached. If it reaches the same state twice, then it's in an infinite loop. What you are describing is just a more efficient way of detecting the same event, which is a particular type of infinite loop.

Turing machines can fail to halt – enter an infinite loop – in other ways. For example, a machine can keep going to the right indefinitely. The machine never halts, yet it doesn't reach the same state twice. A cycle finding algorithm won't detect this situation. Of course, there is no general way of detecting infinite loops, since the halting problem is undecidable.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514