Computable functions can have some quite complex definitions. For example, a loop programmable function might be given via a loop program that has depth of nesting of the loop-end pair, say, equal to 200. Now this is complex! Or a function might be given via an arbitrarily complex sequence of primitive recursions, with the restriction that the computed function is majorized by some known function, for all values of the input (for the concept of majorization see Subsection 2.4.3 ).

But does such definitional —and therefore, “static” —complexity have any bearing on the computational —dynamic—complexity of the function? We will see that it does, and we will connect definitional and computational complexities quantitatively.

Our study will be restricted to the class Images that we will subdivide into an infinite sequence of increasingly more inclusive subclasses, S i . A so-called hierarchy of classes of functions.

5.2.0.4 Definition. A sequence ( S i ) i ≥0 of subsets of Images is a primitive recursive hierarchy provided all of the following hold:

(1) S i ⊆ S i +1 , for all i ≥ 0

(2) Images = ⋃ i ≥0 S i .

The hierarchy is proper or nontrivial iff S i ≠ S i +1 , for all but finitely many i.

If f Images S i then we say that its level in the hierarchy is ≤ i . If f Images S i +1 − S i , then its level is equal to i + 1. Images

The first hierarchy that we will define is due to Axt and Heinermann [Heinermann (1961) and Axt (1965)].

5.2.0.5 Definition. (The Axt-Heinermann Hierarchy) We define the class Images n for each n ≥ 0 by recursion on n. We let Images 0 stand for the closure of {λ x . x , λ x . x + 1} under substitution ( 2.1.2.6 ).

For n ≥ 0, Images n +1 is the closure under substitution of Images n ⋃ { prim ( h , g ) : h Images Images n ⋀ g Images Images n }, where prim ( h, g ) is the function defined by primitive recursion from the basis function h and the iterator function g (cf. 2.1.1.14 ). Images

Images Thus, primitive recursion is the “expensive” operation, an application of which takes us out of a given Images n . On the other hand, as the classes are defined (the n + 1 case), it follows that any finite number of substitution operations keeps us in the same class; all Images n , that is, are closed under substitution. Images

We list a number of straightforward properties.

5.2.0.6 Proposition. ( Images n ) n ≥0 is a hierarchy, that is ,

(1) Images n ⊆ Images n +1 , for n ≥ 0,
and

(2) Images = ⋃ i ≥0 Images i .

Proof.

(1) Immediate from the definition of Images n +1 in 5.2.0.5 .

(2) This is straightforward, from 5.2.0.5 and 2.1.2.3 . The part ⊇ is rather trivial, while the ⊆ part can be done by induction on Images . Images

5.2.0.7 Proposition. λ x . A n ( x ) Images Images n , for all n ≥ 0, where λ nx . A n ( x ) is the Ackermann function of Subsection 2.4.1 .

Proof. Induction on n. For n = 0, we note that A 0 = λ x . x + 2 Images Images 0 . By 5.2.0.5 and 2.4.1.2 , if λ x . A n ( x ) Images Images n , then λ x . A n +1 ( x ) Images Images n +1 — since λ x .2 Images Images 0 by substitution, and Images 0 ⊆ Images n — and this concludes the induction. Images

5.2.0.8 Proposition. For every f Images Images n there is a k Images Images such that f ( Images ) ≤ Images , for all Images .

Proof In 2.4.3.1 we proved that the Ackermann function majorizes every primitive recursive function. The induction proof over Images demonstrated that composing finitely many functions f i —each majorized by Images using the same fixed n —produces a function that is majorized by Images . Thus, in the present context, and to settle the proposition by induction on n , we will only need to show that every initial function of Images 0 is majorized by some Images and each initial function of Images n +1 , namely,

Images

is majorized by some appropriate Images .

Well, each of x and x + 1 are less than x + 2 = A 0 ( x ) and this settles the basis. Assume the claim (I.H.) for Images n —fixed n ≥ 0—and tackle that for Images n +1 . By our plan, we need to show the initial function are majorized by some Images . For those f Images Images n [cf. (1)] this is the result of Lemmata 2.4.2.7 and 2.4.2.10 . If f = prim ( h , g ), then, by the I.H. on n , we have, for all x , z and Images ,

Images

and

Images

