3) Construct a standard, deterministic, one-tape Turing machine M to compute each of the following functions:
a) The function sub3, which is defined as follows: sub3(n) = n - 3 if n > 2, 0 if n <= 2. Specifically, compute sub3 of a natural number represented in binary. For example, on input 10111, M should output 10100. On input 11101, M should output 11010. Hint: you may want to define a subroutine.
Chapter 17
298
Turing Machines
b) Addition of two binary natural numbers (as described in Example 17.13). Specifically, given the input string <x><y>, where <x> is the binary encoding of a natural number x and <y> is the binary encoding of a natural number y, M should output <z>, where z is the binary encoding of x + y. For example, on input 10111, M should output 1000.
c) Multiplication of two unary numbers. Specifically, given the input string <x><y>, where <x> is the unary encoding of a natural number x and <y> is the unary encoding of a natural number y, M should output <z>, where z is the unary encoding of x * y. For example, on input 111;1111, M should output 111111111111.
d) The proper subtraction function monus, which is defined as follows: u < v → u - v = (u u) s n u o u, 0 if n ≤ m. Specifically, compute monus of two natural numbers represented in binary. For example, on input 101;11, M should output 1. On input 11;101, M should output 0.