Function Obtained by Primitive Recursion from URM Computable Functions

Theorem
Let the functions $$f: \N^k \to \N$$ and $$g: \N^{k+2} \to \N$$ be URM computable functions.

Let $$h: \N^{k+1} \to \N$$ be obtained from $$f$$ and $$g$$ by primitive recursion.

Then $$h$$ is also URM computable.

Proof
From the definition:
 * $$\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} $$

Let $$P$$ and $$Q$$ be normalized URM programs which compute $$f$$ and $$g$$ respectively.

Let $$s = \lambda \left({P}\right)$$ and $$t = \lambda \left({Q}\right)$$ be the number of basic instructions in $$P$$ and $$Q$$.

Let $$u = \max \left\{{\rho \left({P}\right), \rho \left({Q}\right), k+2}\right\}$$.

Thus registers $$R_{u+1}, R_{u+2}, \ldots$$ are neither used by $$P$$ nor $$Q$$ nor for input.

So they can be used for storing values.

The following algorithm can be followed to create a URM program $$H$$ to compute $$h$$.

We assume that the input is $$\left({n_1, n_2, \ldots, n_k, n}\right)$$, which is held in $$R_1, R_2, \ldots, R_k, R_{k+1}$$.

The plan is that the program will compute $$h \left({n_1, n_2, \ldots, n_k, i}\right)$$ for $$i = 0, 1, 2, \ldots, n$$ in order.

At the end of the last iteration, $$h \left({n_1, n_2, \ldots, n_k, n}\right)$$ will be left in $$R_1$$.

We are to use the following registers:
 * $$R_{u+1}, R_{u+2}, \ldots, R_{u+k+1}$$ will be used to store the input $$\left({n_1, n_2, \ldots, n_k, n}\right)$$ so it does not get overwritten. We note that $$R_{u+k+1}$$ will hold the value of $$n$$.
 * $$R_{u+k+2}$$ will hold the current value of the recursion variable $$i$$.

When $$r_{u+k+2} = r_{u+k+1}$$, the computation will have ended.

The program $$H$$ finally looks like this:

It can easily be determined that $$H$$ computes $$h$$.

Hence $$h$$ is URM computable.

Comment
Note that there are two things going on here. The first table is an algorithm for creating the program, the second table is the program itself.