- Primitive recursive function
The

**primitive recursive functions**are defined using primitive recursion and composition as central operations and are a strictsubset of the recursive functions (recursive functions are also known ascomputable function s). The term was coined byRózsa Péter .In computability theory, primitive recursive functions are a class of functions which form an important building block on the way to a full formalization of computability. These functions are also important in

proof theory .Many of the functions normally studied in

number theory , and approximations to real-valued functions, are primitive recursive, such asaddition , division,factorial , exponential, finding the "n"th prime, and so on (Brainerd and Landweber, 1974). In fact, it is difficult to devise a function that is "not" primitive recursive, although some are known (see the section on Limitations below).The set of primitive recursive functions is known as PR in

complexity theory .Every primitive recursive function is a general recursive function.

**Definition**The primitive recursive functions are among the number-theoretic functions which are functions from the

natural number s (nonnegative integers) {0, 1, 2 , ...} to the natural numbers which take "n" arguments for some natural number "n". Such a function is called "n"-ary.The basic primitive recursive functions are given by these

axiom s:#

**Constant function**: The 0-ary constant function 0 is primitive recursive.

#**Successor function**: The 1-ary successor function "S", which returns the successor of its argument (seePeano postulates ), is primitive recursive. That is, "S"("k") = "k" + 1.

#**Projection function**: For every "n"≥1 and each "i" with 1≤"i"≤"n", the "n"-ary projection function "P"_{"i"}^{"n"}, which returns its "i"-th argument, is primitive recursive.More complex primitive recursive functions can be obtained by applying the

operator s given by these axioms:#

**Composition**: Given "f", a "k"-ary primitive recursive function, and "k" "m"-ary primitive recursive functions "g"_{1},...,"g"_{"k"}, the composition of "f" with "g"_{1},...,"g"_{"k"}, i.e. the "m"-ary function "h"("x"_{1},...,"x"_{"m"}) = "f"("g"_{1}("x"_{1},...,"x"_{"m"}),...,"g"_{"k"}("x"_{1},...,"x"_{"m"})), is primitive recursive.

#**Primitive recursion**: Given "f", a "k"-ary primitive recursive function, and "g", a ("k"+2)-ary primitive recursive function, the ("k"+1)-ary function defined as the primitive recursion of "f" and "g", i.e. the function "h" where "h"(0,"x"_{1},...,"x"_{"k"}) = "f"("x"_{1},...,"x"_{"k"}) and "h"("S"("n"),"x"_{1},...,"x"_{"k"}) = "g"("h"("n","x"_{1},...,"x"_{"k"}),"n","x"_{1},...,"x"_{"k"}), is primitive recursive.The

**primitive recursive**functions are the basic functions and those which can be obtained from the basic functions by applying the operators a finite number of times.**Role of the projection functions**The projection functions can be used to avoid the apparent rigidity in terms of the

arity of the functions above; by using compositions with various projection functions, it is possible to pass a subset of the arguments of one function to another function. For example, if "g" and "h" are 2-ary primitive recursive functions then:$f(a,b,c)\; =\; g(h(a,c),h(a,b))\; !$is also primitive recursive. One formal definition using projections functions is:$f(a,b,c)\; =\; g(h(P^3\_1(a,b,c),P^3\_3(a,b,c)),h(P^3\_1(a,b,c),P^3\_2(a,b,c)))$.**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 { t= true, f=false }, or which produce truth values as outputs (see Kleene [1952 pp.226-227] ). 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 literally 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.

**Examples**Most number-theoretic functions which can be defined using recursion on a single variable are primitive recursive. Basic examples include the addition and "limited subtraction" functions.

**Addition**Intuitively, addition can be recursively defined with the rules:

:add(0,"x")="x",:add("n"+1,"x")=add("n","x")+1.

In order to fit this into a strict primitive recursive definition, define:

:add(0,"x")="P"

_{1}^{1}("x") ,:add(S("n"),"x")="S"("P"_{1}^{3}(add("n","x"),"n","x")).Here "P"_{1}^{3}is theprojection function that takes 3 arguments and returns the first one."P"

_{1}^{1}is simply theidentity function ; its inclusion is required by the definition of the primitive recursion operator above; it plays the role of "f". The composition of "S" and "P"_{1}^{3}, which is primitive recursive, plays the role of "g".**Subtraction**Because primitive recursive functions use natural numbers rather than integers, and the natural numbers are not closed under subtraction, a

