Consider the TM that always moves the tape head to the right and prints a special non-blank tape symbol at each step. This means that the TM never halts, since it always moves to the right, and never repeats a state, since after k steps the tape head is over the kth cell of the machine. Consequently, each configuration of the machine is different from all others, and the machine always loops.
We could also nonconstructively show the existence of such machines. Assume for contradiction that every TM that never halts eventually loops. This means that if you start a TM $M$ on a string $w$, one of the following will eventually happen:
- $M$ halts, or
- $M$ repeats a configuration.
In this case, the halting problem would be decidable as follows. Given a TM $M$ and string $w$, simulate $M$ on $w$, at each point writing out the contents of the tape, current state, and current tape position. If this configuration is a duplicate, output "does not halt." Otherwise, if $M$ halts on $w$, output "halts." Since one of these is guaranteed to happen eventually, this process always terminates, so we would have an algorithm for the halting problem, which we know does not exist.
Hope this helps!
x^2
wherex
cycles between-100
and100
and the cycling is done with a modulo and halt when the result is negative. It could computex%2
where x ranges from zero to positive infinity and stop when the result equals 2. In assembly language do/while/for loops all come down do having a conditional jump, but cond jump alone means little. $\endgroup$