Turing Machine
Turing Machine
Instructor :NitinPurohitChapter-1
Turing machine
A Turing machine is a device that manipulates symbols on a strip of tape according to a table of rules.
Despite its simplicity, a Turing machine can be adapted to simulate the logic of any computer algorithm, and is
particularly useful in explaining the functions of a CPU inside a computer.
A Turing machine that is able to simulate any other Turing machine is called a universal Turing machine
(UTM, or simply a universal machine).
History
They were described in 1936 by Alan Turing. Robin Gandy (1919–1995)—a student of Alan Turing (1912–
1954) and his life-long friend— traces the lineage of the notion of "calculating machine" back to Babbage (circa
1834) and actually proposes "Babbage's Thesis":
Gandy's analysis of Babbage's Analytical Engine describes the following five operations
The arithmetic functions +, −, × where − indicates "proper" subtraction x − y = 0 if y ≥ x
Any sequence of operations is an operation
Iteration of an operation (repeating n times an operation P)
Conditional iteration (repeating n times an operation P conditional on the "success" of test T)
Conditional transfer (i.e. conditional "goto")Gandy states that "the functions which can be calculated by
(1), (2), and (4) are precisely those which are Turing computable."
1937–1970: The "digital computer", the birth of "computer science". In 1937, while at Princeton working
on his PhD thesis, Turing built a digital (Boolean-logic) multiplier from scratch, making his own
electromechanical relays. "Alan's task was to embody the logical design of a Turing machine in a network of
relay-operated switches ...‖
1970–present: The Turing machine as a model of computation
The Church-Turing Thesis (Church Thesis).―Every effective computation can be carried
out by a Turing machine.
TheThesis& its history.It concerns the notion of an effective or mechanical method logic and mathematics. A
method or procedure M for achieving some desired result is called ―effective‖ or ―mechanical‖ just in case:
M is set out in terms of a finite number of exact instructions.
M will, if carried out without error, produce the desired result in a finite number of steps.
M can be carried out by a human being.
M demands no insight or ingenuity on the part of the human being carrying it out.
Structure of TM
Tape:A tape which is divided into cells, one next to the other. Each cell contains a symbol from some
finite alphabet. The alphabet contains a special blank symbol (here written as 'B') and one or more other
symbols. The tape is assumed to be arbitrarily extendable to the left and to the right, i.e., the Turing
machine is always supplied with as much tape as it needs for its computation. Cells that have not been
written to before are assumed to be filled with the blank symbol. In some models the tape has a left end
marked with a special symbol; the tape extends or is indefinitely extensible to the right.
Read Write Head :A head that can read and write symbols on the tape and move the tape left and right
one (and only one) cell at a time. In some models the head moves and the tape is stationary.
Transition table/Function :A finite table (occasionally called an action table or transition function)
of instructions (qi, aj) →)q’i ,a’j ,dk,) that, given the state(qi) the machine is currently in and the
symbol(aj) it is reading on the tape (symbol currently under the head) tells the machine to do the
following in sequence
o Either erase or write a symbol (instead of aj , write a’j), and then
o Move the head (which is described by dk and can have values: 'L' for one step left or 'R' for one step
right or 'N' for staying in the same place), and then
o Assume the same or a new state as prescribed (go to state q’i).
oIn this models, if there is no entry in the table for the current combination of symbol and state then the
machine will halt.
A state register that stores the state of the Turing machine, one of finitely many. There is one special
start state with which the state register is initialized. These states, writes Turing, replace the "state of
mind" a person performing computations would ordinarily be in.
Working of TM
Example 1: design a Truing machine that accept strings over Σ={0,1} and which contains 010 as a substring.
Orturing machine that accept language L={w|w∈{0,1} and w contains 010 }
1/(1,R) 0/(0,R)
1/(1,R)
0/(0,R)
1/(1,R)
Pesent
state Input
0 1
q0 (q1,0,R) (q0,1,R)
q1 (q1,0,R) (q2,1,R)
q2 (F,0,R) (q0,1,R)
F (F,0,R) (F,1,R)
a/(x,R) b/(y,L)
q0 q1 q2
x/(x,R)
y/(y,R)
y/(y,R) B/(B,N)
q3 F
1/(1,R) 1/(1,R)
Nondeterministic TM
An NTM starts working and stops working in the same way as a DTM.
Each move of an NTM can be nondeterministic.
o reads the symbol under its tape head
oAccording to the transition relation on the symbol read from the tape and its current state, the TM
choose one move nondeterministically to:
write a symbol on the tape
move its tape head to the left or right one cell or not
changes its state to the next state
Formal Definition of Nondeterministic TM (NTM)
A NonDeterministic Turing machine is a 7-tuple or quintupleM = (Q, Σ, q0, F, , B, δ)where
Qis non-empty, finite set of statesnot including the blank symbol B,.
Σis non-empty, finite set of input alphabets.
qo∈ Qis the start state.
9 Department Of Computer Science, School Of Computing and Informatics, MizanTepi University.
Course Name: Complexity Theory Course Code: CoSc4132
Instructor :NitinPurohitChapter-1
F⊆ Qis set of accepting or final states
B is Blank symbol written on tape
is the tape alphabet and is a finite set of symbols containing , but not including the blank symbol B.
δthe transition function:Q x →2(Q X X(L/R/N))
The shift left and shift right operations may shift the tape head across the tape, but when actually building
a Turing machine it is more practical to make the tape slide back and forth under the head instead.
The tape can be finite, and automatically extended with blanks as needed (which is closest to the
mathematical definition), but it is more common to think of it as stretching infinitely at both ends and being
pre-filled with blanks except on the explicitly given finite fragment the tape head is on. (This is, of course,
not implementable in practice.) The tape cannot be fixed in length, since that would not correspond to the
given definition and would seriously limit the range of computations the machine can perform to those of a
linear bounded automaton.
Other Construction Convention Adopted By Different Authors
The most common convention represents each "Turing instruction" in a "Turing table" by one of nine 5-
tuples, per the convention of Turing/Davis: (definition 1): (qi, Sj, Sk/E/N, L/R/N, qm)
10 Department Of Computer Science, School Of Computing and Informatics, MizanTepi University.
Course Name: Complexity Theory Course Code: CoSc4132
Instructor :NitinPurohitChapter-1
( current state qi , symbol scanned Sj , print symbol Sk/erase E/none N , move_tape_one_square left L/right
R/none N , new state qm )
Other authors (Minsky, Hopcroft and Ullman, Stone) adopt a different convention, with new state
qm listed immediately after the scanned symbol Sj: (definition 2): (qi, Sj, qm, Sk/E/N, L/R/N)
( current state qi , symbol scanned Sj , new state qm , print symbol Sk/erase E/none
N , move_tape_one_square left L/right R/none N )
It is often said that Turing machines, unlike simpler automata, are as powerful as real machines, and are
able to execute any operation that a real program can. What is missed in this statement is that, because a real
machine can only be in finitely many configurations, in fact this "real machine" is nothing but a linear
bounded automaton. On the other hand, Turing machines are equivalent to machines that have an unlimited
amount of storage space for their computations. In fact, Turing machines are not intended to model
computers, but rather they are intended to model computation itself; historically, computers, which compute
only on their (fixed) internal storage, were developed only later.
There are a number of ways to explain why Turing machines are useful models of real computers:
Anything a real computer can compute, a Turing machine can also compute. For example: "A Turing
machine can simulate any type of subroutine found in programming languages, including recursive
procedures and any of the known parameter-passing mechanisms" (Hopcroft and Ullman). A large enough
FSA can also model any real computer, disregarding IO. Thus, a statement about the limitations of Turing
machines will also apply to real computers.
The difference lies only with the ability of a Turing machine to manipulate an unbounded amount of data.
However, given a finite amount of time, a Turing machine (like a real machine) can only manipulate a finite
amount of data.
Like a Turing machine, a real machine can have its storage space enlarged as needed, by acquiring more
disks or other storage media. If the supply of these runs short, the Turing machine may become less useful
as a model. But the fact is that neither Turing machines nor real machines need astronomical amounts of
storage space in order to perform useful computation. The processing time required is usually much more of
a problem.
11 Department Of Computer Science, School Of Computing and Informatics, MizanTepi University.
Course Name: Complexity Theory Course Code: CoSc4132
Instructor :NitinPurohitChapter-1
Descriptions of real machine programs using simpler abstract models are often much more complex than
descriptions using Turing machines. For example, a Turing machine describing an algorithm may have a
few hundred states, while the equivalent deterministic finite automaton on a given real machine has
quadrillions. This makes the DFA representation infeasible to analyze
Turing machines describe algorithms independent of how much memory they use. There is a limit to the
memory possessed by any current machine, but this limit can rise arbitrarily in time. Turing machines allow
us to make statements about algorithms which will (theoretically) hold forever, regardless of advances in
conventional computing machine architecture.
Turing machines simplify the statement of algorithms. Algorithms running on Turingequivalent abstract
machines are usually more general than their counterparts running on real machines, because they have
arbitrary-precision data types available and never have to deal with unexpected conditions (including, but
not limited to, running out of memory).
Universal Turing Machine:
A universal Turing machine (UTM) is a Turing machine that can simulate an arbitrary Turing machine
on arbitrary input. The universal machine essentially achieves this by reading both the description of the
machine to be simulated as well as the input thereof from its own tape.
A universal Turing machine can calculate any recursive function, decide any recursive language, and
accept any recursively enumerable language.
According to the Church-Turing thesis, the problems solvable by a universal Turing machine are exactly
those problems solvable by an algorithm or an effective method of computation, for any reasonable
definition of those terms. For these reasons, a universal Turing machine serves as a standard against which
to compare computational systems, and a system that can simulate a universal Turing machine is called
Turing complete.
Alternating Turing Machine:
An alternating Turing machine is a non-deterministic Turing machine whose states are divided into two
sets: existential states and universal states
An existential state is accepting if some transition leads to an accepting state (complexity class-NP)
A quantum Turing machine (QTM), also a universal quantum computer, is an abstract machine used
to model the effect of a quantum computer.
It provides a very simple model which captures all of the power of quantum computation. Any quantum
algorithm can be expressed formally as a particular quantum Turing machine.
Read-only Turing Machine:
In the case of these types of Turing Machines, the only movement is to the right.
Multi-tape Turing Machine:
It consists n>1 infinite tapes and a head over each tape. All heads are connected to control and control
can be in any of a finite number of states. Program specifies the next move which depends of the state of
the control and the current symbol in each tape head. Typically tape 1 is used for input and others for
workspace.
A. Acceptor: It can be used for accepting or rejecting a string, so it is also be used as acceptor.
B. Generator: It can be used for generating a language on the basis of given rules and regulations as it
can also write on the tape provided, so it can is also be used as language generator.
C. Transducers: Transducer can compute a given mathematical function. As TM can also compute a
mathematical function and write its result into tape given while previous models are only acceptors.
Computation of TM
A Turing machine M = (Q, Σ, , δ,q0,qaccept,qreject) computes as follows. Initially M receives its input on
the leftmost n squares of the tape, and the rest of the tape is blank (i.e., filled with blank symbols). The
head starts on the leftmost square of the tape. Note that ∑ does not contain the blank symbol, so the first
blank appearing on the tape marks the end of the input.
14 Department Of Computer Science, School Of Computing and Informatics, MizanTepi University.
Course Name: Complexity Theory Course Code: CoSc4132
Instructor :NitinPurohitChapter-1
Once M has started the computation proceeds according to the rules described by the transition function.
If M ever tries to move its head to the left off the left-hand end of the tape, the head stays in the same
place for that move, even though the transition function indicates L. The computation continues until it
enters either accept or reject states at which point it halts. If neither occurs, M goes on forever.
As a Turing machine computes, changes occur in the current state, the current tape contents, and the
current head location. A setting of these three items is called a configuration of the Turing machine.
Configurations often are represented in a special way. For a state q and two strings u and v over the tape
alphabet we write u q v for the configuration where the current state is q, the current tape contents is
uv, and the current head location is the first symbol of v. The tape contains only blanks following the
last symbol of v.
For example, 10 1 1q701111 represents the configuration when the tape is 101101111, the current state
is q7, and the head is currently on the second 0. The following figure depicts a Turing machine with that
configuration
Here we formalize our intuitive understanding of the way that a Turing machine computes. Say that
configuration C1 yields configuration C2 if the Turing machine can legally go from Cl to C2 in a single
step. We define this notion formally as follows. Suppose that we have a, b, and c in , as well as u and v
in * and states qi and qj. In that case ua qi bv and u qj acv are two configurations. Say that ua qi bv
yields u qj acv if in the transition function δ(qi,b)=(qj,c,L). That handles the case where the Turing
machine moves leftward. For a rightward move, say that ua qi bv yields uacqj v if δ(qi,b)=(qj,c,R).
Special cases occur when the head is at one of the ends of the configuration. For the left-hand end, the
configuration qi bv yields qj cv if the transition is left-moving (because we prevent the machine from
going off the left-hand end of the tape), and it yields c qj v for the right-moving transition. For the right-
hand end, the configuration ua qi is equivalent to ua qi B because we assume that blanks follow the part
of the tape represented in the configuration. Thus we can handle this case as before, with the head no
longer at the right-hand end.
Turing Recognizable
The start configuration of M on input w is the configuration qO w, which indicates that the machine is in
the start state qO with its head at the leftmost position on the tape. In an accepting configuration the
state of the configuration is qaccept. In a rejecting configuration the state of the configuration is qreject.
Accepting and rejecting configurations are halting configurations and do not yield further
configurations. Because the machine is defined to halt when in the states qaccept and qreject,
A Turing machine M accepts input w if a sequence of configurations C1, C2 , ... , Ck exists, where
o Clis the start configuration of M on input w,
o each Ciyields Ci+1, and
o Ckis an accepting configuration.
The collection of strings that M accepts is the language of M, or the language recognized by M, denoted
L(M).
Call a language Turing-recognizable if some Turing machine recognizes it.
When we start a Turing machine on an input, three outcomes are possible. The machine may accept,
reject, or loop. By loop we mean that the machine simply does not halt. Looping may entail any simple
or complex behavior that never leads to a halting state
A Turing machine M can fail to accept an input by entering the qreject state and rejecting, or by looping.
Sometimes distinguishing a machine that is looping from one that is merely taking a long time is difficult.
For this reason we prefer Turing machines that halt on all inputs; such machines never loop. These machines
are called deciders because they always make a decision to accept or reject.
A decider that recognizes some language also is said to decide that language.
Call a language Turing-decidable or simply decidable if some Turing machine decides it.
Now we begin to investigate the power of algorithms to solve problems. There are certain problems that
can be solved algorithmically and others that cannot. Our objective is to explore the limits of algorithmic
solvability. You are probably familiar with solvability by algorithms because much of computer science is
devoted to solving problems. The unsolvability of certain problems may come as a surprise.
Why should you study unsolvability? After all, showing that a problem is unsolvable doesn't appear to be
of any use if you have to solve it.
You need to study this phenomenon for two reasons. First, knowing when a problem is algorithmically
unsolvable is useful because then you realize that the problem must be simplified or altered before you can
find an algorithmic solution. Like any tool, computers have capabilities and limitations that must be
appreciated if they are to be used well. The second reason is cultural. Even if you deal with problems that
clearly are solvable, a glimpse of the unsolvable can stimulate your imagination and help you gain an
important perspective on computation.
Decidable Languages
Here we see some examples of languages that are decidable by algorithms. We focus on languages
concerning automata and grammars. For example, we present an algorithm that test whether a string is a
member of a context-free language (CFL).
These languages are interesting for several reasons. First, certain problems of this kind are related to
applications. This problem of testing whether a CFL generates a string is related to the problem of
recognizing and compiling programs in a programming language. Second, certain other problems
concerning automata and grammars are not decidable by algorithms.
A decider Turing machine is also called total Turing Machine, and it has only two options aceept or
reject.
When we start a Turing machine on an input, three outcomes are possible. The machine may accept,
reject, or loop. By loop we mean that the machine simply does not halt. Looping may entail any simple
or complex behavior that never leads to a halting state.
A Turing machine M can fail to accept an input by entering the qreject state and rejecting, or by looping.
Sometimes distinguishing a machine that is looping from one that is merely taking a long time is
difficult.
But due to complexity of languages, for some languages we are able to accept the language but we are
not able to reject the string if it does not belongs to the language due to looping of machine.
So for some language we are only able to design a turing machine which have all three options accept,
reject or loop, such languages are called sem-decidable languages.
Undecidable languages:
All language which are not decidable are called undecidable languages, Even semi decidable language
are also one kind of undecidable language.
A language for which we are not able to design a total Turing Machine are called undecidable
languages.
For undecidable language we may or may not design a recognizer.
Decidibility/Undecidibility
Decidability or undecidability are basically deals with methods for proving that a given problem or language
is decidable or not?
If we can design a proper algorithm for a problem that can give a definite answer in yes or no that means the
problem or language is decidable. We don’t have any fix method for proving that a language is undecidable.
We used some methods like diagonalization, reducibility, or some theorm etc.
Theorem: If a language L is decidable that means L and its complement over same alphabet are recognizable
and vice-versa.