**limited subtraction**function is studied in this context. This limited subtraction function sub("a","b") returns $b\; -\; a$ if this is nonnegative and returns "0" otherwise.The

**predecessor function**acts as the opposite of the successor function and is recursively defined by the rules::pred(0)=0,:pred("n"+1)="n".

These rules can be converted into a more formal definition by primitive recursion:

:pred(0)=0,:pred(S("n"))="P"

_{2}^{2}(pred("n"),"n").The limited subtraction function is definable from the predecessor function in a manner analogous to the way addition is defined from successor:

:sub(0,"x")="P"

_{1}^{1}("x"),:sub(S("n"),"x")=pred("P"_{1}^{3}(sub("n","x"),"n","x")).Here sub("a","b") corresponds to "b"-"a"; for the sake of simplicity, the order of the arguments has been switched from the "standard" definition to fit the requirements of primitive recursion. This could easily be rectified using composition with suitable projections.

Other primitive recursive functions include

exponentiation andprimality test ing. Given primitive recursive functions "e", "f", "g", and "h", a function which 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 number s, the primitive recursive functions can be extended to operate on other objects such as integers andrational number 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.**Relationship to recursive functions**The broader class of

partial recursive function s is defined by introducing an unbounded search operator. The use of this operator may result in apartial function , that is, a relation which has at most one value for each argument but, unlike a total function, does not necessarily have any value for an argument (see domain). An equivalent definition states that a partial recursive function is one that can be computed by aTuring machine . A total recursive function is a partial recursive function which 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 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 recursiveif 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.Fact|date=February 2007**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 computable function — this can be seen with a variant of

Cantor's diagonal argument . This argument provides a computable function which is not primitive recursive. A sketch of the proof is as follows::The primitive recursive functions can be computably numerated. This numbering is unique on the definitions of functions, though not unique on the actual functions themselves (as every function can have an infinite number of definitions — consider simply composing by the

identity function ). The numbering is computable in the sense that it can be defined under formal models of computability such as μ-recursive functions orTuring machine s; but an appeal to theChurch-Turing thesis is likely sufficient.:Now consider a matrix where the rows are the primitive recursive functions of one argument under this numbering, and the columns are the natural numbers. Then each element ("i", "j") corresponds to the "i"th unary primitive recursive function being calculated on the number "j". We can write this as "f"

_{"i"}("j").:Now consider the function "g"("x") = S("f"

_{"x"}("x")). "g" lies on the diagonal of this matrix and simply adds one to the value it finds. This function is computable (by the above), but clearly no primitive recursive function exists which computes it as it differs from each possible primitive recursive function by at least one value. Thus there must be computable functions which are not primitive recursive.This argument can be applied to any class of computable (total) functions that can be enumerated in this way, as explained in the article

Machines that always halt . Note however that the "partial" computable functions (those which need not be defined for all arguments) can be explicitly enumerated, for instance by enumeratingTuring machine encodings.Other examples of total recursive but not primitive recursive functions are known:

*The function which 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 which is not primitive recursive. Because this function is motivated byRamsey theory , it is sometimes considered more “natural” than the Ackermann function.**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 #22 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 { 0, 1, 2, ...} to { 0, 1, 2, ...},

# "predicates": from { 0, 1, 2, ...} to truth values { t =true, f =false },

# "propositional connectives": from truth values { t, f } to truth values { t, f },

# "representing functions": from truth values { t, f } to { 0, 1, 2, ... }. Many times a predicate requires a representing function to convert the predicate's output { t, f } to { 0, 1 } (note the order "t" to "0" and "f" to "1" matches with ~(sig( )) 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-21 and #G are of particular interest with respect to converting primitive recursive predicates to, and extracting them from, their "arithmetical" form expressed asGödel number s.:# Addition: a+b:# Multiplication: a×b:# Exponentiation: a

^{b,}:# Factorial a! : 0! = 1, a'! = a!×a' :# pred(a): Decrement: "predecessor of a" defined as "If a> 0 then a-1 → a_{new}else 0 → a.":# Proper subtraction: a ┴ b defined as "If a ≥ b then a-b else 0.":# Minimum (a_{1}, ... a_{n}):# Maximum (a_{1}, ... a_{n}):# Absolute value: | a-b | =_{defined}a ┴ b + b ┴ a :# ~sg(a): NOT [signum(a}] : If a=0 then sg(a)=1 else if a>0 then sg(a)=0:# sg(a): signum(a): If a=0 then sg(a)=0 else if a>0 then sg(a)=1:# "b divides a" [ a | b ] : If the remainder ( a, b )=0 then [ a | b ] else b does not divide a "evenly":# Remainder ( a, b ): the leftover if b does not divide a "evenly". Also called MOD(a, b):# s = b: sg | a - b

