Rice–Shapiro theorem

From testwiki
Jump to navigation Jump to search

Template:Short description In computability theory, the Rice–Shapiro theorem is a generalization of Rice's theorem, named after Henry Gordon Rice and Norman Shapiro. It states that when a semi-decidable property of partial computable functions is true on a certain partial function, one can extract a finite subfunction such that the property is still true.

The informal idea of the theorem is that the "only general way" to obtain information on the behavior of a program is to run the program, and because a computation is finite, one can only try the program on a finite number of inputs.

A closely related theorem is the Kreisel–Lacombe–Shoenfield–Tseitin theorem (or KLST theorem), which was obtained independently by Georg Kreisel, Daniel Lacombe and Joseph R. Shoenfield Template:R, and by Grigori TseitinTemplate:R.

Formal statement

Rice-Shapiro theorem.Template:RTemplate:RTemplate:R Let P be a set of partial computable functions such that the index set of P (i.e., the set of indices e such that ϕe∈P, for some fixed admissible numbering ϕ) is semi-decidable. Then for any partial computable function f, it holds that P contains f if and only if P contains a finite subfunction of f (i.e., a partial function defined in finitely many points, which takes the same values as f on those points).

Kreisel–Lacombe–Shoenfield–Tseitin theorem.Template:RTemplate:RTemplate:RTemplate:RTemplate:RTemplate:R Let P be a set of total computable functions such that the index set of P is decidable with a promise that the input is the index of a total computable function (i.e., there is a partial computable function D which, given an index e such that ϕe is total, returns 1 if ϕe∈P and 0 otherwise; D(e) need not be defined if ϕe is not total). We say that two total functions f, g "agree until n" if f(k)=g(k) holds for all k≤n. Then for any total computable function f, there exists n such that for all total computable function g which agrees with f until n, we have f∈P⟺g∈P.

Examples

By the Rice-Shapiro theorem, it is neither semi-decidable nor co-semi-decidable whether a given program:

  • Terminates on all inputs (universal halting problem);
  • Terminates on finitely many inputs;
  • Is equivalent to a fixed other program.

By the Kreisel–Lacombe–Shoenfield–Tseitin theorem, it is undecidable whether a given program which is assumed to always terminate:

  • Always returns an even number;
  • Is equivalent to a fixed other program that always terminates;
  • Always returns the same value.

Discussion

The two theorems are closely related, and also relate to Rice's theorem. Specifically:

  • Rice's theorem applies to decidable sets of partial computable functions, concluding that they must be trivial.
  • The Rice-Shapiro theorem applies to semi-decidable sets of partial computable functions, concluding that they can only recognize elements based on a finite number of values.
  • The Kreisel–Lacombe–Shoenfield–Tseitin theorem applies to decidable sets of total computable functions, with a conclusion similar to the Rice-Shapiro theorem.

It is natural to wonder what can be said about semi-decidable sets of total computable functions. Perhaps surprisingly, these need not verify the conclusion of the Rice-Shapiro and Kreisel–Lacombe–Shoenfield–Tseitin theorems. The following counterexample is due to Richard M. Friedberg.Template:RTemplate:R

Let Q be the set of total computable functions f:ℕ→ℕ such that f is not the constant zero function and, defining n to be the maximum index such that f(n) is zero, there exists a program of code e≤n such that ϕe(i) is defined and equal to f(i) for each i≤n+1. Let P be the set Q with the constant zero function added.

On the one hand, P contains the constant zero function by definition, yet there is no n such that if a total computable g agrees with the constant zero function until n then g∈P. Indeed, given n, we can define a total function g by setting g(n+1) to some value larger than every ϕe(n+1) for e≤n+1 such that ϕe(n+1) is defined, and g(n′)=0 for n′≠n+1. The function g is zero except on the value n+1, thus computable, it agrees with the zero function up to n, but it does not belong to P by construction.

On the other hand, given a program e and a promise that ϕe is total, it is possible to semi-decide whether ϕe∈P by dovetailing, running one task to semi-decide ϕe∈Q, which can clearly be done, and another task to semi-decide whether ϕe(k)=0 for all k≤e. This is correct because the zero function is detected by the second task, and conversely, if the second task returns true, then either ϕe is zero, or ϕe is only zero up to an index n, which must satisfy e≤n, which by definition of Q implies that ϕe∈Q.

Proof of the Rice-Shapiro theorem

Let P be a set of partial computable functions with semi-decidable index set. We prove the two implications separately.

Upward closedness

We first prove that if f is a finite subfunction of g and f∈P then g∈P. The hypothesis that f is finite is in fact of no use.

