Chapter 9. Turing Machines
We have seen earlier that FSA have finite amount of memory and hence cannot do certain things. For example, no FSA can accept {anbn|n
≥ 1}. Though, it is possible to have FSA for adding two arbitrarily
long binary numbers, we cannot have an FSA which can multiply two
arbitrarily long binary numbers. Hence the question arises. What happens
when we leave this restriction of finite memory? What problems can be
solved by mechanical process with unlimited memory? By mechanical
process, it is meant a procedure so completely specified that a machine
can carry it out. Are there processes that can be precisely described
yet still cannot be realized by a machine (computer)?
Programming – the job of specifying the procedure
that a computer is to carry out – amounts to determining in advance,
everything that a computer will do. In this sense, a computer’s program
can serve as a precise description of the process the machine can carry
out, and in this same sense it is meaningful to say that anything that
can be done by a computer can be precisely described.
9.1. Turing Machine as an Acceptor
The TM can be considered as an accepting device
accepting sets of strings. Later, we shall see that TM accept the family
of languages generated by type 0 grammars. The set accepted by a TM is
called a recursively enumerable set.
When we consider the TM as an accepting device, we
usually consider a one-way infinite tape. In the next chapter, we shall
see that by having a two-way infinite tape, the power does not change.
The TM consists of a one-way infinite read/write tape and a finite
control (Figure 9.1).'
9.2. Turing Machine as a Computing Device
In
the last section, we have viewed TM as an acceptor. In this section, we
consider the TM as a computing device. It computes functions which are
known as partial-recursive functions. In this section, we consider the
tape of the TM as infinite in both directions. We can make this
assumption without loss of generality as in the next chapter, we shall
prove the equivalence of one-way and two-way infinite tapes. The machine
is started with some non-blank portion on the tape, with the rest of
the tape containing blanks only. This is taken as the input. After
making some moves, when the machine halts, the non-blank portion of the
tape is taken as the output. For some inputs, the machine may get into a
loop in which case the output is not defined. Hence, the function
computed will be a partial function. While considering the TM as a
computing device we do not bother about the final states. Initial tape
head position has to be specified.
Example 9.4. (Unary to binary converter)
The input is a string of a’s which is taken as the unary representation of an integer; ai represents integer i. The output is of the form biXi where bi is a binary string which is the binary representation of integer i. The mapping for the TM which does this is given below. The tape symbols are {, a, X, 0, 1}. The machine has two states q0 and q1. q0 is the initial state and a right moving state. q1 is a left moving state.
δ(q0, a) | = | (q1, X, L) |
δ(q1, X) | = | (q1, X, L) |
δ(q1, ) | = | (q0, 1, R) |
δ(q1, 0) | = | (q1, 1, R) |
δ(q1, 1) | = | (q1, 0, L) |
δ(q0, X) | = | (q0, X, R) |
δ(q0, ) | = | (q2, , halt) |
The machine works like a binary counter. When it has converted j ‘a’s into X’s, it prints binary number j to the left of the position where it started. Let us consider the working of the machine on aaaaa. It should output 101X X X X X.
The machine starts in state q0 on the leftmost a.
9.3. Techniques for Turing Machine Construction
Designing
a TM to solve a problem is an interesting task. It is somewhat similar
to programming. Given a problem, different TMs can be constructed to
solve it. But, we would like to have a TM which does it in a simple and
efficient manner. Like we learn some techniques of programming to deal
with alternatives, loops etc, it is helpful to understand some
techniques in TM construction, which will help in designing
simple and efficient TM. It should be noted that we are using the word
‘efficient’ in an intuitive manner here, though later in Chapter 12, we shall deal with it formally. Next, we consider some techniques.
1. Considering the state as a tuple
In Example 9.2.2, we considered a TM which makes a copy of a given string over Σ = {a, b}. After reading a ‘a,’ the machine remembers it by going to qa and after reading a ‘b,’ it goes to qb. In general, we can represent the state as [q, x] where x ∊ Σ denoting that it has read a ‘x.’
Problems and Solutions
1. | Consider the following TM M′ with transitions as follows:
q0 is the initial state and 0 is taken as blank symbol.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Solution. |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2. | Construct a TM with three characters 0, 1, and # which locates a ‘1’ under the following conditions. There is only one # on the tape and somewhere to the right of it is a ‘1.’ The rest of the tape is blank. The head starts at or to the left of the #. When the TM halts, the tape is unchanged and head stops at the ‘1.’ Zero is taken as the blank symbol. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Solution. | The transition table is as follows. Here q3 is the (halt or) final state:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3. | Construct a TM over an alphabet {0, 1, #}, where 0 indicates blank, which takes a non-null string of 1’s and #’s and transfers the rightmost symbol to the left-hand end. Thus, ...000#1#1#1000... becomes ...0001#1#1#000.... The head is initially at the leftmost non-blank symbol. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Solution. | The
machine mainly has to move to the right-hand end, read the character,
to identify the rightmost 1 or #. Then, move it to the leftmost end and
halt. The transitions are:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
4. | Design a TM
with one track, one head, and three characters 0, 1, # to compute the
following functions. Input and output are to be in binary form as
follows. Zero is represented as # # and 7 is represented as # 1 1 1 #.
That is the binary string represented by ‘n’ is enclosed between two #’s on left and right of it. is the blank symbol.
Input is #n#
Output is #n + 1# in (a) and #2n# in (b)
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Solution. |
|
No comments:
Post a Comment