Unit 5 Turing Machine
Unit 5 Turing Machine
• Turing Machine was invented by Alan Turing in 1936 and it is used to accept Recursive
Enumerable Languages (generated by Type-0 Grammar).
• Turing machines are a fundamental concept in the theory of computation and play an
important role in the field of computer science. They were first described by the
mathematician and computer scientist Alan Turing in 1936 and provide a mathematical
model of a simple abstract computer.
• In the context of automata theory and the theory of computation, Turing machines are
used to study the properties of algorithms and to determine what problems can and
cannot be solved by computers. They provide a way to model the behavior of algorithms
and to analyze their computational complexity, which is the amount of time and
memory they require to solve a problem.
• A Turing machine is a finite automaton that can read, write, and erase symbols on an
infinitely long tape. The tape is divided into squares, and each square contains a symbol.
The Turing machine can only read one symbol at a time, and it uses a set of rules (the
transition function) to determine its next action based on the current state and the
symbol it is reading.
Example:
Construct a turing machine which accepts the language of aba over ∑ = {a, b}.
Solution:
We will assume that on input tape the string 'aba' is placed like this:
The tape head will read out the sequence up to the Δ characters. If the tape head is readout 'aba'
string then TM will halt after reading Δ.
Now, we will see how this turing machine will work for aba. Initially, state is q0 and head
points to a as:
The move will be δ(q0, a) = δ(q1, A, R) which means it will go to state q1, replaced a by A and
head will move to right as:
The move will be δ(q1, b) = δ(q2, B, R) which means it will go to state q2, replaced b by B and
head will move to right as:
The move will be δ(q2, a) = δ(q3, A, R) which means it will go to state q3, replaced a by A and
head will move to right as:
The move δ(q3, Δ) = (q4, Δ, S) which means it will go to state q4 which is the HALT state and
HALT state is always an accept state for any TM.
States a b Δ
q0 (q1, A, R) – –
q1 – (q2, B, R) –
q2 (q3, A, R) – –
q3 – – (q4, Δ, S)
q4 – – –
• Recursive Technique: The recursive technique involves defining a set of rules for
the Turing machine to follow. These rules are usually defined in terms of simple
operations such as moving the tape head left or right, reading and writing symbols,
and changing the state of the machine. The machine is then constructed by
recursively applying these rules until a final result is obtained.
• State Table Technique: This technique involves creating a state table that specifies
the transitions between states and symbols on the tape. The state table is usually
organized in rows and columns, with each row representing a particular state, and
each column representing a symbol on the tape. The entries in the table specify the
transition rules between states and symbols.
• High-Level Language Technique: High-level languages such as C++ and Java can
be used to program Turing machines. This technique involves writing a program in
a high-level language that simulates the behavior of the Turing machine. The
program can then be compiled and executed on a computer.
(Q, X, *, f, q0, B, F)
where
Q is a finite set of states
X is the tape alphabet
* is the input alphabet
f is a transition function;
f: Q × X à Q × X × {Left_shift, Right_shift}.
A standard Turing machine is capable of accepting some of the languages, called recursively
enumerable language. Let’s see if by doing some kind of modification we can increase the
number of languages accepted by Turing Machine.
i. Turing Machine with Stay option: If instead of moving left or right on seeing an
input, the head could also stay at one position without moving anywhere i.e.
f: Q × X --> Q × X × {Left_shift, Right_shift, Stay}.
Still the number of languages accepted by turing machine remains same.
ii. Turing Machine with Semi-infinite tape:
We know that Turing machine has an
infinite input tape with extends in both the directions (left and right) infinitely. So now
if we restrict it to extend only in one direction and not in both the directions, i.e., we
make the tape to be semi-infinite, then also the number of languages accepted by the
Turing machine remains same.
iii. Offline Turing machine: In standard Turing machine both the input and output are
present on the tape, the head has the authority to move across the input and can change
or modify the input, if we don’t want to modify the input we can provide the input in
separate file, which is read only then the head cannot make changes to it. If the Turing
machine wants to modify the input, the input need to be copied on the tape and the
changes can be made by the head but still the input file remains unchanged as changes
are made in the tape and not in the file. By doing such modification to Turing machine
still the number of languages accepted by the Turing machine remains the same.
iv. Jumping Turing Machine: The standard Turing machine’s head can move only one
step to the right or left, but in case of jumping Turing machine the head can move not
only just one step to the left or right but it can move more the one, i.e., 2, 3, 4, 5, 6, …
so on, or it can jump to any cell to the right or left of the input tape.
f: Q × X --> Q × X × {Left_shift, Right_shift} x {n}
n, is the number of steps that we wish to move to the right or left. But still the languages
accepted by Turing machine remains the same.
v. Non erasing Turing Machine: In standard Turing machine the input symbol can be
changed to blank, but if we remove this facility of changing the input symbol to blank
then such type of Turing machine is called as non-erasing Turing machine. We can
replace the input with any other symbol except blank. By doing this modification still
the number of languages accepted by the Turing machine remains the same.
vi. Always writing Turing Machine: Standard Turing machine gives us the freedom that
on seeing an input we can leave it as it is without doing any changes but in always
writing Turing machine it is compulsory to modify the input whenever we see it we
cannot leave it as it is. But this kind of modification didn’t help in increasing the number
of languages accepted by the Turing machine.
Hence, we see that in spite of doing so many modifications to the Turing machine still the
number of languages accepted by it remains the same. Therefore, Turing Machine is most
powerful machine.
The difference between Turing Machine and Universal Turing Machine are as
follows:
It is a mathematical model of
Universal Turing Machine is like a single
computation it manipulates
1. Turing Machine that has a solution to all
symbols on the tape according to
problem that is computable
the rules defined
In 1930, this statement was first formulated by Alonzo Church and is usually referred
to as Church’s thesis, or the Church-Turing thesis. However, this hypothesis cannot be
proved.
The recursive functions can be computable after taking following assumptions:
• Each and every function must be computable.
• Let ‘F’ be the computable function and after performing some elementary
operations to ‘F’, it will transform a new function ‘G’ then this function ‘G’
automatically becomes the computable function.
• If any functions that follow above two assumptions must be states as computable
function.
L1 says n no. of a’s followed by n no. of b’s followed by n no. of c’s. L2 says m no. of d’s
followed by m no. of e’s followed by m no. of f’s. Their concatenation first matches no. of a’s,
b’s and c’s and then matches no. of d’s, e’s and f’s. So it can be decided by TM.
• Kleene Closure: If L1is recursive, its kleene closure L1* will also be recursive. For
Example:
L1= {anbncn|n>=0}
L1*= { anbncn||n>=0}* is also recursive.
L1 says n no. of a’s followed by n no. of b’s followed by n no. of c’s and then any no. of d’s.
L2 says any no. of a’s followed by n no. of b’s followed by n no. of c’s followed by n no. of
d’s. Their intersection says n no. of a’s followed by n no. of b’s followed by n no. of c’s
followed by n no. of d’s. So it can be decided by turing machine, hence recursive.
Similarly,
complement of recursive language L1 which is ∑*-L1, will also be recursive.
Note: As opposed to REC languages, RE languages are not closed under complementation
which means complement of RE language need not be RE.
Example
ATM = {(M,w) | M is a TM and M halts at input w }.
We can build a universal Turing machine which can simulate any Turing machine on any
input.
Let’s consider TM which recognizing the Altering Turing Machine (ATM) −
Recognize-ATM (<M,w>)
Simulate M using UTM till it halts
If M halts and accept then
Accept
Else
Reject
Suppose, if M goes into an infinite loop on input w, then the TM Recognize-ATM is going to
run forever which means TM is only a recognizer, not a decider.
A decider for this problem would call a halt to simulations that loop forever.
Now the question is whether an ATM is TM decidable is equivalent to asking the question
whether we can tell if a TM M will halt on input w.
Because of this, both versions of this question are generally called the halting problem.
The Post Correspondence Problem (PCP), introduced by Emil Post in 1946, is an undecidable
decision problem. The PCP problem over an alphabet ∑ is stated as follows −
Given the following two lists, M and N of non-empty strings over ∑ −
M = (x1, x2, x3,………, xn)
N = (y1, y2, y3,………, yn)
We can say that there is a Post Correspondence Solution, if for some i1,i2,………… ik, where 1
≤ ij ≤ n, the condition xi1 …….xik = yi1 …….yik satisfies.
Example 1
Find whether the lists
M = (abb, aa, aaa) and N = (bba, aaa, aa)
have a Post Correspondence Solution?
Solution
x1 x2 x3
M Abb aa aaa
N Bba aaa aa
Here,
x2x1x3 = ‘aaabbaaa’
and y2y1y3 = ‘aaabbaaa’
We can see that
x2x1x3 = y2y1y3
Hence, the solution is i = 2, j = 1, and k = 3.
Example 2
Find whether the lists M = (ab, bab, bbaaa) and N = (a, ba, bab) have a Post Correspondence
Solution?
Solution
x1 x2 x3
M ab bab bbaaa
N a ba bab