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 in a formal one. If the function is total, it is also called a total recursive function. In computability theory, it is shown that the μ-recursive functions are precisely the functions that can be computed by Turing machines. The μ-recursive functions are closely related to primitive recursive functions, and their inductive definition 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 is known in computational complexity theory as the complexity class R.
Definition
The μ-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 minimization operator.The smallest class of functions including the initial functions and closed under composition and primitive recursion 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 : For each natural number and every
- ::
- :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:
- ::
- Projection function : For all natural numbers such that :
- ::
- Composition operator : Given an m-ary function and m k-ary functions :
- ::
- :This means that is defined only if and are all defined.
- Primitive recursion operator : Given the k-ary function and k+2 -ary function :
- ::
- :This means that is defined only if and are defined for all
- Minimization operator : Given a -ary function, the k-ary function is defined by:
- ::
While some textbooks use the μ-operator as defined here, others demand that the μ-operator is applied to total functions 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. The only difference is, that it becomes undecidable whether a specific function definition defines a μ-recursive function, as it is undecidable whether a computable function is total.
The strong equality relation can be used to compare partial μ-recursive functions. This is defined for all partial functions f and g so that
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.
Examples
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.
The following examples define general recursive functions that are not primitive recursive; hence they cannot avoid using the minimization operator.
Total recursive function
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 computability
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".
Normal form theorem
A normal form theorem due to Kleene says that for each k there are primitive recursive functions and such that for any μ-recursive function with k free variables there is an e such thatThe number e is called an index or Gödel number for the function f. A consequence of this result is that any μ-recursive function can be defined using a single instance of the μ operator applied to a primitive recursive function.
Minsky observes the defined above is in essence the μ-recursive equivalent of the universal Turing machine:
Symbolism
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 is abbreviated as :- Constant function: Kleene uses "" and Boolos-Burgess-Jeffrey use the abbreviation "":
- Successor function: Kleene uses and for "Successor". As "successor" is considered to be primitive, most texts use the apostrophe as follows:
- Identity function: Kleene uses to indicate the identity function over the variables ; B-B-J use the identity function over the variables to :
- Composition operator: Kleene uses a bold-face . The superscript refers to the function, whereas the subscript refers to the variable :
- Primitive Recursion: Kleene uses the symbol where n indicates the number of variables; B-B-J use. Given:
He arrives at: