4

Turing proved that the halting problem is undecidable over Turing machines. However, real computers are not actually Turing-complete: They would be, if they had an infinite amount of memory.

Given the fact that computers have a finite amount of memory, hence are not quite Turning-complete, does the halting problem become decidable? My intuition tells me that yes, but the program that solves this restricted halting problem might have a time and space complexity exponential to the size of the memory of the targeted computer.

user1202136
  • 11,171
  • 4
  • 41
  • 62

1 Answers1

4

The halting problem can be solved for a Turing machine with finite tape by a Turing machine with infinite tape. All the infinite Turing machine has to do is enumerate every possible state of the finite Turing machine (and there will be a finite, though very large, number of possible states) and mark which states have been visited by the Turing machine in the course of running a program. Eventually, one of two things will happen:

  1. The finite Turing machine will halt.
  2. The finite Turing machine will revisit a state. If it revisits a state, then you know there is an infinite loop, since the machine is deterministic, and the next state is therefore determined entirely by the previous state. If there are n states, the machine is guaranteed to revisit one of them on the n+1th step.
Neil Forrester
  • 5,101
  • 29
  • 32
  • Thanks for the answer! As a follow-up, does this mean that we are giving up too easily on some problems by raising the "halting problem" flag? E.g., detecting uninitialized variables. – user1202136 Apr 04 '14 at 07:41
  • I'm not completely certain, but probably not. A program that consumes 1 GB of memory has 2^(10^9) states. There are not enough atoms in the universe to solve the halting problem by the method I described for such a program (assuming each bit of memory takes one atom). My experience with computability theory and related subjects is limited, however. – Neil Forrester Apr 04 '14 at 14:55
  • Maybe this number could be reduced if only the variables in the current scope (e.g., function) were taken into account. However, it might still be a large state-space to explore. – user1202136 Apr 04 '14 at 15:47
  • 1
    I don't think you need an infinite tape. See [cycle detection](https://en.wikipedia.org/wiki/Cycle_detection). You only need enough memory to simulate the machine and keep one additional complete state in memory. – olejorgenb Nov 22 '16 at 12:42