General recursive function
Template:Short description 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 in a formal one. If the function is total, it is also called a total recursive function (sometimes shortened to recursive function).<ref>Template:Cite book</ref> In computability theory, it is shown that the μ-recursive functions are precisely the functions that can be computed by Turing machines<ref>Stanford Encyclopedia of Philosophy, Entry Recursive Functions, Sect.1.7: "[The class of μ-recursive functions] turns out to coincide with the class of the Turing-computable functions introduced by Alan Turing as well as with the class of the λ-definable functions introduced by Alonzo Church."</ref><ref>Template:Cite journal Proof outline on p.153: <math>\lambda\mbox{-definable}</math> <math>\stackrel{triv}{\implies}</math> <math>\lambda\mbox{-}K\mbox{-definable}</math> <math>\stackrel{160}{\implies}</math> <math>\mbox{Turing computable}</math> <math>\stackrel{161}{\implies}</math> <math>\mu\mbox{-recursive}</math> <math>\stackrel{Kleene}{\implies}</math><ref>Template:Cite journal</ref> <math>\lambda\mbox{-definable}</math></ref> (this is one of the theorems that supports the Church–Turing thesis). The μ-recursive functions are closely related to primitive recursive functions, and their inductive definition (below) builds upon that of the primitive recursive functions. However, not every total recursive function is a primitive recursive function—the most famous example is the Ackermann function.
Other equivalent classes of functions are the functions of lambda calculus and the functions that can be computed by Markov algorithms.
The subset of all total recursive functions with values in Template:Math is known in computational complexity theory as the complexity class R.
DefinitionEdit
The μ-recursive functions (or general recursive functions) are partial functions that take finite tuples of natural numbers and return a single natural number. They are the smallest class of partial functions that includes the initial functions and is closed under composition, primitive recursion, and the [[μ operator|minimization operator Template:Mvar]].
The smallest class of functions including the initial functions and closed under composition and primitive recursion (i.e. without minimisation) is the class of primitive recursive functions. While all primitive recursive functions are total, this is not true of partial recursive functions; for example, the minimisation of the successor function is undefined. The primitive recursive functions are a subset of the total recursive functions, which are a subset of the partial recursive functions. For example, the Ackermann function can be proven to be total recursive, and to be non-primitive.
Primitive or "basic" functions:
- Constant functions Template:Mvar: For each natural number Template:Mvar and every Template:Mvar
- <math>C_n^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\ n</math>
- Alternative definitions use instead a zero function as a primitive function that always returns zero, and build the constant functions from the zero function, the successor function and the composition operator.
- Successor function S:
- <math>S(x) \ \stackrel{\mathrm{def}}{=}\ x + 1\,</math>
- Projection function <math>P_i^k</math> (also called the Identity function): For all natural numbers <math>i, k</math> such that <math>1\le i\le k</math>:
- <math>P_i^k(x_1,\ldots,x_k) \ \stackrel{\mathrm{def}}{=}\ x_i \, .</math>
Operators (the domain of a function defined by an operator is the set of the values of the arguments such that every function application that must be done during the computation provides a well-defined result):
- Composition operator <math>\circ\,</math> (also called the substitution operator): Given an m-ary function <math>h(x_1,\ldots,x_m)\,</math> and m k-ary functions <math>g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots, x_k)</math>:
- <math>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)).</math>
- This means that <math>f(x_1,\ldots,x_k)</math> is defined only if <math>g_1(x_1,\ldots,x_k),\ldots, g_m(x_1,\ldots,x_k),</math> and <math>h(g_1(x_1,\ldots,x_k),\ldots,g_m(x_1,\ldots,x_k))</math> are all defined.
- Primitive recursion operator Template:Mvar: Given the k-ary function <math>g(x_1,\ldots,x_k)\,</math> and k+2 -ary function <math>h(y,z,x_1,\ldots,x_k)\,</math>:
- <math>\begin{align}
\rho(g, h) &\ \stackrel{\mathrm{def}}{=}\ f \quad\text{where the k+1 -ary function } f \text{ is defined by}\\ f(0,x_1,\ldots,x_k) &= g(x_1,\ldots,x_k) \\ f(S(y),x_1,\ldots,x_k) &= h(y,f(y,x_1,\ldots,x_k),x_1,\ldots,x_k)\,.\end{align}</math>
- This means that <math>f(y,x_1,\ldots,x_k)</math> is defined only if <math>g(x_1,\ldots,x_k)</math> and <math>h(z,f(z,x_1,\ldots,x_k),x_1,\ldots,x_k)</math> are defined for all <math>z<y.</math>
- Minimization operator Template:Mvar: Given a (k+1)-ary function <math>f(y, x_1, \ldots, x_k)\,</math>, the k-ary function <math>\mu(f)</math> is defined by:
- <math>\begin{align}
\mu(f)(x_1, \ldots, x_k) = z \stackrel{\mathrm{def}}{\iff}\ f(i, x_1, \ldots, x_k)&>0 \quad \text{for}\quad i=0, \ldots, z-1 \quad\text{and}\\ f(z, x_1, \ldots, x_k)&=0\quad
\end{align}</math> Intuitively, minimisation seeks—beginning the search from 0 and proceeding upwards—the smallest argument that causes the function to return zero; if there is no such argument, or if one encounters an argument for which Template:Mvar is not defined, then the search never terminates, and <math> \mu(f)</math> is not defined for the argument <math>(x_1, \ldots, x_k).</math>
While some textbooks use the μ-operator as defined here,<ref name="Enderton.1972">Enderton, H. B., A Mathematical Introduction to Logic, Academic Press, 1972</ref><ref name="Boolos.Burgess.Jeffrey.2007">Boolos, G. S., Burgess, J. P., Jeffrey, R. C., Computability and Logic, Cambridge University Press, 2007</ref> others<ref name="Jones.1997">Jones, N. D., Computability and Complexity: From a Programming Perspective, The MIT Press, Cambridge, Massachusetts, London, England, 1997</ref><ref>Kfoury, A. J., R. N. Moll, and M. A. Arbib, A Programming Approach to Computability, 2nd ed., Springer-Verlag, Berlin, Heidelberg, New York, 1982</ref> demand that the μ-operator is applied to total functions Template:Mvar only. Although this restricts the μ-operator as compared to the definition given here, the class of μ-recursive functions remains the same, which follows from Kleene's Normal Form Theorem (see below).<ref name="Enderton.1972"/><ref name="Boolos.Burgess.Jeffrey.2007"/> The only difference is, that it becomes undecidable whether a specific function definition defines a μ-recursive function, as it is undecidable whether a computable (i.e. μ-recursive) function is total.<ref name="Jones.1997"/>
The strong equality relation <math>\simeq</math> can be used to compare partial μ-recursive functions. This is defined for all partial functions f and g so that
- <math>f(x_1,\ldots,x_k) \simeq g(x_1,\ldots,x_l)</math>
holds if and only if for any choice of arguments either both functions are defined and their values are equal or both functions are undefined.
ExamplesEdit
Examples not involving the minimization operator can be found at Primitive recursive function#Examples.
The following examples are intended just to demonstrate the use of the minimization operator; they could also be defined without it, albeit in a more complicated way, since they are all primitive recursive. Template:Unordered list The following examples define general recursive functions that are not primitive recursive; hence they cannot avoid using the minimization operator. Template:Unordered list
Total recursive functionEdit
A general recursive function is called total recursive function if it is defined for every input, or, equivalently, if it can be computed by a total Turing machine. There is no way to computably tell if a given general recursive function is total - see Halting problem.
Equivalence with other models of computabilityEdit
In the equivalence of models of computability, a parallel is drawn between Turing machines that do not terminate for certain inputs and an undefined result for that input in the corresponding partial recursive function. The unbounded search operator is not definable by the rules of primitive recursion as those do not provide a mechanism for "infinite loops" (undefined values).
Normal form theoremEdit
A normal form theorem due to Kleene says that for each k there are primitive recursive functions <math>U(y)\!</math> and <math>T(y,e,x_1,\ldots,x_k)\!</math> such that for any μ-recursive function <math>f(x_1,\ldots,x_k)\!</math> with k free variables there is an e such that
- <math>f(x_1,\ldots,x_k) \simeq U(\mu(T)(e,x_1,\ldots,x_k))</math>.
The number e is called an index or Gödel number for the function f.<ref>Template:Cite journal</ref>Template:Rp A consequence of this result is that any μ-recursive function can be defined using a single instance of the μ operator applied to a (total) primitive recursive function.
Minsky observes the <math>U</math> defined above is in essence the μ-recursive equivalent of the universal Turing machine:
<templatestyles src="Template:Blockquote/styles.css" />
To construct U is to write down the definition of a general-recursive function U(n, x) that correctly interprets the number n and computes the appropriate function of x. to construct U directly would involve essentially the same amount of effort, and essentially the same ideas, as we have invested in constructing the universal Turing machine Template:Sfn{{#if:|{{#if:|}}
— {{#if:|, in }}Template:Comma separated entries}}
{{#invoke:Check for unknown parameters|check|unknown=Template:Main other|preview=Page using Template:Blockquote with unknown parameter "_VALUE_"|ignoreblank=y| 1 | 2 | 3 | 4 | 5 | author | by | char | character | cite | class | content | multiline | personquoted | publication | quote | quotesource | quotetext | sign | source | style | text | title | ts }}
SymbolismEdit
A number of different symbolisms are used in the literature. An advantage to using the symbolism is a derivation of a function by "nesting" of the operators one inside the other is easier to write in a compact form. In the following the string of parameters x1, ..., xn is abbreviated as x:
- Constant function: Kleene uses " CTemplate:Su(x) = q " and Boolos-Burgess-Jeffrey (2002) (B-B-J) use the abbreviation " constn( x) = n ":
- e.g. CTemplate:Su ( r, s, t, u, v, w, x ) = 13
- e.g. const13 ( r, s, t, u, v, w, x ) = 13
- Successor function: Kleene uses x' and S for "Successor". As "successor" is considered to be primitive, most texts use the apostrophe as follows:
- S(a) = a +1 =def a', where 1 =def 0', 2 =def 0 ' ', etc.
- Identity function: Kleene (1952) uses " UTemplate:Su " to indicate the identity function over the variables xi; B-B-J use the identity function idTemplate:Su over the variables x1 to xn:
- UTemplate:Su( x ) = idTemplate:Su( x ) = xi
- e.g. UTemplate:Su = idTemplate:Su ( r, s, t, u, v, w, x ) = t
- Composition (Substitution) operator: Kleene uses a bold-face STemplate:Su (not to be confused with his S for "successor" ! ). The superscript "m" refers to the mth of function "fm", whereas the subscript "n" refers to the nth variable "xn":
- If we are given h( x )= g( f1(x), ... , fm(x) )
- h(x) = STemplate:Su(g, f1, ... , fm )
- In a similar manner, but without the sub- and superscripts, B-B-J write:
- h(x')= Cn[g, f1 ,..., fm](x)
- Primitive Recursion: Kleene uses the symbol " Rn(base step, induction step) " where n indicates the number of variables, B-B-J use " Pr(base step, induction step)(x)". Given:
- base step: h( 0, x )= f( x ), and
- induction step: h( y+1, x ) = g( y, h(y, x),x )
- Example: primitive recursion definition of a + b:
- base step: f( 0, a ) = a = UTemplate:Su(a)
- induction step: f( b' , a ) = ( f ( b, a ) )' = g( b, f( b, a), a ) = g( b, c, a ) = c' = S(UTemplate:Su( b, c, a ))
- R2 { UTemplate:Su(a), S [ (UTemplate:Su( b, c, a ) ] }
- Pr{ UTemplate:Su(a), S[ (UTemplate:Su( b, c, a ) ] }
Example: Kleene gives an example of how to perform the recursive derivation of f(b, a) = b + a (notice reversal of variables a and b). He starts with 3 initial functions
- S(a) = a'
- UTemplate:Su(a) = a
- UTemplate:Su( b, c, a ) = c
- g(b, c, a) = S(UTemplate:Su( b, c, a )) = c'
- base step: h( 0, a ) = UTemplate:Su(a)
- induction step: h( b', a ) = g( b, h( b, a ), a )
He arrives at:
- a+b = R2[ UTemplate:Su, STemplate:Su(S, UTemplate:Su) ]
ExamplesEdit
See alsoEdit
ReferencesEdit
Template:Reflist Template:Refbegin
- On pages 210-215 Minsky shows how to create the μ-operator using the register machine model, thus demonstrating its equivalence to the general recursive functions.
External linksEdit
- Stanford Encyclopedia of Philosophy entry
- A compiler for transforming a recursive function into an equivalent Turing machine
ru:Рекурсивная функция (теория вычислимости)#Частично рекурсивная функция