16
A standalone statement of my question

Given a program that takes no argument, we are interested in whether the program will eventually terminate. My question is this:

Theoretically speaking, can we always find a proof of the termination/non-termination of a program?

Clarification

Unlike the general halting problem, this problem does not require a mechanical procedure to generate a proof for each program which can potentially depend on the procedure itself, but instead, it allows the proof to depend on the specified program. It is thus a much weaker version.

There are obviously some proofs for some terminations and some non-terminations, and there are cases that remain unknown to this day (such as the evaluation of incrementing a number until finding a counter example of Collatz conjecture).

But more generally, is there any result on this? Is it always possible to prove whether the program terminates or not? Or is it provable that some programs cannot be proved either ways?

(Note that the answer to this question does not require solving, say, Collatz conjecture because it will only say there is a proof maybe that it terminates or maybe that it does not)

What I have thought about?

Cases that are easy are these two:

  1. If it terminates, we just run the program and the termination proves itself.
  2. If it falls into some repetitive periods, we track the history of all variables and we can prove that it does not terminate by remarking that it goes into a loop after certain step.

One case remains where the non-termination will never fall into periods and keep visiting new states. In this case, my first thought is that it comes down (almost) to prove the unboundedness (of some sort) of a sequence (of some kind of structures) defined by a program. So maybe a weaker version of my question would be: Is the unboundedness of a sequence of natural numbers (generated by the program) always provable?

DatoClement
  • 308
  • 2
  • 9

5 Answers5

32

Actually this is no different from the halting problem unsolvability. If you have any formal system T with a proof verifier program V that can reason about programs (as you desire in your question), then let H be the program that does the following on input (P,X):
  For each string s in length-lexicographic order:
    If V( "Program P halts on input X." , s ) then output "true".
    If V( "Program P does not halt on input X." , s ) then output "false".
Here V(Q,s) outputs "true" if s is a valid proof of Q and "false" otherwise. V always halts, because that is what it means for T to have a proof verifier program. (And we cannot use and do not care about formal systems that do not.)

Now, if for every (P,X) there is always a proof over T of either "Program P halts on input X." or its negation, then H solves the halting problem (because H eventually checks each possible proof), which is impossible.

Here I am assuming that your T is sound for program halting (i.e. does not prove a false statement about program halting). Otherwise, it is possible that T proves the wrong thing and hence H fails to solve the halting problem.

By the way, unsolvability of the halting problem and another computability question called the zero-guessing problem are very important facts that can be used to easily prove the generalized incompleteness theorem, by essentially the same kind of reasoning. Incidentally, Godel proved his incompleteness theorem for PA under an assumption called ω-consistency, which is essentially equivalent to PA being sound for program halting. Rosser removed that assumption by a clever trick. But Rosser's version also can be proven easily using the zero-guessing problem instead of the halting problem.

user21820
  • 728
  • 7
  • 13
5

Unlike the general halting problem, this problem does not require a mechanical procedure to generate a proof for each program which can potentially depend on the procedure itself, but instead, it allows the proof to depend on the specified program. It is thus a much weaker version.

The general halting problem already allows such program-specific proofs. Your stated problem is in fact completely identical to the general halting problem. Perhaps you have underestimated the potential complexity of what you call "mechanical procedures"? It is theoretically possible, though incredibly difficult, to create a "mechanical procedure" that duplicates the full capabilities of an expert living sapient human mathematician.

Or is it provable that some programs cannot be proved either ways?

If a program does halt, then it can be proven by simply running it until it halts. Any proof that a program cannot be proven to halt is therefore inherently a proof that it does not halt. "Cannot be proven either way" is a self-contradictory and thus invalid result of a proof about whether a particular program halts.

Douglas
  • 221
  • 1
  • 3
0

When you make an informal statement like "Is it provably true/false that for a program, there exists a proof whether it halts or not?", the "a" article is interpreted as a universal quantifier: if we increase the formality of the question it becomes: for every program P, is there a halting proof?

And this is what the Halting Problem informs us that there isn't, with careful definitions of what is meant by program and proof.

Unlike the general halting problem, this problem does not require a mechanical procedure to generate a proof for each program which can potentially depend on the procedure itself, but instead, it allows the proof to depend on the specified program

Here you seem to be expressing a belief that mechanical generation is qualitatively different from human generation: that if we allow a human to inspect every one of the infinite set of programs, the human may be able to decide halting every case, without it being possible to replicate what the human is doing by an algorithm, because the human isn't simply mechanical but "super mechanical".

Even if that were the case, it would mean that the human is somehow more powerful than a Turing machine. You would then have to carefully articulate the domain which is covered in your claim: that your claim isn't whether a Turing machine can decide halting over the domain of Turing machines, but whether a Human machine (possessing some magic oracle powers that transcend the power of Turing machines) can decide halting over the domain of Turing machines.

If we rephrase the statement along these lines, the answer is a resounding yes: machines from a domain more powerful than Turing machines can decide halting of all Turing machines.

Practically speaking, all we have is computers that are (not even quite) Turing machines. So the Turing machine set is of particular interest, because the results inform us about the limitations of the computers that we have.

If something cannot be "mechanically", you're not going to program your PC into solving it.

Given a program that takes no argument

This "no argument" requirement is a red herring; if you believe it makes any difference, you have to readjust your thinking.

We can take any program P which has an external input that is given to it as an argument, into an equivalent program Q which embeds that input and then takes no argument.

The set of all programs P with no arguments is exactly the same as the set of programs Q(I), which have inputs, for all possible inputs I. All the possible Q(I) pairs can each be combined into a single program image P.

Consider that the machine which Turing used to explore this problem domain doesn't have any arguments either: it is a combination of a simple mechanism, and a tape that loaded with some initial contents.

A program P with no arguments loaded into a machine is exactly the same thing as a Turing tape loaded into a tape machine; we can replace "given a program with no argument" with "given a Turing tape".

Kaz
  • 374
  • 1
  • 6
-2

If you're really asking about every program then of course not. Such proof would need to consider every possible outcome of every choice within the most complex program imaginable… which would make the proof more complex than the program, which would spin on its own axis until it ceased to matter.

If "for a program…" doesn't mean "for any and all programs" then what does it mean?

-3

This is basically the Church-Turing hypothesis.

We know there are programs P such that no program X can prove that P halts, or that P doesn't halt. That's not what you asked. You asked "can we prove..." The Church-Turing hypothesis claims that everything "we" can do, some program could do. If the Church-Turing hypothesis is correct, then "we" cannot prove for every program that it halts. If it is incorrect, then "we" might be able to prove it for every program.

I can easily write a program that halts if it finds a counter-example to Fermat's Last Theorem, and that will eventually find a counter-example if one exists. "We" (or rather Andrew Wiles) proved that this program doesn't halt. It's not at all obvious that a computer program could have found this proof. Church-Turing says "yes".

Just for fun: If that FLT-counter-example-finder halts, then there is actually a very simple proof that it halts. (The proof would look like "The program will halt with a = xxx, b = xxx, c = xxx, n = xxx". ). So if there is no proof that it halts or doesn't halt, then it doesn't halt, but we might not have a proof for it.

gnasher729
  • 32,238
  • 36
  • 56