In
mathematical logic
Mathematical logic is the study of Logic#Formal logic, formal logic within mathematics. Major subareas include model theory, proof theory, set theory, and recursion theory (also known as computability theory). Research in mathematical logic com ...
and
computer science
Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, a general recursive function, partial recursive function, or μ-recursive function is a
partial function
In mathematics, a partial function from a set to a set is a function from a subset of (possibly the whole itself) to . The subset , that is, the '' domain'' of viewed as a function, is called the domain of definition or natural domain ...
from
natural number
In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
s 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). 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 since ex ...
, it is shown that the μ-recursive functions are precisely the functions that can be computed by
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 algori ...
s (this is one of the theorems that supports the
Church–Turing thesis
In Computability theory (computation), computability theory, the Church–Turing thesis (also known as computability thesis, the Turing–Church thesis, the Church–Turing conjecture, Church's thesis, Church's conjecture, and Turing's thesis) ...
). The μ-recursive functions are closely related to
primitive recursive function
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 befor ...
s, 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
In computability theory, the Ackermann function, named after Wilhelm Ackermann, is one of the simplest and earliest-discovered examples of a total function, total computable function that is not Primitive recursive function, primitive recursive. ...
.
Other equivalent classes of functions are the functions of
lambda calculus
In mathematical logic, the lambda calculus (also written as ''λ''-calculus) is a formal system for expressing computability, computation based on function Abstraction (computer science), abstraction and function application, application using var ...
and the functions that can be computed by
Markov algorithm
In theoretical computer science, a Markov algorithm is a string rewriting system that uses grammar-like rules to operate on strings of symbols. Markov algorithms have been shown to be Turing-complete, which means that they are suitable as a gen ...
s.
The subset of all ''total'' recursive functions with values in is known in
computational complexity theory
In theoretical computer science and mathematics, computational complexity theory focuses on classifying computational problems according to their resource usage, and explores the relationships between these classifications. A computational problem ...
as the
complexity class R.
Definition
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
minimization operator .
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
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 befor ...
. 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
In computability theory, the Ackermann function, named after Wilhelm Ackermann, is one of the simplest and earliest-discovered examples of a total function, total computable function that is not Primitive recursive function, primitive recursive. ...
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''
(also called the ''Identity function''): For all natural numbers
such that
:
#::
Operators (the
domain of a function
In mathematics, the domain of a function is the Set (mathematics), set of inputs accepted by the Function (mathematics), function. It is sometimes denoted by \operatorname(f) or \operatornamef, where is the function. In layman's terms, the doma ...
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''
(also called the ''substitution 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