Skip to content

10.1 Recursive Functions

Primitive recursive functions, general recursive functions, minimization, and the formal construction of computable numerical functions.

Recursive function theory gives a mathematical definition of computable numerical functions by specifying basic functions and closure operations that generate increasingly complex functions from simple ones, and this framework allows one to reason about computation purely within arithmetic.

All functions considered in this section have inputs and outputs in the natural numbers:

N={0,1,2,}. \mathbb{N} = \{0,1,2,\dots\}.

An nn ary function is written:

f:NnN, f : \mathbb{N}^n \to \mathbb{N},

and the number nn is called the arity of the function.

Initial Functions

We begin with three basic types of functions, which are taken as primitive building blocks.

Definition 10.1 (Zero Function)

For each n1n \geq 1, the zero function is:

Zn:NnN,Zn(x1,,xn)=0. Z_n : \mathbb{N}^n \to \mathbb{N}, \quad Z_n(x_1,\dots,x_n)=0.

Definition 10.2 (Successor Function)

The successor function is:

S:NN,S(x)=x+1. S : \mathbb{N} \to \mathbb{N}, \quad S(x)=x+1.

Definition 10.3 (Projection Functions)

For 1in1 \leq i \leq n, define:

Pin:NnN,Pin(x1,,xn)=xi. P_i^n : \mathbb{N}^n \to \mathbb{N}, \quad P_i^n(x_1,\dots,x_n)=x_i.

Composition

Definition 10.4 (Composition)

Let:

g:NkN g : \mathbb{N}^k \to \mathbb{N}

and:

h1,,hk:NnN. h_1,\dots,h_k : \mathbb{N}^n \to \mathbb{N}.

Define:

f(x1,,xn)=g(h1(x1,,xn),,hk(x1,,xn)). f(x_1,\dots,x_n) = g\big(h_1(x_1,\dots,x_n),\dots,h_k(x_1,\dots,x_n)\big).

Then ff is obtained from gg and the hih_i by composition.

Primitive Recursion

Definition 10.5 (Primitive Recursion)

Let:

g:NnN,h:Nn+2N. g : \mathbb{N}^n \to \mathbb{N}, \quad h : \mathbb{N}^{n+2} \to \mathbb{N}.

Define:

f:Nn+1N f : \mathbb{N}^{n+1} \to \mathbb{N}

by:

f(x1,,xn,0)=g(x1,,xn), f(x_1,\dots,x_n,0)=g(x_1,\dots,x_n),

f(x1,,xn,y+1)=h(x1,,xn,y,f(x1,,xn,y)). f(x_1,\dots,x_n,y+1) = h(x_1,\dots,x_n,y,f(x_1,\dots,x_n,y)).

Definition 10.6 (Primitive Recursive Function)

The class of primitive recursive functions is the smallest class containing ZnZ_n, SS, and PinP_i^n, and closed under composition and primitive recursion.

Example 10.7 (Addition)

Define:

add(x,0)=x, \operatorname{add}(x,0)=x,

add(x,y+1)=S(add(x,y)). \operatorname{add}(x,y+1)=S(\operatorname{add}(x,y)).

Then addition is primitive recursive.

Proof

The base function is:

g(x)=x=P11(x). g(x)=x=P_1^1(x).

The step function is:

h(x,y,z)=S(z)=S(P33(x,y,z)). h(x,y,z)=S(z)=S(P_3^3(x,y,z)).

Both are primitive recursive, so addition is primitive recursive.

Example 10.8 (Multiplication)

Define:

mul(x,0)=0, \operatorname{mul}(x,0)=0,

mul(x,y+1)=add(mul(x,y),x). \operatorname{mul}(x,y+1)=\operatorname{add}(\operatorname{mul}(x,y),x).

Proof

The base function is:

g(x)=0=Z1(x). g(x)=0=Z_1(x).

The step function is:

h(x,y,z)=add(z,x)=add(P33(x,y,z),P13(x,y,z)). h(x,y,z)=\operatorname{add}(z,x) = \operatorname{add}(P_3^3(x,y,z),P_1^3(x,y,z)).

Thus multiplication is primitive recursive.

Example 10.9 (Exponentiation)

Define:

exp(x,0)=1, \operatorname{exp}(x,0)=1,

exp(x,y+1)=mul(exp(x,y),x). \operatorname{exp}(x,y+1)=\operatorname{mul}(\operatorname{exp}(x,y),x).

Proof

The constant function 11 is primitive recursive since:

1=S(0)=S(Z1(x)). 1 = S(0) = S(Z_1(x)).

The step function:

h(x,y,z)=mul(z,x) h(x,y,z)=\operatorname{mul}(z,x)

is primitive recursive by composition.

Thus exponentiation is primitive recursive.

Definition 10.10 (Predecessor)

Define:

pred(0)=0, \operatorname{pred}(0)=0,

pred(y+1)=y. \operatorname{pred}(y+1)=y.

Lemma 10.11

The predecessor function is primitive recursive.

Proof

Use primitive recursion with:

g=0, g=0,

h(y,z)=y=P12(y,z). h(y,z)=y=P_1^2(y,z).

Thus pred\operatorname{pred} is primitive recursive.

Definition 10.12 (Truncated Subtraction)

Define truncated subtraction by:

x0=x, x - 0 = x,

x(y+1)=pred(xy). x - (y+1) = \operatorname{pred}(x - y).

This function agrees with ordinary subtraction when xyx \ge y, and returns 00 when x<yx < y, since repeated application of the predecessor function never produces negative values.

Lemma 10.13

Truncated subtraction is primitive recursive.

Proof

Base:

g(x)=x. g(x)=x.

Step:

h(x,y,z)=pred(z)=pred(P33(x,y,z)). h(x,y,z)=\operatorname{pred}(z)=\operatorname{pred}(P_3^3(x,y,z)).

Thus primitive recursive.

Definition 10.14 (Minimization)

Let:

f:Nn+1N. f : \mathbb{N}^{n+1} \to \mathbb{N}.

Define:

g(x1,,xn)=μy[f(x1,,xn,y)=0]. g(x_1,\dots,x_n) = \mu y \,[ f(x_1,\dots,x_n,y)=0 ].

This returns the least yy such that f(x1,,xn,y)=0f(x_1,\dots,x_n,y)=0, if such a yy exists, and is undefined otherwise.

Definition 10.15 (Partial Recursive Function)

The class of partial recursive functions is obtained from the initial functions by closure under composition, primitive recursion, and minimization.

Definition 10.16 (General Recursive Function)

A function is general recursive if it is partial recursive and defined for all inputs.

Theorem 10.17

Every primitive recursive function is general recursive.

Proof

Primitive recursive functions are built from the initial functions using composition and primitive recursion.

The class of partial recursive functions contains the initial functions and is closed under these operations.

Thus every primitive recursive function is partial recursive.

Since primitive recursive functions are total, they are general recursive.

Remarks

Primitive recursion captures computations that always terminate with a bounded number of steps determined by the input, while minimization introduces unbounded search and allows the definition of functions that may fail to terminate on some inputs, which leads naturally to the study of partial computable functions.