Right. Cycle detection can be done by running two copies of the program in lockstep, but at a 2:1 step rate. If the state of both programs match, you're in an infinite loop.