The most common aperiodic hang is a Sweep Hang. Here DP sweeps across the data, going back and forth. It will extend the sequence at one or both ends while doing so. This causes the sequence to grow, which means that it takes increasingly more time to traverse the sequence, which is why the hang is not periodic.
Sweep Hangs require at a minimum two Sweep Loops. One sweep loop moves DP to the right. This loop exits when the sweep reaches the end of the sweep body. The program then starts executing the other sweep loop, which moves DP leftwards. In between both sweep loops the program may execute some transition instructions. Figure 1 shows a typical example of a Sweep Hang.
There are several characteristics that can be used to classify sweeps: how the sweeped sequence grows, how the sweeped sequence changes during each sweep, and how the sweep is implemented by one or more loops.
A sweep in a given direction can result in the following:
During a sweep, the sequence can be modified as follows:
The sweep in a given direction can be realized in multiple ways. For 6x6 programs the sweep can be realized as follows:
Note, there is no fundamental restriction that limits a sweep in a given direction to two loops. When the program grid is sufficiently large, programs can be created that realize sweeps using three or more loops. However, the goal for my search program is to correctly classify all 6x6 hangs using logic that does not falsely classify larger programs as hanging. Given that, it suffices that the detection algorithm limits itself to this. As it turns out, this is complex enough.