Loop Types

In programming terminology a for loop requires that the number of steps in the loop is bounded, prior to entering the loop, in terms of functions and parameters previously computed.

An until/while loop has no such prior bound and is allowed to continue looping until some condition is met, and so it may require an unbounded search and also may never halt.

Primitive Recursive (definition 1)

A function is primitive recursive if it can be computed using only “for” loops. The number of loops can depend on the function.

A relation/set is primitive recursive if its characteristic function is primitive recursive. The characteristic function is define by

1 & (a_1, \dots, a_k) \in R, \ 0 & (a_1, \dots, a_k) \notin R. \end{cases}$$ We think of the statement as saying is true of .

Initial Functions

The following functions () are initial functions:

  • the zero functions, for ,
  • the successor function ,
  • the projection functions for .
    The function () is obtained by composition from , The function () is obtained by primitive recursion from and if That is,

Primitive Recursive (definition 2)

A function is primitive recursive if it is an initial function, or is obtained from primitive recursive functions by composition or by primitive recursion.

Equivalently, the function is primitive recursive if there is a sequence of functions such that is and such that each is an initial function or is obtained from previous by composition or primitive recursion.

A set is primitive recursive iff its characteristic function is primitive recursive.

Remark

the set of primitive recursive functions is a proper subset of computable functions. On the other hand, we can give an algorithm for listing all primitive recursive functions (e.g. first list all appropriate definitional sequences of length at most 100 in which all functions are at most 10-ary, then those of length 200 in which all functions are at most 20-ary, etc.). From this we can effectively list all unary primitive recursive functions. Let where is the -th unary primitive recursive function. Clearly is computable but not primitive recursive. Thus the primitive recursive functions are a proper subset of the set of all computable functions. (Although we have yet to give a precise definition of this latter set.)

Theorem

The above two definitions of primitive recursive are equivalent.

Non-negative subtraction

Non-negative subtraction is defined by

Theorem

(1) The functions , , , , , and the constant functions, are primitive recursive. The relations and are primitive recursive. (2) If and are primitive recursive subsets of , then so are , , . (3) If is primitive recursive, then so are where is the least such that if such a exists, and is otherwise. (4) Suppose are primitive recursive functions and are primitive recursive subsets of . Suppose are primitive recursive sets forming a partition of . Let and , be defined by
Then and are primitive recursive.

Defining in and Representing in P.A. a P.R. function

If is primitive recursive, then is both definable (in in the language ) and representable in , by a -formula.

Representing a P.R. relation by a -Formula

If is primitive recursive, then is both definable (in in the language ) and representable in , by a -formula.

Proof If is p.r. then so is its characteristic function . If is represented by the -formula then is represented by .