HOME

TheInfoList



OR:

In
computability theory Computability theory, also known as recursion theory, is a branch of mathematical logic, computer science, and the theory of computation that originated in the 1930s with the study of computable functions and Turing degrees. The field has sinc ...
, a primitive recursive function is roughly speaking a function that can be computed by a
computer program A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. Computer programs are one component of software, which also includes software documentation, documentation and oth ...
whose loops are all "for" loops (that is, an upper bound of the number of iterations of every loop can be determined before entering the loop). Primitive recursive functions form a strict
subset In mathematics, set ''A'' is a subset of a set ''B'' if all elements of ''A'' are also elements of ''B''; ''B'' is then a superset of ''A''. It is possible for ''A'' and ''B'' to be equal; if they are unequal, then ''A'' is a proper subset of ...
of those
general recursive function In mathematical logic and computer science, a general recursive function, partial recursive function, or μ-recursive function is a partial function from natural numbers to natural numbers that is "computable" in an intuitive sense – as well as i ...
s that are also
total function In mathematics, a partial function from a set to a set is a function from a subset of (possibly itself) to . The subset , that is, the domain of viewed as a function, is called the domain of definition of . If equals , that is, if is de ...
s. The importance of primitive recursive functions lies in the fact that most computable functions that are studied in
number theory Number theory (or arithmetic or higher arithmetic in older usage) is a branch of pure mathematics devoted primarily to the study of the integers and integer-valued functions. German mathematician Carl Friedrich Gauss (1777–1855) said, "Ma ...
(and more generally in mathematics) are primitive recursive. For example,
addition Addition (usually signified by the plus symbol ) is one of the four basic operations of arithmetic, the other three being subtraction, multiplication and division. The addition of two whole numbers results in the total amount or '' sum'' ...
and division, the
factorial In mathematics, the factorial of a non-negative denoted is the product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial: \begin n! &= n \times (n-1) \times (n-2) \ ...
and
exponential function The exponential function is a mathematical function denoted by f(x)=\exp(x) or e^x (where the argument is written as an exponent). Unless otherwise specified, the term generally refers to the positive-valued function of a real variable, ...
, and the function which returns the ''n''th prime are all primitive recursive. In fact, for showing that a computable function is primitive recursive, it suffices to show that its
time complexity In computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations performed by t ...
is bounded above by a primitive recursive function of the input size. It is hence not that easy to devise a
computable function Computable functions are the basic objects of study in computability theory. Computable functions are the formalized analogue of the intuitive notion of algorithms, in the sense that a function is computable if there exists an algorithm that can do ...
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 In theoretical computer science and mathematics, computational complexity theory focuses on classifying computational problems according to their resource usage, and relating these classes to each other. A computational problem is a task solved ...
.


Definition

A primitive recursive function takes a fixed number of arguments, each a
natural number In mathematics, the natural numbers are those numbers used for counting (as in "there are ''six'' coins on the table") and ordering (as in "this is the ''third'' largest city in the country"). Numbers used for counting are called '' cardinal ...
(nonnegative integer: ), and returns a natural number. If it takes ''n'' arguments it is called ''n''-
ary ARY may stand for: * Abdul Razzak Yaqoob, a Pakistani expatriate businessman * Andre Romelle Young, real name of Dr. Dre * Ary and the Secret of Seasons, an action adventure video game * ARY Digital, a Pakistani television network * ARY Digital Net ...
. The basic primitive recursive functions are given by these
axiom An axiom, postulate, or assumption is a statement that is taken to be true, to serve as a premise or starting point for further reasoning and arguments. The word comes from the Ancient Greek word (), meaning 'that which is thought worthy or ...
s: More complex primitive recursive functions can be obtained by applying the
operation Operation or Operations may refer to: Arts, entertainment and media * ''Operation'' (game), a battery-operated board game that challenges dexterity * Operation (music), a term used in musical set theory * ''Operations'' (magazine), Multi-Man ...
s given by these axioms: The primitive recursive functions are the basic functions and those obtained from the basic functions by applying these operations a finite number of times.


Examples


Addition

A definition of the 2-ary function 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 0+y & = & y & \text \\ S(x)+y & = & S(x+y) & . \\ \end 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 Add(0,y) = g(y) = y; the second equation suggests to choose h = S \circ P_2^3 to obtain Add(S(x),y) = h(x,Add(x,y),y) = (S \circ P_2^3)(x,Add(x,y),y) = S(Add(x,y)). Therefore, the addition function can be defined as Add = \rho(P_1^1,S \circ P_2^3). As a computation example, :\begin & Add(1,7) \\ = & \rho(P_1^1,S \circ P_2^3) \; (S(0),7) & \text Add, S \\ = & (S \circ P_2^3)(0,Add(0,7),7) & \text \rho(g,h) \; (S(...),...) \\ = & S(Add(0,7)) & \text \circ, P_2^3 \\ = & S( \; \rho(P_1^1,S \circ P_2^3) \; (0,7) \; ) & \text Add \\ = & S(P_1^1(7)) & \text \rho(g,h) \; (0,...) \\ = & S(7) & \text P_1^1 \\ = & 8 & \text S . \\ \end


Doubling

Given Add, the 1-ary function Add \circ (P_1^1,P_1^1) doubles its argument, (Add \circ (P_1^1,P_1^1))(x) = Add(x,x) = x+x.


Multiplication

In a similar way as addition, multiplication can be defined by Mul = \rho(C_0^1,Add \circ(P_2^3,P_3^3)). This reproduces the well-known multiplication equations: :\begin & Mul(0,y) \\ = & \rho(C_0^1,Add \circ(P_2^3,P_3^3)) \; (0,y) & \text Mul \\ = & C_0^1(y) & \text \rho(g,h) \; (0,...)\\ = & 0 & \text C_0^1 . \\ \end and :\begin & Mul(S(x),y) \\ = & \rho(C_0^1,Add \circ(P_2^3,P_3^3)) \; (S(x),y) & \text Mul \\ = & (Add \circ(P_2^3,P_3^3)) \; (x,Mul(x,y),y) & \text \rho(g,h) \; (S(...),...) \\ = & Add(Mul(x,y),y) & \text \circ, P_2^3, P_3^3 \\ = & Mul(x,y)+y & \text Add . \\ \end


Predecessor

The predecessor function acts as the "opposite" of the successor function and is recursively defined by the rules Pred(0) = 0 and Pred(S(n)) = n. A primitive recursive definition is Pred = \rho(C_0^0, P_1^2). As a computation example, :\begin & Pred(8) \\ = & \rho(C_0^0, P_1^2) \; (S(7)) & \text Pred, S \\ = & P_1^2(7,Pred(7)) & \text \rho(g,h) \; (S(...),...) \\ = & 7 & \text P_1^2 . \\ \end


Truncated subtraction