:# a < b: sg( a' ┴ b ):# Pr(a): a is a prime number Pr(a) =_{def}a>1 & NOT(Exists c)_{1 [ c|a ] :# Pi: the i+1-st prime number:# (a)i : exponent ai of pi =def μx [ x [pix|a & NOT(pi x'|a ] ; μx is the minimization operator described in #E below. :# lh(a): the "length" or number of non-vanishing exponents in a:# a×b: given the expression of a and b as prime factors then a×b is the product's expression as prime factors:# lo(x, y): logarithm of x to the base y}: "In the following, the abbreviation

**x**=_{def}x_{i}, ... x_{n}; subscripts may be applied if the meaning requires.* #A: A function φ definable explicitly from functions Ψ and constants q

_{1}, ... q_{n}is primitive recursive in Ψ.

* #B: The finite sum Σ_{y ψ(x, y) and product Πyψ(x, y) are primite 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): (Ey)y denotes "there exists at least one y -- given that y is less than z -- such that"::* (y)y R(x, y): (y) denotes "for all y -- given that y is 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 -- given y is less than z -- such that R(x, y) is true." * #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 which 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, NOT-φ(y; x2, ... xn ), x2, ... xn then φ is primitive recursive in χ. 'So, in a sense the knowledge of the value NOT-φ(y; x2 to n ) of the course-of-values function is equivalent to the knowledge of the sequence of values φ(0,x2 to n), ..., φ(y-1,x2 to n) of the original function."}**ee also***

Course-of-values recursion

*Machine that always halts

*Grzegorczyk hierarchy

*Recursion (computer science) **References*** Brainerd, W.S., Landweber, L.H. (1974), "Theory of Computation", Wiley, ISBN 0-471-09585-0

* Robert I. Soare, "Recursively Enumerable Sets and Degrees", Springer-Verlag, 1987. ISBN 0-387-15299-7

*Stephen Kleene (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 ,John Burgess ,Richard Jeffrey (2002), "Computability and Logic: Fourth Edition", Cambridge University Press, Cambridge, UK. Cf pp. 70-71.

*Wikimedia Foundation.
2010.*

### См. также в других словарях:

**Primitive recursive arithmetic**— Primitive recursive arithmetic, or PRA, is a quantifier free formalization of the natural numbers. It was first proposed by Skolem [Thoralf Skolem (1923) The foundations of elementary arithmetic in Jean van Heijenoort, translator and ed. (1967)… … Wikipedia**Recursive function**— may refer to: Recursion (computer science), a procedure or subroutine, implemented in a programming language, whose implementation references itself A total computable function, a function which is defined for all possible inputs See also μ… … Wikipedia**primitive recursive**— adjective Of a function, capable of being constructed from the zero function, successor function, and projection functions, by a finite number of applications of composition and recursion … Wiktionary**Μ-recursive function**— In mathematical logic and computer science, the μ recursive functions are a class of partial functions from natural numbers to natural numbers which are computable in an intuitive sense. In fact, in computability theory it is shown that the μ… … Wikipedia**μ-recursive function**— In mathematical logic and computer science, the μ recursive functions are a class of partial functions from natural numbers to natural numbers which are computable in an intuitive sense. In fact, in computability theory it is shown that the μ… … Wikipedia**Non-recursive function**— might refer to: Recursion (computer science): a procedure or subroutine, implemented in a programming language, whose implementation references itself μ recursive function, defined from a particular formal model of computable functions using… … Wikipedia**Recursive**— may refer to:*Recursion *Recursively enumerable language *Recursively enumerable set *Recursive filter *Recursive function *Recursive language *Recursive acronym *Recursive set *Primitive recursive function … Wikipedia**Function (mathematics)**— f(x) redirects here. For the band, see f(x) (band). Graph of example function, In mathematics, a function associates one quantity, the a … Wikipedia**Recursive set**— In computability theory, a set of natural numbers is called recursive, computable or decidable if there is an algorithm which terminates after a finite amount of time and correctly decides whether or not a given number belongs to the set. A more… … Wikipedia**recursive**— A procedure that is applied once, and then applied to the result of that application, and so on. A recursive definition (definition by induction) defines the result of some operation for 0, and then the result for any number n + 1 in terms of the … Philosophy dictionary