Questions tagged [halting-problem]

The halting problem is a famous problem in theoretical computer science. Given as input a description of a program (typically a Turing machine) and an input to that program, the Halting problem is to decide whether that program terminates on that input.

The Halting Problem is a fundamental limitation on computability - that, given a program and a machine with infinite memory (usually a Turing Machine), it is impossible to know if the program will halt for a given input.

Although a program can be checked to see if it will halt on physical computers (because of limited memory), heuristics are used instead of an actual solution.

Here, most questions will have to do with how it impacts everyday coding and finding heuristics for code analysis purposes. However, consider asking your question on Computer Science if it is very abstract.

79 questions
7
votes
3 answers

How can undecidable instances actually hang the compiler?

By the time I first read serious criticism on -XUndecidableInstances, I had already completely accustomed to it, seeing it as merely removal of an annoying restriction Haskell98 has to make compilers easier to implement. In fact I've encountered…
leftaroundabout
  • 117,950
  • 5
  • 174
  • 319
7
votes
4 answers

Is finding pointers in C/C++ code statically equivalent to the Halting Ρroblem?

I'm not too deeply rooted in the very formal side of static code analysis, hence this question. A couple of years ago I read that distinguishing code from data using static code analysis is equivalent to the Halting Problem. (Citation needed, but I…
Jens
  • 8,423
  • 9
  • 58
  • 78
6
votes
3 answers

Automated computation of algorithm time complexity for terminating algorithms

There are a lot of related questions here on SO, but they all ask about writing a program to compute the complexity of arbitrary algorithms (which is obviously undecideable). I am willing to make the following restrictions on the input: The…
4
votes
2 answers

Explanation of the Turing Machine Halting Problem

I'm looking for a simple explanation of the halting problem for Turing machines. I know the basis of how TMs work, how they enumerate things, machine configurations, etc., but I don't have a good handle on the halting problem. Can someone provide a…
user2440665
  • 101
  • 5
4
votes
2 answers

Is it possible to make a halting function if you don't call it on itself?

The standard proof of of the impossibility of solving the halting problem is usually something like this //does_halt() takes a function as input and returns true if it will ever finish computing function paradox() {if does_halt(paradox()) …
David Greydanus
  • 2,551
  • 1
  • 23
  • 42
4
votes
1 answer

Halting really undecidable for computers with limited memory?

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…
user1202136
  • 11,171
  • 4
  • 41
  • 62
4
votes
2 answers

Do agda programs necessarily terminate?

It has been stated a few places that all agda programs terminate. However I can construct a function like this: stall : ∀ n → ℕ stall 0 = 0 stall x = stall x The syntax highlighter doesn't seem to like it, but there are no compilation…
user833970
  • 2,729
  • 3
  • 26
  • 41
4
votes
5 answers

Java: Iterative method returning an object

Out of curiosity I came to write the following method: public Object getObject() { return this.getObject(); } Why would Java allow me to write this? This method would never return any Object and would result in a StackOverflow Error.
Luke Taylor
  • 9,481
  • 13
  • 41
  • 73
3
votes
2 answers

Will this algorithm terminate?

With different values in a collection, will this algorithm (pseudeocode) ever terminate? while (curElement != average(allElements)) { curElement = average(allElements); nextElement(); } Note that I'm assuming that we will re-start from the…
Franz
  • 11,353
  • 8
  • 48
  • 70
3
votes
2 answers

Detecting if a Program is in an Infinite Loop (Read: Solving the Halting Problem)

Is detecting whether a deterministic program (i.e. state machine) is in an infinite loop equivalent to solving the halting problem? I came up with a solution, and I'm not sure why it shouldn't work: Let the program run When you think it's in an…
user541686
  • 205,094
  • 128
  • 528
  • 886
3
votes
1 answer

poweroff redirect system halted

I'm playing with image built from Builtroot, and run with QEMU. But when I run "poweroff" command, machine not shutdown. And "System halted" appear! (See console output bellow) # poweroff # Stopping network: OK Saving random seed: random: dd:…
manhkhoa168
  • 151
  • 1
  • 4
  • 8
3
votes
1 answer

HaltingProblem in Agda?

I am working through a paper trying to implement their Haskell code in Agda. They want to formulate the halting problem by saying let bot be a program such that for any data type a: bot :: a bot = bot They go on to define data S = T so the…
3
votes
1 answer

Does the halting p‌r‌o‌b‌l‌e‌m mean that programs cannot check other programs?

I'm taking a theoretical CS class and we just discussed the halting problem. In my understanding, the reason that the problem cannot be solved is that if there is a program Halt that tells us whether a not a program halts, and you write another…
Darvish Kamalia
  • 817
  • 1
  • 7
  • 19
3
votes
3 answers

P-NP problems solved? FindBugs solves the halting prob?

There is a tool called FindBugs it can detect infinite never ending loops in a given program/ code base. This implies FindBugs can detect if a program will end or not by analyzing the code. Halting problem is the problem defining that: Given a…
cornercoder
  • 276
  • 1
  • 4
  • 15
2
votes
11 answers

What would programming languages look like if every computable thing could be done in 1 second?

Inspired by this question Suppose we had a magical Turing Machine with infinite memory, and unlimited CPU power. Use your imagination as to how this might be possible, e.g. it uses some sort of hyperspace continuum to automatically parallelize…