0% found this document useful (0 votes)
76 views16 pages

Unit 5 Turing Machine

The Turing Machine was invented by Alan Turing in 1936 and provides an abstract model of computation. It consists of a tape divided into squares, a head that reads and writes symbols on the tape, a finite set of states, and a set of transition rules. Turing Machines can model the behavior of algorithms and determine what problems can be solved by computers. A Universal Turing Machine is a Turing Machine that can simulate any other Turing Machine by taking the description of that machine as input. This shows that a single machine with unlimited memory can compute anything that is computable.

Uploaded by

Aman Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views16 pages

Unit 5 Turing Machine

The Turing Machine was invented by Alan Turing in 1936 and provides an abstract model of computation. It consists of a tape divided into squares, a head that reads and writes symbols on the tape, a finite set of states, and a set of transition rules. Turing Machines can model the behavior of algorithms and determine what problems can be solved by computers. A Universal Turing Machine is a Turing Machine that can simulate any other Turing Machine by taking the description of that machine as input. This shows that a single machine with unlimited memory can compute anything that is computable.

Uploaded by

Aman Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

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.

Formal definition of Turing machine:


A Turing machine can be defined as a collection of 7 components:

Q: the finite set of states


∑: the finite set of input symbols
T: the tape symbol
q0: the initial state
F: a set of final states
B: a blank symbol used as a end marker for input
δ: a transition or mapping function.
Language accepted by Turing machine:
The turing machine accepts all the language even though they are recursively enumerable.
Recursive means repeating the same set of rules for any number of times and enumerable means
a list of elements. The TM also accepts the computable functions, such as addition,
multiplication, subtraction, division, power function, and many more.

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.

The same TM can be represented by Transition Table:

States a b Δ
q0 (q1, A, R) – –
q1 – (q2, B, R) –
q2 (q3, A, R) – –
q3 – – (q4, Δ, S)
q4 – – –

The same TM can be represented by Transition Diagram:


Explain techniques for Turing Machine Construction:
A Turing machine is a theoretical model of a computing device that can perform
computations on an infinite tape of symbols. It is a fundamental concept in the field of
computer science and plays a significant role in the study of computability and
complexity. In this blog post, we will discuss the techniques for Turing Machine
Construction.
• Enumeration Technique: This technique involves listing all the possible
combinations of states, input symbols, and tape symbols. The Turing machine is
then constructed by specifying the transitions between these combinations.
However, this technique can be quite cumbersome, especially for larger input sets.

• 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.

• State Diagram Technique: The state diagram technique involves drawing a


diagram that represents the states and transitions of the Turing machine. Each state
is represented by a node, and the transitions between states are represented by edges.
This technique is useful for visualizing the behavior of the Turing machine.

• 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.

In conclusion, the construction of a Turing machine involves various techniques such


as enumeration, recursion, state tables, state diagrams, and high-level language
programming. The choice of technique depends on the complexity of the problem and
the expertise of the programmer. The techniques discussed in this blog post provide a
starting point for constructing Turing machines and understanding their behavior.
Modifications to standard Turing Machine:
A standard Turing Machine is a machine which on providing an input moves either to the left
or right and it may overwrite the existing symbol.
A standard TM can be described as a 7-tuple:

(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}.

q0 is the initial state


B is the blank symbol
F is the set of final states

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.

Explain the universal Turing machine in TOC:


The Turing Machine (TM) is the machine level equivalent to a digital computer.
It was suggested by the mathematician Turing in the year 1930 and has become the most
widely used model of computation in computability and complexity theory.
The model consists of an input and output. The input is given in binary format form on to the
machine’s tape and the output consists of the contents of the tape when the machine halts
The problem with the Turing machine is that a different machine must be constructed for every
new computation to be performed for every input output relation.
This is the reason the Universal Turing machine was introduced which along with input on the
tape takes the description of a machine M.
The Universal Turing machine can go on then to simulate M on the rest of the content of the
input tape.
A Universal Turing machine can thus simulate any other machine.
The idea of connecting multiple Turing machine gave an idea to Turing −
• Can a Universal machine be created that can ‘simulate’ other machines?
• This machine is called as Universal Turing Machine
This machine would have three bits of information for the machine it is simulating

• A basic description of the machine.