The limited subtraction function (also called "
monus In mathematics, monus is an operator on certain commutative monoids that are not groups. A commutative monoid on which a monus operator is defined is called a commutative monoid with monus, or CMM. The monus operator may be denoted with the &minus ...
", and denoted "\stackrel.-") is definable from the predecessor function. It satisfies the equations :\begin y \stackrel.- 0 & = & y & \text \\ y \stackrel.- S(x) & = & Pred(y \stackrel.- x) & . \\ \end Since the recursion runs over the second argument, we begin with a primitive recursive definition of the reversed subtraction, RSub(y,x) = x \stackrel.- y. Its recursion then runs over the first argument, so its primitive recursive definition can be obtained, similar to addition, as RSub = \rho(P_1^1, Pred \circ P_2^3). To get rid of the reversed argument order, then define Sub = RSub \circ (P_2^2,P_1^2). As a computation example, :\begin & Sub(8,1) \\ = & (RSub \circ (P_2^2,P_1^2)) \; (8,1) & \text Sub \\ = & RSub(1,8) & \text \circ, P_2^2, P_1^2 \\ = & \rho(P_1^1, Pred \circ P_2^3) \; (S(0),8) & \text RSub, S \\ = & (Pred \circ P_2^3) \; (0,RSub(0,8),8) & \text \rho(g,h) \; (S(...),...) \\ = & Pred(RSub(0,8)) & \text \circ, P_2^3 \\ = & Pred( \; \rho(P_1^1, Pred \circ P_2^3) \; (0,8) \; ) & \text RSub \\ = & Pred(P_1^1(8)) & \text \rho(g,h) \; (0,...) \\ = & Pred(8) & \text P_1^1 \\ = & 7 & \text Pred . \\ \end


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 value In logic and mathematics, a truth value, sometimes called a logical value, is a value indicating the relation of a proposition to truth, which in classical logic has only two possible values ('' true'' or '' false''). Computing In some pro ...
s (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 In mathematics, the term "characteristic function" can refer to any of several distinct concepts: * The indicator function of a subset, that is the function ::\mathbf_A\colon X \to \, :which for a given subset ''A'' of ''X'', has value 1 at points ...
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 IsZero shall be defined such that IsZero(x) = 1 if x = 0, and IsZero(x) = 0, otherwise. This can be achieved by defining IsZero = \rho(C_1^0,C_0^2). Then, IsZero(0) = \rho(C_1^0,C_0^2)(0) = C_1^0(0) = 1 and e.g. IsZero(8) = \rho(C_1^0,C_0^2)(S(7)) = C_0^2(7,IsZero(7)) = 0.


Predicate "Less or equal"

Using the property x \leq y \iff x \stackrel.- y = 0, the 2-ary function Leq can be defined by Leq = IsZero \circ Sub. Then Leq(x,y) = 1 if x \leq y, and Leq(x,y) = 0, otherwise. As a computation example, :\begin & Leq(8,3) \\ = & IsZero(Sub(8,3)) & \text Leq \\ = & IsZero(5) & \text Sub \\ = & 0 & \text IsZero \\ \end


Predicate "Greater or equal"

Once a definition of Leq is obtained, the converse predicate can be defined as Geq = Leq \circ (P_2^2,P_1^2). Then, Geq(x,y) = 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 \textit = \rho(P_2^2,P_3^4). Then, for arbitrary x, :\begin & \textit(S(x),y,z) \\ = & \rho(P_2^2,P_3^4) \; (S(x),y,z) & \text \textit \\ = & P_3^4(x,\textit(x,y,z),y,z) & \text \rho(S(...),...) \\ = & y & \text P_3^4 \\ \end and :\begin & \textit(0,y,z) \\ = & \rho(P_2^2,P_3^4) \; (0,y,z) & \text \textit \\ = & P_2^2(y,z) & \text \rho(0,...) \\ = & z & \text P_2^2 . \\ \end. That is, \textit(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 \textit function, it is easy to define logical junctors. For example, defining And = \textit \circ (P_1^2,P_2^2,C_0^2), one obtains And(x,y) = \textit(x,y,0), that is, And(x,y) is true
if, and only if In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false. The connective is bicon ...
, both x and y are true (
logical conjunction In logic, mathematics and linguistics, And (\wedge) is the truth-functional operator of logical conjunction; the ''and'' of a set of operands is true if and only if ''all'' of its operands are true. The logical connective that represents thi ...
of x and y). Similarly, Or = \textit \circ (P_1^2,C_1^2,P_2^2) and Not = \textit \circ (P_1^1,C_0^1,C_1^1) lead to appropriate definitions of
disjunction In logic, disjunction is a logical connective typically notated as \lor and read aloud as "or". For instance, the English language sentence "it is raining or it is snowing" can be represented in logic using the disjunctive formula R \lor ...
and
negation In logic, negation, also called the logical complement, is an operation that takes a proposition P to another proposition "not P", written \neg P, \mathord P or \overline. It is interpreted intuitively as being true when P is false, and false ...
: Or(x,y) = \textit(x,1,y) and Not(x) = \textit(x,0,1).


Equality predicate

Using the above functions Leq, Geq and And, the definition Eq = And \circ (Leq, Geq) implements the equality predicate. In fact, Eq(x,y) = And( Leq(x,y) , Geq(x,y) ) is true if, and only if, x equals y. Similarly, the definition Lt = Not \circ Geq implements the predicate "less-than", and Gt = Not \circ Leq implements "greater-than".


Other operations on natural numbers

Exponentiation Exponentiation is a mathematical operation, written as , involving two numbers, the '' base'' and the ''exponent'' or ''power'' , and pronounced as " (raised) to the (power of) ". When is a positive integer, exponentiation corresponds to ...
and
primality test A primality test is an algorithm for determining whether an input number is prime. Among other fields of mathematics, it is used for cryptography. Unlike integer factorization, primality tests do not generally give prime factors, only stating whet ...
ing are primitive recursive. Given primitive recursive functions ''e'', ''f'', ''g'', and ''h'', a function that returns the value of ''g'' when ''e''≤''f'' and the value of ''h'' otherwise is primitive recursive.


Operations on integers and rational numbers

By using
Gödel numbering In mathematical logic, a Gödel numbering is a function that assigns to each symbol and well-formed formula of some formal language a unique natural number, called its Gödel number. The concept was developed by Kurt Gödel for the proof of h ...
s, the primitive recursive functions can be extended to operate on other objects such as integers and
rational number In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (e.g. ). The set of all ra ...
s. 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 Kleene (1952) pp. 223–231 — many appear with proofs. Most also appear with similar names, either as proofs or as examples, in Boolos-Burgess-Jeffrey 2002 pp. 63–70; they add the logarithm lo(x, y) or lg(x, y) depending on the exact derivation. In the following we observe that primitive recursive functions can be of four types: # ''functions'' for short: "number-theoretic functions" from to , # ''predicates'': from to truth values , # ''propositional connectives'': from truth values to truth values , # ''representing functions'': from truth values to . Many times a predicate requires a representing function to convert the predicate's output to (note the order "t" to "0" and "f" to "1" matches with ~sg( ) defined below). By definition a function φ(x) is a "representing function" of the predicate P(x) if φ takes only values 0 and 1 and produces ''0'' when P is true". 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 ignum(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 < b: sg( a' ∸ b ) :# Pr(a): a is a prime number Pr(a) =def a>1 & NOT(Exists c)1 a :# pi: the i+1-st 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.


Use in first-order Peano arithmetic

In
first-order In mathematics and other formal sciences, first-order or first order most often means either: * "linear" (a polynomial of degree at most one), as in first-order approximation and other calculus uses, where it is contrasted with "polynomials of hig ...
Peano arithmetic In mathematical logic, the Peano axioms, also known as the Dedekind–Peano axioms or the Peano postulates, are axioms for the natural numbers presented by the 19th century Italian mathematician Giuseppe Peano. These axioms have been used nearl ...
, there are infinitely many variables (0-ary symbols) but no k-ary non-logical symbols with k>0 other than S, +, *, and ≤. Thus in order to define primitive recursive functions one has to use the following trick by Gödel. By using a
Gödel numbering for sequences In mathematics, a Gödel numbering for sequences provides an effective way to represent each finite sequence of natural numbers as a single natural number. While a set theoretical embedding is surely possible, the emphasis is on the effectiveness ...
, for example Gödel's β function, any finite sequence of numbers can be encoded by a single number. Such a number can therefore represent the primitive recursive function until a given n. Let ''h'' be a 1-ary primitive recursion function defined by: : h(0) = C : h(n+1) = g(n,h(n)) where C is a constant and ''g'' is an already defined function. Using Gödel's β function, for any sequence of natural numbers (k0, k1, ..., kn), there are natural numbers b and c such that, for every i ≤ n, β(b, c, i) = ki. We may thus use the following formula to define ''h''; more precisely, ''m''=''h''(''n'') is a shorthand for the following: :\exists b: \exists c: \beta(b, c, 0) = C \land \forall i: (i and the equating to ''g'', being already defined, is in fact shorthand for some other already defined formula (as is β, whose formula is given
here Here is an adverb that means "in, on, or at this place". It may also refer to: Software * Here Technologies, a mapping company * Here WeGo (formerly Here Maps), a mobile app and map website by Here Television * Here TV (formerly "here!"), a ...
). The generalization to any k-ary primitive recursion function is trivial.


Relationship to recursive functions

The broader class of partial recursive functions is defined by introducing an
unbounded search operator Boundedness or bounded may refer to: Economics * Bounded rationality, the idea that human rationality in decision-making is bounded by the available information, the cognitive limitations, and the time available to make the decision * Bounded e ...
. The use of this operator may result in a
partial function In mathematics, a partial function from a set to a set is a function from a subset of (possibly itself) to . The subset , that is, the domain of viewed as a function, is called the domain of definition of . If equals , that is, if is de ...
, that is, a relation with ''at most'' one value for each argument, but does not necessarily have ''any'' value for any argument (see
domain Domain may refer to: Mathematics *Domain of a function, the set of input values for which the (total) function is defined ** Domain of definition of a partial function ** Natural domain of a partial function **Domain of holomorphy of a function * ...
). An equivalent definition states that a partial recursive function is one that can be computed by a
Turing machine A Turing machine is a mathematical model of computation describing an abstract machine that manipulates symbols on a strip of tape according to a table of rules. Despite the model's simplicity, it is capable of implementing any computer alg ...
. 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 In computability theory, the Ackermann function, named after Wilhelm Ackermann, is one of the simplest and earliest-discovered examples of a total computable function that is not primitive recursive. All primitive recursive functions are total ...
''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 In logic and related fields such as mathematics and philosophy, "if and only if" (shortened as "iff") is a biconditional logical connective between statements, where either both statements are true or both are false. The connective is bic ...
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 In computability theory, a set ''S'' of natural numbers is called computably enumerable (c.e.), recursively enumerable (r.e.), semidecidable, partially decidable, listable, provable or Turing-recognizable if: *There is an algorithm such that the ...
subset of the set of all
total recursive function In mathematical logic and computer science, a general recursive function, partial recursive function, or μ-recursive function is a partial function from natural numbers to natural numbers that is "computable" in an intuitive sense – as well as ...
s (which is not itself recursively enumerable). This means that there is a single computable function ''f''(''m'',''n'') that enumerates the primitive recursive functions, namely: * For every 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. ''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 In set theory, Cantor's diagonal argument, also called the diagonalisation argument, the diagonal slash argument, the anti-diagonal argument, the diagonal method, and Cantor's diagonalization proof, was published in 1891 by Georg Cantor as a m ...
. This argument provides a total computable function that is not primitive recursive. A sketch of the proof is as follows: 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 In mathematical logic, the Paris–Harrington theorem states that a certain combinatorial principle in Ramsey theory, namely the strengthened finite Ramsey theorem, is true, but not provable in Peano arithmetic. This has been described by some (su ...
involves a total recursive function that is not primitive recursive. *The
Sudan function In the theory of computation, the Sudan function is an example of a function that is recursive, but not primitive recursive. This is also true of the better-known Ackermann function. The Sudan function was the first function having this property t ...
*The
Goodstein function In mathematical logic, Goodstein's theorem is a statement about the natural numbers, proved by Reuben Goodstein in 1944, which states that every ''Goodstein sequence'' eventually terminates at 0. Kirby and Paris showed that it is independence (math ...


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 built the constant functions from the zero function, the successor function and the composition operator.


Weak primitive recursion

The 1-place predecessor function is primitive recursive, see section #Predecessor. Fischer, Fischer & Beigel removed the implicit predecessor from the recursion rule, replacing it by the weaker rule : \begin f (0, x_1, \ldots, x_k) & = & g (x_1, \ldots, x_k) & \text \\ f (S(y), x_1, \ldots, x_k) & = & h (S(y), f (y, x_1, \ldots, x_k), x_1, \ldots, x_k) \end They proved that the predecessor function still could be defined, and hence that "weak" primitive recursion also defines the primitive recursive functions.


Iterative functions

Weakening this even further by using functions h of arity ''k''+1, removing y and S(y) from the arguments of h completely, we get the ''iteration rule'': \begin f(0,x_1,\ldots,x_k) & = & g(x_1,\ldots,x_k) &\textrm \\ f(S(y),x_1,\ldots,x_k) & = & h(f(y,x_1,\ldots,x_k),x_1,\ldots,x_k) \end The class of iterative functions is defined the same way as the class of primitive recursive functions except with this weaker rule. These are conjectured to be a proper subset of the primitive recursive functions.


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 In computability theory, course-of-values recursion is a technique for defining number-theoretic functions by recursion. In a definition of a function ''f'' by course-of-values recursion, the value of ''f''(''n'') is computed from the sequence \lan ...
defines primitive recursive functions. Some forms of
mutual recursion In mathematics and computer science, mutual recursion is a form of recursion where two mathematical or computational objects, such as functions or datatypes, are defined in terms of each other. Mutual recursion is very common in functional progra ...
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 In computer science a for-loop or for loop is a control flow statement for specifying iteration. Specifically, a for loop functions by running a section of code repeatedly until a certain condition has been satisfied. For-loops have two par ...
, 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 loop In most computer programming languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition. The ''while'' loop can be thought of as a repeating if statement. Overview The ' ...
s or IF-THEN plus
GOTO GoTo (goto, GOTO, GO TO or other case combinations, depending on the programming language) is a statement found in many computer programming languages. It performs a one-way transfer of control to another line of code; in contrast a function c ...
, are admitted in a primitive recursive language. The LOOP language, introduced in a 1967 paper by Albert R. Meyer and Dennis M. Ritchie, is such a language. Its computing power coincides with the primitive recursive functions. A variant of the LOOP language is
Douglas Hofstadter Douglas Richard Hofstadter (born February 15, 1945) is an American scholar of cognitive science, physics, and comparative literature whose research includes concepts such as the sense of self in relation to the external world, consciousness, a ...
's BlooP in ''
Gödel, Escher, Bach ''Gödel, Escher, Bach: an Eternal Golden Braid'', also known as ''GEB'', is a 1979 book by Douglas Hofstadter. By exploring common themes in the lives and works of logician Kurt Gödel, artist M. C. Escher, and composer Johann Sebastian Bach, t ...
''. Adding unbounded loops (WHILE, GOTO) makes the language general recursive and
Turing-complete In computability theory, a system of data-manipulation rules (such as a computer's instruction set, a programming language, or a cellular automaton) is said to be Turing-complete or computationally universal if it can be used to simulate any ...
, as are all real-world computer programming languages. 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 In computability theory, the halting problem is the problem of determining, from a description of an arbitrary computer program and an input, whether the program will finish running, or continue to run forever. Alan Turing proved in 1936 that a ...
is undecidable for general recursive functions, even if they are total. That is, there are programs that halt on every input, but for which this can not be verified by an algorithm.


Finitism and consistency results

The primitive recursive functions are closely related to mathematical
finitism Finitism is a philosophy of mathematics that accepts the existence only of finite mathematical objects. It is best understood in comparison to the mainstream philosophy of mathematics where infinite mathematical objects (e.g., infinite sets) are ...
, and are used in several contexts in mathematical logic where a particularly constructive system is desired.
Primitive recursive arithmetic Primitive recursive arithmetic (PRA) is a quantifier-free formalization of the natural numbers. It was first proposed by Norwegian mathematician , reprinted in translation in as a formalization of his finitist conception of the foundations of ...
(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 In mathematical logic, the Peano axioms, also known as the Dedekind–Peano axioms or the Peano postulates, are axioms for the natural numbers presented by the 19th century Italian mathematician Giuseppe Peano. These axioms have been used nearl ...
, which is not a finitistic system. Nevertheless, many results in
number theory Number theory (or arithmetic or higher arithmetic in older usage) is a branch of pure mathematics devoted primarily to the study of the integers and integer-valued functions. German mathematician Carl Friedrich Gauss (1777–1855) said, "Ma ...
and in
proof theory Proof theory is a major branchAccording to Wang (1981), pp. 3–4, proof theory is one of four domains mathematical logic, together with model theory, axiomatic set theory, and recursion theory. Barwise (1978) consists of four corresponding part ...
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 Set theory is the branch of mathematical logic that studies sets, which can be informally described as collections of objects. Although objects of any kind can be collected into a set, set theory, as a branch of mathematics, is mostly concern ...
, there is an interest in finitistic
consistency proof In classical deductive logic, a consistent theory is one that does not lead to a logical contradiction. The lack of contradiction can be defined in either semantic or syntactic terms. The semantic definition states that a theory is consistent ...
s, 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 Julius Wilhelm Richard Dedekind (6 October 1831 – 12 February 1916) was a German mathematician who made important contributions to number theory, abstract algebra (particularly ring theory), and the axiomatic foundations of arithmetic. His ...
'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 Primitive recursive arithmetic (PRA) is a quantifier-free formalization of the natural numbers. It was first proposed by Norwegian mathematician , reprinted in translation in as a formalization of his finitist conception of the foundations of ...
was first proposed by
Thoralf Skolem Thoralf Albert Skolem (; 23 May 1887 – 23 March 1963) was a Norwegian mathematician who worked in mathematical logic and set theory. Life Although Skolem's father was a primary school teacher, most of his extended family were farmers. Skolem ...
Thoralf Skolem Thoralf Albert Skolem (; 23 May 1887 – 23 March 1963) was a Norwegian mathematician who worked in mathematical logic and set theory. Life Although Skolem's father was a primary school teacher, most of his extended family were farmers. 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.
in 1923. The current terminology was coined by
Rózsa Péter Rózsa Péter, born Rózsa Politzer, (17 February 1905 – 16 February 1977) was a Hungarian mathematician and logician. She is best known as the "founding mother of recursion theory". Early life and education Péter was born in Budapest, ...
(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.


See also

* Grzegorczyk hierarchy *
Recursion (computer science) In computer science, recursion is a method of solving a computational problem where the solution depends on solutions to smaller instances of the same problem. Recursion solves such recursive problems by using functions that call themselves ...
*
Primitive recursive functional In mathematical logic, the primitive recursive functionals are a generalization of primitive recursive functions into higher type theory. They consist of a collection of functions in all pure finite types. The primitive recursive functionals are ...
*
Double recursion In recursive function theory, double recursion is an extension of primitive recursion which allows the definition of non-primitive recursive functions like the Ackermann function. Raphael M. Robinson called functions of two natural number variabl ...
* Primitive recursive set function *
Primitive recursive ordinal function In mathematics, primitive recursive set functions or primitive recursive ordinal functions are analogs of primitive recursive functions, defined for sets or ordinals rather than natural numbers. They were introduced by . Definition A primiti ...


Notes


References

* Brainerd, W.S., Landweber, L.H. (1974), ''Theory of Computation'', Wiley, * * Robert I. Soare, ''Recursively Enumerable Sets and Degrees'', Springer-Verlag, 1987. *
Stephen Kleene Stephen Cole Kleene ( ; January 5, 1909 – January 25, 1994) was an American mathematician. One of the students of Alonzo Church, Kleene, along with Rózsa Péter, Alan Turing, Emil Post, and others, is best known as a founder of the branch of ...
(1952) ''Introduction to Metamathematics'', North-Holland Publishing Company, New York, 11th reprint 1971: (2nd edition notes added on 6th reprint). In Chapter XI. General Recursive Functions §57 *
George Boolos George Stephen Boolos (; 4 September 1940 – 27 May 1996) was an American philosopher and a mathematical logician who taught at the Massachusetts Institute of Technology. Life Boolos is of Greek- Jewish descent. He graduated with an A.B. ...
, John Burgess,
Richard Jeffrey Richard Carl Jeffrey (August 5, 1926 – November 9, 2002) was an American philosopher, logician, and probability theorist. He is best known for developing and championing the philosophy of radical probabilism and the associated heuristic of ...
(2002), ''Computability and Logic: Fourth Edition'', Cambridge University Press, Cambridge, UK. Cf pp. 70–71. * Robert I. Soare 1995 ''Computability and Recursion'' http://www.people.cs.uchicago.edu/~soare/History/compute.pdf * Daniel Severin 2008, ''Unary primitive recursive functions'', J. Symbolic Logic Volume 73, Issue 4, pp. 1122–113
arXivprojecteuclid
{{Mathematical logic Computability theory Theory of computation Functions and mappings Recursion