The proof uses a diagonal argument typical of theorems in computability. We build a program p as follows. This program takes an input x. Using a standard dovetailing technique, p runs two tasks in parallel.

  • The first task executes a semi-algorithm that semi-decides P on p itself (p can get access to its own source code by Kleene's recursion theorem). If this eventually returns true, then this first task continues by executing a semi-algorithm that semi-computes g on x (the input to p), and if that terminates, then the task makes p as a whole return g(x).
  • The second task runs a semi-algorithm that semi-computes f on x. If this returns true, then the task makes p as a whole return f(x).

If ϕp∉P, the first task can never finish, therefore the result of p is entirely determined by the second task, thus ϕp is simply f, a contradiction. This shows that ϕp∈P.

Thus, both tasks are relevant; however, because f is a subfunction of g and the second task returns f(x)=g(x) when f(x) is defined, while the first task returns g(x) when defined, the program in fact computes g, i.e., ϕp=g, and therefore g∈P.

Extracting a finite subfunction

Conversely, we prove that if P contains a partial computable function f, then it contains a finite subfunction of f. Let us fix f∈P. We build a program p which takes input x and runs the following steps:

  • Run x computation steps of a semi-algorithm that semi-decides P, with p itself as input. If this semi-algorithm terminates and returns true, then loop indefinitely.
  • Otherwise, semi-compute f on x, and if this terminates, return the result f(x).

Suppose that ϕp∉P. This implies that the semi-algorithm for semi-deciding P used in the first step never returns true. Then, p computes f, and this contradicts the assumption f∈P. Thus, we must have ϕp∈P, and the algorithm for semi-deciding P returns true on p after a certain number of steps n. The partial function ϕp can only be defined on inputs x such that x≤n, and it returns f(x) on such inputs, so it is a finite subfunction of f that belongs to P.

Proof of the Kreisel–Lacombe–Shoenfield–Tseitin theorem

Preliminaries

A total function h:ℕ→ℕ 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≥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 ϕU(k) is ultimately zero;
  • For all total function h which is ultimately zero, there exists k such that ϕ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 ϕe is total, decides whether ϕe∈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∈P⟺h∈P.

To prove this lemma, fix a total computable function f and an integer N, and let B be the boolean f∈P. Build a program p which takes input x and takes these steps:

  • If x≤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., ϕp is total. Therefore, the promise to P run on p is fulfilled.

Suppose for contradiction that one of f and ϕp belongs to P and the other does not, i.e., (ϕp∈P)≠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=ϕp, contradicting the fact that one of f and ϕp belongs to P and the other does not. This argument proves that f∈P⟺ϕp∈P. Then, the second step makes p return zero for sufficiently large x, thus ϕp is ultimately zero; and by construction (due to the first step), ϕp agrees with f until N. Therefore, we can take h=ϕp and the lemma is proved.

Main proof

With the previous lemma, we can now prove the Kreisel–Lacombe–Shoenfield–Tseitin theorem. Again, fix P as in the theorem statement, let f be a total computable function and let B be the boolean "f∈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)∈P)≠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 ¬B, or P does not terminate). Then p actually computes f. In particular, ϕp is total, so the promise to P when run on p is fulfilled, and P returns the boolean ϕp∈P, which is f∈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∈P⟺g∈P. Assume for contradiction that there exists g total computable which agrees with f until n and such that (g∈P)≠B.

Applying the lemma again, there exists k such that U(k) agrees with g until n and g∈P⟺U(k)∈P. Since both U(k) and f agree with g until n, U(k) also agrees with f until n, and since (g∈P)≠B and g∈P⟺U(k)∈P, we have (U(k)∈P)≠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)∈P)≠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 ϕ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≤n, and we know that U(k) agrees with f until n.

In particular, ϕp=U(k) is total. This makes the promise to P run on p fulfilled, therefore P returns ϕp∈P on p.

We have found a contradiction: one the one hand, the boolean ϕp∈P is the return value of P on p, which is B, and on the other hand, we have ϕp=U(k), and we know that (U(k)∈P)≠B.

Topological view

The set of total computable functions can be viewed as a subspace of the Baire space 𝒯⊆ℕℕ. The Kreisel–Lacombe–Shoenfield–Tseitin theorem states that if a function F:𝒯→2 (where the set of booleans 2 has the discrete topology) is computable (from a program computing f∈𝒯, we can compute F(f)), then F must be continuous.

The above proof of the Kreisel–Lacombe–Shoenfield–Tseitin gives a strengthening of the theorem: from programs computing F and f, one can compute n such that F is constant on functions agreeing with f until n. This strengthened version has a natural interpretation from the point of view of realizability: inside the internal logic of the effective topos, it holds that every function ℕℕ→2 is continuous.Template:R

For the Rice–Shapiro theorem, one views the set of partial computable functions as a subspace of the space 𝒫 of all partial functions from ℕ to ℕ topologized in the following way: for each finite partial function f, the set of partial functions extending f is declared to be a basic open set. The theorem states that if a subset P⊆𝒫 is semi-decidable (from a program computing f∈𝒫, we can semi-decide whether f∈P), then it must be open.

Notes

  1. ↑ Template:Cite journal Cite error: <ref> tag with name "moschovakis" defined in <references> is not used in prior text.
  2. ↑ Template:Cite journal Cite error: <ref> tag with name "royer" defined in <references> is not used in prior text.
  3. ↑ Template:Cite book Cite error: <ref> tag with name "rogers" defined in <references> is not used in prior text.
  4. ↑ Template:Cite book; Theorem 7-2.16. Cite error: <ref> tag with name "cutland" defined in <references> is not used in prior text.
  5. ↑ Template:Cite book Cite error: <ref> tag with name "odifreddi" defined in <references> is not used in prior text.
  6. ↑ Template:Cite book Cite error: <ref> tag with name "kls" defined in <references> is not used in prior text.
  7. ↑ Template:Cite book Cite error: <ref> tag with name "longley-normann" defined in <references> is not used in prior text.
  8. ↑ Template:Cite journal Cite error: <ref> tag with name "tseitin" defined in <references> is not used in prior text.
  9. ↑ Template:Cite journal Cite error: <ref> tag with name "friedberg" defined in <references> is not used in prior text.
  10. ↑ Template:Cite book Cite error: <ref> tag with name "van-oosten-klst-brouwer" defined in <references> is not used in prior text.