There is a very general formulation of the result of Rice-Shapiro in terms of effective domains, but we will see only the instance which is relevant for this course. We will not see the proof because it involves topological techniques that are beyond the scope of this course.
Theorem (Rice-Shapiro) Let p be a property of recursively enumerable languages, i.e. p: RE -> {true,false}. Let X = {e(M) | M is a TM and p(L(M)) holds}. Then X is RE iff there exists a recursively enumerable set of indexes I, and a sequence of finite sets indexed on I, {Li | i in I} such that
{L in RE | p(L) holds} = unioni in I UC(Li).Were UC(L) (upward-closure of L) is the set of all supersets of L, i.e.
UC(L) = {L' | L is a subest of L'}.One part of this theorem is the so-called "Lemma of effective discontinuity" (it's called "lemma" because it is used to prove the theorem).
Lemma (Effective discontinuity) Let p: RE -> {true,false}. Let X = {e(M) | M is a TM and p(L(M)) holds}. If X is RE then
Again, we will not see a formal proof of this lemma since it requires notions from topology theory. However the intuitive explanation is the following. Suppose that X is RE. Then we have a machine MX that, given as input the (encoding of) another machine M, it is able to terminate with answer "yes" iff L(M) satisfies p. Since the decision of saying "yes" is taken after a finite number of steps, it must be based only on a finite subset of the set L(M) (because in finite time we can test only a finite number of strings). This justifies Point 2 in the lemma above. As for Point 1, note that if the machine says "yes" on M, then it must say "yes" also on any other machine M' whose language L(M') is a superset of L(M). In fact, we have no way to know (in general) that a string does not belong to L(M) (M might loop on the strings which are not in L(M)). Hence the strings which are in L(M') and not in L(M) cannot change the decision of MX of saying "yes".
It should be clear that the Theorem of Rice (Lecture 36) is an immediate consequence of the theorem of Rice-Shapiro. In fact, if the set X defined above is Recursive, then both X and the complement of X are RE. By the lemma of effective discontinuity, both p and the negation of p should then be upward closed. We have two possibilities:
In general it is not possible to semidecide whether a given language is context-free or not. In other words, there exist no general method to construct a CF grammar for any CF language, and there exist no general method able to prove that a langauge is not CF for any not-CF langauge.The above negative result depends critically, of course, on the fact that we allow here the most general kind of definitions for languages (Turing machines). If we would fix the format of the specification (for instance, if we would allow only certain kinds of recursive definitions) then the problem "is L CF?" might become semidecidable or even decidable.
It should be remarked that these results regard "extensional properties" of programs, (i.e. properties of the input-output relation computed by a program), and not the "intentional properties" (i.e. properties of the code). The latter are in general decidable.
Let us consider in detail two main negative results for programming languages related to the theorem of Rice-Shapiro. In the following, we assume the programming language to be fixed, for intance C.
The problem "given a program P, does P terminate on input x0?" (where x0 is a given string) is semidecidable, but not decidable (Proof: from the results for L3 and L4 above.) This is the so-called "halting problem".
The problem becomes semidecidable (but not decidable) if r0 is finite, i.e. if the correctness has to be tested only on a finite number of inputs.