By 2.4.3.1 we have some r such that f ( x , Images ) ≤ Images (max( x , Images ), for all x and Images . Images

5.2.0.9 Corollary. The Axt-Heinermann hierarchy is proper .

Proof . Indeed, λ x . A n +1 Images Images n +1 − Images n , for all n ≥ 0. By 5.2.0.7 , we only need to see that λ x . A n +1 Images Images n . Indeed, otherwise, we would have, for all x , and some r , A n +1 ( x ) ≤ Images ( x ) (cf. 2.4.2.10 ). Images

We can also base the definition of classes similar to Images n on simultaneous recursion:

5.2.0.10 Definition. We define the class Images for each n ≥ 0 by recursion on n . We let Images = Images 0 .

For n ≥ 0, Images is the closure under substitution of Images ⋃ { f : f is obtained by simultaneous primitive recursion from functions in Images }. Images

The following are straightforward (see Exercises 5.3.15 , 5.3.16 ).

5.2.0.11 Proposition. For n ≥ 0, we have Images n ⊆ Images .

Images Thus, Images . Images

Thus, by 5.2.0.7 ,

5.2.0.12 Corollary. For n ≥ 0, we have λ x . A n ( x ) Images Images .

5.2.0.13 Proposition. For every f Images Images there is a k Images Images such that f ( Images ) ≤ Images (max( Images )), for all Images .

Proof . A straightforward modification of the proof of 5.2.0.8 . Images

5.2.0.14 Corollary. The ( Images ) n ≥0 hierarchy is proper .

Proof. Exactly as in the proof of 5.2.0.9 . Images

A closely related hierarchy—that is once again defined in terms of how complex a function’s definition is—is based on loop programs [Ritchie (1965)].

5.2.0.15 Definition. (A Hierarchy of Loop Programs) Cf. Section 2.2 . We denote by L 0 the class of all loop programs that do not employ the Loop-end instruction pair.

Assuming that L n has been defined, then L n +1 is the set of programs that is the closure under program concatenation of this initial set:

L n ∪ Images Loop X ; P ; end : for any variable X and P Images L n Images Images

Images Trivially, L n ⊆ L n +1 and the maximum nesting depth of the Loop-end pair increases by one as we pass from L n to L n +1 . Of course, by virtue of L n ⊆ L n +1 , not every P Images L n +1 nests the Loop-end pair as deep as n + 1. Thus, R Images L n iff the depth of nesting of the Loop-end instruction pair is at most n . Nesting depth equal to 0 means the absence of a Loop-end instruction pair. Images

The following is immediate.

5.2.0.16 Proposition. Cf. 2.2.0.8. ( L n ) n ≥ 0 is a proper L-hierarchy. That is ,

(1) L n ⊂ L n +1 , for n ≥ 0
and

(2) L = Images n ≥0 L n

We are more interested in the induced (by the L n sets) hierarchy of primitive recursive classes:

5.2.0.17 Definition. Cf. 2.2.1.2 . We denote by Images n , for n ≥ 0, the class

{ Images : P Images L n ∧ the Images r and x k occur in P } Images

5.2.0.18 Proposition. For n ≥ 0, we have that Images = Images n .

Proof. In outline, the instruction pair Loop-end implements one simultaneous recursion. On the other hand, by the definition of Images , this class contains functions obtained from those of Images = Images 0 by n nested simultaneous recursions (and possibly some substitutions).

In detail, one can do induction on n and imitate the proofs of 2.2.1.4 and 2.2.1.3 . See Exercise 5.3.17 . Images

Thus, everything we said about the ( Images ) n ≥0 hierarchy carries over to the ( Images n ) n ≥0 hierarchy—after all, it is the same hierarchy under two different definitions. In particular, by 5.2.0.14 ,

5.2.0.19 Proposition. The Images - ( or Images -) hierarchy , ( Images n ) n ≥0 , is proper .

Images 5.2.0.20 Example. Here are some functions and predicates in the “lower” (small n ) classes of the ( Images ) n ≥0 hierarchy.

The following are in Images 1 and hence in Images = Images 1 .

(1) λ xy . x + y . Indeed,

0 + y = y       
( x + 1) + y = ( x + y ) + 1

and λ y . y and λ z . z + 1 are in Images 0 = Images .

(2) λ xy . x (1 ∸ y ). Indeed,

            x (1 ∸ 0) = x
x (1 ∸ ( y + 1)) = 0

and λ y . y and λ z .0 are in Images 0 = Images .

(3) λ x .1 ∸ x . By substitution operations from the previous function.

(4) λ x . x ∸ 1. Indeed,

        0 ∸ 1 = 0
( x + 1) ∸ 1 = x

and λ y . y and λ z .0 are in Images 0 = Images .

(5) λ x .⌊ x /2⌋ Images Images . Indeed, see 2.1.3.3 .

This example shows that Images 1 ≠ Images , since λ x . ⌊ x /2⌋ Images Images 1 as follows from results of Ritchie (1965) and Tsichritzis (1970) that were retold in Tourlakis (1984).

(6) switch = λ xyz .if x = 0 then y else z . Indeed, we have the recursion

       switch (0, y , z ) = y
switch ( x + 1, y , z ) = z

where λ y . y is in Images 0 = Images .

The following are in Images 2 and hence in Images = Images 2 .

(a) λ xy . x ∸ y . Indeed,

x ∸ 0 = x        
x ∸ ( y + 1) = ( x ∸ y ) ∸ 1

and λ y . y and λ z . z ∸ 1 are in Images 1 ⊆ Images .

(b) λ xy . xy . Indeed,

x 0 = 0
x ( y + 1) = xy + x

and λ y .0 and λ wz . w + z are in Images 1 ⊆ Images .

(c) λ x .2 x . Indeed,

2 0 = 1    
2 y +1 \= 2 y + 2 y

and λ y .1 and λ wz . w + z are in Images 1 ⊆ Images . Images

5.2.0.21 Definition. As is usual, the predicate classes Images n ,* and Images —the latter being the same as Images n ,* —are defined for all n ≥ 0 as { f ( Images ) = 0 : f Images Images n } and { f ( Images ) = 0 : f Images Images }, respectively. Images

5.2.0.22 Proposition. For n ≥ 1, we have that Images n ,* and Images are closed under ¬ and ν— and hence under ∧, →, and ≡ as well .

Proof Let Q ( Images ) Images Images n ,* . Then, for some q Images Images n , Q ( Images ) ≡ q ( Images ) = 0. Since r = λ Images .1 ∸ q ( Images ) Images Images n if n ≥ 1 by 5.2.0.20 , we are done, noting ¬ Q ( Images ) ≡ r ( Images ) = 0. Next, let also S ( Images ) ≡ s ( Images ) = 0 with s Images Images n . Then Q ( Images ) ∨ S ( Images ) ≡ switch ( q ( Images ), 0, r ( Images ) = 0; but switch Images Images n , for n ≥ 1 (cf. 5.2.0.20 ).

The cases for Images are argued identically with the preceding two. Images

5.2.0.23 Corollary. The relations λ x . x ≤ a , λ x . x < a and λ x . x = a are in Images 1,* . and hence in Images .

Proof. By 5.2.0.20(4) and substitution, we have that λ x . x ∸ a Images Images 1 . But x ≤ a ≡ x ∸ a = 0. On the other hand, x < a ≡ x + 1 ∸ a = 0. Thus the claim about λ x . x < a is true. Noting that λ x . a ≤ x is in Images 1,* due to

a ≤ x ≡ ¬ x < a

and 5.2.0.22 , we have that λ x . x = a is in Images 1,* by 5.2.0.22 and the observation x = a ≡ x ≤ a ∧ a ≤ x . Images

5.2.0.24 Proposition. For n ≥ 1, we have that Images n and Images are closed under definition by cases .

Proof. This is immediate from either of the suggested proofs for 2.1.2.37 , noting 5.2.0.20 , (1), (2) and (6). Images

The three hierarchies that we introduced include increasingly complex classes, using as a yardstick of complexity the nesting depth of primitive recursion. The next hierarchy, due to Grzegorczyk (1953), gauges complexity of definition by the (numerical) size of the function it produces—and, correspondingly, the class complexity at level n by the size of the functions it contains. As the definition does not necessarily force a function such as prim ( h , g ) to exit from a given level, the Grzegorczyk hierarchy is much more amenable to mathematical analysis.

5.2.0.25 Definition. (The Grzegorczyk Hierarchy) We are given a fixed sequence of functions, ( g n ) n ≥0 by

g 0 = λ x . x + 1
   g 1 = λ xy . x + y
g 2 = λ xy . xy   

and, for n ≥ 2,

g n +1 \= λ x . A n (max( x , y ))

where λ ny . A n ( x ) is the Ackermann function of Subsection 2.4.1 .

The hierarchy ( ε n ) n ≥0 is defined as follows: ε n is the closure of

{λ x . x + 1, λ x . x , g n }

under substitution and bounded primitive recursion, the latter being the schema below

Images

where h, q and B are given functions. Images

Images A class Images is closed under bounded primitive recursion iff whenever h , q , and B are in Images , then so is the f produced as above.

We note that the bounded recursion is not on notation. Rather, it is an ordinary number-theoretic primitive recursion along with a condition that the function f has actually been “produced” only if its values are bounded everywhere by those of the given B .

The g n -function included among the initial functions at each level, which gauges the (numerical) size of functions included in each ε n is (a version of) the Ackermann function. Grzegorczyk used a different version than we do here. Our choice to use the function of Subsection 2.4.1 was partly dictated by ease-of-use considerations, but mostly because we know quite a bit about the A n already. The reader may consult Tourlakis (1984) to read a proof that the version we use here produces the same ε n classes as in Grzegorczyk (1953). Images

The class of relations at level n of the Grzegorczyk hierarchy is defined as usual.

5.2.0.26 Definition. Images for n ≥ 0, denotes the class of relations { f ( Images ) = 0: f Images ε n }. Images

Images 5.2.0.27 Example. Here are some examples of functions and relations in ε 0 and Images :

(1) λ xy . x (1 ∸ y ).

Images

(2) λ x .1 ∸ x . By (1) and substitution.

(3) λ x . x ∸ 1.

Images

(4) λ xy . x ∸ y .

Images

(5) λ xy . x ≤ y and λ xy . x < y are in Images . Indeed, x ≤ y ≡ x ∸ y = 0 and x < y ≡ ( x + 1) ∸ y = 0   Images

5.2.0.28 Lemma. For all n ≥ 0, ε 0 ⊆ ε n .

Proof . ε n contains the initial functions of ε 0 and is closed under the same operations.   Images

5.2.0.29 Theorem. For n ≥ 0, Images is closed under Boolean operations and also under bounded quantification, namely , (∃ y ) < z , (∃ y ) ≤ z , (∀ y ) < z , (∀ y ) ≤ z .

Proof. We implicitly use 5.2.0.28 . For Boolean operations it suffices to consider ¬ and ∨ only. So, let R ( Images ) ≡ r ( Images ) = 0 and Q ( Images ) ≡ q ( Images ) = 0, where r and q are in ε n . Now, ¬ R ( Images ) ≡ 1 ∸ r ( Images ) = 0 and we are done by 5.2.0.27(2) . On the other hand, R ( Images ) ∨ Q ( Images ) ≡ r ( Images ) (1 ∸ (1 ∸ q ( Images ))) = 0 and we are done by 5.2.0.27(1) .

For closure under bounded quantification, let P ( y , Images ) ≡ P ( y , Images ) = 0, where p Images ε n . Let χ ∃ be the characteristic function (cf. 2.1.2.15 ) of (∃ y ) < z P ( y , Images ). Noting that

(∃ y ) <0 P ( y , Images ) is false, and (∃ y ) < z +1 P ( y , Images ) ≡ P ( z , Images ) ∨ (∃ y ) < z P ( y , Images )

we have that χ ∃ satisfies the bounded recursion below:

Images

and we are done. The “1” in the inequality above is the output of λ x .1 which is in ε 0 . Clearly χ ∃ belongs where p does, and (∃ y ) < z P ( y , Images ) ≡ χ ∃ ( z , Images ) = 0.

To conclude the proof for the remaining cases of quantification, note that (∃ y ) ≤ z R ≡ R ∨(∃ y ) < z R ; moreover, the universal quantifier cases follow from the closure of Images under negation. Images

Images Note that if a class Images contains λ x .1 ∸ x and is closed under substitution, then 2.1.2.16 applies to its class of predicates Images * . Images

The following result is, modulo choice of Ackermann function, from Grzegorczyk (1953).

5.2.0.30 Lemma. (Bounding Lemma) (1) For each f Images ε 0 , there are i and k such that f ( Images ) ≤ x i + k everywhere .

(2) For each f Images ε 1 , there are C and k such that f ( Images ) ≤ C max( Images ) + k everywhere .

(3) For each f Images ε 2 , there are C, n, and k such that f ( Images ) ≤ C max( Images ) n + k everywhere .

(4) For each f Images ε n +1 , n ≥ 2, there is a k such that f ( Images ) ≤ Images (max( Images )) everywhere .

Proof .

All proofs are by induction over the appropriate ε n .

(1) The claim trivially holds for the initial functions and propagates with bounded recursion since the I.H. applies to whichever bounding function B was employed.
Let then f be obtained by substitution,

Images

The I.H. applies to g . Now, if g ( Images ) ≤ x j + k everywhere, for j ≠ i , then also

f ( x 1 ,..., x i −1 , ..., x n , Images ) ≤ x j + k , everywhere.

If, on the other hand, j = i , then f ( x 1 , . . . , x i −1 , x i +1 , . . . , x n , Images ) ≤ h ( Images ) + k , everywhere. By the I.H. on h , f ( x 1 , . . . , x i −1 , x i +1 , . . . , x n , Images ) ≤ y m + k + k ′, everywhere, for some m and k ′.

The other cases of substitution are as easy.

(2) The basis and the propagation of the claim with bounded recursion are as above [note, incidentally, that x + y ≤ 2 max( x , y )]. Let us now look at a substitution h ( Images , g ( Images ), Images ). We have, by the I.H. applied to h ,

Images

(3) Left as an exercise (see Exercise 5.3.20 ).

(4) The claim is true for the initial functions and propagates with bounded recursion for the reason named earlier. As for substitution, we know that the subscript n will not change (cf. 2.4.3.1 ) and thus if Images majorize the component-functions of the substitution, then Images majorizes the result. Images

We can now prove that ε n ⊂ ε n +1 for all n .

5.2.0.31 Theorem. ( ε n ) n ≥0 is a proper primitive recursive hierarchy .

Proof. First, ε n ⊆ ε n +1 , for all n , since every bounded recursion in ε n can use as bounding functions the bounds x i + k , C max( Images ) + k, and C max( Images ) n + k if n = 0, 1, 2, respectively—cf. (1)–(3) in 5.2.0.30 —or Images if n ≥ 3.

Images I am implying an induction over ε n in the above remark. But is A n −1 Images ε n +1 ? Yes, if we assume that A n −2 is. See Exercise 5.3.21 . Images

Reverting to the unified notation “ g n ” and noting that g n +1 Images ε n +1 − ε n by 5.2.0.30 , we promote ⊆ above to ⊂:

ε n ⊂ ε n +1 , for all n .

Now, trivially, ε n ⊂ Images , for all n . On the other hand, by 2.4.3.1 , every primitive recursion is a bounded recursion with bounding function Images for some k , so Images ⊆ Images n ≥0 ε n as well.

Images 5.2.0.32 Exercise. In view of 5.2.0.30 , prove that switch (the “full” if-then-else) and max are not in ε 0 . Images

We defined bounded summation and multiplication in 2.1.2.30 and saw that, as operations, they do not take us out of Images . More interesting is this:

5.2.0.33 Proposition. For n ≥ 2, ε n is closed under bounded summation .

Proof. By reference to 2.1.2.30 , we only need a bounding function for Σ i < z f ( i , Images ) in ε n .

For n = 2, f ( i , Images ) = O (max( i , Images ) r ), for some r , due to 5.2.0.30 . But then,

Images

Since, for any constants C and D , λ z Images . C z max( z , Images ) r + D is in ε 2 , our bounding function is obtained by choosing the right C and D .

For n > 2, let, by 5.2.0.30 , r be such that f ( i , Images ) ≤ Images (max( i , Images )), for all i , Images .

Then

Images

But λ xy . xy and Images (max(z, Images )) are in ε n for n > 2. We have obtained the required bounding function in (1).

5.2.0.34 Proposition. For n ≥ 3, Images n is closed under bounded multiplication .

Proof . We proceed as in the proof of 5.2.0.33 above.

Let, by 5.2.0.30 , r be such that f ( i , Images ) ≤ Images (max( i , Images )), for all i , Images . Then

Images

But λ xy.x y and λ z Images . Images (max( z , Images )) are in Images n , for n ≥ 3. We obtained the required bounding function in (2). Images

A definition of bounded search that is used in Grzegorczyk (1953) [cf. also Péter (1967)] is the following:

5.2.0.35 Definition. (Alternative Bounded Search) For any total number-theoretic function λ y Images . f ( y , Images ) we define

Images

( Images y ) ≤ z f ( y , Images ) means ( Images y ) < z +1 f ( y , Images ), and ( Images y ) < z R ( y , Images ) means ( Images y ) < z χ R ( y , Images ), where χ R is the characteristic function of R . Images

5.2.0.36 Theorem. For n ≥ 0, Images n is closed under ( Images y ) < z .

Proof . Let f Images Images n . We set g ( z , Images ) = ( Images y ) < z f ( y , Images ). Notice that

Images

The above bounded recursion works for n ≥ 1, but will not work for n = 0 due to 5.2.0.32 ; some acrobatics will be necessary:

We note that the right hand side of the second equation is obtained by substituting g ( z , Images ) into w and χ( z , Images )—the value at Images z , Images Images of the characteristic function of (∀ y ) < z f ( y , Images ) ≠ 0 ∧ f ( z , Images ) = 0—into x in

if x = 0 then z else w

Noting that g ( z , Images ) ≤ z , we can replace the troublesome full if-then-else by the expression sw ( x , z , w ) given by

if x = 0 then z     
else if w ≤ z then w else 0

Note that sw Images Images 0 because of the bounded recursion below.

Images

Moreover, note that g ( z + 1, Images ) = sw (χ ( z , Images ), z , g ( z , Images )). Images

The absence of the full switch from Images 0 qualifies the result about closure under definition by cases:

5.2.0.37 Corollary. For n ≥ 1, Images n is closed under definition by cases 2.1.2.37 .

Images 0 is closed under definition by cases provided the produced function f satisfies f ( Images ) ≤ x i + k everywhere, for some i and k.

Proof . For n ≥ 1 the proof of 2.1.2.37 works. For Images 0 , if f is given as in 2.1.2.37 , where the f i are in Images 0 and the R i in Images , then

Images

where we wrote R n +1 for the “otherwise” relation. The reader should carefully identify all the results that we proved so far about the Grzegorczyk classes that make (1) work. Images

5.2.0.38 Theorem. Images 2 is closed under simultaneous bounded recursion, that is, under the schema of Subsection 2.1.3 , where, additionally, k bounding functions B i for i \= 1,…, k, are given, and the functions f i resulting from the schema must satisfy f i ( x , Images ) ≤ B i ( x , Images ) everywhere.

Proof . Consider the schema below, where the h i , g i and B i are in Images 2 .

Images

The pairing function J = λ xy .( x + y ) 2 + x (cf. 2.1.4.8 ) is in Images 2 , and so are its projections K = λ z .( Images x ) ≤ z (∃ y ) ≤ z J ( x , y ) = z and L = λ z . ( Images y ) ≤ z (∃ x ) ≤ z J ( x , y ) = z .

Thus, we have the coding-decoding scheme—λ Images k . Images z 1 ,…, z k Images ( k ) and Images —of 2.1.4.9 in Images 2 .

The proof of 2.1.3.1 —that shows how to simulate a simultaneous recursion by a single recursion—goes through unchanged if we replace the used there prime power coding/decoding by the alternative Images … Images / Images adopted here. Noting that

Images

and that the right hand side of the above ≤ is in Images 2 (as a function of x , Images n ) by substitution, we obtain that

Images

and therefore, for i = 1,…, k , f i \= λ x Images n . Images ( Images f 1 ( x , Images n ),…, f k ( x , Images n ) Images ( k ) ) is in Images 2 . Images

5.2.0.39 Corollary. Images n , for n ≥ 2, is closed under simultaneous bounded recursion .

Images We have introduced four primitive recursive hierarchies—of Axt-Hienermann, Dennis Ritchie, and Grzegorczyk—the yardstick of “complexity” of a class at each level n being that of its definition , whether the measure was numerical size of produced functions (Grzegorczyk) or nesting depth of primitive recursion (in all the others).

We conclude this subsection by showing that this definitional complexity tracks very accurately the computational complexity of the primitive recursive functions. The URM formalism will be the computing model to which the computational complexity will related . Images

The “main lemma” toward connecting the four hierarchies to each other on one hand, and with the computational complexity of their functions on the other, will be the Ritchie 154 - Cobham property of the Grzegorczyk classes, that

for n ≥ 0, f Images Images n iff f is computable by some URM within time t Images Images n     ( RC )

We will need a simulation tool , namely, we will show that the computation of a URM can be simulated by a very simple simultaneous primitive recursion. The reader is referred to 2.3.0.5 , which defines the computation-related concepts that we need.

Images Important! Unlike our practice in Section 5.1 , where run time was expressed as a function of input length , in the present section we will gauge run time as function of input (numerical) value. Images

Thus, for the record:

5.2.0.40 Definition. Consider the function f = Images , where M is a URM—whether M is normalized or not is immaterial for the purpose of this definition. A function λ Images n . t ( Images n ) majorizes the run time complexity of Images iff, for all Images n , if f ( Images n ) ↓ with an M -computation of length l , then l ≤ t ( Images n ); else if f ( Images n ) ↑, then also t ( Images n ) ↑.

We say that λ Images n . f ( Images n ) is computable within time λ Images n . t ( Images n ). Images

5.2.0.41 Simulation lemma. Let M be a normalized URM ( 2.3.0.4 ) with variables V 1 , V 2 , … V n +1 , V n +2 , …, V m , of which V 1 is the output variable and the V i , for i =2,…, n + 1, are input variables. With reference to 2.3.0.5 we define m + 1 simulating functions— for all y , Images n — as follows:

v i ( y , Images n ) = the value of variable V i in the y-th ID of a (possibly non terminating) computation with input Images n

I ( y , Images n ) = instruction number in the y-th ID of a (possibly non terminating) computation with input Images n

All the simulating functions are in Images .

Images In view of (v) in 2.3.0.5 , all the simulating functions are total, since once the instruction stop is reached the computation continues forever “trivially”, that is, without changing either the V i or the instruction number. Images

Proof . We have the following simultaneous recursion that defines the simulating functions:

v 1 (0, Images n ) = 0
v i (0, Images n )  = a i −1 , for i = 2,…, n + 1
v i (0, Images n )  = 0, for i = n + 2,…, m
I (0, Images n )   = 1

For y ≥ 0 and i = 1,…, m , we have

Images

Since the iterator functions only utilize the functions λ x . a , λ x.x + 1, λ x.x ∸ 1, λ x . x , and predicates λ x . x = a , and λ x . x > a —all in Images and Images —it follows that all the simulating functions are in Images , as claimed. Images

5.2.0.42 Example. Let M be the program below

1 : V 1 ← V 1 + 1
2 : V 2 ← V 2 ∸ 1
3 : if V 2 = 0 goto 4 else goto 1
4 : stop

Let us assume that V 2 is the input variable and V 1 is the output variable. The simulating equations take the concrete form below, where a denotes the input value:

v 1 (0, a ) = 0
v 2 (0, a ) = a

For y ≥ 0 we have

Images Images

5.2.0.43 Corollary. The simulating functions are in Images 4 .

Proof . The above mentioned predicates and functions that are part of the iterator are in Images 1 and Images 1,∗ . Moreover, K 1 is closed under definition by cases ( 5.2.0.24 ). To convert the simultaneous recursion to a single recursion and back, we need pairing functions and their projections.

The quadratic pairing function J = λ xy .( x + y ) 2 + x is appropriate. Immediately, J Images Images 2 by 5.2.0.20 . Now, let us place its projections, K and L , in the Axt hierarchy. We know that ( 2.1.4.8 ) Kz = z ∸ Images 2 and Lz = Images ∸ Kz . By the results of 5.2.0.20 we need only locate λ z . Images in the hierarchy.

We start by noting that if z + 1 is a perfect square, that is, z + 1 = ( k + 1) 2 for some k , then z + 1 = k 2 + 2 k + 1 hence z = k 2 + 2 k , thus

k 2 ≤ z < ( k + 1) 2

hence k = Images . This yields

Images

Suppose next that z + 1 is not a perfect square. That is,

Images

for some m , and hence m 2 ≤ z < m 2 + 2 m < ( m + 1) 2 . This entails m ≤ Images < m + 1, thus m = Images . But m = Images as well, by (2).

At the end of all this we obtain the following recursion:

Images

By reference to 5.2.0.20 —and noting that x = y ≡ ( x ∸ y ) + ( y ∸ x ) = 0, thus λ xy . x = y Images Images 2,∗ —we see that λ z . Images Images Images 3 , and thus so are K and L . But then, the coding/decoding scheme that is based on this J , K , L ( 2.1.4.9 ) is in Images 3 . Referring to 2.1.3.1 , we see that, due to the presence of the Images in the iterator part, the single recursion that simulates the simultaneous recursion of the simulation lemma yields the function

Images

in Images 4 . This guarantees that

Images

are in Images 4 , for i = 1,…, m + 1. Images

5.2.0.44 Corollary. The simulating functions are in Images 2 .

Proof . Given that the iterators in the simultaneous recursion employed in 5.2.0.41 are trivially in Images 2 , we only need to provide Images 2 -bounds for all the produced functions ( 5.2.0.38 ). Well, I ( y , Images n ) ≤ k , where k is the label of the stop instruction of M . On the other hand, since all we do with the iterators can at most add 1 in each step, we also have the bounds v ( y , Images n ) ≤ max Images n + y + C , a bound which is in Images 2 as a function of y and Images n , seeing that max( x , y ) = x ∸ y + y . The “ + C ” accounts for all the constants that may be assigned to a variable during the computation (instructions of type V i ← a ). Images

We can now prove (the nontrivial) half of the Ritchie-Cobham property:

5.2.0.45 Lemma. If f = Images runs on M within time t Images Images n , for some n ≥ 2, then f Images Images n .

Proof . Let the simulating functions of M be as in 5.2.0.41 , where z is “ V 1 ”, the output variable. Then, for all Images n , we have f ( Images n ) = v 1 ( t ( Images n ), Images n ), and this settles the claim by 5.2.0.44 . Images

The “easy” half of the Ritchie-Cobham property is proved by doing a bit of programming.

5.2.0.46 Lemma. For n ≥ 2, any λ Images . f ( Images ) Images Images n is URM-computable within time λ Images . t ( Images ) Images Images n .

Proof . Induction over Images n .

We settle the case of the initial functions first (cf. 5.2.0.25 ). λ x . x is computable, as Images , within O ( x ) steps by the normalized URM M below

1 : V 1 ← V 1 + 1
2 : V 2 ← V 2 ∸ 1
3 : if V 2 = 0 goto 4 else goto 1
4 : stop

while λ x . x + 1 is computable, as Images , also within O ( x ) steps by the normalized URM N below:

1 : V 1 ← V 1 + 1
2 : V 2 ← V 2 ∸ 1
3 : if V 2 = 0 goto 4 else goto 1
4 : V 1 ← V 1 + 1
5 : stop

Images The non normalized URM P below

1 : V 1 ← V 1 + 1
2 : stop

computes λ x . x + 1 as Images in O (1) steps. Images

λ xy . xy is computable by the following loop-program, R , within time O ( xy ), as Images :

Loop X
     Loop Y
         Z ← Z + 1
     end
end

A straightforward URM simulation of the above is

1 : goto 7
2 : goto 5
3 :      Z ← Z + 1
4:       Y ← Y ∸ 1
5 : if Y = 0 goto 6 else goto 3
6:       X ← X ∸ 1
7 : if X = 0 goto 8 else goto 2
8 : stop

This still runs within O ( xy ) time. With the case of n = 2 done, we now turn to the initial functions of Images n +1 for n ≥ 2.

The only new case is A n . We show that it is computable by some URM M within time Images , for some k .

We know that A n Images Images n . So let A n = Images , where the program P Images L n terminates within O ( Images ( x )) steps (cf. Exercise 5.3.22 ).

But how about computing Images on a URM? We can efficiently translate any loop program into a URM program!

To this end, note that loop program instructions, other than those of type X ← Y and the Loop-end pair, occur also in URM programs and thus can be the translated as themselves. On the other hand, X ← Y can be simulated by a URM (cf. 2.1.1.10 ).

Recursively, assume that we know how to translate R into a URM Images and consider Q :

Images

This is simulated by the URM

               B ← X       {A new B is associated with each instruction “Loop X ” 155 }
               goto L       { L labels the “end” that matches the simulated “ Loop X ”}
M :
               Images
               B ← B ∸ 1
L :          if B = 0         goto L + 1 else goto M
L + 1 :

Let next the run time of a loop program be O ( t ). If an instruction of type “ B ← X ” were to take 1 step in a URM, then the above described simulating URM would also run within time O ( t ). But this is not a primitive instruction of a URM! It takes time O ( X ) to perform it (cf. 2.1.1.10 ).

For the P above in particular, and since t = O ( Images ( x )), it follows that for any variable X of P , we have O ( X ) = O ( Images ( x )), 156 and thus the URM runs within time O Images = O ( Images ( x )) due to x 2 = O ( A 2 ( x )) = O ( A n ( x )).

We have concluded the basis case for all n ≥ 2. To conclude the induction over Images n ( n ≥ 2) we show that the property propagates with substitution and bounded recursion.

Let then f and g from Images n , n ≥ 2, be URM-computable (by programs M f and M g ) with run times bounded by t f and t g —both in Images n . Consider

Images

We can (essentially) concatenate M g and M f in that order (cf. 2.1.1.11 ) to compute (*). The run time of this program is bounded by λ Images Images . t g ( Images ) + t f ( Images , g ( Images )), which is in Images n , just as λ Images Images . f ( Images , g ( Images )) is. The other cases of substitution are trivial and are omitted.

Finally, let λ x Images . f ( x , Images ) be obtained by a bounded recursion from basis h , iterator g and bound B , all in Images n , and all programmable in respective URMs within time bounds t h , t g and t B , all in Images n . A URM program for f , in “pseudo code”, is

      z ← h ( Images )
      i ← 0
R : if x = 0 goto L else goto L ′
      z ← g ( i , Images , z )
      i ← i + 1
      x ← x ∸ 1
      goto R
L : stop

Its run time is

Images

Since t h , t g and f are all in Images n , then so is the function given by expression (1), due to 5.2.0.33 . Images

Images The simulation of a loop program by a URM given on p. 367 represents the generalpurpose, “faithful” simulation that, in particular, is true to the fact that the number of iterations of a loop, Loop X , depend only on the value of X upon entry in the loop . That is the purpose of the new variable B .

The simulation on p. 366 is expedient but acceptable since neither X nor Y are present inside the “scope” of either loop. Images

By virtue of Lemmata 5.2.0.45 and 5.2.0.46 we have now proved:

5.2.0.47 Theorem. (The Ritchie-Cobham Property of Images n ) For n ≥ 2, a function f is in Images n iff it can be computed on some URM within time t f Images Images n .

Images n +1 —as it is measured by the amount of time it takes to compute it, namely, Images —is exactly predicted by the definitional complexity of the function: its level in the hierarchy. And conversely! The run time predicts the definitional complexity. Very accurately . Images

We can now compare all the hierarchies that we introduced:

5.2.0.48 Corollary. For n ≥ 2, we have Images = Images n +1 .

Proof . The ⊇ is immediate by 5.2.0.47 : Let f Images Images n +1 and let it run on some M within time t f Images Images n +1 . Now t f ( Images ) ≤ Images (max Images ), everywhere, by 5.2.0.30 . If v 1 is, as before ( 5.2.0.41 ), the simulating function for the output variable of M , then

f = λ Images . v 1 ( Images (max Images ), Images )

But Images Images Images ( 5.2.0.12 ), thus, f Images Images .

For the ⊆ we do induction on n ≥ 2. For n = 2 note that, trivially, Images ⊆ Images 3 . Now—by varying r — we can make Images majorize every function of Images ( 5.2.0.13 ), thus every simultaneous recursion that produces functions in Images (from functions in Images ) is a bounded recursion within Images 3 ( A 1 = λ x.2x + 2 Images Images 3 ). Therefore, Images ⊆ Images 3 . Repeating this argument we have that

every simultaneous recursion that produces functions in Images (from functions in Images ) a bounded recursion within Images 3 ( since A 2 Images Images 3 ).

thus, Images ⊆ Images 3 .

Taking as an I.H. the validity of the claim for some fixed n ≥ 2, the case for n + 1 is repeating the idea we employed in the basis: recursions taking us from Images to Images are bounded recursions performed within Images n +2 (⊇ Images n +1 ⊇, by I.H., Images ), with bounding function some Images —since Images Images Images ∩ Images n +2 .

By 5.2.0.18 we have at once

5.2.0.49 Corollary. For n ≥ 2, we have Images n = Images n +1 .

5.2.0.50 Corollary. For n ≥ 4, we have Images n = Images n +l .

Proof . The proof follows very closely that of 5.2.0.48 . The ⊆ goes through unchanged, but the ⊇ “starts” later, n ≥ 4, due to the fact that the simulating function v 1 is in cf. 5.2.0.43 .

Images Schwichtenberg has improved 5.2.0.50 by proving the case for n = 3 [H. Schwichtenberg (1969)]. This is retold in Tourlakis (1984). H. Müller (1973) gives a proof for the case n = 2. Images

Images 5.2.0.51 Remark. (A Very Hard Problem—Revisited) Corollary 5.2.0.49 adversely impacts a problem of practical significance: That of program correctness . The problem “program correctness” is an instance of the equivalence problem of programs, since it tasks us to determine whether a program follows faithfully a specification , the latter being, of course, given by a finite description , just as the program is.

We strengthen here the observation we made in 2.5.0.22 about the equivalence problem of primitive recursive functions, that is, the equivalence problem of loop programs:

Given loop programs P and Q, is it the case that Images = Images ?

We saw that the equivalence problem for Images is unsolvable—indeed, worse: not even c.e.—as a consequence of the fact λ x .1 and λ y .χ T ( x , x , y ) are in Images .

As these functions are also in Images 3 —a fact that can be readily verified by looking at the proof of the normal form theorem (Corollary 2.3.0.8 )—it follows that the equivalence problem for Images 3 functions is not c.e. either. By virtue of 5.2.0.49 , this yields the rather disappointing alternative formulation:

The equivalence problem for programs in L 2 — i.e., those that have loop depth equal to two—is not c.e.

Thus the various techniques employed to tackle loop correctness can be successful in all instances of the problem only when we have un-nested loops— L 1 -programs. This holds true even though the loops are “FOTRAN-like”, that is, they always terminate and the number of iterations of any such loop is known at the time the loop is entered. It should be noted that Tsichritzis (cf. Tsichritzis (1970) and Tourlakis (1984)) has shown that programs in L 1 have a solvable equivalence problem, but, on the other hand, the corresponding set of functions, Images 1 is rather trivial: it is the closure under substitution of {λ xy.x + y , λ x.x ∸ 1, λ xyz . if x = 0 then y else z , λ x , Images , λ x.rem ( x , k )}. That is, all “looping” can be eliminated if we adopt this enlarged set of initial functions. Images