These problems all concern Turing machines and computability.
Question text is in black, solutions in blue.
Copy: Place a marker on the first character of w. Remember that character, move the head right past w and one blank, and copy the remembered character. Then repeatedly (1) go left to the marker, (2) move the marker right one character, (3) remember the character now marked, if any, (3) move right to the first blank past the second string, (4) copy the remembered character to the space with this blank. Once there is no character of w found in step (3), stop.
Successor: Move right to the low-order bit of n and change it. If you changed it from 0 to 1, stop, otherwise move left one space and change that character if any. Keep moving left and changing as long as you are changing 1's to 0's. If the 1 you have changed to a 0 is the high-order bit, write a 1, move to the right of the string, and write a new 0. (In this case the input n must have been a string of all 1's.)
Plus: This is easy on a three-tape machine, where the inputs are originally on the first and second tapes. Starting from the two low-order bits, add them, write the output to the third tape, remember the carry, move left on all three tapes, and repeat the process adding the carry to the two new bits. If you reach the high-order bits of the input and still have a carry, write a 1 and move the whole string written on the third tape one space to the right.
Times: The simplest thing to do, though not the most efficient, is
to execute the code while (y > 0) {out += x, y--;}
where
out
represents the value on the third tape, initially zero.
The steps of this algorithm can each be carried out as above.
Power: Similarly we can initialize out
to 1 and execute the
code while (y > 0) {out *= x; y--;}
, using the solution to
Times to implement the *=
.
Even: Assuming n is given in binary, move to its low-order bit and test it for 0.
Partial even: Same as for even except now halt if the low-order bit is 0 and run right forever if it is 1.
The simiulating TM will have a string on its tape to represent the contents of each row of the 2DTM's tape. These strings can be written on the simulating machine's single tape, with a marker between each. A marker on this tape indicates where the head is. To update the simulation for one step of the 2DTM we may have to:
If f is computed by N according to this definition, we can build a DTM D that will compute f where it is defined and never halt where it is not. D loops through all strings, testing each one as a choice-string for a run of N on input x. If N halts on one of these runs, D halts and reports N' answer as its answer. This answer is correct because no other run of N on this input produces a different output. If there is no choice-string causing N to halt on this input, D never halts, which is good because f is undefined on this input. Since D exists and has the appropriate relationship to f, f is partial recursive.
Since the concepts of "NDTM-partial recursive" and "partial recursive" are identical, the subsets of these classes of functions that are total are identical, and the classes of languages that are decided by total "partial recursive" functions are also identical.
BTHP is r.e.: Design a machine that on input M, a TM, runs M on blank tape. This machine halts iff M is in BTHP, so BHP is an r.e. language.
BTHP is r,e.-hard: We reduce K to BTHP. Given a Turing machine M and an input w, define Mw to be a machine that erases its input, writes w on its tape, and runs M on w. Let f be the function that takes the pair (M,w) to the machine Mw. Then f is a reduction from K to BTHP, because (M,W) is in K iff M halts on w iff Mw halts on blank tape iff Mw is in BTHP.
TILING is r.e.: The following code defines a Turing machine that will halt if a given set of rules has a solution and will not halt otherwise:
for (int n = 0; ; n++)
for (int m = 0; m <= n, m++)
for (T cycles through all possible m by n tilings)
if (T is a legal tiling) halt;
TILING is r.e.-hard: We reduce BTHP to TILING. Given a one-tape Turing machine M, we design a set of rules such that:
Last modified 4 November 2004