You are on page 1of 8

TURING MACHINES

Introduction
In 1936, A.M. Turing proposed the Turing machine as a model of any possible
computation. This model is computer like rather than program like, even though electronic or
electrochemical computers were in the future. A model of computation has the same power that
is they compute the same functions or recognize the same languages. The un-provable
assumption that any general way to compute will allow us to compute only the partial recursive
functions (equivalently Turing machines or modern day computers compute) is known as Church
Turing hypothesis. Turing hypothesis believed that a function is said to be computable if and
only if it can be computed by a Turing machine
It is used to define languages and compute integer functions.
It accepts recursive languages or recursively enumerable languages.
Turing machine differs from finite automata and pushdown automata.
The advantage of Turing machine over programs as representation of what can be
computed is that the Turing machine is sufficiently simple that we can represent its configuration
precisely, using a simple notation much like instantaneous descriptions (IDs) of PDA.
Turing machine has infinite memory and there is no restriction in accessing the inputs
and also the tape head can move either left or right. The PDA has infinite memory and access in
LIFO order and the finite automata has finite memory.

4.1.1 Definitions of Turing machines


Turing machine can solve any problem that a modern computer can solve. The Turing
machine can be formally defined as follows,
M= (Q, , , , q0, or B, F)
Where,
Q- Finite set of states
- Finite set of input alphabets
- Set of all tape symbols
- Transition function
q0- Starting state
- Blank symbol
F- Set of final or accepting states
4.2 Models
The basic model of a Turing machine consists of finite control and input tape, in which
the finite control has finite set of states and the transition between the states. The input tape is
divided into cells and each cell can hold only one input symbol from the input alphabet and also
the tape head scans one cell on the tape at a time.
Tape head

Input tape

All other tape cells extending infinitely to the left and right of the input tape contains the
special symbol called Blank symbol. The tape head is positioned at one of the tape cells for
scanning the input symbol from the input tape and initially the tape head points at the left most
cell of the input tape.

The single move of a Turing machine depends on the current state of finite control and
the tape symbol present in the input tape. These are the following changes happen in one move
of a Turing machine.

1. Changes the state after consuming an input symbol and it may remain in the same
state or transfer to a new state.
2. Tape symbol has to be replaced for the scanned input tape symbol.
3. Decide the moves of tape head either to the left or right of the input tape.
4. Whether to halt the Turing machine or not.
The two-way infinite tape Turing machine is same as that of basic Turing machine but
the only difference exists in Blank symbols. The tuples of two way infinite Turing machine are,
M= (Q, , , , q0, or B, F)
Where,
Q- Finite non-empty set of states
- non-empty finite set of input alphabets
- Set of all tape symbols
- Transition function
q0- Starting state
- Blank symbol which is placed on both ends of the tape and the input string has to
be placed in between the blank symbols.
F- Set of final or accepting states
4.2.1 Transition function of Turing Machine
The transition function of Turing machine is of the form,
(p, X) = (q, Y, D)
Where,
p- Current state
X- Tape symbol
q- Next state in Q
Y- Symbol in written in the cell being scanned
D- Direction of move (Left or Right)

Give transition functions for the following transition diagram of the Turing machine.

1/Y
0/Y X/X /

p 1 / X q 0/X
r

The Turing machine M is defined as,


M = (Q, , , , q0, , F)
M = ({p, q, r}, {0, 1}, {X, Y}, , p, , {r})
Transition function is given as,
(p, 0) = (p, Y, R)
(p, 1) = (q, X, R)
(q, X) = (q, X, L)
(q, 0) = (r, X, R)
(r, 1) = (r, Y, R)
(r, ) = (r, , L)
Transition diagram of Turing Machine
The pictorial representation of transition functions of the Turing machine is called
transition diagram. The transition diagram consists of a set of nodes corresponding to the states
of Turing machine. An arc from state p to another state q is labeled by one or more items of
the form X/Y D
Where,
X, Y Tape symbols
D Direction of move (Left L or Right R)
Left ()
Right ()
Example
Draw transition diagram for the transition function (p, X) = (q, Y, R).

