Primitive recursive function
Function computable with bounded loops
title: "Primitive recursive function" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["computability-theory", "theory-of-computation", "functions-and-mappings", "recursion"] description: "Function computable with bounded loops" topic_path: "technology/computing" source: "https://en.wikipedia.org/wiki/Primitive_recursive_function" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Function computable with bounded loops ::
In computability theory, a primitive recursive function is, roughly speaking, a function that can be computed by a computer program whose loops are all "for" loops (that is, an upper bound of the number of iterations of every loop is fixed before entering the loop). Primitive recursive functions form a strict subset of those general recursive functions that are also total functions.
The importance of primitive recursive functions lies in the fact that most computable functions that are studied in number theory (and more generally in mathematics) are primitive recursive. For example, addition and division, the factorial and exponential function, and the function which returns the nth prime are all primitive recursive. In fact, for showing that a computable function is primitive recursive, it suffices to show that its time complexity is bounded above by a primitive recursive function of the input size. It is hence not particularly easy to devise a computable function that is not primitive recursive; some examples are shown in section below.
The set of primitive recursive functions is known as PR in computational complexity theory.
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: |1=Constant functions C_n^k: For each natural number n and every k, the k-ary constant function, defined by C_n^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\ n, is primitive recursive.
| 2=Successor function: The 1-ary successor function S, which returns the successor of its argument (see Peano postulates), that is, S(x) \ \stackrel{\mathrm{def}}{=}\ x + 1, is primitive recursive.
| 3=Projection functions P_i^k: For all natural numbers i, k such that 1\le i\le k, the k-ary function defined by P_i^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\ x_i is primitive recursive.
More complex primitive recursive functions can be obtained by applying the operations given by these axioms: | 4=Composition operator \circ, (also called the substitution operator): Given an m-ary function h(x_1,\ldots,x_m), and m k-ary functions g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots, x_k): h \circ (g_1, \ldots, g_m) \ \stackrel{\mathrm{def}}{=}\ f, \quad\text{where}\quad f(x_1,\ldots,x_k) = h(g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots,x_k)). For m=1, the ordinary function composition h \circ g_1 is obtained.
| 5=Primitive recursion operator \rho: Given the k-ary function g(x_1,\ldots,x_k), and the (k+2)-ary function h(y,z,x_1,\ldots,x_k),: :\begin{align} \rho(g, h) &\ \stackrel{\mathrm{def}}{=}\ f, \quad\text{where the }(k+1)\text{-ary function } f \text{ is defined by}\ f(y, x_1, \dots, x_k) &= \begin{cases} g(x_1, \dots, x_k) & \text{if } y=0, \ h(y', f(y', x_1, \dots, x_k) ,x_1, \dots, x_k) & \text{if } y=S(y') \text{ for a } y' \in \mathbb{N}. \end{cases} \end{align} Interpretation: The function f acts as a for-loop from 0 up to the value of its first argument. The rest of the arguments for f, denoted here with x_1,\ldots,x_k, 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 g and h on the right-hand side of the equations that define f represent the body of the loop, which performs calculations. The function g is used only once to perform initial calculations. Calculations for subsequent steps of the loop are performed by h. The first parameter of h is fed the "current" value of the for-loop's index. The second parameter of h is fed the result of the for-loop's previous calculations, from previous steps. The rest of the parameters for h are those immutable initial conditions for the for-loop mentioned earlier. They may be used by h to perform calculations but they will not themselves be altered by h.
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) function f : \mathbb{N}^m \to \mathbb{N}^n is primitive recursive if it can be written as :f(x_1, \dots, x_m) = (f_1(x_1, \dots, x_m), \dots, f_n(x_1, \dots, x_m)) where each component f_i : \mathbb{N}^m \to \mathbb{N} is a (scalar-valued) primitive recursive function.
Examples
|C_0^1 is a 1-ary function which returns 0 for every input: C_0^1(x) = 0.
|C_1^1 is a 1-ary function which returns 1 for every input: C_1^1(x) = 1.
|C_3^0 is a 0-ary function, i.e. a constant: C_3^0 = 3.
|P_1^1 is the identity function on the natural numbers: P_1^1(x) = x.
|P_1^2 and P_2^2 is the left and right projection on natural number pairs, respectively: P_1^2(x,y) = x and P_2^2(x,y) = y.
|S \circ S is a 1-ary function that adds 2 to its input, (S \circ S)(x) = x+2.
|S \circ C_0^1 is a 1-ary function which returns 1 for every input: (S \circ C_0^1)(x) = S(C_0^1(x)) = S(0) = 1. That is, S \circ C_0^1 and C_1^1 are the same function: S \circ C_0^1 = C_1^1. In a similar way, every C_n^k can be expressed as a composition of appropriately many S and C_0^k. Moreover, C_0^k equals C_0^1 \circ P_1^k, since C_0^k(x_1,\ldots,x_k) = 0 = C_0^1(x_1) = C_0^1(P_1^k(x_1,\ldots,x_k)) = (C_0^1 \circ P_1^k)(x_1,\ldots,x_k). For these reasons, some authors define C_n^k only for n = 0 and k = 1.
Addition
A definition of the 2-ary function \operatorname{Add}, to compute the sum of its arguments, can be obtained using the primitive recursion operator \rho. To this end, the well-known equations :\begin{align} 0 + y &= y, \ S(x) + y &= S(x+y) \end{align} are "rephrased in primitive recursive function terminology": In the definition of \rho(g, h), the first equation suggests to choose g = P_1^1 to obtain \operatorname{Add}(0, y) = g(y) = y; the second equation suggests to choose h = S \circ P_2^3 to obtain \operatorname{Add}(S(x), y) = h(x, \operatorname{Add}(x, y), y) = (S \circ P_2^3)(x, \operatorname{Add}(x, y), y) = S(\operatorname{Add}(x, y)). Therefore, the addition function can be defined as \operatorname{Add} = \rho(P_1^1, S \circ P_2^3). As a computation example, :\begin{align} \operatorname{Add}(1, 7) &= \rho(P_1^1, S \circ P_2^3) (S(0), 7) && \text{ by Def. } \operatorname{Add}, S \ &= (S \circ P_2^3)(0, \operatorname{Add}(0, 7), 7) && \text{ by case } \rho(g, h) (S(...), ...) \ &= S(\operatorname{Add}(0, 7)) && \text{ by Def. } \circ, P_2^3 \ &= S(\rho(P_1^1, S \circ P_2^3) (0, 7)) && \text{ by Def. } \operatorname{Add} \ &= S(P_1^1(7)) && \text{ by case } \rho(g, h) (0,...) \ &= S(7) && \text{ by Def. } P_1^1 \ &= 8 && \text{ by Def. } S. \ \end{align}
Doubling
Given \operatorname{Add}, the 1-ary function \operatorname{Add} \circ (P_1^1, P_1^1) doubles its argument, (\operatorname{Add} \circ (P_1^1, P_1^1))(x) = \operatorname{Add}(x, x) = x + x.
Multiplication
In a similar way as addition, multiplication can be defined by \operatorname{Mul} = \rho(C_0^1, \operatorname{Add} \circ(P_2^3, P_3^3)). This reproduces the well-known multiplication equations: :\begin{align} \operatorname{Mul}(0, y) &= \rho(C_0^1, \operatorname{Add} \circ(P_2^3, P_3^3)) (0, y) && \text{ by Def. } \operatorname{Mul} \ &= C_0^1(y) && \text{ by case } \rho(g, h) (0, ...) \ &= 0 && \text{ by Def. } C_0^1. \end{align} and :\begin{align} \operatorname{Mul}(S(x), y) &= \rho(C_0^1, \operatorname{Add} \circ(P_2^3, P_3^3)) (S(x),y) && \text{ by Def. } \operatorname{Mul} \ &= (\operatorname{Add} \circ(P_2^3 ,P_3^3)) (x, \operatorname{Mul}(x, y), y) && \text{ by case } \rho(g, h) (S(...), ...) \ &= \operatorname{Add}(\operatorname{Mul}(x, y), y) && \text{ by Def. } \circ, P_2^3, P_3^3 \ &= \operatorname{Mul}(x, y) + y && \text{ by property of } \operatorname{Add}. \end{align}
Predecessor
The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules \operatorname{Pred}(0) = 0 and \operatorname{Pred}(S(n)) = n. A primitive recursive definition is \operatorname{Pred} = \rho(C_0^0, P_1^2). As a computation example, :\begin{align} \operatorname{Pred}(8) &= \rho(C_0^0, P_1^2) (S(7)) && \text{ by Def. } \operatorname{Pred}, S \ &= P_1^2(7, \operatorname{Pred}(7)) && \text{ by case } \rho(g, h) (S(...), ...) \ &= 7 && \text{ by Def. } P_1^2. \end{align}
Truncated subtraction
The limited subtraction function (also called "monus", and denoted "\mathbin{\dot{-}}") is definable from the predecessor function. It satisfies the equations :\begin{align} y \mathbin{\dot{-}} 0 &= y, \ y \mathbin{\dot{-}} S(x) &= \operatorname{Pred}(y \mathbin{\dot{-}} x). \end{align} Since the recursion runs over the second argument, we begin with a primitive recursive definition of the reversed subtraction, \operatorname{RSub}(y, x) = x \mathbin{\dot{-}} y. Its recursion then runs over the first argument, so its primitive recursive definition can be obtained, similar to addition, as \operatorname{RSub} = \rho(P_1^1, \operatorname{Pred} \circ P_2^3). To get rid of the reversed argument order, then define \operatorname{Sub} = \operatorname{RSub} \circ (P_2^2, P_1^2). As a computation example, :\begin{align} \operatorname{Sub}(8, 1) &= (\operatorname{RSub} \circ (P_2^2, P_1^2)) (8, 1) && \text{ by Def. } \operatorname{Sub} \ &= \operatorname{RSub}(1, 8) && \text{ by Def. } \circ, P_2^2, P_1^2 \ &= \rho(P_1^1, \operatorname{Pred} \circ P_2^3) (S(0), 8) && \text{ by Def. } \operatorname{RSub}, S \ &= (\operatorname{Pred} \circ P_2^3) (0, \operatorname{RSub}(0, 8), 8) && \text{ by case } \rho(g, h) (S(...), ...) \ &= \operatorname{Pred}(\operatorname{RSub}(0, 8)) && \text{ by Def. } \circ, P_2^3 \ &= \operatorname{Pred}(\rho(P_1^1, \operatorname{Pred} \circ P_2^3) (0, 8)) && \text{ by Def. } \operatorname{RSub} \ &= \operatorname{Pred}(P_1^1(8)) && \text{ by case } \rho(g, h) (0, ...) \ &= \operatorname{Pred}(8) && \text{ by Def. } P_1^1 \ &= 7 && \text{ by property of } \operatorname{Pred}. \end{align}
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 truth values (that is, t for true, and f 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 t with the number 1, and the truth value f with the number 0. Once this identification has been made, the characteristic function of a set A, which always returns 1 or 0, can be viewed as a predicate that tells whether a number is in the set A. Such an identification of predicates with numeric functions will be assumed for the remainder of this article.
Predicate "Is zero"
As an example for a primitive recursive predicate, the 1-ary function \operatorname{IsZero} shall be defined such that \operatorname{IsZero}(x) = 1 if x = 0, and \operatorname{IsZero}(x) = 0 otherwise. This can be achieved by defining \operatorname{IsZero} = \rho(C_1^0, C_0^2). Then \operatorname{IsZero}(0) = \rho(C_1^0, C_0^2)(0) = C_1^0() = 1, and e.g. \operatorname{IsZero}(8) = \rho(C_1^0, C_0^2)(S(7)) = C_0^2(7, \operatorname{IsZero}(7)) = 0.
Predicate "Less or equal"
Using the property x \leq y \iff x \mathbin{\dot{-}} y = 0, the 2-ary function \operatorname{Leq} can be defined by \operatorname{Leq} = \operatorname{IsZero} \circ \operatorname{Sub}. Then \operatorname{Leq}(x, y) = 1 if x \leq y, and \operatorname{Leq}(x, y) = 0 otherwise. As a computation example, :\begin{align} \operatorname{Leq}(8, 3) &= \operatorname{IsZero}(\operatorname{Sub}(8, 3)) && \text{ by Def. } \operatorname{Leq} \ &= \operatorname{IsZero}(5) && \text{ by property of } \operatorname{Sub} \ &= 0 && \text{ by property of } \operatorname{IsZero} \ \end{align}
Predicate "Greater or equal"
Once a definition of \operatorname{Leq} is obtained, the converse predicate can be defined as \operatorname{Geq} = \operatorname{Leq} \circ (P_2^2, P_1^2). Then, \operatorname{Geq}(x, y) = \operatorname{Leq}(y, x) is true (more precisely: has value 1) if and only if x \geq y.
If-then-else
The 3-ary if-then-else operator known from programming languages can be defined by \operatorname{If} = \rho(P_2^2, P_3^4). Then, for arbitrary x, :\begin{align} \operatorname{If}(S(x), y, z) &= \rho(P_2^2, P_3^4) (S(x), y, z) && \text{ by Def. } \operatorname{If} \ &= P_3^4(x, \operatorname{If}(x, y, z), y, z) && \text{ by case } \rho(S(...), ...) \ &= y && \text{ by Def. } P_3^4 \end{align} and :\begin{align} \operatorname{If}(0, y, z) &= \rho(P_2^2, P_3^4) (0, y, z) && \text{ by Def. } \operatorname{If} \ &= P_2^2(y, z) && \text{ by case } \rho(0, ...) \ &= z && \text{ by Def. } P_2^2. \end{align} That is, \operatorname{If}(x, y, z) returns the then-part (y) if the if-part (x) is true, and the else-part (z) otherwise.
Junctors
Based on the \operatorname{If} function, it is easy to define logical junctors. For example, defining \operatorname{And} = \operatorname{If} \circ (P_1^2, P_2^2, C_0^2), one obtains \operatorname{And}(x, y) = \operatorname{If}(x, y, 0), that is, \operatorname{And}(x, y) is true if and only if both x and y are true (logical conjunction of x and y).
Similarly, \operatorname{Or} = \operatorname{If} \circ (P_1^2, C_1^2, P_2^2) and \operatorname{Not} = \operatorname{If} \circ (P_1^1, C_0^1, C_1^1) lead to appropriate definitions of disjunction and negation: \operatorname{Or}(x, y) = \operatorname{If}(x, 1, y) and \operatorname{Not}(x) = \operatorname{If}(x, 0, 1).
Equality predicate
Using the above functions \operatorname{Leq}, \operatorname{Geq} and \operatorname{And}, the definition \operatorname{Eq} = \operatorname{And} \circ (\operatorname{Leq}, \operatorname{Geq}) implements the equality predicate. In fact, \operatorname{Eq}(x, y) = \operatorname{And}(\operatorname{Leq}(x, y), \operatorname{Geq}(x, y)) is true if and only if x equals y.
Similarly, the definition \operatorname{Lt} = \operatorname{Not} \circ \operatorname{Geq} implements the predicate "less-than", and \operatorname{Gt} = \operatorname{Not} \circ \operatorname{Leq} implements "greater-than".
Other operations on natural numbers
Exponentiation and primality testing are primitive recursive. Given primitive recursive functions e, f, g, and h, a function that returns the value of g when e \leq f and the value of h otherwise is primitive recursive.
Operations on integers and rational numbers
By using Gödel numberings, the primitive recursive functions can be extended to operate on other objects such as integers and rational numbers. If integers are encoded by Gödel numbers in a standard way, the arithmetic operations including addition, subtraction, and multiplication are all primitive recursive. Similarly, if the rationals are represented by Gödel numbers then the field operations are all primitive recursive.
Some common primitive recursive functions
The following examples and definitions are from . Many appear with proofs. Most also appear with similar names, either as proofs or as examples, in they add the logarithm lo(x, y) or lg(x, y) depending on the exact derivation.
In the following the mark " ' ", e.g. a', is the primitive mark meaning "the successor of", usually thought of as " +1", e.g. a +1 =def a'. The functions 16–20 and #G are of particular interest with respect to converting primitive recursive predicates to, and extracting them from, their "arithmetical" form expressed as Gödel numbers.
:# Addition: a+b :# Multiplication: a×b :# Exponentiation: ab :# Factorial a! : 0! = 1, a'! = a!×a' :# pred(a): (Predecessor or decrement): If a 0 then a−1 else 0 :# Proper subtraction a ∸ b: If a ≥ b then a−b else 0 :# Minimum(a1, ... an) :# Maximum(a1, ... an) :# Absolute difference: | a−b | =def (a ∸ b) + (b ∸ a) :# ~sg(a): NOT[signum(a)]: If a=0 then 1 else 0 :# sg(a): signum(a): If a=0 then 0 else 1 :# a | b: (a divides b): If b=k×a for some k then 0 else 1 :# Remainder(a, b): the leftover if b does not divide a "evenly". Also called MOD(a, b) :# a = b: sg | a − b | (Kleene's convention was to represent true by 0 and false by 1; presently, especially in computers, the most common convention is the reverse, namely to represent true by 1 and false by 0, which amounts to changing sg into ~sg here and in the next item) :# a :# Pr(a): a is a prime number Pr(a) =def a1 & NOT(Exists c)1 [ c|a ] :# pi: the i+1th prime number :# (a)i: exponent of pi in a: the unique x such that pix|a & NOT(pix'|a) :# lh(a): the "length" or number of non-vanishing exponents in a :# lo(a, b): (logarithm of a to base b): If a, b 1 then the greatest x such that bx | a else 0
: In the following, the abbreviation x =def x1, ... xn; subscripts may be applied if the meaning requires.
- #A: A function φ definable explicitly from functions Ψ and constants q1, ... qn is primitive recursive in Ψ.
- #B: The finite sum Σy ψ(x, y) and product Πyψ(x, y) are primitive recursive in ψ.
- #C: A predicate P obtained by substituting functions χ1,..., χm for the respective variables of a predicate Q is primitive recursive in χ1,..., χm, Q.
- #D: The following predicates are primitive recursive in Q and R: ::* NOT_Q(x) . ::* Q OR R: Q(x) V R(x), ::* Q AND R: Q(x) & R(x), ::* Q IMPLIES R: Q(x) → R(x) ::* Q is equivalent to R: Q(x) ≡ R(x)
- #E: The following predicates are primitive recursive in the predicate R: ::* (Ey)y R(x, y) where (Ey)y denotes "there exists at least one y that is less than z such that" ::* (y)y R(x, y) where (y)y denotes "for all y less than z it is true that" ::* μyy R(x, y). The operator μyy R(x, y) is a bounded form of the so-called minimization- or mu-operator: Defined as "the least value of y less than z such that R(x, y) is true; or z if there is no such value."
- #F: Definition by cases: The function defined thus, where Q1, ..., Qm are mutually exclusive predicates (or "ψ(x) shall have the value given by the first clause that applies), is primitive recursive in φ1, ..., Q1, ... Qm: :: φ(x) = ::* φ1(x) if Q1(x) is true, ::* . . . . . . . . . . . . . . . . . . . ::* φm(x) if Qm(x) is true ::* φm+1(x) otherwise
- #G: If φ satisfies the equation: :: φ(y,x) = χ(y, COURSE-φ(y; x2, ... xn ), x2, ... xn then φ is primitive recursive in χ. The value COURSE-φ(y; x2 to n ) of the course-of-values function encodes the sequence of values φ(0,x2 to n), ..., φ(y-1,x2 to n) of the original function.
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.
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 f(m,n) that enumerates the primitive recursive functions, namely:
- For every unary primitive recursive function g, there is an m such that g(n) = f(m,n) for all n, and
- For every m, the function h(n) = f(m,n) is primitive recursive.
- Primitive recursive functions with two or more arguments can be encoded as unary primitive recursive functions by using a primitive recursive pairing function with two primitive recursive inverses. f can be explicitly constructed by iteratively repeating all possible ways of creating primitive recursive functions. Thus, it is provably total. One can use a diagonalization argument to show that f is not recursive primitive in itself: had it been such, so would be h(n) = f(n,n)+1. But if this equals some primitive recursive function, there is an m such that h(n) = f(m,n) for all n, and then h(m) = f(m,m), leading to contradiction.
However, the set of primitive recursive functions is not the largest recursively enumerable subset of the set of all total recursive functions. For example, the set of provably total functions (in Peano arithmetic) is also recursively enumerable, as one can enumerate all the proofs of the theory. While all primitive recursive functions are provably total, the converse is not true.
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:
Now define the "evaluator function" ev with two arguments, by ev(i,j) = f_i(j). Clearly ev is total and computable, since one can effectively determine the definition of f_i, and being a primitive recursive function f_i is itself total and computable, so f_i(j) is always defined and effectively computable. However a diagonal argument will show that the function ev of two arguments is not primitive recursive.
Suppose ev were primitive recursive, then the unary function g defined by g(i) = S(ev(i,i)) would also be primitive recursive, as it is defined by composition from the successor function and ev. But then g occurs in the enumeration, so there is some number n such that g = f_n. But now g(n) = S(ev(n,n)) = S(f_n(n)) = S(g(n)) gives a contradiction.}}
This argument can be applied to any class of computable (total) functions that can be enumerated in this way, as explained in the article Machine that always halts. Note however that the partial computable functions (those that need not be defined for all arguments) can be explicitly enumerated, for instance by enumerating Turing machine encodings.
Other examples of total recursive but not primitive recursive functions are known:
- The function that takes m to Ackermann(m,m) is a unary total recursive function that is not primitive recursive.
- The Paris–Harrington theorem involves a total recursive function that is not primitive recursive.
- The Sudan function
- The Goodstein function
Variants
Constant functions
Instead of C_n^k, alternative definitions use just one 0-ary zero function C_0^0 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
Robinson 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): :\begin{align} f(0,x) & = x,\ f(S(y),x) & = h(y,f(y,x)). \end{align} He proved that the class of all primitive recursive functions can still be obtained in this way.
Pure recursion
Another restriction considered by Robinson is pure recursion, where h does not have access to the induction variable y: :\begin{align} f(0,x_1,\ldots,x_k) & = g(x_1,\ldots,x_k),\ f(S(y),x_1,\ldots,x_k) & = h(f(y,x_1,\ldots,x_k),x_1,\ldots,x_k). \end{align} Gladstone proved that this rule is enough to generate all primitive recursive functions. Gladstone improved this so that even the combination of these two restrictions, i.e., the pure iteration rule below, is enough: :\begin{align} f(0,x) & = x,\ f(S(y),x) & = h(f(y,x)). \end{align} Further improvements are possible: Severin prove that even the pure iteration rule without parameters, namely :\begin{align} f(0) & = 0,\ f(S(y)) & = h(f(y)), \end{align} 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.
Additional primitive recursive forms
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. Course-of-values recursion defines primitive recursive functions. Some forms of mutual recursion also define primitive recursive functions.
The functions that can be programmed in the LOOP programming language are exactly the primitive recursive functions. This gives a different characterization of the power of these functions. The main limitation of the LOOP language, compared to a Turing-complete language, is that in the LOOP language the number of times that each loop will run is specified before the loop begins to run.
Computer language definition
An example of a primitive recursive programming language is one that contains basic arithmetic operators (e.g. + and −, or ADD and SUBTRACT), conditionals and comparison (IF-THEN, EQUALS, LESS-THAN), and bounded loops, such as the basic for loop, where there is a known or calculable upper bound to all loops (FOR i FROM 1 TO n, with neither i nor n modifiable by the loop body). No control structures of greater generality, such as while loops or IF-THEN plus GOTO, are admitted in a primitive recursive language.
The LOOP language, introduced in a 1967 paper by Albert R. Meyer and Dennis M. Ritchie,{{citation | doi=10.1145/800196.806014 | contribution=The complexity of loop programs | last1=Meyer | first1=Albert R. | authorlink1=Albert R. Meyer | last2=Ritchie | first2=Dennis M. | authorlink2=Dennis Ritchie | title=ACM '67: Proceedings of the 1967 22nd national conference | year=1967 | pages=465–469 | doi-access=free
The definition of primitive recursive functions implies that their computation halts on every input (after a finite number of steps). On the other hand, the halting problem is undecidable for general 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 G**T, then PRA proves the implication Con(T)→G**T. 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 forcing 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.
Primitive recursive arithmetic was first proposed by Thoralf Skolem 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.
Notes
References
-
{{cite book | last1 = Boolos | first1 = George | author-link = George Boolos | last2 = Burgess | first2 = John | author2-link = John P. Burgess | last3 = Jeffrey | first3 = Richard C. | author3-link = Richard Jeffrey | title = Computability and Logic | publisher = Cambridge University Press | edition = 4th | date = 2002 | isbn = 9780521007580
-
{{cite book | last1 = Brainerd | first1 = W.S. | last2 = Landweber | first2 = L.H. | year = 1974 | title = Theory of Computation | publisher = Wiley | isbn = 0471095850
-
{{cite journal |last1= Fachini |first1= Emanuela |last2= Maggiolo-Schettini |first2= Andrea |year= 1979 |title= A hierarchy of primitive recursive sequence functions |journal= R.A.I.R.O. - Informatique Théorique - Theoretical Informatics |volume= 13 |issue= 1 |pages= 49–67 |doi= 10.1051/ita/1979130100491 |doi-access= free |url=https://www.rairo-ita.org/articles/ita/pdf/1979/01/ita1979130100491.pdf
-
{{cite journal |last1= Fachini |first1= Emanuela |last2= Maggiolo-Schettini |first2= Andrea |year= 1982 |title= Comparing Hierarchies of Primitive Recursive Sequence Functions |journal= Zeitschrift für mathematische Logik und Grundlagen der Mathematik |volume= 28 |issue= 27-32 |pages= 431–445 |doi= 10.1002/malq.19820282705
-
{{cite journal | last = Gladstone | first = M. D. | doi = 10.2307/2270177 | journal = The Journal of Symbolic Logic | mr = 224460 | pages = 505–508 | title = A reduction of the recursion scheme | volume = 32 | year = 1967 | issue = 4 | jstor = 2270177
-
{{cite journal | last = Gladstone | first = M. D. | doi = 10.2307/2272468 | journal = The Journal of Symbolic Logic | mr = 305993 | pages = 653–665 | title = Simplifications of the recursion scheme | volume = 36 | year = 1971 | issue = 4 | jstor = 2272468
-
{{cite book | last = Hartmanis | first = Juris | author-link = Juris Hartmanis | year = 1989 | chapter = Overview of Computational Complexity Theory | title = Computational Complexity Theory | publisher = American Mathematical Society | pages = 1–17 | isbn = 978-0-8218-0131-4 | series = Proceedings of Symposia in Applied Mathematics | volume = 38 | mr = 1020807
-
{{cite book | last = Kleene | first = Stephen Cole | author-link = Stephen Cole Kleene | year = 1974 | orig-year = 1952 | title = Introduction to Metamathematics | chapter = Chapter XI. General Recursive Functions §57 | edition = 7th reprint; 2nd | publisher = North-Holland Publishing Company | oclc = 3757798 | isbn = 0444100881
-
{{cite web | author = PlanetMath | title = primitive recursive vector-valued function | url = https://planetmath.org/primitiverecursivevectorvaluedfunction | access-date = 2025-07-04
-
{{cite book | last = Rogers | first = Hartley Jr. | title = Theory of Recursive Functions and Effective Computability | publisher = MIT Press | year = 1987 | orig-year = 1967 | edition = Reprint | isbn = 9780262680523
-
{{cite journal | last = Robinson | first = Raphael M. | doi = 10.1090/S0002-9904-1947-08911-4 | journal = Bulletin of the American Mathematical Society | mr = 22536 | pages = 925–942 | title = Primitive recursive functions | volume = 53 | year = 1947 | issue = 10 | doi-access = free
-
{{cite journal | last = Severin | first = Daniel E. | arxiv = cs/0603063 | doi = 10.2178/jsl/1230396909 | issue = 4 | journal = The Journal of Symbolic Logic | jstor = 275903221 | mr = 2467207 | pages = 1122–1138 | title = Unary primitive recursive functions | volume = 73 | year = 2008
-
{{cite book | last = Soare | first = Robert I. | author-link = Robert I. Soare | isbn = 0-387-15299-7 | title = Recursively Enumerable Sets and Degrees | publisher = Springer-Verlag | year = 1987
-
{{cite journal | last = Soare | first = Robert I. | author-link = Robert I. Soare | doi = 10.2307/420992 | volume = 2 | issue = 3 | journal = The Bulletin of Symbolic Logic | mr = 1416870 | pages = 284–321 | title = Computability and recursion | url = https://scholar.archive.org/work/ruvjr6nkyre4nfxjdme2refpwe | year = 1996 | jstor = 420992
References
- {{harvtxt. PlanetMath.
- Henk Barendregt. (1990). "Formal Models and Semantics". Elsevier.
- Linz, Peter. (2011). ["An Introduction to Formal Languages and Automata"](https://books.google.com/books?id=hsxDiWvVdBcC&pg=PA332}}. For the latter, see {{citation). Jones & Bartlett Publishers.
- Peter Smith. (2013). "An Introduction to Gödel's Theorems". Cambridge University Press.
- George Tourlakis. (2003). "Lectures in Logic and Set Theory: Volume 1, Mathematical Logic". Cambridge University Press.
- (2014). "Turing's Legacy: Developments from Turing's Ideas in Logic". Cambridge University Press.
- [[Thoralf Skolem]] (1923) "The foundations of elementary arithmetic" in [[Jean van Heijenoort]], translator and ed. (1967) ''From Frege to Gödel: A Source Book in Mathematical Logic, 1879-1931''. Harvard Univ. Press: 302-33.
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::