Single Instruction URM Programs

Basic Primitive Recursive Functions
The basic primitive recursive functions are URM computable by a single-instruction URM program:

Identity Function
No other functions $f: \N^k \to \N$ can be computed using a single-instruction URM program.

Proof
Apart from the programs given, the only other single-instruction programs are of the form:

The convention is that, at the start of the program, $R_1$ contains the input, and all other registers contain $0$.

Suppose $q > 1$.

Then whatever $m$ or $n$ are, the program either jumps to $q$ (a location outside the program) or steps one instruction.

In either case the program stops without changing what is in $R_1$.

Hence this is another way of computing the identity function $I_\N$.

Suppose $q = 1$.

If $m = n$, then whatever is held in the registers, $r_m = r_n$ and the program will go back to execute step 1 again.

Thus the program will loop round and do step 1 endlessly, and never terminate.

If $m \ne n$, then the program's behaviour depends on the contents of $R_n$ and $R_m$.

If $m = 1$ and $n \ne 1$, then the program will compare the input against the contents of $r_n$.

If $r_1 = 0$ the program will go into an endless loop, and never terminate.

Otherwise, i.e. if $r_1 \ne 0$, the program will never terminate with $r_1$ unchanged.

If $m \ne 1$ and $n \ne 1$ then the program will once more never terminate, as $r_m = r_n = 0$ at the start of the program.

So the program:

does not specify a URM computable function, as:
 * when $m = n$ the program will never terminate for any input;
 * when $m \ne n, m = 1$ the program will never terminate on input $0$;
 * when $m \ne n, n = 1$ the program similarly will never terminate on input $0$;
 * when $m \ne n, m \ne 1, n \ne 1$ the program will never terminate for any input.

In all cases there is at least one input for which the program will never terminate.

The result follows from the definition of URM computability.