• The contents of machine tape.
• The internal state of the machine.
The Universal machine would simulate the machine by looking at the input on the tape and
the state of the machine.
It would control the machine by changing its state based on the input. This leads to the idea of
a “computer running another computer”.
It would control the machine by changing its state based on the input. This leads to the idea of
a “computer running another computer”.
The schematic diagram of the Universal Turing Machine is as follows −

The difference between Turing Machine and Universal Turing Machine are as
follows:

Turing Machine Universal Turing Machine

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

A program can be compared to a Programmable Turing Machine is called


2.
Turing Machine Universal Turing Machine

Turing machine’s temporary Universal Turing Machine contains Turing


storage is tape. The infinite cells of Machine description as input along with an
3.
the Turing machine can contain input string, runs the Turing Machine on
input symbols and blanks. the input and returns the result.
Turing machines help us
Although developed for theoretical
understand the fundamental
4. reasons, it helped in the development of
limitations of mechanical
stored program computers
computation power

A Turing machine is a formal


Universal Turing Machine provides a
5. model of a computer with a fixed
solution to problems that are computable
program

It does not minimize the space


6. It minimizes space complexity
complexity

Transition function which Turing


The transition function is Q × T → Q × T
Machine performs is defined as: δ
7, × {L, R}, where Q is a finite set of states,
X T -> Q X T X {L,R}, where δ is
T is the tape of the alphabet
the transition function

In the set theory point of view, all


Turing machines form a set of the Universal Turing Machine is a subset of all
8.
all the device that accepts type 0 the Turing Machines
grammar

Linear bounded automaton:


A linear bounded automaton is a multi-track non-deterministic Turing machine with a tape of
some bounded finite length.
Length = function (Length of the initial input string, constant c)
Here,
Memory information ≤ c × Input information
The computation is restricted to the constant bounded area. The input alphabet contains two
special symbols which serve as left end markers and right end markers which mean the
transitions neither move to the left of the left end marker nor to the right of the right end marker
of the tape.
A linear bounded automaton can be defined as an 8-tuple (Q, X, ∑, q0, ML, MR, δ, F) where −
• Q is a finite set of states
• X is the tape alphabet
• ∑ is the input alphabet
• q0 is the initial state
• ML is the left end marker
• MR is the right end marker where MR ≠ ML
• δ is a transition function which maps each pair (state, tape symbol) to (state, tape
symbol, Constant ‘c’) where c can be 0 or +1 or -1
• F is the set of final states
A deterministic linear bounded automaton is always context-sensitive and the linear bounded
automaton with empty language is undecidable.
Examples:
Languages that form LBA with tape as shown above,
• L = {an! | n >= 0}
• L = {wn | w from {a, b}+, n >= 1}
• L = {wwwR | w from {a, b}+}
Facts :
Suppose that a given LBA M has
--> q states,
--> m characters within the tape alphabet, and
--> the input length is n
• Then M can be in at most f(n) = q * n * mn configurations i.e. a tape of n cells
and m symbols, we are able to have solely mn totally different tapes.
• The tape head is typically on any of the n cells which we have a tendency to are
typically death penalty in any of the q states.

Church’s Thesis for Turing Machine:

In 1936, A method named as lambda-calculus was created by Alonzo Church in which


the Church numerals are well defined, i.e. the encoding of natural numbers. Also in
1936, Turing machines (earlier called theoretical model for machines) was created by
Alan Turing, that is used for manipulating the symbols of string with the help of tape.
Church Turing Thesis :
Turing machine is defined as an abstract representation of a
computing device such as hardware in computers. Alan Turing proposed Logical
Computing Machines (LCMs), i.e. Turing’s expressions for Turing Machines. This was
done to define algorithms properly. So, Church made a mechanical method named as
‘M’ for manipulation of strings by using logic and mathematics.

This method M must pass the following statements:


• Number of instructions in M must be finite.
• Output should be produced after performing finite number of steps.
• It should not be imaginary, i.e. can be made in real life.
• It should not require any complex understanding.
Using these statements Church proposed a hypothesis called Church’s Turing
thesis that can be stated as: “The assumption that the intuitive notion of computable
functions can be identified with partial recursive functions.”

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.

Recursive and Recursive Enumerable Languages in TOC:

Recursive Enumerable (RE) or Type -0 Language


