






















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























4.6. THE PRIMITIVE RECURSIVE FUNCTIONS 309
The class of primitive recursive functions is defined in terms of base functions and closure operations.
Definition 4.6.1 Let Σ = {a 1 ,... , aN }. The base functions over Σ are the following functions:
(1) The erase function E, defined such that E(w) = , for all w ∈ Σ∗;
(2) For every j, 1 ≤ j ≤ N , the j-successor function Sj , defined such that Sj (w) = waj , for all w ∈ Σ∗;
(3) The projection functions P (^) in , defined such that
P (^) in (w 1 ,... , wn) = wi,
for every n ≥ 1, every i, 1 ≤ i ≤ n, and for all w 1 ,... , wn ∈ Σ∗.
Note that P 11 is the identity function on Σ∗. Projection functions can be used to permute the arguments of another function.
310 CHAPTER 4. RAM PROGRAMS, TURING MACHINES
A crucial closure operation is (extended) composition.
Definition 4.6.2 Let Σ = {a 1 ,... , aN }. For any function
g: Σ ︸ ∗^ × · · · ×︷︷ Σ︸∗ m
and any m functions hi: Σ ︸ ∗^ × · · · ×︷︷ Σ︸∗ n
the composition of g and the hi is the function
f : Σ ︸ ∗^ × · · · ×︷︷ Σ︸∗ n
denoted as g ◦ (h 1 ,... , hm), such that
f (w 1 ,... , wn) = g(h 1 (w 1 ,... , wn),... , hm(w 1 ,... , wn)),
for all w 1 ,... , wn ∈ Σ∗.
As an example, f = g ◦ (P 22 , P 12 ) is such that
f (w 1 , w 2 ) = g(w 2 , w 1 ).
312 CHAPTER 4. RAM PROGRAMS, TURING MACHINES
When m = 1, for some fixed w ∈ Σ∗, we have
f () = w, f (ua 1 ) = h 1 (u, f (u)),
... =... f (uaN ) = hN (u, f (u)),
for all u ∈ Σ∗.
For numerical functions (i.e., when Σ = {a 1 }), the scheme of primitive recur- sion is simpler:
f (0, x 2 ,... , xm) = g(x 2 ,... , xm), f (x + 1, x 2 ,... , xm) = h 1 (x, f (x, x 2 ,... , xm), x 2 ,... , xm),
for all x, x 2 ,... , xm ∈ N.
4.6. THE PRIMITIVE RECURSIVE FUNCTIONS 313
The successor function S is the function
S(x) = x + 1.
Addition, multiplication, exponentiation, and super-exponentiation can, be defined by primitive recursion as follows (being a bit loose, we should use some projections ...):
add(0, n) = n, add(m + 1, n) = S(add(m, n)), mult(0, n) = 0, mult(m + 1, n) = add(mult(m, n), n), rexp(0, m) = 1, rexp(m + 1, n) = mult(rexp(m, n), n), exp(m, n) = rexp ◦ (P 22 , P 12 ), supexp(0, n) = 1, supexp(m + 1, n) = exp(n, supexp(m, n)).
4.6. THE PRIMITIVE RECURSIVE FUNCTIONS 315
Definition 4.6.4 Let Σ = {a 1 ,... , aN }. The class of primitive recursive functions is the smallest class of functions (over Σ∗) which contains the base functions and is closed under composition and primitive recursion.
We leave as an exercise to show that every primitive recursive function is a total function. The class of primitive recursive functions may not seem very big, but it contains all the total functions that we would ever want to compute.
Although it is rather tedious to prove, the following theorem can be shown.
316 CHAPTER 4. RAM PROGRAMS, TURING MACHINES
Theorem 4.6.5 For an alphabet Σ = {a 1 ,... , aN }, every primitive recursive function is Turing computable.
The best way to prove the above theorem is to use the computation model of RAM programs. Indeed, it was shown in Theorem 4.4.1 that every Turing machine can simulate a RAM program.
It is also rather easy to show that the primitive recursive functions are RAM- computable.
318 CHAPTER 4. RAM PROGRAMS, TURING MACHINES
It is easily shown that if P and Q are primitive recursive predicates (over (Σ∗)n), then P ∨ Q, P ∧ Q and ¬P are also primitive recursive.
As an exercise, the reader may want to prove that the predicate (defined over N): prime(n) iff n is a prime number, is a primitive recursive predicate.
For any fixed k ≥ 1, the function: ord(k, n) = exponent of the kth prime in the prime factorization of n, is a primitive recursive function.
We can also define functions by cases.
4.6. THE PRIMITIVE RECURSIVE FUNCTIONS 319
Lemma 4.6.7 If P 1 ,... , Pn are pairwise disjoint primitive recursive pred- icates (which means that Pi ∩ Pj = ∅ for all i = j) and f 1 ,... , fn+1 are primitive recursive functions, the function g defined below is also primitive recursive:
g(x) =
f 1 (x) iff P 1 (x) ... fn(x) iff Pn(x) fn+1(x) otherwise.
(writing x for (x 1 ,... , xn).)
It is also useful to have bounded quantification and bounded minimization.
4.6. THE PRIMITIVE RECURSIVE FUNCTIONS 321
Definition 4.6.10 If P is an (n + 1)-ary predicate, then the bounded mini- mization of P , min y/x P (y, z), is the function defined such that min y/x P (y, z) is the shortest prefix of x such that P (y, z) if such a y exists, xa 1 otherwise.
The bounded maximization of P , max y/x P (y, z), is the function defined such that max y/x P (y, z) is the longest prefix of x such that P (y, z) if such a y exists, xa 1 otherwise.
Lemma 4.6.11 If P is an (n + 1)-ary primitive recursive predicate, then min y/x P (y, z) and max y/x P (y, z) are primitive recursive functions.
So far, the primitive recursive functions do not yield all the Turing-computable functions. In order to get a larger class of functions, we need the closure op- eration known as minimization.
322 CHAPTER 4. RAM PROGRAMS, TURING MACHINES
The operation of minimization (sometimes called minimalization) is defined as follows.
Definition 4.7.1 Let Σ = {a 1 ,... , aN }. For any function
g: Σ ︸ ∗^ × · · · ×︷︷ Σ︸∗ m+
where m ≥ 0, for every j, 1 ≤ j ≤ N , the function
f : Σ ︸ ∗^ × · · · ×︷︷ Σ︸∗ m
is defined by minimization over {aj }∗^ from g, if the following conditions hold for all w 1 ,... , wm ∈ Σ∗:
(1) f (w 1 ,... , wm) is defined iff there is some n ≥ 0 such that g(apj , w 1 ,... , wm) is defined for all p, 0 ≤ p ≤ n, and
g(anj , w 1 ,... , wm) = .
324 CHAPTER 4. RAM PROGRAMS, TURING MACHINES
Note: When f (w 1 ,... , wm) is defined,
f (w 1 ,... , wm) = anj ,
where n is the smallest integer such that condition (1) holds. It is very important to require that all the values g(apj , w 1 ,... , wm) be defined for all p, 0 ≤ p ≤ n, when defining f (w 1 ,... , wm). Failure to do so allows non- computable functions.
Minimization can be viewed as an abstract version of a while loop:
4.7. THE PARTIAL RECURSIVE FUNCTIONS 325
u := ; while g(u, w 1 ,... , wm) = do u := uaj ; endwhile let f (w 1 ,... , wm) = u
Remark : Kleene used the μ-notation:
f (w 1 ,... , wm) = μj u[g(u, w 1 ,... , wm) = ],
actually, its numerical form:
f (x 1 ,... , xm) = μx[g(x, x 1 ,... , xm) = 0],
4.7. THE PARTIAL RECURSIVE FUNCTIONS 327
One of the major results of computability theory is the following theorem.
Theorem 4.7.3 For an alphabet Σ = {a 1 ,... , aN }, every partial recursive function is Turing-computable. Conversely, every Turing-computable func- tion is a partial recursive function. Similarly, the class of recursive functions is equal to the class of Turing-computable functions that halt in a proper ID for every input.
To prove that every partial recursive function is indeed Turing-computable, since by Theorem 4.4.1, every Turing machine can simulate a RAM program, the simplest thing to do is to show that every partial recursive function is RAM-computable.
328 CHAPTER 4. RAM PROGRAMS, TURING MACHINES
For the converse, one can show that given a Turing machine, there is a prim- itive recursive function describing how to go from one ID to the next. Then, minimization is used to guess whether a computation halts. The proof shows that every partial recursive function needs minimization at most once. The characterization of the recursive functions in terms of TM’s follows easily.
There are recursive functions that are not primitive recursive. Such an ex- ample is given by Ackermann’s function.