The language of while
programs can express the computably enumerable functions. (This is true even if the only arithmetical operations on variables are, say, incrementation and decrementation.)
If while
is replaced by for
, making loops always bounded, the language can then express only the primitive recursive functions.
I recently became aware of the class of elementary functions, which are strictly below the primitive recursive functions, but still strictly above the exponential hierarchy.
Obviously it would be possible to define an imperative programming language which captures exactly the elementary functions, say by introducing operators for bounded sum and product. However, my question is,
Is there a syntactic change to the language of
while
programs which restricts it to the elementary functions and which can be stated as simply as the (while
->for
) restriction to primitive recursive functions?
A restriction on for
programs instead would also suffice, of course, and perhaps I should clarify that I'm not looking for something that is absolutely as simply-stated, just something with comparable simplicity which does not require the addition of extra operators or the like.
Edit: An example of a representative for
language is PL-{GOTO} from Brainerd and Landweber's "Theory of Computation" (1974), in which each program has a finite but unrestricted number of variables, each of which can contain a natural number, and which consists essentially of the following commands:
X <- 0
(assign 0 to a variable)X <- Y
(assign the value ofY
toX
)X <- Y + 1
(assign the successor of the value ofY
toX
)LOOP X; ... END;
(repeat the contained block of codeX
times; does not alterX
)
The authors give a proof that this can express exactly the primitive recursive functions. The language PL does not match the question perfectly, as it uses GOTO
instead of while
, and PL-{GOTO} is derived from PL by removing GOTO
from it. However, PL programs are just as powerful as while
programs, and this GOTO
-removal transformation is just as simply stated as replacing while
with for
. (Arguably perhaps even a bit simpler.)
Edit 2: http://en.wikipedia.org/wiki/Total_Turing_machine suggests this result goes back to: Meyer, A.R., Ritchie, D.M. (1967), The complexity of loop programs, Proc. of the ACM National Meetings, 465.
for
loops, but I have never seen a proof. Have you? $\endgroup$LOOP
(what I've calledfor
) andGOTO
, is Turing-complete, but that withoutGOTO
it can only express the p.r. functions. I will edit the question to include a brief description of this language. $\endgroup$