# How far out can one determine a program is halting?

Suppose we have a finite set of programs, say, something like every Turing machine with 2 states and 7 symbols. After running all of them for a very long time, we've narrowed it down to a small subset thereof. Of those remaining, let's suppose that at least one will run forever and at least one will eventually halt, and that they fall into that category where it is impossible to tell which without running them for arbitrarily many more steps.

As I understand it, if we're determined enough and ignore physical considerations of time and memory, we'll theoretically reach the halting points for all those which are going to halt, although we'll never know that for sure. But before we reach that point, e.g., one step before the longest-running program halts, it will be obvious that that program is about to halt; we'll be able to look at its current symbol, state, and transform table, and it will be clear what's next.

Arguably, that's effectively computing that final step. But in reality, I have a very hard time imagining a scenario in which it isn't obvious that it's winding down 2, 3, or many steps earlier. In particular, if it's one of those recursion-based algorithms typical of BB-champions, or something like a Collatz sequence, various indicators that had been growing and growing for much of its run will suddenly be shrinking, or otherwise changing behavior.

There must be a limit to how far out such behavior can be detectable, or the halting problem wouldn't exist. On the other hand, it seems likely to me that there's probably also an upper bound on how obfuscated its behavior can be, or more concretely, how many steps out from a halt we could theoretically determine it will halt, without needing to directly compute all the remaining steps.

My question is whether this seems correct, and if so, whether anybody's figured out results along these lines already.

• I suspect that it will be challenging to turn this into a well-defined question, because you haven't defined "obviously", and important details are being swept under the rug into the ambiguity of what "obviously" means.
– D.W.
Commented Dec 22, 2023 at 6:26
• An example of "obvious" behavior: en.wikipedia.org/wiki/Borwein_integral Commented Dec 22, 2023 at 6:54
• @D.W. I don't disagree, but I would clarify that rather than "obvious", I suppose I really mean "theoretically detectable". Before running any code, it is impossible in general to identify all halting programs; by running them, eventually you can identify all halting programs as such; therefore, at some point, for each program, it must change from non-identifiable to identifiable as eventually-halting. (Except yes, I suppose you could simply say that all halting programs are "identifiable" in that sense from the start, in that they can be run until they halt.)
– Trev
Commented Dec 22, 2023 at 7:57
• "There must be a limit to how far out such behavior can be detectable" At the very least, you'd need a TM with more states than the machine you are deciding the halting problem for. Similar to how you need a stronger theory to determine if the (weaker) theory is consistent. Commented Dec 22, 2023 at 9:09
• Well of course it is detectable whether it will halt in the next 10 steps: you can just simulate further execution for 10 steps. You seem to want some definition that excludes that strategy, but still allows other strategies, and I'm saying that it is not clear how to do that -- it is not clear that "wish" is well-defined or meaningful.
– D.W.
Commented Dec 24, 2023 at 22:34

2. running it for $$n$$ steps
So to answer your question in the header: You can determine, if your Turing machine is halting $$n$$ steps ahead, by running $$n$$ computations ahead on a copy of it.