You are on page 1of 7

NaseerAhmed: Handout 23 -1- Theory of Automata and Formal Languages

Turing Machines

Objectives

 Turing Machine
o Simple
o Computing

TURING MACHINE Definition:


A Turing machine (TM) consists of the following
1. An alphabet Σ of input letters.
2. An input TAPE partitioned into cells, having infinite many locations in one direction.
The input string is placed on the TAPE starting its first letter on the cell i, the rest of
the TAPE is initially filled with blanks (∆’s).
3. A TM consists of an infinite length tape, on which
input is provided as a finite sequence of symbols.
4. A head reads the input tape.
5. The TM starts at start state s0
6. On reading an input symbol it optionally replaces it with another symbol, changes its
internal state and moves one cell to the right or left.
7. A tape Head can read the contents of cell on the TAPE in one step. It can replace the
character at any cell and can reposition itself to the next cell to the right or to the left
of that it has just read.
8. An alphabet Γ of characters that can be printed on the TAPE by the TAPE Head. ΓΣ
may include the letters of Σ. Even the TAPE Head can print blank ∆, which means to
erase some character from the TAPE.
9. Finite set of states containing exactly one START state and some (may be none)
HALT states that cause execution to terminate when the HALT states are entered.
10. A program which is the set of rules, which show that which state is to be entered
when a letter is read form the TAPE and what character is to be printed. This
program is shown by the states connected by directed edges labeled by triplet
(letter, letter, direction)

7-TUPLE
 A Turing machine is a 7-tuple (Q, , , , q0, qaccept, qreject),
 Q is a set of states
  is a set of symbols (the alphabet)
  is a set of symbols that can be written in tape,
 q0 Q is the initial state
 qaccept is the accepting state
 qreject is the rejecting state, qrejectqaccept

GRAPHICAL REPRESENTATION OF TM

START
NaseerAhmed: Handout 23 -2- Theory of Automata and Formal Languages

STATE ‘S
HALT

EDGES

EXAMPLES:
Consider the following TM

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

(b,b,R) (a,a,L)
2 3 4
(b,a,R)

(∆, ∆,R) (a,*,R) (a,a,R)


9 1 5
HAL STAR
(*,*,R) (∆, ∆,L)
(a,a,L)
(b,b,L) (a, ∆,L)
(a, ∆,L)
7 6
8
NaseerAhmed: Handout 23 -3- Theory of Automata and Formal Languages

The string aaabbbaaa can be observed to be accepted by


the above TM. It can also be observed that the above
TM accepts the non-CFL {anbnan}.

Sample Execution of Increment


Let’s see how they are carried out on a piece of paper that contains the reverse binary
representation of 47:
If read 1, write 0, go right, repeat.
If read 0, write 1, HALT!
If read •, write 1, HALT!

1 1 1 1 0 1 ∆

0 1 1 1 0 1 ∆

0 0 1 1 0 1 ∆

0 0 0 1 0 1 ∆

0 0 0 0 0 1 ∆

0 0 0 0 1 1 ∆

So the successor’s output on 111101 was 000011 which is the reverse binary representation
of 48.
Sample Execution
Similarly, the successor of 127 should be 128:
If read 1, write 0, go right, repeat.
If read 0, write 1, HALT!
If read ∆ •, write 1, HALT!

1 1 1 1 1 1 1 ∆

0 1 1 1 1 1 1 ∆
NaseerAhmed: Handout 23 -4- Theory of Automata and Formal Languages

0 0 1 1 1 1 1 ∆

0 0 0 1 1 1 1

0 0 0 0 1 1 1 ∆

0 0 0 0 0 1 1 ∆

0 0 0 0 0 0 1 ∆

0 0 0 0 0 0 0 ∆

0 0 0 0 0 0 0 1

Comparison with Previous Models


Device Separate Input? Read/Write Data Structure Deterministic by default?
FA Yes None Yes
PDA Yes Stack No
Yes
1-way infinite tape. 1 cell
TM No (but will also allow
access per step.
crashes)
ExamplesTM for 2X
NaseerAhmed: Handout 23 -5- Theory of Automata and Formal Languages

TM for Complement(inverse)

TM for (a+b)b(a+b)*

TM for even a’s and even b’s

TM of Palindrome
NaseerAhmed: Handout 23 -6- Theory of Automata and Formal Languages

1. Turing Machine For 2x+ 1:


1  1, R
0  0, R

  1, L

1. Increment Machine :
0  0, R
1 1, R 1 0, L

$  1, R
$  $, R   , L 0  1, R

Decrement Machine:
NaseerAhmed: Handout 23 -7- Theory of Automata and Formal Languages

0  0, R
1  1, R 0  1, L

$  $, R   , L 1  0, R

Comparison with Previous Models

Separate Read/Write Data Deterministic


Device
Input? Structure by default?

FA Yes None Yes

PDA Yes Stack No

1-way infinite Yes


TM No tape. 1 cell access (but will also
per step. allow crashes)

You might also like