This lesson connects the previous ones with computation. Counting shows that almost all functions are not computable, but it exhibits none. Diagonalization does better: applied to an enumeration that is itself computable, it produces a function that is computable, and escapes the enumeration. Applied to the enumeration of all partial computable functions, it does not produce a contradiction, but a point of divergence, and from there the undecidability of the halting problem. The last section presents diagonalization as the satisfaction of a list of requirements, the form in which it is used in the rest of computability theory.
We use the notation of the course on models of computation: is the partial function computed by the program of code , and is partial computable (Universal function). We write when the computation halts and otherwise.
6.1 Counting
The set of partial computable functions , the set of total computable functions and the set of computable subsets of are countably infinite.
By Universal function, every partial computable function is for some , so is a surjection from onto the partial computable functions, which are therefore countable (Proposition 3.3). The total computable functions form a subset, and the computable sets are the images of the computable characteristic functions under the bijection , so both are countable by Corollary 3.4. All three sets are infinite: they contain the constant functions, or the finite sets .
The set of functions that are not computable, and the set of subsets of that are not computable, have the cardinality of the continuum.
They are the complements of countable sets in and , which have the cardinality of the continuum by Theorem 5.5. Conclude by Proposition 5.7.
The argument does not depend on the details of the model of computation. It uses only that every computable function has a finite description, so that there are countably many of them. For the same reason, there are only countably many subsets of definable by a formula of first-order arithmetic, so that most sets are not definable in arithmetic. The argument is not constructive: it does not exhibit any particular non-computable function.
6.2 Effective diagonalization
The diagonal function of Example 4.5 is defined from the whole sequence . If this sequence is given by an algorithm, so is .
A sequence of total functions is uniformly computable if the function is computable. A sequence of sets is uniformly computable if the sequence of their characteristic functions is.
Each function of a uniformly computable sequence is computable, but the converse fails: being uniformly computable means that a single algorithm computes from and , not only that each has an algorithm of its own. For instance, let be the constant function with value if and otherwise, where is the halting set of Corollary 6.8 below. Each is constant, hence computable, but is the characteristic function of , which is not computable.
If is a uniformly computable sequence of total functions, then the function is total computable and differs from every . Consequently, there is no uniformly computable sequence containing all total computable functions.
The function is obtained by composing the computable function with and with the successor, so it is computable; it is total since each is. It differs from every by Proposition 4.3. If a uniformly computable sequence contained all total computable functions, it would contain .
The primitive recursive functions form a uniformly computable sequence : enumerate the derivations and evaluate them. This is the argument of Theorem 7.6 of “The Ackermann function”, which yields a total computable function that is not primitive recursive. The theorem shows that the total computable functions themselves cannot be enumerated in this way. The obstacle is identified by the following consequence.
The set is not computable.
The set is infinite: the constant functions are total computable and pairwise distinct, and each of them is for some . Suppose computable. Then its principal function (Lemma 3.2) is computable, by
where each search terminates since is infinite. Let . Since is partial computable, is partial computable; and it is total, since . So is a uniformly computable sequence of total functions. Every total computable function is for some , that is, for some , so it is . This contradicts Theorem 6.4.
6.3 Partial functions
The enumeration of the partial computable functions is uniformly computable in the sense that is partial computable. What happens when one diagonalizes against it?
The partial function is partial computable. If is a code of , that is, , then .
is obtained by composing , which is partial computable, with and with the successor; it is defined exactly when . If and , then , which is impossible. So .
So the diagonal argument does not fail: it determines a point, , where the enumerated function must be undefined. The partial functions escape diagonalization by being undefined at the diagonal point. This is why an enumeration of all partial computable functions can be computable, while an enumeration of all total computable functions cannot.
The partial computable function has no total computable extension: there is no total computable with whenever .
Suppose is such an extension, and let be a code of , so that is total. Then , so is defined, and , a contradiction.
The halting set is not computable.
If were computable, the function defined by if , and otherwise, would be total computable: to compute , decide whether , and run the computation of only if it halts. It would extend , contradicting Theorem 6.7.
This is the halting problem, which is the starting point of the course on fundamentals (Theorem 3.2 of “The halting problem”). Its proof there is the same diagonal argument, presented directly.
6.4 Diagonalization by requirements
In the diagonal argument, the sequence is built to satisfy infinitely many conditions, for each , each of which can be secured by fixing a single bit. Constructions in computability theory are usually organized in this way: one lists requirements , and builds the desired object by finite approximations, ensuring each requirement at its turn.
For strings , write if is a prefix of , and if is a prefix of . A requirement is a property of elements of , that is, a subset .
Let be a sequence of requirements such that for every and every , there is such that every satisfies . Then there is satisfying every .
Fix an enumeration of , given by Proposition 3.11. If is as in the hypothesis, so is every extension of ; in particular there is such a with . Define as the empty string and as the first such that , , and every satisfies . The strings have strictly increasing lengths, so there is a unique with for every : its -th bit is the -th bit of any of length greater than . Since , satisfies .
Choosing as the first suitable string in a fixed enumeration avoids any use of the axiom of choice, and makes the construction explicit.
Let be a sequence in , and . Given , the string with satisfies the hypothesis: every differs from at position . This is the diagonal argument, except that the position at which is defeated is now chosen by the construction rather than fixed in advance.
For every sequence in , there is that differs from every at infinitely many positions. If is uniformly computable, can be taken computable.
For , let be the requirement ” for some ”. Given , extend it by zeros to a string of length at least , and let with ; every differs from at the position . By Lemma 6.9, some satisfies all , that is, differs from each beyond every .
If is uniformly computable, use the explicit extension above instead of a search in an enumeration: is obtained from by padding with zeros to length and appending the bit , where ; both steps are computable from and . Then is computable, and so is , since is the -th bit of , which has length at least .
The requirements of this proposition never interfere: once a requirement is satisfied, it remains satisfied whatever is done afterwards. Requirements of this kind can be handled one after the other, by finite extensions. The method was introduced by Kleene and Post to build Turing degrees with prescribed properties, and it is the elementary case of forcing. When requirements conflict, so that satisfying one may later injure another, one needs the priority method, which is the main technique of the theory of computably enumerable sets.
6.5 Exercises
A function dominates a function if for all sufficiently large . Show that no total computable function dominates every total computable function.
Solution
If is total computable and dominates every total computable function, it dominates , which is total computable: for large , a contradiction.
Show that there is no uniformly computable sequence of sets containing every computable set.
Solution
If is uniformly computable, then is computable, as a composition of computable functions, and differs from every . Alternatively, apply Theorem 6.4 to the characteristic functions, replacing by .
Let and . Show that there is no computable set with and . (The sets and are computably inseparable.)
Solution
Let be computable, and let be a code of its characteristic function, so that is total with values in . If , then , so , and . If , then , so , and . This is a diagonal argument in which the program is defeated at its own index.
Using Proposition 4.4 of “Computably enumerable sets” of the course on fundamentals, where computably enumerable sets are defined, show that is not even computably enumerable.
Solution
is infinite. If it were computably enumerable, there would be an injective total computable with . Then defines a uniformly computable sequence of total functions containing every total computable function, contradicting Theorem 6.4. The proof of Corollary 6.5 is the special case where is the principal function.
Show that there is a set such that neither nor its complement contains an infinite computable set.
Hint
For each infinite computable set , the requirement is: and . Satisfy it by a finite extension.
Solution
The infinite computable sets form a countably infinite set, by Proposition 6.1 and Corollary 3.4 (it contains the sets ); let be an enumeration of them. Requirement : for some ; requirement : for some . Given , since is infinite there is with ; extend by zeros to length , then append the required bit. Every extending the result satisfies the requirement. By Lemma 6.9, some satisfies all requirements: each infinite computable set meets both and its complement, so it is contained in neither. Such a set is called bi-immune.
6.6 Notes and references
The undecidability of the halting problem is due to Turing (1936), in the form that no machine decides whether a given machine is circle-free, that is, prints infinitely many digits. The finite extension method is due to Kleene and Post (1954), and the priority method to Friedberg and Muchnik (1956–1957). Rogers’ and Soare’s textbooks present diagonalization as the basic method of computability theory; Odifreddi gives a historical account of the many forms of the argument.
- A. M. Turing, On computable numbers, with an application to the Entscheidungsproblem, Proceedings of the London Mathematical Society (2) 42 (1936), 230–265.
- S. C. Kleene and E. L. Post, The upper semi-lattice of degrees of recursive unsolvability, Annals of Mathematics 59 (1954), 379–407.
- H. Rogers, Theory of Recursive Functions and Effective Computability, McGraw-Hill, 1967.
- P. Odifreddi, Classical Recursion Theory, North-Holland, 1989.
- R. I. Soare, Turing Computability: Theory and Applications, Springer, 2016.