Reading preferences
Optional display controls need JavaScript. All reading content and navigation work without it.
Source file content/computability/computability-theory/computability-theory.tex
Editorial
Material in this chapter should be reviewed and expanded. In particular, there are no exercises yet.
Source file content/computability/computability-theory/introduction.tex
Introduction
The branch of logic known as computability theory deals with issues having to do with the computability, or relative computability, of functions and sets. It is evidence of Kleene's influence that the subject used to be known as recursion theory, and today, both names are commonly used.
Let us call a function source partial computable if it can be computed in some model of computation. If source is total we will simply say that source is computable. A relation source with computable characteristic function source is also called computable. If source and source are partial functions, we will write source to mean that source is defined at source, i.e., source is in the domain of source; and source to mean the opposite, i.e., that source is not defined at source. We will use source to mean that either source and source are both undefined, or they are both defined and equal.
One can explore the theory of computability without having to refer to a specific model of computation. To do this, one shows that there is a universal partial computable function source. This allows us to enumerate the partial computable functions. We will adopt the notation source to denote the source-th unary partial computable function, defined by source. (Kleene used source for this purpose, but this notation has not been used as much recently.) Slightly more generally, we can uniformly enumerate the partial computable functions of arbitrary arities, and we will use source to denote the source-th source-ary partial recursive function.
If source is a total or partial function, then source is the function of source that returns the least source such that source, assuming that all of source, dots, source are defined; if there is no such source, source is undefined. If source is a relation, source is defined to be the least source such that source is true; in other words, the least source such that source.
To show that a function is computable, there are two ways one can proceed:
Rigorously: describe a Turing machine or partial recursive function explicitly, and show that it computes the function you have in mind;
Informally: describe an algorithm that computes it, and appeal to Church's thesis.
There is no fine line between the two; a detailed description of an algorithm should provide enough information so that it is relatively clear how one could, in principle, design the right Turing machine or sequence of partial recursive definitions. Fully rigorous definitions are unlikely to be informative, and we will try to find a happy medium between these two approaches; in short, we will try to find intuitive yet rigorous proofs that the precise definitions could be obtained.
Source file content/computability/computability-theory/coding-computations.tex
Coding Computations
In every model of computation, it is possible to do the following:
Describe the definitions of computable functions in a systematic way. For instance, you can think of Turing machine specifications, recursive definitions, or programs in a programming language as providing these definitions.
Describe the complete record of the computation of a function given by some definition for a given input. For instance, a Turing machine computation can be described by the sequence of configurations (state of the machine, contents of the tape) for each step of computation.
Test whether a putative record of a computation is in fact the record of how a computable function with a given definition would be computed for a given input (on which the function is defined, i.e., the computation halts).
Extract from such a description of the complete record of a computation the value of the function for a given input. For instance, the contents of the tape in the very last step of a halting Turing machine computation is the value.
Using coding, it is possible to assign to each description of a computable function a numerical index in such a way that the instructions can be recovered from the index in a computable way. Similarly, the complete record of a computation can be coded by a single number as well. The resulting arithmetical relation “source codes the record of computation of the function with index source for input source” and the function “output of computation sequence with code source” are then computable; in fact, they are primitive recursive.
This fundamental fact is very powerful, and allows us to prove a number of striking and important results about computability, independently of the model of computation chosen.
Source file content/computability/computability-theory/normal-form.tex
The Normal Form Theorem
Suppose we can describe definitions of computable functions, and test if some putative description of the complete record of the computation of that function on some input is correct. Then it stands to reason that independently of the model of computation, we can determine the value of any computable function source on any input source as follows:
Search through all possible descriptions of records of computation.
Test if a given record is the record of a computation of source.
Extract the value of source from the correct record if we have found it.
That this is in fact true is the content of Kleene's normal form theorem.
Kleene normal form theorem
[Kleene's Normal Form Theorem] There is a primitive recursive relation source and a primitive recursive function source, with the following property: if source is any partial computable function, then for some source,
for every source.
Proof
[Proof Sketch] For any model of computation one can rigorously define a description of the computable function source and code such description using a natural number source. One can also rigorously define a notion of “computation sequence” which records the process of computing the function with index source for input source. Such a computation sequence can likewise be coded as a number source. This can be done in such a way that
the relation source, which holds iff a number source codes the computation sequence of the function with index source on input source, and
the function source which maps a computation sequence coded by source to the end result of that computation
are both computable. In fact, the relation source and the function source are primitive recursive.
Explain
In order to give a rigorous proof of the Normal Form Theorem, we would have to fix a model of computation and carry out the coding of descriptions of computable functions and of computation sequences in detail, and verify that the relation source and function source are primitive recursive. For most applications, it suffices that source and source are computable and that source is total.
It is probably best to remember the proof of the normal form theorem in slogan form: source searches for a computation sequence of the function with index source on input source, and source returns the output of the computation sequence if one can be found.
If the model of computation is the partial recursive functions (which is what Kleene originally used), it shows that only a single use of unbounded search, i.e., a single source operator is necessary for the definition of any function. In this sense it shows that any partial recursive function has a normal form.
source and source can be used to define the enumeration source, source, source, dots. From now on, we will assume that we have fixed a suitable choice of source and source, and take the equation
to be the definition of source.
Here is another useful fact:
Infinitely many indices theorem
Every partial computable function has infinitely many indices.
Again, this is intuitively clear. Given any (description of) a computable function, one can come up with a different description which computes the same function (input-output pair) but does so, e.g., by first doing something that has no effect on the computation (say, test if source, or count to source, etc.). The index of the altered description will always be different from the original index. Both are indices of the same function, just computed slightly differently.
Source file content/computability/computability-theory/s-m-n.tex
The source-source-source Theorem
Explain
The next theorem is known as the “source-source-source theorem,” for a reason that will be clear in a moment. The hard part is understanding just what the theorem says; once you understand the statement, it will seem fairly obvious.
Parameterization theorem
For each pair of natural numbers source and source, there is a primitive recursive function source such that for every sequence source, source, dots, source, source ,dots, source, we have
Explain
It is helpful to think of source as acting on programs. That is, source takes a program source for an source-ary function, as well as fixed inputs source, dots, source; and it returns a program source for the source-ary function of the remaining arguments. It you think of source as the description of a Turing machine, then source is the Turing machine that, on input source, dots, source, prepends source, dots, source to the input string, and runs source. Each source is then just a primitive recursive function that finds a code for the appropriate Turing machine.
Source file content/computability/computability-theory/universal-part-function.tex
The Universal Partial Computable Function
Universal partial computable function theorem
There is a universal partial computable function source. In other words, there is a function source such that:
Proof
Let source, where source and source are as in Kleene's normal form theorem (Universal function proof reference to normal form).
Explain
This is just a precise way of saying that we have an effective enumeration of the partial computable functions; the idea is that if we write source for the function defined by source, then the sequence source, source, source, dots includes all the partial computable functions, with the property that source can be computed “uniformly” in source and source. For simplicity, we are using a binary function that is universal for unary functions, but by coding sequences of numbers we can easily generalize this to more arguments. For example, note that if source is a source-place partial recursive function, then the function source is a unary recursive function.
Source file content/computability/computability-theory/no-universal-function.tex
No Universal Computable Function
Although there is a partial computable function that is total for the partial computable functions, there is no total computable function that is universal for the total computable functions.
No universal total computable function theorem
There is no universal computable function. In other words, any function source which is such that if source is a total computable function, then there is a natural number source such that source for every source, is not computable.
Proof
The proof is a simple diagonalization: if source were total and computable, then
would also be total and computable. However, by definition, source is not equal to source. Hence, for every source, the values of source and source differ for at least one source, namely source.
Explain
Diagonalization explanation reference to universality above shows that we can get around this diagonalization argument, but only at the expense of allowing the universal function to be partial. That is, source is universal for the total computable functions, it just isn't total. The diagonalization argument doesn't work in the partial case.
Partial diagonalization exercise
To understand why the diagonalization argument in the proof of Partial diagonalization exercise reference does not work in the partial case, consider the function source. Is it partial computable? If so, it has an index source, i.e., source. What can you say about source?
Source file content/computability/computability-theory/halting-problem.tex
The Halting Problem
By construction, the universal partial computable function source is defined if and only if the computation of the function coded by source produces a value for input source. It is natural to ask if we can decide whether this is the case. In fact, it is not. For the Turing machine model of computation, this means that whether a given Turing machine halts on a given input is computationally undecidable. The following theorem is therefore known as the “undecidability of the halting problem.” We will provide two proofs below. The first continues the thread of our previous discussion, while the second is more direct.
Halting function theorem
Let
Then source is not computable.
Proof
Suppose source is computable. We show that this would let us define a universal computable function. Define
But now source is a total function, and is computable if source is. For instance, we could define source using primitive recursion, by
then
Since source agrees with source wherever the latter is defined, source is universal for those partial computable functions that happen to be total. But this contradicts Halting proof contradiction reference.
Proof
Suppose source were computable. Define the function source by
The function source is partial computable. For example, one can define it as source. So, for some source, source for every source. Is source defined at source? If it is, then, by the definition of source, source (source can only take the value source if it is defined). By the definition of source, this means that source is undefined. By our assumption that source for every source, we have that source is undefined, a contradiction. On the other hand, if source is undefined, then source, and so source. It follows that source is defined. But since source, then source would also be defined. Again, a contradiction.
Explain
We can describe this argument in terms of Turing machines. Suppose there were a Turing machine source that takes as input a description of a Turing machine source and an input source, and decides whether or not source halts on input source. Then we could build another Turing machine source which takes a single input source, runs source to decide if the machine source with index source halts on input source, and does the opposite. In other words, if source reports that source halts on input source, source goes into an infinite loop, and if source reports that source doesn't halt on input source, then source just halts. Does source halt on its own index as input? The argument above shows that it does if and only if it doesn't---a contradiction. So our supposition that there is a such Turing machine source must be false.
Source file content/computability/computability-theory/russells-paradox.tex
Comparison with Russell's Paradox
It is instructive to compare and contrast the arguments in this section with Russell's paradox:
Russell's paradox: let source. Then source if and only if source, a contradiction.
Conclusion: There is no such set source. Assuming the existence of a “set of all sets” is inconsistent with the other axioms of set theory.
A modification of Russell's paradox: let source be the “function” from the set of all functions to source, defined by
A similar argument shows that source if and only if source, a contradiction.
Conclusion: source is not a function. The “set of all functions” is too big to be the domain of a function.
The diagonalization argument: let source, source, dots be the enumeration of the partial computable functions, and let source be defined by
If source is computable, then it is the function source for some source. But then source if and only if source, a contradiction.
Conclusion: source is not computable. Note that according to the axioms of set theory, source is still a function; there is no paradox here, just a clarification.
That talk of partial functions, computable functions, partial computable functions, and so on can be confusing. The set of all partial functions from source to source is a big collection of objects. Some of them are total, some of them are computable, some are both total and computable, and some are neither. Keep in mind that when we say “function,” by default, we mean a total function. Thus we have:
computable functions
partial computable functions that are not total
functions that are not computable
partial functions that are neither total nor computable
To sort this out, it might help to draw a big square representing all the partial functions from source to source, and then mark off two overlapping regions, corresponding to the total functions and the computable partial functions, respectively. It is a good exercise to see if you can describe an object in each of the resulting regions in the diagram.
Source file content/computability/computability-theory/computable-sets.tex
Computable Sets
We can extend the notion of computability from computable functions to computable sets:
Definition of computable sets and relations
Let source be a set of natural numbers. Then source is computable iff its characteristic function source is. In other words, source is computable iff the function
is computable. Similarly, a relation source is computable if and only if its characteristic function is.
Computable sets and relations are also called decidable.
Explain
Notice that we now have a number of notions of computability: for partial functions, for functions, and for sets. Do not get them confused! The Turing machine computing a partial function returns the output of the function, for input values at which the function is defined; the Turing machine computing a set returns either source or source, after deciding whether or not the input value is in the set or not.
Source file content/computability/computability-theory/ce-sets.tex
Computably Enumerable Sets
Definition of computably enumerable sets
A set is computably enumerable if it is empty or the range of a computable function.
History
Computably enumerable sets are also called recursively enumerable instead. This is the original terminology, and today both are commonly used, as well as the abbreviations “c.e.” and “r.e.”
Explain
You should think about what the definition means, and why the terminology is appropriate. The idea is that if source is the range of the computable function source, then
and so source can be seen as “enumerating” the elements of source. Note that according to the definition, source need not be an increasing function, i.e., the enumeration need not be in increasing order. In fact, source need not even be injective, i.e., repetitions in the enumeration source, source, source, dots of source are allowed. For instance, the constant function source enumerates the set source.
Any computable set is computably enumerable. To see this, suppose source is computable. If source is empty, then by definition it is computably enumerable. Otherwise, let source be any element of source. Define source by
Then source is a computable function, and source is the range of source.
Source file content/computability/computability-theory/equiv-ce-defs.tex
Equivalent Defininitions of Computably Enumerable Sets
The following gives a number of important equivalent statements of what it means to be computably enumerable.
Equivalent definitions of computably enumerable sets theorem
Let source be a set of natural numbers. Then the following are equivalent:
Explain
The first three clauses say that we can equivalently take any non-empty computably enumerable set to be enumerated by either a computable function, a partial computable function, or a primitive recursive function. The fourth clause tells us that if source is computably enumerable, then for some index source,
In other words, source is the set of inputs on for which the computation of source halts. For that reason, computably enumerable sets are sometimes called semi-decidable: if a number is in the set, you eventually get a “yes,” but if it isn't, you never get a “no”!
Proof
Since every primitive recursive function is computable and every computable function is partial computable, Primitive range clause implication source implies Primitive range implication destination and Partial range implication source implies Partial range implication destination. (Note that if source is empty, source is the range of the partial computable function that is nowhere defined.) If we show that Primitive range return implication source implies Primitive range return implication destination, we will have shown the first three clauses equivalent.
So, suppose source is the range of the partial computable function source. If source is empty, we are done. Otherwise, let source be any element of source. By Kleene's normal form theorem, we can write
In particular, source and source if and only if there is an source such that source and source. Define source by
Then source is primitive recursive, because source and source are. Expressed in terms of Turing machines, if source codes a pair source such that source is a halting computation of machine source on input source, then source returns the output of the computation; otherwise, it returns source.
We need to show that source is the range of source, i.e., for any natural number source, source if and only if it is in the range of source. In the forwards direction, suppose source. Then source is in the range of source, so for some source and source, source holds and source. But then source. Conversely, suppose source is in the range of source. Then either source, or for some source, source and source. Since, in the latter case, source, either way, source is in source.
(The notation source means “source is defined and equal to source.” We could just as well use source, but the extra arrow is sometimes helpful in reminding us that we are dealing with a partial function.)
To finish up the proof of Equivalent definitions proof resumption reference, it suffices to show that Range and domain equivalence first clause reference and Range and domain equivalence second clause reference are equivalent. First, let us show that Range to domain implication source implies Range to domain implication destination. Suppose source is the range of a computable function source, i.e.,
Let
Then source is a partial computable function, and source is defined if and only if for some source, source. In other words, the domain of source is the range of source. Expressed in terms of Turing machines: given a Turing machine source that enumerates the elements of source, let source be the Turing machine that semi-decides source by searching through the outputs of source to see if a given element is in the set, halts if it is and keeps searching forever if it isn't.
Finally, to show Domain to range implication source implies Domain to range implication destination, suppose that source is the domain of the partial computable function source, i.e.,
If source is empty, we are done; otherwise, let source be any element of source. Define source by
Then, as above, a number source is in the range of source if and only if source, i.e., if and only if source. Expressed in terms of Turing machines: given a machine source that semi-decides source, enumerate the elements of source by running through all possible Turing machine computations, and returning the inputs that correspond to halting computations.
Clause Domain clause enumeration reference of Enumeration consequence theorem reference provides us with a convenient way of enumerating the computably enumerable sets: for each source, let source denote the domain of source, i.e.,
Then if source is any computably enumerable set, source, for some source.
The following provides yet another characterization of the computably enumerable sets.
Existential characterization theorem
A set source is computably enumerable if and only if there is a computable relation source such that
Proof
In the forward direction, suppose source is computably enumerable. Then for some source, source. For this value of source we can write source as
In the reverse direction, suppose source. Define source by
Then source is partial computable, and source is the domain of source.
Source file content/computability/computability-theory/non-comp-set.tex
There Are Non-Computable Sets
We saw above that every computable set is computably enumerable. Is the converse true? The following shows that, in general, it is not.
Paired halting set theorem
Let source be the set source. Then source is computably enumerable but not computable.
Proof
To see that source is computably enumerable, note that it is the domain of the function source defined by
For, if source is defined, source finds a halting computation sequence; if source is undefined, so is source; and if source doesn't even code a pair, then source is also undefined.
The fact that source is not computable is just the undecidability of the halting problem, Paired halting set undecidability reference.
The set source is the set of pairs source such that source, i.e., source iff source is defined (halts) on input source, so it is also called the “halting set.” The set source is the “self-halting set.” It is often used as a canonical undecidable set.
Self halting set theorem
The self-halting set source is c.e. but not decidable.
Proof
Suppose source is decidable, i.e., its characteristic function source is computable. Let
Let source be the index of source, i.e., source. Then source. This contradicts the fact that source iff source, which follows from the definition of source.
Source file content/computability/computability-theory/ce-closed-cup-cap.tex
Computably Enumerable Sets are Closed under Union and Intersection
The following theorem gives some closure properties on the set of computably enumerable sets.
Closure under union and intersection theorem
Suppose source and source are computably enumerable. Then so are source and source.
Proof
Closure proof characterization reference allows us to use various characterizations of the computably enumerable sets. By way of illustration, we will provide a few different proofs.
For the first proof, suppose source is enumerated by a computable function source, and source is enumerated by a computable function source. Let
Then source is the domain of source, and source is the domain of source.
Explain
Here is what is going on, in computational terms: given procedures that enumerate source and source, we can semi-decide if an element source is in source by looking for source in either enumeration; and we can semi-decide if an element source is in source for looking for source in both enumerations at the same time.
For the second proof, suppose again that source is enumerated by source and source is enumerated by source. Let
Then source enumerates source; the idea is that source just alternates between the enumerations offered by source and source. Enumerating source is tricker. If source is empty, it is trivially computably enumerable. Otherwise, let source be any element of source, and define source by
In computational terms, source runs through pairs of elements in the enumerations of source and source, and outputs every match it finds; otherwise, it just stalls by outputting source.
For the last proof, suppose source is the domain of the partial function source and source is the domain of the partial function source. Then source is the domain of the partial function source.
Explain
In computational terms, if source is the set of values for which source halts and source is the set of values for which source halts, source is the set of values for which both procedures halt.
Expressing source as a set of halting values is more difficult, because one has to simulate source and source in parallel. Let source be an index for source and let source be an index for source; in other words, source and source. Then source is the domain of the function
Explain
In computational terms, on input source, source searches for either a halting computation for source or a halting computation for source, and halts if it finds either one.
Source file content/computability/computability-theory/complement-ce.tex
Computably Enumerable Sets not Closed under Complement
Suppose source is computably enumerable. Is the complement of source, source, always computably enumerable as well? The following theorem and corollary show that the answer is “no.”
Complement characterization theorem
Let source be any set of natural numbers. Then source is computable if and only if both source and source are computably enumerable.
Proof
The forwards direction is easy: if source is computable, then source is computable as well (source), and so both are computably enumerable.
In the other direction, suppose source and source are both computably enumerable. Let source be the domain of source, and let source be the domain of source. Define source by
In other words, on input source, source searches for either a halting computation of source or a halting computation of source. Now, if source, it will succeed in the first case, and if source, it will succeed in the second case. So, source is a total computable function. But now we have that for every source, source if and only if source, i.e., if source is the one that is defined. Since source is a computable relation, source is computable.
Explain
It is easier to understand what is going on in informal computational terms: to decide source, on input source search for halting computations of source and source. One of them is bound to halt; if it is source, then source is in source, and otherwise, source is in source.
Complement of paired halting set corollary
source is not computably enumerable.
Proof
We know that source is computably enumerable, but not computable. If source were computably enumerable, then source would be computable by Complement corollary characterization reference, contradicting Complement corollary halting set reference.
Source file content/computability/computability-theory/reducibility.tex
Reducibility
Explain
We now know that there is at least one set, source, that is computably enumerable but not computable. It should be clear that there are others. The method of reducibility provides a powerful method of showing that other sets have these properties, without constantly having to return to first principles.
Generally speaking, a “reduction” of a set source to a set source is a method of transforming answers to whether or not elements are in source into answers as to whether or not elements are in source. We will focus on a notion called “many-one reducibility,” but there are many other notions of reducibility available, with varying properties. Notions of reducibility are also central to the study of computational complexity, where efficiency issues have to be considered as well. For example, a set is said to be “NP-complete” if it is in NP and every NP problem can be reduced to it, using a notion of reduction that is similar to the one described below, only with the added requirement that the reduction can be computed in polynomial time.
We have already used the notion of reduction notion implicitly. Define the set source by
i.e., source. Our proof that the halting problem in unsolvable (Reducibility introduction halting reference) shows most directly that source is not computable. Recall that source is the set
i.e., source. It is easy to extend any proof of the uncomputability of source to the uncomputability of source: if source were computable, we could decide whether or not an element source is in source simply by asking whether or not the pair source is in source. The function source which maps source to source is an example of a reduction of source to source.
Definition of many one reducibility
Let source and source be sets of natural numbers. A computable function source is a many-one reduction of source to source iff, for every natural number source,
If such a reduction source exists, we say that source is many-one reducible to source, written source. If source is many-one reducible to source and vice-versa, then source and source are said to be many-one equivalent, written source.
If the function source in the definition above happens to be injective, source is said to be one-one reducible to source. Most of the reductions described below meet this stronger requirement, but we will not use this fact.
Digress
It is true, but by no means obvious, that one-one reducibility really is a stronger requirement than many-one reducibility. In other words, there are infinite sets source and source such that source is many-one reducible to source but not one-one reducible to source.
Source file content/computability/computability-theory/prop-reduce.tex
Properties of Reducibility
We write source if source reduces to source, and this notation suggests that if source, then source is “no harder than” source and that source is “as hard or harder than” source, and that source, like the usual source on numbers, orders sets (or decision problems) by their complexity. The following two propositions support this intuition. The first one say taht source is transitive.
Transitivity of many one reducibility proposition
Proof
Composing a reduction of source to source with a reduction of source to source yields a reduction of source to source.
Transitivity proof exercise
Prove Transitivity exercise proposition reference by showing that if source and source are many-one reductions of source to source and source to source, respectively, then source is a many-one reduction of source to source.
Reduction preservation proposition
Proof
Let source be a many-one reduction from source to source. For the first claim, just check that if source is the domain of a partial function source, then source is the domain of source:
For the second claim, remember that if source is computable then source and source are computably enumerable (Reduction proof complement premise reference). It is not hard to check that source is also a many-one reduction of source to source, so, by the first part of this proof, source and source are computably enumerable. So source is computable as well by Reduction proof complement conclusion reference. (Alternatively, you can check that source; so if source is computable, then so is source.)
Complement reduction exercise
Suppose source is a many-one reduction of source to source. Show that source is also a many-one reduction of source to source.
Characteristic function composition exercise
Digress
A more general notion of reducibility called Turing reducibility is useful in other contexts, especially for proving undecidability results. Note that by Complement nonreducibility corollary reference, the complement of source is not reducible to source, since it is not computably enumerable. But, intuitively, if you knew the answers to questions about source, you would know the answer to questions about its complement as well. A set source is said to be Turing reducible to source if one can determine answers to questions in source using a computable procedure that can ask questions about source. This is more liberal than many-one reducibility, in which (1) you are only allowed to ask one question about source, and (2) a “yes” answer has to translate to a “yes” answer to the question about source, and similarly for “no.” It is still the case that if source is Turing reducible to source and source is computable then source is computable as well (though, as we have seen, the analogous statement does not hold for computable enumerability).
You should think about the various notions of reducibility we have discussed, and understand the distinctions between them. We will, however, only deal with many-one reducibility in this chapter. Incidentally, both types of reducibility discussed in the last paragraph have analogues in computational complexity, with the added requirement that the Turing machines run in polynomial time: the complexity version of many-one reducibility is known as Karp reducibility, while the complexity version of Turing reducibility is known as Cook reducibility.
Source file content/computability/computability-theory/complete-ce-sets.tex
Complete Computably Enumerable Sets
Definition of complete computably enumerable sets
A set source is a complete computably enumerable set (under many-one reducibility) if
In other words, complete computably enumerable sets are the “hardest” computably enumerable sets possible. They allow one to answer questions about any computably enumerable set.
Completeness of the canonical halting sets theorem
source, source, and source are all complete computably enumerable sets.
Proof
To see that source is complete, let source be any computably enumerable set. Then for some index source,
Let source be the function source. Then for every natural number source, source if and only if source. In other words, source reduces source to source.
To see that source is complete, note that in the proof of Completeness proof zero input set reference we reduced source to it. So, by Completeness proof transitivity reference, any computably enumerable set can be reduced to source as well.
Reduction from self halting to paired halting exercise
Digress
So, it turns out that all the examples of computably enumerable sets that we have considered so far are either computable, or complete. This should seem strange! Are there any examples of computably enumerable sets that are neither computable nor complete? The answer is yes, but it wasn't until the middle of the 1950s that this was established by Friedberg and Muchnik, independently.
Source file content/computability/computability-theory/k-1.tex
An Example of Reducibility
Let us consider an application of Zero input set reduction proposition reference.
Zero input halting set proposition
Let
Then source is computably enumerable but not computable.
Proof
Since source, source is computably enumerable by Zero input set existential characterization reference.
To show that source is not computable, let us show that source is reducible to it.
Explain
This is a little bit tricky, since using source we can only ask questions about computations that start with a particular input, source. Suppose you have a smart friend who can answer questions of this type (friends like this are known as “oracles”). Then suppose someone comes up to you and asks you whether or not source is in source, that is, whether or not machine source halts on input source. One thing you can do is build another machine, source, that, for any input, ignores that input and instead runs source on input source. Then clearly the question as to whether machine source halts on input source is equivalent to the question as to whether machine source halts on input source (or any other input). So, then you ask your friend whether this new machine, source, halts on input source; your friend's answer to the modified question provides the answer to the original one. This provides the desired reduction of source to source.
Using the universal partial computable function, let source be the 3-ary function defined by
Note that source ignores its third input entirely. Pick an index source such that source; so we have
By the source-source-source theorem, there is a function source such that, for every source,
Explain
In terms of the informal argument above, source is an index for the machine that, for any input source, ignores that input and computes source.
In particular, we have
In other words, source if and only if source. So the function source defined by
Source file content/computability/computability-theory/total.tex
Totality is Undecidable
Let us consider one more example of using the source-source-source theorem to show that something is noncomputable. Let source be the set of indices of total computable functions, i.e.
Undecidability of totality proposition
source is not computable.
Proof
To see that source is not computable, it suffices to show that source is reducible to it. Let source be defined by
Note that source does not depend on source at all. It should not be hard to see that source is partial computable: on input source, the we compute source by first simulating the function source on input source; if this computation halts, source outputs source and halts. So source is just source, where source is the constant zero function.
Using the source-source-source theorem, there is a primitive recursive function source such that for every source and source,
So source is total if source, and undefined otherwise. Thus, source is a reduction of source to source.
Digress
It turns out that source is not even computably enumerable---its complexity lies further up on the “arithmetical hierarchy.” But we will not worry about this strengthening here.
Source file content/computability/computability-theory/rice-theorem.tex
Rice's Theorem
If you think about it, you will see that the specifics of source do not play into the proof of Rice theorem motivation totality reference. We designed source to act like the constant function source exactly when source is in source; but we could just as well have made it act like any other partial computable function under those circumstances. This observation lets us state a more general theorem, which says, roughly, that no nontrivial property of computable functions is decidable.
Keep in mind that source, source, source, dots is our standard enumeration of the partial computable functions.
Rice theorem
[Rice's Theorem] Let source be any set of partial computable functions, and let source. If source is computable, then either source is empty or source is the set of all the partial computable functions.
An em index set is a set source with the property that if source and source are indices which “compute” the same function, then either both source and source are in source, or neither is. It is not hard to see that the set source in the theorem has this property. Conversely, if source is an index set and source is the set of functions computed by these indices, then source.
Explain
With this terminology, Rice's theorem is equivalent to saying that no nontrivial index set is decidable. To understand what the theorem says, it is helpful to emphasize the distinction between programs (say, in your favorite programming language) and the functions they compute. There are certainly questions about programs (indices), which are syntactic objects, that are computable: does this program have more than 150 symbols? Does it have more than 22 lines? Does it have a “while” statement? Does the string “hello world” ever appear as the argument to a “print” statement? Rice's theorem says that no nontrivial question about the program's behavior is computable. This includes questions like these: does the program halt on input source? Does it ever halt? Does it ever output an even number?
Proof
[Proof of Rice's theorem] Suppose source is neither empty nor the set of all the partial computable functions, and let source be the set of indices of functions in source. We will show that if source were computable, we could solve the halting problem; so source is not computable.
Without loss of generality, we can assume that the function source which is nowhere defined is not in source (otherwise, switch source and its complement in the argument below). Let source be any function in source. The idea is that if we could decide source, we could tell the difference between indices computing source, and indices computing source; and then we could use that capability to solve the halting problem.
Here's how. Using the universal partial computable functions, we can define a function
To compute source, first we try to compute source; if that computation halts, we go on to compute source; and if em that computation halts, we return the output. More formally, we can write
where source is the source-place projection function returning the source-th argument, which is computable.
Then source is a composition of partial computable functions, and the right side is defined and equal to source just when source and source are both defined.
Notice that for a fixed source, if source is undefined, then source is undefined for every source; and if source is defined, then source. So, for any fixed value of source, either source acts just like source or it acts just like source, and deciding whether or not source is defined amounts to deciding which of these two cases holds. But this amounts to deciding whether or not source is in source or not, and if source were computable, we could do just that.
More formally, since source is partial computable, it is equal to the function source for some index source. By the source-source-source theorem there is a primitive recursive function source such that for each source, source. Now we have that for each source, if source, then source is the same function as source, and so source is in source. On the other hand, if source, then source is the same function as source, and so source is not in source. In other words, we have that for every source, source if and only if source. If source were computable, source would be also, which is a contradiction. So source is not computable.
Rice's theorem is very powerful. The following immediate corollary shows some sample applications.
Rice theorem examples corollary
The following sets are undecidable.
Proof
These are all nontrivial index sets.
Source file content/computability/computability-theory/fixed-point-thm.tex
The Fixed-Point Theorem
Let's consider the halting problem again. As temporary notation, let us write source for source; think of this as representing a “name” for the value source. With this notation, we can reword one of our proofs that the halting problem is undecidable.
Question: is there a computable function source, with the following property? For every source and source,
Answer: No; otherwise, the partial function
would be computable, and so have some index source. But then we have
in which case source is defined if and only if it isn't, a contradiction.
Now, take a look at the equation with source. There is an instance of self-reference there, in a sense: we have arranged for the value of source to depend on source, in a certain way. The fixed-point theorem says that we em can do this, in general---not just for the sake of proving contradictions.
Fixed point equivalence discussion reference gives two equivalent ways of stating the fixed-point theorem. Logically speaking, the fact that the statements are equivalent follows from the fact that they are both true; but what we really mean is that each one follows straightforwardly from the other, so that they can be taken as alternative statements of the same theorem.
Fixed point equivalence lemma
The following statements are equivalent:
Proof
source: Given source, define source by source. Use (1) to get an index source such that for every source,
source: Given source, use the source-source-source theorem to get source such that for every source and source, source. Use (2) to get an index source such that
This concludes the proof.
Explain
Before showing that statement (1) is true (and hence (2) as well), consider how bizarre it is. Think of source as being a computer program; statement (1) says that given any partial computable source, you can find a computer program source that computes source. In other words, you can find a computer program that computes a function that references the program itself.
Computability fixed point theorem
The two statements in Fixed point theorem statement reference are true. Specifically, for every partial computable function source, there is an index source such that for every source,
Proof
The ingredients are already implicit in the discussion of the halting problem above. Let source be a computable function which for each source returns an index for the function source, i.e.
Think of source as a function that transforms a program for a 2-ary function into a program for a 1-ary function, obtained by fixing the original program as its first argument. The function source can be defined formally as follows: first define source by
where source is a 3-ary function that is universal for partial computable 2-ary functions. Then, by the source-source-source theorem, we can find a primitive recursive function source satisfying
Now, define the function source by
and let source be an index for source. Finally, let source. Then for every source, we have
as required.
Explain
What's going on? Suppose you are given the task of writing a computer program that prints itself out. Suppose further, however, that you are working with a programming language with a rich and bizarre library of string functions. In particular, suppose your programming language has a function source which works as follows: given an input string source, source locates each instance of the symbol `x' occurring in source, and replaces it by a quoted version of the original string. For example, given the string
Verbatim
hello x world
as input, the function returns
Verbatim
hello 'hello x world' world
as output. In that case, it is easy to write the desired program; you can check that
Verbatim
print(diag('print(diag(x))'))
does the trick. For more common programming languages like C++ and Java, the same idea (with a more involved implementation) still works.
We are only a couple of steps away from the proof of the fixed-point theorem. Suppose a variant of the print function source accepts a string source and another numeric argument source, and prints the string source repeatedly, source times. Then the “program”
Verbatim
getinput(y); print(diag('getinput(y); print(diag(x), y)'), y)
prints itself out source times, on input source. Replacing the source---source---source skeleton by an arbitrary function source yields
Verbatim
g(diag('g(diag(x), y)'), y)
which is a program that, on input source, runs source on the program itself and source. Thinking of “quoting” with “using an index for,” we have the proof above.
For now, it is o.k.\ if you want to think of the proof as formal trickery, or black magic. But you should be able to reconstruct the details of the argument given above. When we prove the incompleteness theorems (and the related “fixed-point theorem”) we will discuss other ways of understanding why it works.
Digress
The same idea can be used to get a “fixed point” combinator. Suppose you have a lambda term source, and you want another term source with the property that source is source-equivalent to source. Define terms
and
using our notational conventions; in other words, source is the term source. Let source be the term source. Then we have
If one takes
then source and source reduce to a common term; so source. This is known as “Curry's combinator.” If instead one takes
then in fact source reduces to source, which is a stronger statement. This latter version of source is known as “Turing's combinator.”
Source file content/computability/computability-theory/application-fixed-point.tex
Applying the Fixed-Point Theorem
The fixed-point theorem essentially lets us define partial computable functions in terms of their indices. For example, we can find an index source such that for every source,
As another example, one can use the proof of the fixed-point theorem to design a program in Java or C++ that prints itself out.
Remember that if for each source, we let source be the domain of source, then the sequence source, source, source, dots enumerates the computably enumerable sets. Some of these sets are computable. One can ask if there is an algorithm which takes as input a value source, and, if source happens to be computable, returns an index for its characteristic function. The answer is “no,” there is no such algorithm:
No uniform characteristic index selector theorem
There is no partial computable function source with the following property: whenever source is computable, then source is defined and source is its characteristic function.
Proof
Let source be any computable function; we will construct an source such that source is computable, but source is not its characteristic function. Using the fixed point theorem, we can find an index source such that
That is, source is obtained by applying the fixed-point theorem to the function defined by
Informally, we can see that source is partial computable, as follows: on input source and source, the algorithm first checks to see if source is equal to source. If it is, the algorithm computes source, and then uses the universal machine to compute source. If this last computation halts and returns source, the algorithm returns source; otherwise, the algorithm doesn't halt.
But now notice that if source is defined and equal to source, then source is defined exactly when source is equal to source, so source. If source is not defined, or is defined but not equal to source, then source. Either way, source is not the characteristic function of source, since it gives the wrong answer on input source.
Source file content/computability/computability-theory/def-functions-self-reference.tex
Defining Functions using Self-Reference
It is generally useful to be able to define functions in terms of themselves. For example, given computable functions source, source, and source, the fixed-point lemma tells us that there is a partial computable function source satisfying the following equation for every source:
Again, more specifically, source is obtained by letting
and then using the fixed-point lemma to find an index source such that source.
For a concrete example, the “greatest common divisor” function source can be defined by
where source denotes the remainder of dividing source by source. An appeal to the fixed-point lemma shows that source is partial computable. (In fact, this can be put in the format above, letting source code the pair source.) A subsequent induction on source then shows that, in fact, source is total.
Of course, one can cook up self-referential definitions that are much fancier than the examples just discussed. Most programming languages support definitions of functions in terms of themselves, one way or another. Note that this is a little bit less dramatic than being able to define a function in terms of an index for an algorithm computing the functions, which is what, in full generality, the fixed-point theorem lets you do.
Source disclosures
- TR031-SOURCE-001: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-002: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-003: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-004: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-005: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-006: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-007: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-008: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-009: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-010: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-011: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-012: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-013: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-014: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-015: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-016: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-017: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-018: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-019: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-020: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-021: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-022: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-023: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-029: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-030: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-031: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-032: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-024: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-025: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-026: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-027: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source
- TR031-SOURCE-028: Source note. The frozen source is preserved. A reviewed correction is applied here in the accessible reading. The exact source and correction details remain available in Read mode. source