The recursion theorem , by that name, is due to Kleene but owes its existence (and proof) to the work of Gödel (1931) on the incompleteness phenomenon. We look at few versions of this very powerful tool in what follows, and then come back to this comment regarding the connection with Gödel’s work.

2.9.0.26 Theorem. (Kleene’s Recursion Theorem) If Images z Images . f ( z , Images n ) images Images , then for some e, we have Images ( Images n ) ⋍ f ( e , Images n ), for all Images n .

Proof . Let Images . Then

Images         by 2.6.0.38

Take e = Images ( a , a ).          □

2.9.0.27 Corollary. (Recursion Theorem—Rogers’s version) If Images x . g ( x ) is recursive. then there is an e such that Images g ( e ) \= Images e .

Images This does not say that g ( e ) = e . Rather, that the two programs g ( e ) and e compute the same function.           Images

Proof. Let f ( x , y ) ≃ Images g ( x ) ( y ), for all x , y . Since f images Images , 2.9.0.26 applies to yield an e such that f ( e , y ) ≃ Images e ( y ), for all y .          □

Images 2.9.0.28 Remark. It is instructive to see Rogers’s direct proof for the corollary: Define Images by

images

By the normal form theorem, Images images Images . Let h be obtained by S-m-n such that Images ( x , y ) ≃ Images h ( x ) ( y ), for all x, y . Let a be such that ( gh ) = Images a . By (1) we now get (for all y )

images

e = h ( a ) works.

Note that, in (1), Images x ( x ) is not a Images -index unless Images x ( x ) ↓, but this is irrelevant to the proof, in which we applied the S-m-n theorem to the computable function Images given—in detail—by

Images images

2.9.0.29 Corollary. (Recursion Theorem with Parameters)

If Images z Images m Images n . f ( z , Images m , Images n ) images Images , then there is a 1-1 primitive recursive function h such that Images , for all Images m , Images n .

Proof . Let Images and a images Images be such that F = Images . Thus,

images

Just take Images and note that the S-m-n functions are 1-1.         □

2.9.0.30 Corollary. (Recursion Theorem with Parameters—Rogers Style)

For any g images Images of m + 1 arguments, there is a 1-1 primitive recursive function h such that Images , for all Images m .

Proof. Images is in Images . Now apply 2.9.0.29.           □

Images The reader has noted no doubt that the proofs of all versions of the recursion theorem are constructive. For example, in the proof of 2.9.0.30 , if g is given as Images , then we use a new f : f = Images and, correspondingly, the new h will be an S-m-n function dependent on w as well, yielding for all w , Images m , Images n ,

images             Images

Images 2.9.0.31 Remark. (Indebtedness to Gödel (1931)) The proof that Gödel gave in loc. cit. to his first incompleteness theorem was based on a modification to the liar’s paradox (the latter due to the Cretan philosopher Epimenides). Epimenides is credited with the sentence “All Cretans are liars”. But then, him being a Cretan, the statement must be false, so there is at least one Cretan who is not a liar. This is rather unsettling since by virtue of him simply making this utterance he forced the existence of truthful Cretans! A more unsettling version is the statement “I am lying”, for, if I am, then I am not, for my statement is false; if I am not, then I am, for my statement is true. Gödel built an analogous sentence Images within Peano arithmetic, one that states its own unprovability: “I am not a theorem” (of Peano arithmetic).

Intuitively—and based on the fact that Peano arithmetic cannot prove false statements—such a sentence is neither provable, nor is its negation: Indeed, if Peano arithmetic can prove Images , then it has just proved a false statement. So Images cannot be a theorem. But then it is true, as it says just that! This makes ¬ Images false, therefore it cannot be proved either.

But let us get back on track. Gödel built within Peano arithmetic a so-called provability predicate , ⊝( x ), analogous to the Kleene predicate. ⊝( x ) says “the formula coded by the number x is a theorem”.

Pause. By the way, in honor of Gödel, we call such formula-codes “Gödel numbers”. Images

Gödel also devised in his paper a primitive recursive substitution function of two variables, s ( a, b ), which computes the (new) Gödel number of a formula obtained from Images ( x )—the latter of Gödel number a —if we replace x by b . This is an S-m-n function, but in the context of formulae.

Next, he proved his diagonalization lemma , that for any formula Images ( x ), there is an e such that e is the Gödel number of the sentence Images ( e ).

He did this as follows: Let us consider the new formula Images ( s ( x, x )) of Gödel number, say, a . But then, the Gödel number of Images ( s ( a, a )) is s ( a, a ). Take e = s ( a, a ). Now compare with the statement and proof of 2.9.0.26 !

To conclude this discussion, apply the diagonalization lemma to ¬⊝( x ) to find an m such that m is the Gödel number of ¬⊝( m ). So the latter says, “ m is not a theorem”, that is, “I am not a theorem”.          □    Images

2.9.1 Applications of the Recursion Theorem