X/Y
p q
/ /
Halting of Turing Machine Y Y
Another notation of acceptance commonly used for Turing machine is Acceptance by
halting. If the Turing machine recognizes the languages L then the Turing machine halts.

Turing machine never halts, if the input string is not accepted.
Turing machine halts whenever it reaches an accepting state.
Turing machine halts whether they accept the string or not accept the string if
the language is said to be a recursive language.
If the Turing machine is designed in such a way that it should only halt after
reaching the final state if not then the Turing machine goes into an infinite
loop and the Turing machine does not halt.
Construct Turing Machine for a language consisting of strings having any
number of 0s and only even number of 1s over the input set ={0, 1}.

1. Construct Turing Machine for a language consisting of strings having any number of 0s and
only even number of 1s over the input set ={0, 1}.

SOLUTION
Let us assume the input as 1001 which has even number of 1s and any number of 0s.
1001 Read 1 and move to right


1001 Read 0 and move to right


1001 Read 0 and move to right

1001 Read 1 and move to right


1001 HALT


States 0 1

q0 (q0, 0, R) (q1, 1, R) (HALT, , L)

q1 (q1, 0, R) (q1, 1, R) -

HALT - - -

Thus, the Turing Machine designed is shown below,

(1, 1, R)
(0, 0, R) (0, 0, R)

(1, 1, R)
q0 q1 HALT

(, , L)

2. Design a Turing Machine for checking the palindrome of the string of even length.
SOLUTION
The logic is that we will read first symbol from left and then we compare it with the first
symbol from right to check whether it is the same. Again we compare second symbol from left
with the second symbol from right. We repeat this process for all the symbols.
If we found any symbol not matching, we cannot lead the machine to HALT state. The
simulation of machine for a valid input such as

babbab Read b, convert it to * and move right



*abbab Move right upto

*abbab Move left, if left symbol is b convert it to

*abba Move left till *

*abba Move right

*abba Convert it to * and move right, upto



**bba Move left, if left symbol is a convert it to

**bb Move left till *

**bb Move right

**bb Convert it to * and move right, upto

***b Move left, if left symbol is b convert it to

*** Move left till *

*** Move right and check whether it is

*** Go to HALT state.

States a b *

q0 (q1, *, R) (q4, *, R) - (HALT, , L)

q1 (q1, a, R) (q1, b, R) - (q2, , L)

q2 (q3, , L) - - -

q3 (q3, a, L) (q3, b, L) (q0, *, R) -

q4 (q4, a, R) (q4, b, R) - (q5, , L)

q5 - (q6, , L) - -
q6 (q6, a, L) (q6, b, L) (q0, *, R) -

HALT - - - -

(b, b, R) (b, b, L)
(a, a, R) (a, a, L)

(a, *, R) (, , L) (a, , L)
q0 q1 q2 q3

(b, *, R)
(*, *, R) (, , L)
(, , L)
q4 q5 q6 HALT
(b, , L)

(a, a, R) (a, a, L)
(b, b, R) (b, b, L)
(*, *, R)

3. Construct a Turing machine M for the language L = {an bn | n 1}.(May/June09)

SOLUTION
aabb Read a and convert it to A and move right in search of b

Aabb skip it, moves ahead

Aabb Read b and convert it to B and move left till A

AaBb move right

AaBb convert a to A and move right in search of b

AABb move right

AABb convert it to B and move left till A

AABB now immediately before B is A that means all the as are marked by A.

AABB move right till to ensure that no b is present.

AABB HALT

States A A b B

q0 (q1, A, R) - - (q3, B, R) -

q1 (q1, a, R) - (q2, B, L) (q1, B, R) -

q2 (q2, a, L) (q0, A, R) - (q2, B, L) -

q3 - - - (q3, B, R) (HALT, , L)

HALT - - - - -

(B, B, R) (B, B, L)
(a, a, R) (a, a, L) (B, B, R)

(a, A, R) (b, B, L)
q0 q1 q2 q3

(A, A, R)
(, , L)
(B, B, R)
HALT

You might also like