Turing Machines
[16/94%]Construct a Turing machine that performs the following task: given an input consisting of one or more words over the alphabet (possibly ), produce an output that doubles the last of the words: .
Construct a Turing machine that compares two input words over the alphabet lexicographically. It must compute the dictionary-order function:
Construct programs of Turing machines that compute the following word functions in the alphabet :
cyclic permutation of letters: ;
cyclic permutation of words: ;
"reversal" of a sequence of words: ;
doubling each letter: ;
finding the image under the homomorphism ;
removal of all single letters standing at even positions;
checking whether two words contain the same number of letters (the result equals 1 if the answer is "yes", 0 if "no");
checking whether a word is a palindrome (that is, symmetric);
checking whether the word contains two runs of letters of the same length;
checking whether the counts of letters and in the word form an increasing arithmetic progression.
Construct a Turing machine to convert the representation of a number from binary to unary, input alphabet .
Construct programs of one-way Turing machines that compute the following arithmetic functions in the unary system:
;
comparison ;
exponentiation: ;
square root: ;
logarithm:
integer division: ;
remainder: ;
the function selecting the -th argument: — a predetermined constant.
Given Turing machines with a standard terminal configuration , each of which computes a word function in time , . Indicate how to construct, and estimate the running time of,
the machine , computing the function ;
the machine , computing the function
the machine , computing the function
the machine , computing the function , where is the smallest natural number for which is empty, with and . Assume that and .
Using the Turing machines from the previous problems, construct programs of Turing machines that compute the following functions:
Show how the execution of the following commands can be organized on an ordinary Turing machine:
, return — return the head to whichever of the neighboring cells it came from into the current one;
, zero — return the head to cell zero;
, mirror — move the head to cell , if it was in the cell numbered ;
, double — move the head to cell , if it was in the cell numbered ;
, next — move the head to the nearest cell to the right of the current one that contains (if one exists, otherwise the head stays in place);
— shift the current cell and all cells to the right of it one position to the right and write the symbol into the freed cell; the head ends up in the new cell;
, restore, — replace the symbol with the one that was in the cell in the initial configuration.
Implement the Turing machine from Examples 111 on p. 409 and 112 on p. 410 without extending the alphabet.
Example 111: a Turing machine over the alphabet computing the function for words with (i.e. erase the second half of the word, keeping the middle symbol if the length is odd), implemented by extending the alphabet with primed symbols .
Example 112: a Turing machine over the alphabet that adds two nonempty binary numbers given on the tape, implemented by extending the alphabet with primed symbols .
Complete the construction of the Turing machine from Theorem 156 on p. 413.
Theorem 156: For every Turing machine one can construct a -equivalent Turing machine having a standard terminal configuration (i.e. one in which, at the moment of halting, the head is in cell zero and the tape holds only the result, with no leftover marker symbols).
A different approach, compared to the construction of Theorem 157 on p. 417, to simulating a two-way tape on a one-way tape consists in storing the contents of the nonnegative half of the tape of in cells with odd numbers, and the contents of the left half — in cells with even numbers. That is, the new tape will have the form and for . Construct a program for a one-way machine that implements this approach.
Theorem 157: For every Turing machine there exists a -equivalent one-way Turing machine having a standard terminal configuration. (The construction given in the proof of Theorem 157 folds the two-way tape in half using two-tier symbols, so that cell of 's tape stores a pair consisting of the symbol from cell of 's tape on top and the symbol from cell on the bottom; this problem asks for an alternative, non-two-tier encoding achieving the same goal.)
Prove that the one-way Turing machine , constructed in Theorem 157 on p. 417, correctly simulates the original machine .
Theorem 157: For every Turing machine there exists a -equivalent one-way Turing machine having a standard terminal configuration. (The construction in the proof uses two-tier symbols to fold the two-way tape of in half: cell of 's tape holds a pair whose top is 's cell and whose bottom is 's cell , so nonnegative and negative cells of 's tape are interleaved onto 's single-direction tape.)
Show how to extract the output words from the tape code (Theorem 159 on p. 426).
For a one-way tape over alphabet (with ), holding at each moment a sequence , the tape code is , i.e. reading the sequence of symbol indices as the digits of a number in base (only finitely many terms are nonzero). Theorem 159: every Turing-computable word function is program-computable — the proof simulates a Turing machine by a labeled program that stores 's configuration using a variable holding the tape code ; at the end, the resulting tape code must be decoded back into the sequence of output words, which is exactly what this problem asks for.
Show how, on a Turing machine, to construct the unary representation of the input, and to recover the output from the unary representation (Theorem 160 on p. 429), without extending the alphabet.
Theorem 160: If a word function is computable on a Turing machine with , then it is computable on a one-way Turing machine with no alphabet extension, i.e. . (The proof builds by first converting the input into the unary representation of its tape code , then running a machine computing the same function on that unary representation — as given by Theorem 158 — and finally recovering the output word from the unary representation of the resulting tape code; this problem asks for these two conversion steps.)
Show how to simulate on a Turing machine the operation of a labeled program in the binary system (Theorem 158 on p. 422).
Theorem 158: Every program-computable function is Turing-computable without extending the alphabet. (The proof simulates a labeled program with variables by a one-way Turing machine whose configuration mirrors 's configuration , storing the unary representations of on the tape, separated by blanks; the number system chosen there is unary, and this problem asks to show that the binary system also works.)
Construct a universal Turing machine, implementing items 1)-21) from Theorem 161 on p. 430.
Theorem 161: For every alphabet there exists a -universal Turing machine , i.e. a machine such that for every Turing machine there is an input (encoding 's program) for which for every input .