Example of register machines

  1. "Never halt":

    • $f: \mathbb{W}^{n+1} \dashrightarrow \mathbb{W}^{n+1}$ with $\mathrm{dom}(f) = \emptyset$

    • Performed by $q_\mathrm{S}\mapsto +(0,a,q_\mathrm{S})$ (or any machine that does not have $q_\mathrm{H}$ in its instructions)

  2. "Halt without changing anything":

    • $f(\v w) = \v w$

    • Performed by $q_\mathrm{S} \mapsto {?}(0,ε,q_\mathrm{H},q_\mathrm{H})$

  3. "Is register $i$ empty?"

    • $A_0 = \sb{\v w}{w_i = ε}$, $A_1 = \sb{\v w}{w_i \neq ε}$

    • Performed by $q_\mathrm{S} \mapsto {?}(i, ε, \hat q_0, \hat q_1)$

  4. "Does register $i$ end with letter $a$?"

    • $A_0 = \sb{\v w}{\exists v\in \mathbb{W}(w_i = va)}$, $A_1 = \mathbb{W}^{n+1}\setminus A_0$

    • Performed by $q_\mathrm{S} \mapsto {?}(i,a,\hat q_0, \hat q_1)$

  5. "Delete the final letter in register $i$, if it exists"

    • $q_\mathrm{S} \mapsto -(i,q_\mathrm{H},q_\mathrm{H})$

  6. "Delete the content of register $i$"

    • $q_\mathrm{S} \mapsto -(i,q_\mathrm{H},q_\mathrm{S})$

  7. "Add $a$ to the end of register $i$"

    • $q_\mathrm{S} \mapsto +(i,a, q_\mathrm{H})$

  8. "Add $w = a_0 \ldots a_m$ to the end of register $i$"

  9. "Replace the content of register $i$ with $w$"

    • Empty register $i$ by (6)

    • Add $w$ by (8)

  10. "What is the final letter of register $i$?"

    • Let $Σ = \set{a_1, \ldots, a_k}$. This is a question with $k+1$ answers: $A_i = \sb{\v w}{\exists v (w_i = va_i)}$ for $i=1,\ldots,k$ and $A_0 = \sb{\v w}{w_i = ε}$.

    • Check using (4): if register $i$ end in letter $a_l$,

      • go to state $\hat q_l$.

    • Otherwise

      • if $l\neq k$, answer the next question;

      • if $l=k$, go to state $\hat q_0$.

  11. "Copy the final letter of register $i$ (if it exists) to register $j$"

    • Determine the final letter by (10).

    • If register $i$ is empty,

      • halt using (2).

    • If it is $\hat q_l$,

      • add $a_l$ at the end of register $j$ using (7).

  12. "Move the final letter of register $i$ (if it exists) to register $j$"

    • Check whether register $i$ is empty by (3). If so,

      • halt using (2).

    • Otherwise,

      • copy the final letter of register $i$ to register $j$ using (11),

      • and then delete the final letter in register $i$ using (5).

  13. "Move the content of register $i$ into register $j$ in reverse order"

    • If register $i$ is empty by (3),

      • halt using (2);

    • otherwise

      • Move the final letter of register $i$ to register $j$ using (12),

      • and repeat.

  14. "Move the content of register $i$ into register $j$"

    • Take an additional register $k$, which is first emptied using (6).

    • Move content of register $i$ into register $k$ in reverse order,

    • and then move content of register $k$ into register $j$ in reverse order using (13).

  15. "Copy the content of register $i$ into register $j$ in reverse order"

    • Take an additional register $k$, which is first emptied using (6).

    • Until register $i$ is empty,

      • copy the final letter of register $i$ to register $k$ using (11)

      • and move the final letter of register $i$ to register $j$ using (12).

    • Move the content of register $k$ to register $i$ in reverse order using (13).

  16. "Copy the content of register $i$ to register $j$"

    • Take an additional register $k$, which is first emptied using (6).

    • Copy the content of register $i$ into register $k$ in reverse order,

    • and then copy the content of register $k$ into register $j$ in reverse order using (15).