A function is primitive-recursive if it can be constructed in finitely many steps from the following basic functions using composition and primitive recursion:
Composition: from primitive-recursive and , construct
Primitive recursion: from primitive-recursive and , construct
Here, denotes the input tuple. Thus the primitive-recursive functions form the smallest class containing the basic functions and closed under these two rules.
Totality and Computability
Every primitive-recursive function is total and computable: the basic functions terminate, composition combines terminating computations, and recursion on performs exactly recursive steps after the base case.
The converse does not hold: some total computable functions, such as the Ackermann function, are not primitive-recursive.
The base returns ; every step returns , independently of the previous result. Thus
Here, supplies the initial value, while the constant function ignores both the previous index and previous result . Equivalently, signum is the indicator function of the positive natural numbers: .
The predecessor function returns for and for . It is primitive-recursive, with
The base returns ; each step returns the previous index , ignoring the previous result. Thus
Here, is a constant with no arguments, and is a projection function. This total version is also called the truncated predecessor, since it stops at rather than becoming negative or undefined.
On Boolean inputs , the product is exactly when both inputs are , and otherwise. This uses multiplication directly; outside Boolean inputs, the product need not be a truth value.
Addition counts the true inputs; signum converts a positive count to . Thus
On Boolean inputs, the result is exactly when at least one input is . More generally, it returns exactly when at least one natural-number input is positive.