Chapter 5 TuM
Chapter 5 TuM
Chapter 5
Lecture 8
Contents
Models of computing
DFA - regular languages
Push down automata - Context-free
Bounded Turing M’s - Context sensitive
Turing machines - Phrase-structure
Introduction
Turing machine was invented in 1936 by Alan Turing. It is an
accepting device which accepts Recursive Enumerable Language.
There are various features of the Turing machine:
It has an external memory which remembers arbitrary long sequence of
input.
It has unlimited memory capability.
The model has a facility by which the input at left or right on the tape can
be read easily.
The machine can produce a certain output based on its input. Sometimes it
may be required that the same input has to be used to generate the output.
So in this machine, the distinction between input and output has been
removed. Thus a common set of alphabets can be used for the Turing
machine.
Turing Machines
are…
Very powerful (abstract) machines that could simulate any
modern day computer (although very, very slowly!)
A TM is a mathematical model of computation describing an
abstract machine that manipulates symbols on a strip of tape
according to a table of rules. Despite the model's simplicity, it
is capable of implementing any computer algorithm.
Why design such a machine?
If a problem cannot be “solved” even using a TM, then it
implies that the problem is undecidable For every input,
answer YES or NO
Transition function
Write Move Left
Read
q1 a b, L q2
q1 a b, R q2
(q1, a ) (q2 , b, R )
Turing machine ….General
Input alphabet Tape alphabet
States
M (Q, , , , q0 , , F )
Final states
Transition function
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 0 a a b b
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 1 x a b b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 2 x a b b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 3 x a y b
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 4 x a y b
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
x a y b
Time 5
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 6
x x y b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 7 x x y b
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 8 x x y y
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 9 x x y y
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 10
x x y y
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 11 x x y y
q3
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 12 x x y y
q3
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
Time 13 x x y y
q4
Halt & Accept
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
ID of a TM
Instantaneous Description or ID :
X1X2…Xi-1qXiXi+1…Xn
means:
q is the current state
Tape head is pointing to Xi
X1X2…Xi-1XiXi+1…Xn are the current tape symbols
q0 (q1, A, R) – –
q1 – (q2, B, R) –
q2 (q3, A, R) – –
q3 – – (q4, Δ, S)
q4 – – –
Examples
1. Construct a TM for the language L = {0n1n2n} where n≥1
L = {0n1n2n | n≥1} represents language where we use only 3
character, i.e., 0, 1 and 2. In this, some number of 0's followed by
an equal number of 1's and then followed by an equal number of
2's. Any type of string which falls in this category will be accepted
by this language.
The simulation for 001122 can be shown as below:
Idea:
The tape head reads the leftmost symbol of w, which is 0 and makes is blank
then the next left most 0 is made blank after this we traverse to the rightmost 1
of the string and make it blank. In nth is way we have reduced the string to 0 2n-
1 .If the string belongs to language L then at end empty string will be left and
2 n-1
, L
q0 q1
Time 0 a a a
q0
a a, R
, L
q0 q1
50
Time 1 a a a
q0
a a, R
, L
q0 q1
51
Time 2 a a a
q0
a a, R
, L
q0 q1
52
Time 3 a a a
q0
a a, R
, L
q0 q1
53
Time 4 a a a
q1
a a, R Halt & Accept
, L
q0 q1
Rejection Example
Time 0 a b a
q0
a a, R
, L
q0 q1
Time 1 a b a
q0
No possible Transition
, L
q0 q1
Infinite Loop Example
b b, L
a a, R
, L
q0 q1
Time 0 a b a
q0
b b, L
a a, R
, L
q0 q1
Time 1 a b a
q0
b b, L
a a, R
, L
q0 q1
59
Time 2 a b a
q0
b b, L
a a, R
, L
q0 q1
60
Turing Decidable & Acceptable
• When we talk about Turing machines (TM) it could accept the
input, reject it or keep computing which is called loop.
• A Language is recognizable if and only if a TM accepts the
string, when the provided input lies in the language.
• Also, a language can be recognizable if the TM either terminates
and rejects the string or doesn't terminate at all. This means that
the TM continues with the computing when the provided input
doesn't lie in the language.(i.e. there is no requirement that the
TM should halt for strings not in the language.)
• The language is decidable if and only if there is a machine
which accepts the string when the provided input lies in that
language and rejects the string when provided input doesn't lie
in that language.
• Assume: TM has accepting state qacc
acc
and rejecting state qrej
rej
.
64
Generic description
TMs with storage Will work for both a=0 and a=1
B B 0 1 1 1 1 1 B B … • ([q1,a],B) = ([q2,B], B, R)
Track 1 … …
… …
Track 2
…
…
Track k … …
Multi-Track TMs……Cont…
TM with multiple “tracks” but just one head
BEFORE AFTER
control control
… B B 0 1 0 c 0 1 0 B … Track 1 … B B 0 1 0 c 0 1 0 B …Track 1
… B B B B B B B B B B … Track 2 B B X X X c Y Y Y B …Track 2
…
control
k separate heads
Tape 1 … …
… …
Tape 2
…
Tape k … …
Non-deterministic TMs
A non-deterministic Turing machine has a single, one-way
infinite tape.
For a given state and input symbol has at least one choice to
move (finite number of choices for the next move), each
choice has several choices of the path that it might follow for a
given input string.
A non-deterministic Turing machine is equivalent to the
deterministic Turing machine.
Summary
TMs == Recursively Enumerable languages
TMs can be used as both:
Language recognizers
Calculators/computers
Basic TM is equivalent to all the below:
1. TM + storage
2. Multi-track TM
3. Multi-tape TM
4. Non-deterministic TM
TMs are like universal computing machines with
unbounded storage