Preliminaries A total function h : \mathbb{N} \to \mathbb{N} is said to be ultimately zero if it always takes the value zero except for a finite number of points, i.e., there exists N such that h(n) = 0 for all n \geq N. Note that such a function is always computable (it can be computed by simply checking if the input is in a certain predefined list, and otherwise returning zero). We fix U a computable enumeration of all total functions which are ultimately zero, that is, U is such that: • For all k, the function \phi_{U(k)} is ultimately zero; • For all total function h which is ultimately zero, there exists k such that \phi_{U(k)} = h; • The function U is itself total computable. We can build U by standard techniques (e.g., for increasing N, enumerate ultimately zero functions which are bounded by N and zero on inputs larger than N).
Approximating by ultimately zero functions Let P be as in the statement of the theorem: a set of total computable functions such that there is an algorithm which, given an index e and a
promise that \phi_e is total, decides whether \phi_e \in P. We first prove a lemma: For all total computable function f, and for all integer N, there exists an ultimately zero function h such that h agrees with f until N, and f \in P \iff h \in P. To prove this lemma, fix a total computable function f and an integer N, and let B be the boolean f \in P. Build a program p which takes input x and takes these steps: • If x \leq N then return f(x); • Otherwise, run x computation steps of the algorithm that decides P on p, and if this returns B, then return zero; • Otherwise, return f(x). Clearly, p always terminates, i.e., \phi_p is total. Therefore, the promise to P run on p is fulfilled. Suppose for contradiction that one of f and \phi_p belongs to P and the other does not, i.e., (\phi_p \in P) \neq B. Then we see that p computes f, since P does not return B on p no matter the amount of steps. Thus, we have f = \phi_p, contradicting the fact that one of f and \phi_p belongs to P and the other does not. This argument proves that f \in P \iff \phi_p \in P. Then, the second step makes p return zero for sufficiently large x, thus \phi_p is ultimately zero; and by construction (due to the first step), \phi_p agrees with f until N. Therefore, we can take h = \phi_p and the lemma is proved.
Main proof With the previous lemma, we can now prove the Kreisel–Lacombe–Shoenfield–Tseitin theorem theorem. Again, fix P as in the theorem statement, let f be a total computable function and let B be the boolean "f \in P". Build the program p which takes input x and runs these steps: • Run x computation steps of the algorithm that decides P on p. • If this returns B in a certain number of steps n (which is at most x), then search in parallel for k such that U(k) agrees with f until n and (U(k) \in P) \neq B. As soon as such a k is found, return U(k)(x). • Otherwise (if P did not return B on p in x steps), return f(x). We first prove that P returns B on p. Suppose by contradiction that this is not the case (P returns \lnot B, or P does not terminate). Then p actually computes f. In particular, \phi_p is total, so the promise to P when run on p is fulfilled, and P returns the boolean \phi_p \in P, which is f \in P, i.e., B, contradicting the assumption. Let n be the number of steps that P takes to return B on p. We claim that n satisfies the conclusion of the theorem: for all total computable function g which agrees with f until n, it holds that f \in P \iff g \in P. Assume for contradiction that there exists g total computable which agrees with f until n and such that (g \in P) \neq B. Applying the lemma again, there exists k such that U(k) agrees with g until n and g \in P \iff U(k) \in P. Since both U(k) and f agree with g until n, U(k) also agrees with f until n, and since (g \in P) \neq B and g \in P \iff U(k) \in P, we have (U(k) \in P) \neq B. Therefore, U(k) satisfies the conditions of the parallel search step in the program p, namely: U(k) agrees with f until n and (U(k) \in P) \neq B. This proves that the search in the second step always terminates. We fix k to be the value that it finds. We observe that \phi_p = U(k). Indeed, either the second step of p returns U(k)(x), or the third step returns f(x), but the latter case only happens for x \leq n, and we know that U(k) agrees with f until n. In particular, \phi_p = U(k) is total. This makes the promise to P run on p fulfilled, therefore P returns \phi_p \in P on p. We have found a contradiction: one the one hand, the boolean \phi_p \in P is the return value of P on p, which is B, and on the other hand, we have \phi_p = U(k), and we know that (U(k) \in P) \neq B. ==Perspective from effective topology==