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
z
. f ( z ,
n )
, then for some e, we have
(
n ) ⋍ f ( e ,
n ), for all
n .
Proof . Let
. Then
by 2.6.0.38
Take e =
( a , a ). □
2.9.0.27 Corollary. (Recursion Theorem—Rogers’s version) If
x . g ( x ) is recursive. then there is an e such that
g ( e ) \=
e .
This does not say that g ( e ) = e . Rather, that the two programs g ( e ) and e compute the same function.
Proof. Let f ( x , y ) ≃
g ( x ) ( y ), for all x , y . Since f
, 2.9.0.26 applies to yield an e such that f ( e , y ) ≃
e ( y ), for all y . □
2.9.0.28 Remark. It is instructive to see Rogers’s direct proof for the corollary: Define
by
By the normal form theorem,
. Let h be obtained by S-m-n such that
( x , y ) ≃
h ( x ) ( y ), for all x, y . Let a be such that ( gh ) =
a . By (1) we now get (for all y )
e = h ( a ) works.
Note that, in (1),
x ( x ) is not a
-index unless
x ( x ) ↓, but this is irrelevant to the proof, in which we applied the S-m-n theorem to the computable function
given—in detail—by
2.9.0.29 Corollary. (Recursion Theorem with Parameters)
If
z
m
n . f ( z ,
m ,
n )
, then there is a 1-1 primitive recursive function h such that
, for all
m ,
n .
Proof . Let
and a
be such that F =
. Thus,
Just take
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
of m + 1 arguments, there is a 1-1 primitive recursive function h such that
, for all
m .
Proof.
is in
. Now apply 2.9.0.29. □
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
, then we use a new f : f =
and, correspondingly, the new h will be an S-m-n function dependent on w as well, yielding for all w ,
m ,
n ,
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
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
, then it has just proved a false statement. So
cannot be a theorem. But then it is true, as it says just that! This makes ¬
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”.
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
( 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
( x ), there is an e such that e is the Gödel number of the sentence
( e ).
He did this as follows: Let us consider the new formula
( s ( x, x )) of Gödel number, say, a . But then, the Gödel number of
( 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”. □
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 χ
=
x .1 and χ
=
x .0.
only if -part. By contradiction, suppose that A = { x :
x
} is nontrivial, yet A
* . So, let a
A and b ∉ A . Define f by
Clearly,
By the recursion theorem (e.g., 2.9.0.27 ), there is an e such that
f ( e ) \=
e .
Thus, e
A iff f ( e )
A , contradicting (1). □
2.9.1.2 Corollary. If A = { x :
x
}, then A ≰ m
and thus A ≢ m
.
Proof . Suppose
where f is recursive. If e is as above, then e
A iff
e
iff
f ( e )
iff f ( e )
A , contradicting (∗) . □
2.9.1.3 Example. K is not a complete index set, that is, there is no
⊆
such that
Suppose such a
exists. Define
By definition by positive cases,
is computable, so let by 2.9.0.26 , e be such that
( e, y ) ≃
e ( y ), for all y . It follows that
but
By (2), e
K and, by (1),
Let now m ≠ e be another among the infinitely many indices of
e , that is,
e =
m .
By (4),
m
. By (1) and the original definition of K , this entails
m ( m ) ↓ which also says
e ( m ) ↓, contradicting (3). We cannot have (1)! □
2.9.1.4 Example. A machine that ignores the input and just outputs itself! Define
as
=
xy.x . By 2.9.0.26 there is an e such that
e ( y ) =
( 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
where nesting of occurrences of F is allowed (unlike the case of primitive recursion).
For example, the Ackermann function
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
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
-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
∪ { F } under composition, primitive recursion, and ( μy ), where
is the already adopted set of initial functions of
. □
2.9.1.6 Remark. It follows from 2.9.1.5 that if F
, 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
of the same arity as F , then we end up with a partial recursive function. □
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
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,
Indeed, the function
z
n . G ( z ,
n ) given below by substituting all F in the right hand side of (1) by
is partial recursive by 2.9.1.6 .
By the recursion theorem there is an e such that
, for all
n
Thus, (3) yields
That is, setting the function variable F equal to
we have solved (1), and with a
-solution at that!
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.
2.9.1.7 Example. Here is a second solution to the question “is
nx.A n ( x )
?”. A n ( x ) is given by
We rewrite the above using F as a function variable and setting f ( n, x ) = A n ( x ).
Thus, F is “given” by
(4) has the form (1) of the preceding general discussion, and all assumptions are met. Thus, for some e , F =
works. But is this
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
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
Replacing the h in the right hand side by
, we have a partial recursive G :
By the recursion theorem, there is an e such that
solves (1):
What is the import of this example? That we rediscover the computability of functions defined by
. Indeed, we see that
, for all
k (cf. 2.7.1.2 and Exercise 2.12.72 ). □