Definition
A primitive recursive function takes a fixed number of arguments, each a natural number (nonnegative integer: {0, 1, 2, ...}), and returns a natural number. If it takes n arguments, it is called n-ary.
The basic primitive recursive functions are given by these axioms:
- Constant functions : For each natural number and every , the k-ary constant function, defined by , is primitive recursive.
- Successor function: The 1-ary successor function S, which returns the successor of its argument (see Peano postulates), that is, , is primitive recursive.
- Projection functions : For all natural numbers such that , the k-ary function defined by is primitive recursive.
More complex primitive recursive functions can be obtained by applying the operations given by these axioms:
- Composition operator (also called the substitution operator): Given an m-ary function and m k-ary functions : For , the ordinary function composition is obtained.
- Primitive recursion operator : Given the k-ary function and the -ary function : Interpretation:
The function acts as a for-loop from up to the value of its first argument. The rest of the arguments for , denoted here with , are a set of initial conditions for the for-loop which may be used by it during calculations but which are immutable by it. The functions and on the right-hand side of the equations that define represent the body of the loop, which performs calculations. The function is used only once to perform initial calculations. Calculations for subsequent steps of the loop are performed by . The first parameter of is fed the "current" value of the for-loop's index. The second parameter of is fed the result of the for-loop's previous calculations, from previous steps. The rest of the parameters for are those immutable initial conditions for the for-loop mentioned earlier. They may be used by to perform calculations but they will not themselves be altered by .
The primitive recursive functions are the basic functions and those obtained from the basic functions by applying these operations a finite number of times.
Primitive-recursiveness of vector-valued functions
A (vector-valued) function5 is primitive recursive if it can be written as
where each component is a (scalar-valued) primitive recursive function.6
Examples
- is a 1-ary function which returns for every input: .
- is a 1-ary function which returns for every input: .
- is a 0-ary function, i.e. a constant: .
- is the identity function on the natural numbers: .
- and is the left and right projection on natural number pairs, respectively: and .
- is a 1-ary function that adds 2 to its input, .
- is a 1-ary function which returns 1 for every input: . That is, and are the same function: . In a similar way, every can be expressed as a composition of appropriately many and . Moreover, equals , since . For these reasons, some authors7 define only for and .
Addition
A definition of the 2-ary function , to compute the sum of its arguments, can be obtained using the primitive recursion operator . To this end, the well-known equations
are "rephrased in primitive recursive function terminology": In the definition of , the first equation suggests to choose to obtain ; the second equation suggests to choose to obtain . Therefore, the addition function can be defined as . As a computation example,
Doubling
Given , the 1-ary function doubles its argument,
Multiplication
In a similar way as addition, multiplication can be defined by . This reproduces the well-known multiplication equations:
and
Predecessor
The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules and . A primitive recursive definition is . As a computation example,
Truncated subtraction
The limited subtraction function (also called "monus", and denoted "") is definable from the predecessor function. It satisfies the equations
Since the recursion runs over the second argument, we begin with a primitive recursive definition of the reversed subtraction, . Its recursion then runs over the first argument, so its primitive recursive definition can be obtained, similar to addition, as . To get rid of the reversed argument order, then define . As a computation example,
Converting predicates to numeric functions
In some settings, it is natural to consider primitive recursive functions that take as inputs tuples that mix numbers with (that is, for true, and for false), or that produce truth values as outputs. This can be accomplished by identifying the truth values with numbers in any fixed manner. For example, it is common to identify the truth value with the number , and the truth value with the number . Once this identification has been made, the of a set , which always returns or , can be viewed as a predicate that tells whether a number is in the set . Such an identification of predicates with numeric functions will be assumed for the remainder of this article.
Relationship to recursive functions
The broader class of partial recursive functions is defined by introducing an unbounded search operator. The use of this operator may result in a partial function, that is, a relation which has at most one value for each argument, but which may fail to have a value at some arguments (see domain). An equivalent definition states that a partial recursive function is one that can be computed by a Turing machine. A total recursive function is a partial recursive function that is defined for every input.
Every primitive recursive function is total recursive, but not all total recursive functions are primitive recursive. The Ackermann function A(m,n) is a well-known example of a total recursive function (in fact, provable total), that is not primitive recursive. There is a characterization of the primitive recursive functions as a subset of the total recursive functions using the Ackermann function. This characterization states that a function is primitive recursive if and only if there is a natural number m such that the function can be computed by a Turing machine that always halts within A(m,n) or fewer steps, where n is the sum of the arguments of the primitive recursive function.9
An important property of the primitive recursive functions is that they are a recursively enumerable subset of the set of all total recursive functions (which is not itself recursively enumerable). This means that there is a single recursive function (,) that enumerates the primitive recursive functions, namely:
Limitations
Primitive recursive functions tend to correspond very closely with our intuition of what a computable function must be. Certainly the initial functions are intuitively computable (in their very simplicity), and the two operations by which one can create new primitive recursive functions are also very straightforward. However, the set of primitive recursive functions does not include every possible total computable function—this can be seen with a variant of Cantor's diagonal argument. This argument provides a total computable function that is not primitive recursive. A sketch of the proof is as follows:
The primitive recursive functions of one argument (i.e., unary functions) can be computably enumerated. This enumeration uses the definitions of the primitive recursive functions (which are essentially just expressions with the composition and primitive recursion operations as operators and the basic primitive recursive functions as atoms), and can be assumed to contain every definition once, even though a same function will occur many times on the list (since many definitions define the same function; indeed simply composing by the identity function generates infinitely many definitions of any one primitive recursive function). This means that the -th definition of a primitive recursive function in this enumeration can be effectively determined from . Indeed if one uses some Gödel numbering to encode definitions as numbers, then this -th definition in the list is computed by a primitive recursive function of . Let denote the unary primitive recursive function given by this definition.
Now define the "evaluator function" with two arguments, by . Clearly is total and computable, since one can effectively determine the definition of , and being a primitive recursive function is itself total and computable, so is always defined and effectively computable. However a diagonal argument will show that the function of two arguments is not primitive recursive.
Suppose were primitive recursive, then the unary function defined by would also be primitive recursive, as it is defined by composition from the successor function and . But then occurs in the enumeration, so there is some number such that . But now gives a contradiction.
This argument can be applied to show that the class of total computable functions cannot be enumerated in this way, in particular it shows that cannot be enumerated. Note however that the computable functions (those that need not be defined for all arguments) can be explicitly enumerated, for instance by enumerating Turing machine encodings.
Variants
Constant functions
Instead of , alternative definitions use just one 0-ary zero function as a primitive function that always returns zero, and build the constant functions from the zero function, the successor function and the composition operator.
Iterative functions
Robinson10 considered various restrictions of the recursion rule. One is the so-called iteration rule where the function h does not have access to the parameters xi (in this case, we may assume without loss of generality that the function g is just the identity, as the general case can be obtained by substitution):
He proved that the class of all primitive recursive functions can still be obtained in this way.
Pure recursion
Another restriction considered by Robinson10 is pure recursion, where h does not have access to the induction variable y:
Gladstone11 proved that this rule is enough to generate all primitive recursive functions. Gladstone12 improved this so that even the combination of these two restrictions, i.e., the pure iteration rule below, is enough:
Further improvements are possible: Severin13 prove that even the pure iteration rule without parameters, namely
suffices to generate all unary primitive recursive functions if we extend the set of initial functions with truncated subtraction x ∸ y. We get all primitive recursive functions if we additionally include + as an initial function.
Some additional forms of recursion also define functions that are in fact primitive recursive. Definitions in these forms may be easier to find or more natural for reading or writing. defines primitive recursive functions. Some forms of also define primitive recursive functions.
Finitism and consistency results
The primitive recursive functions are closely related to mathematical finitism, and are used in several contexts in mathematical logic where a particularly constructive system is desired. Primitive recursive arithmetic (PRA), a formal axiom system for the natural numbers and the primitive recursive functions on them, is often used for this purpose.
PRA is much weaker than Peano arithmetic, which is not a finitistic system. Nevertheless, many results in number theory and in proof theory can be proved in PRA. For example, Gödel's incompleteness theorem can be formalized into PRA, giving the following theorem:
- If T is a theory of arithmetic satisfying certain hypotheses, with Gödel sentence GT, then PRA proves the implication Con(T)→GT.
Similarly, many of the syntactic results in proof theory can be proved in PRA, which implies that there are primitive recursive functions that carry out the corresponding syntactic transformations of proofs.
In proof theory and set theory, there is an interest in finitistic consistency proofs, that is, consistency proofs that themselves are finitistically acceptable. Such a proof establishes that the consistency of a theory T implies the consistency of a theory S by producing a primitive recursive function that can transform any proof of an inconsistency from S into a proof of an inconsistency from T. One sufficient condition for a consistency proof to be finitistic is the ability to formalize it in PRA. For example, many consistency results in set theory that are obtained by can be recast as syntactic proofs that can be formalized in PRA.
History
Recursive definitions had been used more or less formally in mathematics before, but the construction of primitive recursion is traced back to Richard Dedekind's theorem 126 of his Was sind und was sollen die Zahlen? (1888). This work was the first to give a proof that a certain recursive construction defines a unique function.151617
Primitive recursive arithmetic was first proposed by Thoralf Skolem18 in 1923.
The current terminology was coined by Rózsa Péter (1934) after Ackermann had proved in 1928 that the function which today is named after him was not primitive recursive, an event which prompted the need to rename what until then were simply called recursive functions.1617
Notes
- 1Brainerd & Landweber 1974.
- 5Also known as "sequence function".34
- 6PlanetMath.
- 7E.g.: Henk Barendregt (1990), "Functional Programming and Lambda Calculus", in Jan van Leeuwen (ed.), Formal Models and Semantics, Handbook of Theoretical Computer Science, vol. B, Elsevier, pp. 321–364, ISBN 0-444-88074-7 Here: 2.2.6 initial functions, Def.2.2.7 primitive recursion, p.331-332.
- 9This follows from the facts that the functions of this form are the most quickly growing primitive recursive functions, and that a function is primitive recursive if and only if its time complexity is bounded by a primitive recursive function. For the former, see . For the latter, see
References
- Brainerd, W.S.; Landweber, L.H. (1974), Theory of Computation, Wiley, ISBN 0471095850
- Fachini, Emanuela; Maggiolo-Schettini, Andrea (1982), "Comparing Hierarchies of Primitive Recursive Sequence Functions", Zeitschrift für mathematische Logik und Grundlagen der Mathematik, 28 (27–32): 431–445, doi:10.1002/malq.19820282705