Definition:Primitive Recursion

Primitive Recursion on Several Variables
Let $f: \N^k \to \N$ and $g: \N^{k+2} \to \N$ be functions.

Let $\left({n_1, n_2, \ldots, n_k}\right) \in \N^k$.

Then the function $h: \N^{k+1} \to \N$ is obtained from $f$ and $g$ by primitive recursion if:
 * $\forall n \in \N: h \left({n_1, n_2, \ldots, n_k, n}\right) = \begin{cases}

f \left({n_1, n_2, \ldots, n_k}\right) & : n = 0 \\ g \left({n_1, n_2, \ldots, n_k, n-1, h \left({n_1, n_2, \ldots, n_k, n-1}\right)}\right) & : n > 0 \end{cases}$

Primitive Recursion on One Variable
Let $a \in \N$ be a natural number.

Let $g: \N^2 \to \N$ be a function.

Then the function $h: \N \to \N$ is obtained from the constant $a$ and $g$ by primitive recursion if:
 * $\forall n \in \N: h \left({n}\right) = \begin{cases}

a & : n = 0 \\ g \left({n-1, h \left({n-1}\right)}\right) & : n > 0 \end{cases}$

It can be seen that this is a special case of primitive recursion on several variables, with $k = 0$ and $f$ replaced by the constant function $f_a$.

Primitive Recursion on Partial Functions
Let $f: \N^k \to \N$ and $g: \N^{k+2} \to \N$ be partial functions.

Let $\left({n_1, n_2, \ldots, n_k}\right) \in \N^k$.

Then the partial function $h: \N^{k+1} \to \N$ is obtained from $f$ and $g$ by primitive recursion if:
 * $\forall n \in \N: h \left({n_1, n_2, \ldots, n_k, n}\right) \approx \begin{cases}

f \left({n_1, n_2, \ldots, n_k}\right) & : n = 0 \\ g \left({n_1, n_2, \ldots, n_k, n-1, h \left({n_1, n_2, \ldots, n_k, n-1}\right)}\right) & : n > 0 \end{cases}$

where $\approx$ is as defined in Partial Function Equality.

Note that $h \left({n_1, n_2, \ldots, n_k, n}\right)$ is defined only when:
 * $h \left({n_1, n_2, \ldots, n_k, n - 1}\right)$ is defined
 * $g \left({n_1, n_2, \ldots, n_k, n-1, h \left({n_1, n_2, \ldots, n_k, n-1}\right)}\right)$ is defined.