2.9.1.1 Theorem. (Rice’s Theorem—Revisited) A complete index set is recursive iff it is trivial.

Proof . [The idea of this proof is attributed in Rogers (1967) to G.C. Wolpin.]

if -part. Immediate, since χ Images = Images x .1 and χ Images = Images x .0.

only if -part. By contradiction, suppose that A = { x : Images x images Images } is nontrivial, yet A images Images * . So, let a images A and b ∉ A . Define f by

images

Clearly,

images

By the recursion theorem (e.g., 2.9.0.27 ), there is an e such that Images f ( e ) \= Images e .

Thus, e images A iff f ( e ) images A , contradicting (1).          □

2.9.1.2 Corollary. If A = { x : Images x images Images }, then A ≰ m Images and thus A ≢ m Images .

Proof . Suppose

images

where f is recursive. If e is as above, then e images A iff Images e images Images iff Images f ( e ) images Images iff f ( e ) images A , contradicting (∗) .          □

Images 2.9.1.3 Example. K is not a complete index set, that is, there is no Images ⊆ Images such that

images

Suppose such a Images exists. Define

images

By definition by positive cases, Images is computable, so let by 2.9.0.26 , e be such that Images ( e, y ) ≃ Images e ( y ), for all y . It follows that

images

but

images

By (2), e images K and, by (1),

images

Let now m ≠ e be another among the infinitely many indices of Images e , that is, Images e = Images m .

By (4), Images m images Images . By (1) and the original definition of K , this entails Images m ( m ) ↓ which also says Images e ( m ) ↓, contradicting (3). We cannot have (1)!          □   Images

2.9.1.4 Example. A machine that ignores the input and just outputs itself! Define Images as Images = Images xy.x . By 2.9.0.26 there is an e such that Images e ( y ) = Images ( e, y ) = e , for all y .          □

The next application is about self-referential (recursive) definitions of functions F that may look arbitrarily complicated as the one below

images

where nesting of occurrences of F is allowed (unlike the case of primitive recursion).

Images For example, the Ackermann function Images nx . A n ( x ) involves some nesting of A inside A in its definition (2.4.1.2). This function’s definition is an instance of (1) as we can immediately see if we rephrase it a bit: A n ( x ) is given by

images            Images

We are interested in just those cases that the right hand side of (1), the “ f (…)” consists only of “computable operations”, meaning that the right hand side can be built by a Images -derivation modified to utilize F as an initial function. Another way to describe the shape of the right hand side of (1) is in terms of closures (cf. 1.6.0.12 ).

2.9.1.5 Definition. We say that a function is partial recursive in F iff it is in the closure of Images ∪ { F } under composition, primitive recursion, and ( μy ), where Images is the already adopted set of initial functions of Images .          □

Images 2.9.1.6 Remark. It follows from 2.9.1.5 that if F images Images , then a function that is partial recursive in F is just partial recursive—see Exercise 2.12.70 .

In particular, if we replace F throughout the right hand side of (1) by a partial recursive function Images of the same arity as F , then we end up with a partial recursive function.          □ Images

In (1) F acts as a function variable to “solve” for. A solution h for F is a specific function that makes (1) true for all Images n if we replace all occurrences of F by h .

We next show that if the right hand side of (1) is partial recursive in F , then (1) always has a partial recursive solution for F. That is,

Images

Indeed, the function Images z Images n . G ( z , Images n ) given below by substituting all F in the right hand side of (1) by Images is partial recursive by 2.9.1.6 .

images

By the recursion theorem there is an e such that

Images , for all Images n

Thus, (3) yields

images

That is, setting the function variable F equal to Images we have solved (1), and with a Images -solution at that!

Images The above technique says nothing about uniqueness of solution for F , or totalness. Such issues must be explored separately by methods other than the recursion theorem.           Images

2.9.1.7 Example. Here is a second solution to the question “is Images nx.A n ( x ) images Images ?”. A n ( x ) is given by

images

We rewrite the above using F as a function variable and setting f ( n, x ) = A n ( x ).

Thus, F is “given” by

images

(4) has the form (1) of the preceding general discussion, and all assumptions are met. Thus, for some e , F = Images works. But is this Images total? Is it the same as A n ( x )? Yes, provided (4) has a unique total solution! That (4) indeed does have a unique total solution is an easy (double) induction exercise that shows f ( n , x ) = F′ ( n , x ) for all n , x if

images

The existence (of a solution), is of course, provided by the recursion theorem. See Exercise 2.12.71.          □

2.9.1.8 Example. Here is a recursion that goes “backwards”, that is, defines a function at input n in terms of its value at input n + 1. Suppose that g is recursive and define

images

Replacing the h in the right hand side by Images , we have a partial recursive G :

images

By the recursion theorem, there is an e such that Images solves (1):

images

What is the import of this example? That we rediscover the computability of functions defined by Images . Indeed, we see that Images , for all Images k (cf. 2.7.1.2 and Exercise 2.12.72 ).          □