Rice–Shapiro Theorem
   HOME

TheInfoList



OR:

In
computability theory Computability theory, also known as recursion theory, is a branch of mathematical logic, computer science, and the theory of computation that originated in the 1930s with the study of computable functions and Turing degrees. The field has since ex ...
, the Rice–Shapiro theorem is a generalization of
Rice's theorem In computability theory, Rice's theorem states that all non-trivial semantic properties of programs are undecidable problem, undecidable. A ''semantic'' property is one about the program's behavior (for instance, "does the program halting problem, ...
, named after Henry Gordon Rice and
Norman Shapiro Norman Zalmon Shapiro was an American mathematician, who was the co-author of the Rice–Shapiro theorem. Education Shapiro obtained a BS in mathematics at University of Illinois in 1952. Shapiro spent the summer of 1954 at Bell Laboratories in ...
. 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 Georg Kreisel FRS (September 15, 1923 – March 1, 2015) was an Austrian-born mathematical logician who studied and worked in the United Kingdom and America. Biography Kreisel was born in Graz and came from a Jewish background; his family s ...
, Daniel Lacombe and Joseph R. Shoenfield , and by Grigori Tseitin.


Formal statement

Rice-Shapiro theorem. Let P be a set of partial computable functions such that the
index set In mathematics, an index set is a set whose members label (or index) members of another set. For instance, if the elements of a set may be ''indexed'' or ''labeled'' by means of the elements of a set , then is an index set. The indexing consists ...
of P (i.e., the set of indices e such that \phi_e \in P, for some fixed admissible numbering \phi) 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. Let P be a set of total computable functions such that the index set of P is decidable with a
promise A promise is a commitment by someone to do or not do something. As a noun ''promise'' means a declaration assuring that one will or will not do something. As a verb it means to commit oneself by a promise to do or give. It can also mean a capacity ...
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 \phi_e is total, returns 1 if \phi_e \in P and 0 otherwise; D(e) need not be defined if \phi_e is not total). We say that two total functions f, g "agree until n" if f(k) = g(k) holds for all k \leq 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 \in P \iff g \in 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 In computability theory, Rice's theorem states that all non-trivial semantic properties of programs are undecidable problem, undecidable. A ''semantic'' property is one about the program's behavior (for instance, "does the program halting problem, ...
. 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. Let Q be the set of total computable functions f : \mathbb \to \mathbb 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 \leq n such that \phi_e(i) is defined and equal to f(i) for each i \leq 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 \in P. Indeed, given n, we can define a total function g by setting g(n+1) to some value larger than every \phi_e(n+1) for e \leq n+1 such that \phi_e(n+1) is defined, and g(n') = 0 for n' \neq 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 \phi_e is total, it is possible to semi-decide whether \phi_e \in P by dovetailing, running one task to semi-decide \phi_e \in Q, which can clearly be done, and another task to semi-decide whether \phi_e(k) = 0 for all k \leq e. This is correct because the zero function is detected by the second task, and conversely, if the second task returns true, then either \phi_e is zero, or \phi_e is only zero up to an index n, which must satisfy e \leq n, which by definition of Q implies that \phi_e \in 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 \in P then g \in P. The hypothesis that f is finite is in fact of no use. The proof uses a
diagonal argument Diagonal argument can refer to: * Diagonal argument (proof technique), proof techniques used in mathematics. A diagonal argument, in mathematics, is a technique employed in the proofs of the following theorems: *Cantor's diagonal argument (the ea ...
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 In computability theory and computational complexity theory, RE (recursively enumerable) is the class of decision problems for which a 'yes' answer can be verified by a Turing machine in a finite amount of time. Informally, it means that if the answ ...
that semi-decides P on p itself (p can get access to its own source code by
Kleene's recursion theorem In computability theory, Kleene's recursion theorems are a pair of fundamental results about the application of computable functions to their own descriptions. The theorems were first proved by Stephen Kleene in 1938 and appear in his 1952 ...
). 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 \phi_p \notin P, the first task can never finish, therefore the result of p is entirely determined by the second task, thus \phi_p is simply f, a contradiction. This shows that \phi_p \in 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., \phi_p = g, and therefore g \in 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 \in 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 \phi_p \notin 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 \in P. Thus, we must have \phi_p \in P, and the algorithm for semi-deciding P returns true on p after a certain number of steps n. The partial function \phi_p can only be defined on inputs x such that x \leq 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 : \mathbb \to \mathbb 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_ is ultimately zero; * For all total function h which is ultimately zero, there exists k such that \phi_ = 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 A promise is a commitment by someone to do or not do something. As a noun ''promise'' means a declaration assuring that one will or will not do something. As a verb it means to commit oneself by a promise to do or give. It can also mean a capacity ...
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. 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

For any finite unary function \theta on integers, let C(\theta) denote the 'frustum' of all partial-recursive functions that are defined, and agree with \theta, on \theta's domain. Equip the set of all partial-recursive functions with the topology generated by these frusta as base. Note that for every frustum C, the index set Ix(C) is recursively enumerable. More generally it holds for every set A of partial-recursive functions: Ix(A) is recursively enumerable iff A is a recursively enumerable union of frusta.


Applications

The Kreisel-Lacombe-Shoenfield-Tseitin theorem has been applied to foundational problems in
computational social choice A computation is any type of arithmetic or non-arithmetic calculation that is well-defined. Common examples of computation are mathematical equation solving and the execution of computer algorithms. Mechanical or electronic devices (or, historic ...
(more broadly,
algorithmic game theory Algorithmic game theory (AGT) is an interdisciplinary field at the intersection of game theory and computer science, focused on understanding and designing algorithms for environments where multiple strategic agents interact. This research area com ...
). For instance, Kumabe and Mihara apply this result to an investigation of the
Nakamura number In cooperative game theory and social choice theory, the Nakamura number measures the degree of rationality of preference aggregation rules (collective decision rules), such as voting rules. It is an indicator of the extent to which an aggregation ...
s for simple games in
cooperative game theory In game theory, a cooperative game (or coalitional game) is a game with groups of players who form binding “coalitions” with external enforcement of cooperative behavior (e.g. through contract law). This is different from non-cooperative ...
and
social choice theory Social choice theory is a branch of welfare economics that extends the Decision theory, theory of rational choice to collective decision-making. Social choice studies the behavior of different mathematical procedures (social welfare function, soc ...
.


Notes

; Theorem 7-2.16. {{DEFAULTSORT:Rice-Shapiro theorem Theorems in the foundations of mathematics Theorems in theory of computation