RE languages or type-0 languages are generated by type-0 grammars. An RE language can be
accepted or recognized by Turing machine which means it will enter into final state for the
strings of language and may or may not enter into rejecting state for the strings which are not
part of the language. It means TM can loop forever for the strings which are not a part of the
language. RE languages are also called as Turing recognizable languages.

Recursive Language (REC)


A recursive language (subset of RE) can be decided by Turing machine which means it will
enter into final state for the strings of language and rejecting state for the strings which are not
part of the language. e.g.; L= {anbncn|n>=1} is recursive because we can construct a turing
machine which will move to final state if the string is of the form anbncn else move to non-
final state. So the TM will always halt in this case. REC languages are also called as Turing
decidable languages. The relationship between RE and REC languages.
Closure Properties of Recursive Languages:
• Union: If L1 and If L2 are two recursive languages, their union L1∪L2 will also be
recursive because if TM halts for L1 and halts for L2, it will also halt for L1∪L2.

• Concatenation: If L1 and If L2 are two recursive languages, their concatenation L1.L2


will also be recursive. For Example:
L1= {anbncn|n>=0}
L2= {dmemfm|m>=0}
L3= L1.L2
= {anbncndm emfm|m>=0 and 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. 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.

• Intersection and complement: If L1 and If L2 are two recursive languages, their


intersection L1 ∩ L2 will also be recursive. For Example:
L1= {anbncndm|n>=0 and m>=0}
L2= {anbncndn|n>=0 and m>=0}
L3=L1 ∩ L2
= { anbncndn |n>=0} will be 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.

What is the Halting Problem in TOC?


Usually, programs consist of loops that are limited or unlimited in length.
The total work done by the program completely depends on the input given to the program.
The program may consist of several different numbers of loops that may be in linear or nested
manner.
The Halting Problem is the problem of deciding or concluding based on a given arbitrary
computer program and its input, whether that program will stop executing or run-in an infinite
loop for the given input.
The Halting Problem tells that it is not easy to write a computer program that executes in the
limited time that is capable of deciding whether a program halts for an input.
In addition to that the Halting Problem never says that it is not practicable to determine whether
a given random program is going to halt (stop).
Generally, it asks the question like “Given a random program and an input, conclude whether
the given random program is going to halt when that input is given”.

Write a Halting Problem


An example of writing the Halting Problem is as follows −
INPUT − Program P and a string S.
OUTPUT − if P stops on S, it returns 1.
Otherwise, if P enters into an endless loop on S, it returns 0.
Let us consider the Halting Problem called H having the solution.
Now H takes the following two inputs −
• Program P
• Input S.
If P stops on S, then H results in “halt”, otherwise H gives the result “loop”.
The diagrammatic representation of H is as follows −

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.

Post Correspondence 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

In this case, there is no solution because −


| x2x1x3 | ≠ | y2y1y3 | (Lengths are not same)
Hence, it can be said that this Post Correspondence Problem is undecidable.

Total Recursive Functions and Partial Recursive Functions in


Automata:

Total Recursive Functions: 
A recursive function is called total recursive function if


it is defined for its all arguments.Let f(a1, a2, …an) be a function defined on
function g(b1, b2, …bn).Then f is a total function if every element of f is assigned to
some unique element of function g.

• A total function is called recursive or primitive recursive if and only if it is an


initial function over n, or it is obtained by applying composition or recursion with finite
number of times to the initial function over n.
• Multiplication of two positive integers is total recursive function or primitive
recursive function.
• Not all total recursive function are primitive recursive function.
• Ackerman’s function is a total function
• All primitive recursive function are total function.
• Function like n!, logn are total recursive function.
Partial Recursive Functions: 
A function f(a1, a2, ….an)computed by a TM is
known as partial recursive function.if f is defined for some but not all values of a1, a2,
….an.Let f(a1, a2, …an) is a function and defined on function g(b1, b2, ….bn) then f is
partial function if some element of f is assigned to almost one element of function g.
A partial function is recursive if it is an initial function over N, or it is obtained by
applying recursion or composition or minimization on initial function N. 


• Subtraction of two positive integers is partial recursive function.


• The composition of partial(total) functions yields a partial(total) function.
• The minimization of a total recursive function is a partial recursive function.
• Primitive Recursive function ? Total function ? Partial recursive Functions

You might also like