Sei sulla pagina 1di 2

CS 373 Fall 2003 November 12, 2003 Homework Assignment 9 - Turing Machines Due 11/21/03 (Friday) Problems related

d to chapter 9 1. Consider the Turing Machine: M = ( {q0, q1, q2, q3}, {a, b}, {a, b, #, (q0, a) = (q1, a, L) (q0, b) = (q0, b, R) (q0, ) = (q0, , R) (q0, #) = (q0, #, R) (q1, a) = (q1, a, L) (q1, b) = (q2, b, R) (q1, ) = (q1, , L) (q1, #) = (q1, #, R) //typo fixed (q2, a) = (q2, a, R) (q2, b) = (q2, b, R) (q2, ) = (q3, , L) (q2, #) = (q2, #, R) }, , q0, , { q3} ), where is given by:

(a) Trace the computation of M (until it halts if it halts) starting with the instantaneous description: #aq0bb bb aba (b) Give an informal description of what M does when started in state q0 at any position on the entire tape. Assume the initial tape content is a random sequence of symbols from = {a, b, #, }, and there may be an arbitrary and unbounded number of these symbols on the tape. 2. Design a Turing machine which accepts the language: L = {anbman+m : n 0, m 1}. Use pseudo code or very clear English to give an overview or description of the algorithm. Finally you must give a low level delta function implementation of this TM. The transition functions must be clearly commented. Remember that in addition to writing the code for the path to accepting a string, you must account for all the ways a string could be rejected. There should be three reasons for rejection to be accounted for by your code: (1) the suffix of as is too long (too many as: larger than n+m), (2) the suffix of as is too short (not enough as, less than n+m), (3) the over all format is wrong: string does not have a distinct prefix of as, a mid field of bs and a suffix of as. 3. Design a turing machine which would accept the language: L = { ww : w (a, b)+ } Instead of using a low level delta function implementation, you may use a high level outline of the algorithm for the design. The outline must be clear enough to allow a person to unambiguously write the transitions functions for this automaton. You just solved a problem previously unsolvable without the power of a Turing Machine. If this language is not context free (see example 8.2), then what is it? What are the implications of this problem in the theory of languages? Do you think there are languages even beyond

the TM? I thought that TMs were supposed to be the supermen of the automata world. 4. Design a Turing machine which computes the function: f(x,y) = x-y, where x and y are signed unary numbers. You may use pseudo code and box diagrams to describe the algorithm.. Pseudo code may be English like, or even very clear English - BUT IT MUST BE CRYSTAL CLEAR AND COMPLETE. x and y in this problem are two signed unary numbers. You may assume that a signed unary number is represented by a sign symbol which is written just to the left of the unary number (simple use the + and symbols). The subtraction is algebraic subtraction on signed numbers. After changing the sign of the second number: It adds the numbers if the resulting signs are the same and the sign of the answer is the sign of either number, and if the resulting signs are different, it take the absolute value of the difference and assigns the sign of the larger number. For your box diagram you may assume that you have the following off the shelf TM boxes - An adder such as given in the example in the book (unary numbers) - A subtractor which puts out the magnitude of the difference between two positive unary numbers. - A compare box as given in the example in the book. - A box which checks the signs of the two numbers give some explanation/pseudo code on how this works The box with the off-the-shelf TMs should show how the whole thing works. Indicate how these are connected and linked together to so one box flows into another and there is no conflict of states. 5. Design a standard Turing Machine that converts a sequence of n as into n2 as. In other words this TM does the function: f(an) = an^2 , n 0. where n^2 is the same as n2. . problem with double superscripts. Note that the n = 0 case gives f( ) = . Assume that tape is initially: q0 aaaa = q0 an (n as), and the final tape should look like: qf aaaa = qf an^2 (n2 as). This problem is similar to example 9.14 in the text. Consider two logical loops: an outer loop so you could write a string of as at the end of the current string of length equal to the original string (n), for each of the symbols in the original string, and an inner loop for creating this string. Auxiliary temporary symbols will needed to keep track of where you are in both of these loops. When done you should have only one symbol in the string, namely a. Initially use very clear pseudocode or an English description, followed by a low level delta function design.

Potrebbero piacerti anche