2

Can a problem (described by a set of inputs and accepted answers) be designed such that for all programs which produce an answer in finite time for a (countably) infinite number of inputs, at least one of those outputs is incorrect.

That is, the program need not terminate for all outputs, but the outputs it does generate must all be correct, and there must be an infinite number of inputs for which it will terminate.

Not too sure about this, but my intuition says that the question may be related to the Halting problem/Turing machines.

As an example, the halting problem, (as far as I understand) does not meet this requirement, as one could run the input program, and output "terminated" if it terminates. If the input program never terminates, nor does the solution, so it never generates an incorrect output.

2 Answers2

3

A simplified example can be the following:

$$T( n ) = \begin{cases} \max \{ M(n) \mid |M| \leq n \} + 1 & \text{if such max exists}\\ 0 &\text{otherwise.} \end{cases}$$

In other words the "unprogrammable" (uncomputable) task $T$ (or better uncomputable function $T$) simply picks all programs $M$ of size at most $n$ as "input" and outputs the maximum value that they output on input $n$, plus 1.

Given a program $M_i$ that satisfies your assumption ( ... which produce an answer in finite time for a (countably) infinite number of inputs ...), there will always be an $x_0$ such that $|M_i| < x_0$ and $M_i$ on $x_0$ halts, and we have:

$$M_i(x_0) \leq \max \{ M(x_0) \mid |M| \leq x_0 \} < T(x_0)\,.$$

David Richerby
  • 82,470
  • 26
  • 145
  • 239
Vor
  • 12,743
  • 1
  • 31
  • 62
0

The halting problem can be solution to your question.

You are saying that the algorithm for halting problem never terminates (or it terminates for a finite number of inputs) when the input is a "non-terminating" program. But this is not quite right. Because, you can actually devise an algorithm for halting problem that outputs "non-terminating" for some of the "non-terminating" inputs, but not all of them.

Let's say, I devise an algorithm that checks if the following code is reachable in the input program,

while (true):
   continue;
end-while

if it is reachable in an input program, the program has an infinite loop and does not terminate at all; otherwise, it may or may not terminate (I assume that this is a reachable part of program without loss of generality; there is an infinite number of programs with such reachable segment).

Therefore, there are an infinite number of "non-terminating" input programs, for which, my algorithm can actually find out that they are not going to terminate. But my algorithm is not able to find all input programs that are "non-terminating" (which means that the problem is still undecidable).

orezvani
  • 1,944
  • 15
  • 20