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
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
is a primitive recursive hierarchy provided all of the following hold:
(1) S i ⊆ S i +1 , for all i ≥ 0
(2)
= ⋃ i ≥0 S i .
The hierarchy is proper or nontrivial iff S i ≠ S i +1 , for all but finitely many i.
If f
S i then we say that its level in the hierarchy is ≤ i . If f
S i +1 − S i , then its level is equal to i + 1.
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
n for each n ≥ 0 by recursion on n. We let
0 stand for the closure of {λ x . x , λ x . x + 1} under substitution ( 2.1.2.6 ).
For n ≥ 0,
n +1 is the closure under substitution of
n ⋃ { prim ( h , g ) : h
n ⋀ g
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 ).
Thus, primitive recursion is the “expensive” operation, an application of which takes us out of a given
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
n , that is, are closed under substitution.
We list a number of straightforward properties.
5.2.0.6 Proposition. (
n ) n ≥0 is a hierarchy, that is ,
(1)
n ⊆
n +1 , for n ≥ 0,
and
(2)
= ⋃ i ≥0
i .
Proof.
(1) Immediate from the definition of
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
.
5.2.0.7 Proposition. λ x . A n ( x )
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
0 . By 5.2.0.5 and 2.4.1.2 , if λ x . A n ( x )
n , then λ x . A n +1 ( x )
n +1 — since λ x .2
0 by substitution, and
0 ⊆
n — and this concludes the induction.
5.2.0.8 Proposition. For every f
n there is a k
such that f (
) ≤
, for all
.
Proof In 2.4.3.1 we proved that the Ackermann function majorizes every primitive recursive function. The induction proof over
demonstrated that composing finitely many functions f i —each majorized by
using the same fixed n —produces a function that is majorized by
. 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
0 is majorized by some
and each initial function of
n +1 , namely,
is majorized by some appropriate
.
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
n —fixed n ≥ 0—and tackle that for
n +1 . By our plan, we need to show the initial function are majorized by some
. For those f
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
,
and
By 2.4.3.1 we have some r such that f ( x ,
) ≤
(max( x ,
), for all x and
.
5.2.0.9 Corollary. The Axt-Heinermann hierarchy is proper .
Proof . Indeed, λ x . A n +1
n +1 −
n , for all n ≥ 0. By 5.2.0.7 , we only need to see that λ x . A n +1
n . Indeed, otherwise, we would have, for all x , and some r , A n +1 ( x ) ≤
( x ) (cf. 2.4.2.10 ).
We can also base the definition of classes similar to
n on simultaneous recursion:
5.2.0.10 Definition. We define the class
for each n ≥ 0 by recursion on n . We let
=
0 .
For n ≥ 0,
is the closure under substitution of
⋃ { f : f is obtained by simultaneous primitive recursion from functions in
}.
The following are straightforward (see Exercises 5.3.15 , 5.3.16 ).
5.2.0.11 Proposition. For n ≥ 0, we have
n ⊆
.
Thus,
.
Thus, by 5.2.0.7 ,
5.2.0.12 Corollary. For n ≥ 0, we have λ x . A n ( x )
.
5.2.0.13 Proposition. For every f
there is a k
such that f (
) ≤
(max(
)), for all
.
Proof . A straightforward modification of the proof of 5.2.0.8 .
5.2.0.14 Corollary. The (
) n ≥0 hierarchy is proper .
Proof. Exactly as in the proof of 5.2.0.9 .
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 ∪
Loop X ; P ; end : for any variable X and P
L n
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
L n +1 nests the Loop-end pair as deep as n + 1. Thus, R
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.
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 =
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
n , for n ≥ 0, the class
{
: P
L n ∧ the
r and x k occur in P }
5.2.0.18 Proposition. For n ≥ 0, we have that
=
n .
Proof. In outline, the instruction pair Loop-end implements one simultaneous recursion. On the other hand, by the definition of
, this class contains functions obtained from those of
=
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 .
Thus, everything we said about the (
) n ≥0 hierarchy carries over to the (
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
- ( or
-) hierarchy , (
n ) n ≥0 , is proper .
5.2.0.20 Example. Here are some functions and predicates in the “lower” (small n ) classes of the (
) n ≥0 hierarchy.
The following are in
1 and hence in
=
1 .
(1) λ xy . x + y . Indeed,
0 + y = y
( x + 1) + y = ( x + y ) + 1
and λ y . y and λ z . z + 1 are in
0 =
.
(2) λ xy . x (1 ∸ y ). Indeed,
x (1 ∸ 0) = x
x (1 ∸ ( y + 1)) = 0
and λ y . y and λ z .0 are in
0 =
.
(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
0 =
.
(5) λ x .⌊ x /2⌋
. Indeed, see 2.1.3.3 .
This example shows that
1 ≠
, since λ x . ⌊ x /2⌋
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
0 =
.
The following are in
2 and hence in
=
2 .
(a) λ xy . x ∸ y . Indeed,
x ∸ 0 = x
x ∸ ( y + 1) = ( x ∸ y ) ∸ 1
and λ y . y and λ z . z ∸ 1 are in
1 ⊆
.
(b) λ xy . xy . Indeed,
x 0 = 0
x ( y + 1) = xy + x
and λ y .0 and λ wz . w + z are in
1 ⊆
.
(c) λ x .2 x . Indeed,
2 0 = 1
2 y +1 \= 2 y + 2 y
and λ y .1 and λ wz . w + z are in
1 ⊆
.
5.2.0.21 Definition. As is usual, the predicate classes
n ,* and
—the latter being the same as
n ,* —are defined for all n ≥ 0 as { f (
) = 0 : f
n } and { f (
) = 0 : f
}, respectively.
5.2.0.22 Proposition. For n ≥ 1, we have that
n ,* and
are closed under ¬ and ν— and hence under ∧, →, and ≡ as well .
Proof Let Q (
)
n ,* . Then, for some q
n , Q (
) ≡ q (
) = 0. Since r = λ
.1 ∸ q (
)
n if n ≥ 1 by 5.2.0.20 , we are done, noting ¬ Q (
) ≡ r (
) = 0. Next, let also S (
) ≡ s (
) = 0 with s
n . Then Q (
) ∨ S (
) ≡ switch ( q (
), 0, r (
) = 0; but switch
n , for n ≥ 1 (cf. 5.2.0.20 ).
The cases for
are argued identically with the preceding two.
5.2.0.23 Corollary. The relations λ x . x ≤ a , λ x . x < a and λ x . x = a are in
1,* . and hence in
.
Proof. By 5.2.0.20(4) and substitution, we have that λ x . x ∸ a
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
1,* due to
a ≤ x ≡ ¬ x < a
and 5.2.0.22 , we have that λ x . x = a is in
1,* by 5.2.0.22 and the observation x = a ≡ x ≤ a ∧ a ≤ x .
5.2.0.24 Proposition. For n ≥ 1, we have that
n and
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).
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
where h, q and B are given functions.
A class
is closed under bounded primitive recursion iff whenever h , q , and B are in
, 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).
The class of relations at level n of the Grzegorczyk hierarchy is defined as usual.
5.2.0.26 Definition.
for n ≥ 0, denotes the class of relations { f (
) = 0: f
ε n }.
5.2.0.27 Example. Here are some examples of functions and relations in ε 0 and
:
(1) λ xy . x (1 ∸ y ).
(2) λ x .1 ∸ x . By (1) and substitution.
(3) λ x . x ∸ 1.
(4) λ xy . x ∸ y .
(5) λ xy . x ≤ y and λ xy . x < y are in
. Indeed, x ≤ y ≡ x ∸ y = 0 and x < y ≡ ( x + 1) ∸ y = 0
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.
5.2.0.29 Theorem. For n ≥ 0,
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 (
) ≡ r (
) = 0 and Q (
) ≡ q (
) = 0, where r and q are in ε n . Now, ¬ R (
) ≡ 1 ∸ r (
) = 0 and we are done by 5.2.0.27(2) . On the other hand, R (
) ∨ Q (
) ≡ r (
) (1 ∸ (1 ∸ q (
))) = 0 and we are done by 5.2.0.27(1) .
For closure under bounded quantification, let P ( y ,
) ≡ P ( y ,
) = 0, where p
ε n . Let χ ∃ be the characteristic function (cf. 2.1.2.15 ) of (∃ y ) < z P ( y ,
). Noting that
(∃ y ) <0 P ( y ,
) is false, and (∃ y ) < z +1 P ( y ,
) ≡ P ( z ,
) ∨ (∃ y ) < z P ( y ,
)
we have that χ ∃ satisfies the bounded recursion below:
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 ,
) ≡ χ ∃ ( z ,
) = 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
under negation.
Note that if a class
contains λ x .1 ∸ x and is closed under substitution, then 2.1.2.16 applies to its class of predicates
* .
The following result is, modulo choice of Ackermann function, from Grzegorczyk (1953).
5.2.0.30 Lemma. (Bounding Lemma) (1) For each f
ε 0 , there are i and k such that f (
) ≤ x i + k everywhere .
(2) For each f
ε 1 , there are C and k such that f (
) ≤ C max(
) + k everywhere .
(3) For each f
ε 2 , there are C, n, and k such that f (
) ≤ C max(
) n + k everywhere .
(4) For each f
ε n +1 , n ≥ 2, there is a k such that f (
) ≤
(max(
)) 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,
The I.H. applies to g . Now, if g (
) ≤ x j + k everywhere, for j ≠ i , then also
f ( x 1 ,..., x i −1 , ..., x n ,
) ≤ x j + k , everywhere.
If, on the other hand, j = i , then f ( x 1 , . . . , x i −1 , x i +1 , . . . , x n ,
) ≤ h (
) + k , everywhere. By the I.H. on h , f ( x 1 , . . . , x i −1 , x i +1 , . . . , x n ,
) ≤ 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 (
, g (
),
). We have, by the I.H. applied to h ,
(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
majorize the component-functions of the substitution, then
majorizes the result.
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(
) + k, and C max(
) n + k if n = 0, 1, 2, respectively—cf. (1)–(3) in 5.2.0.30 —or
if n ≥ 3.
I am implying an induction over ε n in the above remark. But is A n −1
ε n +1 ? Yes, if we assume that A n −2 is. See Exercise 5.3.21 .
Reverting to the unified notation “ g n ” and noting that g n +1
ε n +1 − ε n by 5.2.0.30 , we promote ⊆ above to ⊂:
ε n ⊂ ε n +1 , for all n .
Now, trivially, ε n ⊂
, for all n . On the other hand, by 2.4.3.1 , every primitive recursion is a bounded recursion with bounding function
for some k , so
⊆
n ≥0 ε n as well.
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 .
We defined bounded summation and multiplication in 2.1.2.30 and saw that, as operations, they do not take us out of
. 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 ,
) in ε n .
For n = 2, f ( i ,
) = O (max( i ,
) r ), for some r , due to 5.2.0.30 . But then,
Since, for any constants C and D , λ z
. C z max( z ,
) 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 ,
) ≤
(max( i ,
)), for all i ,
.
Then
But λ xy . xy and
(max(z,
)) are in ε n for n > 2. We have obtained the required bounding function in (1).
5.2.0.34 Proposition. For n ≥ 3,
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 ,
) ≤
(max( i ,
)), for all i ,
. Then
But λ xy.x y and λ z
.
(max( z ,
)) are in
n , for n ≥ 3. We obtained the required bounding function in (2).
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
. f ( y ,
) we define
(
y ) ≤ z f ( y ,
) means (
y ) < z +1 f ( y ,
), and (
y ) < z R ( y ,
) means (
y ) < z χ R ( y ,
), where χ R is the characteristic function of R .
5.2.0.36 Theorem. For n ≥ 0,
n is closed under (
y ) < z .
Proof . Let f
n . We set g ( z ,
) = (
y ) < z f ( y ,
). Notice that
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 ,
) into w and χ( z ,
)—the value at
z ,
of the characteristic function of (∀ y ) < z f ( y ,
) ≠ 0 ∧ f ( z ,
) = 0—into x in
if x = 0 then z else w
Noting that g ( z ,
) ≤ 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
0 because of the bounded recursion below.
Moreover, note that g ( z + 1,
) = sw (χ ( z ,
), z , g ( z ,
)).
The absence of the full switch from
0 qualifies the result about closure under definition by cases:
5.2.0.37 Corollary. For n ≥ 1,
n is closed under definition by cases 2.1.2.37 .
0 is closed under definition by cases provided the produced function f satisfies f (
) ≤ x i + k everywhere, for some i and k.
Proof . For n ≥ 1 the proof of 2.1.2.37 works. For
0 , if f is given as in 2.1.2.37 , where the f i are in
0 and the R i in
, then
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.
5.2.0.38 Theorem.
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 ,
) ≤ B i ( x ,
) everywhere.
Proof . Consider the schema below, where the h i , g i and B i are in
2 .
The pairing function J = λ xy .( x + y ) 2 + x (cf. 2.1.4.8 ) is in
2 , and so are its projections K = λ z .(
x ) ≤ z (∃ y ) ≤ z J ( x , y ) = z and L = λ z . (
y ) ≤ z (∃ x ) ≤ z J ( x , y ) = z .
Thus, we have the coding-decoding scheme—λ
k .
z 1 ,…, z k
( k ) and
—of 2.1.4.9 in
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
…
/
adopted here. Noting that
and that the right hand side of the above ≤ is in
2 (as a function of x ,
n ) by substitution, we obtain that
and therefore, for i = 1,…, k , f i \= λ x
n .
(
f 1 ( x ,
n ),…, f k ( x ,
n )
( k ) ) is in
2 .
5.2.0.39 Corollary.
n , for n ≥ 2, is closed under simultaneous bounded recursion .
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 .
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
n iff f is computable by some URM within time t
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.
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.
Thus, for the record:
5.2.0.40 Definition. Consider the function f =
, where M is a URM—whether M is normalized or not is immaterial for the purpose of this definition. A function λ
n . t (
n ) majorizes the run time complexity of
iff, for all
n , if f (
n ) ↓ with an M -computation of length l , then l ≤ t (
n ); else if f (
n ) ↑, then also t (
n ) ↑.
We say that λ
n . f (
n ) is computable within time λ
n . t (
n ).
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 ,
n — as follows:
v i ( y ,
n ) = the value of variable V i in the y-th ID of a (possibly non terminating) computation with input
n
I ( y ,
n ) = instruction number in the y-th ID of a (possibly non terminating) computation with input
n
All the simulating functions are in
.
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.
Proof . We have the following simultaneous recursion that defines the simulating functions:
v 1 (0,
n ) = 0
v i (0,
n ) = a i −1 , for i = 2,…, n + 1
v i (0,
n ) = 0, for i = n + 2,…, m
I (0,
n ) = 1
For y ≥ 0 and i = 1,…, m , we have
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
and
—it follows that all the simulating functions are in
, as claimed.
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
5.2.0.43 Corollary. The simulating functions are in
4 .
Proof . The above mentioned predicates and functions that are part of the iterator are in
1 and
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
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 ∸
2 and Lz =
∸ Kz . By the results of 5.2.0.20 we need only locate λ z .
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 =
. This yields
Suppose next that z + 1 is not a perfect square. That is,
for some m , and hence m 2 ≤ z < m 2 + 2 m < ( m + 1) 2 . This entails m ≤
< m + 1, thus m =
. But m =
as well, by (2).
At the end of all this we obtain the following recursion:
By reference to 5.2.0.20 —and noting that x = y ≡ ( x ∸ y ) + ( y ∸ x ) = 0, thus λ xy . x = y
2,∗ —we see that λ z .
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
3 . Referring to 2.1.3.1 , we see that, due to the presence of the
in the iterator part, the single recursion that simulates the simultaneous recursion of the simulation lemma yields the function
in
4 . This guarantees that
are in
4 , for i = 1,…, m + 1.
5.2.0.44 Corollary. The simulating functions are in
2 .
Proof . Given that the iterators in the simultaneous recursion employed in 5.2.0.41 are trivially in
2 , we only need to provide
2 -bounds for all the produced functions ( 5.2.0.38 ). Well, I ( y ,
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 ,
n ) ≤ max
n + y + C , a bound which is in
2 as a function of y and
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 ).
We can now prove (the nontrivial) half of the Ritchie-Cobham property:
5.2.0.45 Lemma. If f =
runs on M within time t
n , for some n ≥ 2, then f
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
n , we have f (
n ) = v 1 ( t (
n ),
n ), and this settles the claim by 5.2.0.44 .
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 λ
. f (
)
n is URM-computable within time λ
. t (
)
n .
Proof . Induction over
n .
We settle the case of the initial functions first (cf. 5.2.0.25 ). λ x . x is computable, as
, 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
, 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
The non normalized URM P below
1 : V 1 ← V 1 + 1
2 : stop
computes λ x . x + 1 as
in O (1) steps.
λ xy . xy is computable by the following loop-program, R , within time O ( xy ), as
:
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
n +1 for n ≥ 2.
The only new case is A n . We show that it is computable by some URM M within time
, for some k .
We know that A n
n . So let A n =
, where the program P
L n terminates within O (
( x )) steps (cf. Exercise 5.3.22 ).
But how about computing
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
and consider Q :
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 :
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 (
( x )), it follows that for any variable X of P , we have O ( X ) = O (
( x )), 156 and thus the URM runs within time O
= O (
( 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
n ( n ≥ 2) we show that the property propagates with substitution and bounded recursion.
Let then f and g from
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
n . Consider
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 λ
. t g (
) + t f (
, g (
)), which is in
n , just as λ
. f (
, g (
)) is. The other cases of substitution are trivial and are omitted.
Finally, let λ x
. f ( x ,
) be obtained by a bounded recursion from basis h , iterator g and bound B , all in
n , and all programmable in respective URMs within time bounds t h , t g and t B , all in
n . A URM program for f , in “pseudo code”, is
z ← h (
)
i ← 0
R : if x = 0 goto L else goto L ′
z ← g ( i ,
, z )
i ← i + 1
x ← x ∸ 1
goto R
L : stop
Its run time is
Since t h , t g and f are all in
n , then so is the function given by expression (1), due to 5.2.0.33 .
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.
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
n ) For n ≥ 2, a function f is in
n iff it can be computed on some URM within time t f
n .
n +1 —as it is measured by the amount of time it takes to compute it, namely,
—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 .
We can now compare all the hierarchies that we introduced:
5.2.0.48 Corollary. For n ≥ 2, we have
=
n +1 .
Proof . The ⊇ is immediate by 5.2.0.47 : Let f
n +1 and let it run on some M within time t f
n +1 . Now t f (
) ≤
(max
), 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 = λ
. v 1 (
(max
),
)
But
( 5.2.0.12 ), thus, f
.
For the ⊆ we do induction on n ≥ 2. For n = 2 note that, trivially,
⊆
3 . Now—by varying r — we can make
majorize every function of
( 5.2.0.13 ), thus every simultaneous recursion that produces functions in
(from functions in
) is a bounded recursion within
3 ( A 1 = λ x.2x + 2
3 ). Therefore,
⊆
3 . Repeating this argument we have that
every simultaneous recursion that produces functions in
(from functions in
) a bounded recursion within
3 ( since A 2
![]()
3 ).
thus,
⊆
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
to
are bounded recursions performed within
n +2 (⊇
n +1 ⊇, by I.H.,
), with bounding function some
—since
∩
n +2 .
By 5.2.0.18 we have at once
5.2.0.49 Corollary. For n ≥ 2, we have
n =
n +1 .
5.2.0.50 Corollary. For n ≥ 4, we have
n =
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 .
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.
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
=
?
We saw that the equivalence problem for
is unsolvable—indeed, worse: not even c.e.—as a consequence of the fact λ x .1 and λ y .χ T ( x , x , y ) are in
.
As these functions are also in
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
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,
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 ,
, λ x.rem ( x , k )}. That is, all “looping” can be eliminated if we adopt this enlarged set of initial functions.