Parameterization Theorem

Theorem
Let $m, n \in \N$ be natural numbers.

There exists a primitive recursive function $S^m_n : \N^{m + n} \to \N$ such that, for $e, x_1, \dotsc, x_m$:


 * If $e$ is not the code for a URM program, $\map {S^m_n} {e, x_1, \dotsc, x_m} = 0$


 * Otherwise, let $P$ be that program.
 * Let $f$ be the $m + n$-arity function computed by $P$.
 * Then $\map {S^m_n} {e, x_1, \dotsc, x_m}$ is the code for a URM program $P'$ computing a function $g : \N^n \to \N$, such that:
 * $\map g {y_1, \dotsc, y_n} = \map f {x_1, \dotsc, x_m, y_1, \dotsc, y_n}$ whenever $f$ is defined, and undefined otherwise.

Proof
Let $N$ be an abbreviation for:
 * $m + n + x_1 + \dotso + x_m$

in the following definition.

Define:
 * $\map {S^m_n} {e, x_1, \dotsc, x_m} = \begin{cases}

{\map p 1}^{\map \beta {\map C {n, m + n}}} \times \dotso \times {\map p n}^{\map \beta {\map C {1, 1 + m}}} \times {\map p {1 + n}}^{\map \beta {\map Z 1}} \times \dotso \times {\map p {m + n}}^{\map \beta {\map Z m}} \\ \ds \times \prod_{i = 1}^{x_1} {\map p {m + n + i}}^6 \times \dotso \times \prod_{i = 1}^{x_m} {\map p {m + n + x_1 + \dotso + x_{m - 1} + i}}^{6 \times m} \\ \ds \times \prod_{i = 1}^{\map {\operatorname{len}} {\map {\operatorname{Offset}} {e, N}} {\dot -} N} {\map p { + i}}^{\paren {\map {\operatorname{Offset}} {e, N}}_{N + i}} & : e \in \texttt{Prog} \\ 0 & : e \notin \texttt{Prog} \end{cases}$

First, observe that ellipses each range over either $m$ or $n$.

As these are fixed, the formula is indeed closed.

When $e$ is a code for a program, the value of the function is a product of distinct prime powers.

Thus, when interpreted as a program, each power is the code number for an instruction.
 * The first $n$ instructions are:
 * $\map C {n - k + 1, n + m - k + 1}$


 * The next $m$ instructions are:
 * $\map Z k$


 * Next, for each $i$, there are $x_i$ copies of:
 * $\map S i$


 * The remaining instructions are copied from the result of calling $\operatorname {Offset}$