[step:Fix the computability definitions and the auxiliary functions $f_1, f_2, f_3$]
Let $\mathbb{W} = \Sigma^*$ be the word monoid over a fixed finite alphabet $\Sigma$ with at least one letter $a \in \Sigma$. For $X \subseteq \mathbb{W}^k$:
- $X$ is [computable](/pages/???) iff its *characteristic function*
\begin{align*}
\mathbb{1}_X : \mathbb{W}^k &\to \mathbb{W}, \\
w &\mapsto \begin{cases} a & w \in X, \\ \varepsilon & w \notin X, \end{cases}
\end{align*}
is a computable total function, where $a$ and $\varepsilon$ are treated as fixed representative words for "true" and "false".
- $X$ is [computably enumerable](/pages/???) (c.e.) iff its *semi-characteristic function*
\begin{align*}
\psi_X : \mathbb{W}^k &\rightharpoonup \mathbb{W}, \\
w &\mapsto \begin{cases} a & w \in X, \\ \text{undefined} & w \notin X, \end{cases}
\end{align*}
is a computable partial function.
For a register machine $M$ and register count $k$, write $f_{M, k} : \mathbb{W}^k \rightharpoonup \mathbb{W}$ for the partial function it computes on inputs in $\mathbb{W}^k$; then $\operatorname{dom} f_{M, k}$ is the set of inputs on which $M$ halts.
We work with $k = 1$ for clarity; the case of general $k$ follows the same argument since register machines are defined for arbitrary finite register counts and each reference to "input $w$" becomes "input tuple $w = (w_1, \ldots, w_k)$" without further modification.
Define three total or partial functions, all computable by explicit register machines:
- The *flip*
\begin{align*}
f_1 : \mathbb{W} &\to \mathbb{W}, \\
w &\mapsto \begin{cases} \varepsilon & w \ne \varepsilon, \\ a & w = \varepsilon. \end{cases}
\end{align*}
- The *return-$a$-on-nonempty* total function
\begin{align*}
f_2 : \mathbb{W} &\to \mathbb{W}, \\
w &\mapsto \begin{cases} a & w \ne \varepsilon, \\ \varepsilon & w = \varepsilon. \end{cases}
\end{align*}
- The *loop-on-empty* partial function
\begin{align*}
f_3 : \mathbb{W} &\rightharpoonup \mathbb{W}, \\
w &\mapsto \begin{cases} a & w \ne \varepsilon, \\ \text{undefined} & w = \varepsilon. \end{cases}
\end{align*}
[claim:$f_1, f_2, f_3$ are computable]
We construct a register machine for each.
- *Machine for $f_1$*: test whether register $0$ is empty. This test is a single read instruction which branches on the first letter of register $0$ (or on the letter $\varepsilon$, which by convention signals an empty register). If empty, write $a$ to register $0$ and halt; if non-empty, erase register $0$ and halt. This is a [case distinction](/theorems/1812) on the question "is register $0$ empty?", whose answers are the two cases; each arm is a finite program performing a fixed register operation.
- *Machine for $f_2$*: same structure with the outputs swapped. If register $0$ is empty, leave it alone; if non-empty, erase register $0$, then write $a$ to it; in both cases halt.
- *Machine for $f_3$*: test whether register $0$ is empty. If non-empty, erase and write $a$, then halt; if empty, enter a self-loop (e.g., an instruction that increments an unused register and loops back). The self-loop forms an infinite computation on input $\varepsilon$, so $f_3$ is undefined at $\varepsilon$ and defined with value $a$ elsewhere.
Each machine is finite and realises the claimed function by direct inspection of its branching structure.
[/claim]
[/step]