Transcript 13

COSC 3340: Introduction to Theory of
Computation
University of Houston
Dr. Verma
Lecture 16
1
Lecture 16
UofH - COSC 3340 - Dr. Verma
Turing Machine (TM)
. . .
Bi-direction
Read/Write
Finite
State
control
2
Lecture 16
UofH - COSC 3340 - Dr. Verma
Historical Note

Proposed by Alan Turing in 1936 in:
On Computable Numbers, with an application
to the Entscheidungsproblem, Proc. Lond.
Math. Soc. (2) 42 pp 230-265 (1936-7);
correction ibid. 43, pp 544-546 (1937).
3
Lecture 16
UofH - COSC 3340 - Dr. Verma
Turing Machine (contd.)

Based on (q, ), q – current state,  –
symbol scanned by head, in one move, the
TM can:
(i) change state
(ii) write a symbol in the scanned cell
(iii) move the head one cell to the left or right

4
Some (q, ) combinations may not have
any moves. In this case the machine halts.
Lecture 16
UofH - COSC 3340 - Dr. Verma
Turing Machine (contd.)


We can design TM’s for computing functions from
strings to strings
We can design TM’s to decide languages
–

using special states accept/reject or by writing Y/N on tape.
We can design TM’s to accept languages.
–
if TM halts string is accepted
Note: there is a big difference between language
decision and acceptance!
5
Lecture 16
UofH - COSC 3340 - Dr. Verma
Example of TM for {0n1n | n > 0}

English description of how the machine works:
1.
2.
3.
4.
5.
6.
7.
8.
Look for 0’s
If 0 found, change it to x and move right, else reject
Scan past 0’s and y’s until you reach 1
If 1 found, change it to y and move left, else reject.
Move left scanning past 0’s and y’s
If x found move right
If 0 found, loop back to step 2.
If 0 not found, scan past y’s and accept.
Head is on the left or start of the string.
6
x and y are just variables to keep track of equality
Lecture 16
UofH - COSC 3340 - Dr. Verma
Example of TM for {0n1n | n > 0} contd.
Head is on the left or start of the string.
7
State
Symbol
Next state action
q0
q0
q0
q0
0
1
x
y
(q1, x, R)
halt/reject
halt/reject
(q3, y, R)
Lecture 16
UofH - COSC 3340 - Dr. Verma
Example of TM for {0n1n | n > 0} contd.
Head is on the left or start of the string.
8
State
Symbol
Next state action
q1
q1
q1
q1
0
1
x
y
(q1, 0, R)
(q2, y, L)
halt/reject
(q1, y, R)
Lecture 16
UofH - COSC 3340 - Dr. Verma
Example of TM for {0n1n | n > 0} contd.
Head is on the left or start of the string.
9
State
Symbol
Next state action
q2
q2
q2
q2
0
1
x
y
(q2, 0, L)
halt/reject
(q0, x, R)
(q2, y, L)
Lecture 16
UofH - COSC 3340 - Dr. Verma
Example of TM for {0n1n | n > 0}
contd.
Head is on the left or start of the string.
10
State
Symbol
Next state action
q3
q3
q3
q3
0
1
x
y
halt/reject
halt/reject
halt/reject
(q3, y, R)
q3
□
(q4, □, R)
Lecture 16
UofH - COSC 3340 - Dr. Verma
Example of TM for {0n1n | n > 0}
contd.
Head is on the left or start of the string.
11
State
Symbol
Next state action
q4
q4
q4
q4
0
1
x
y
illegal i/p
illegal i/p
illegal i/p
illegal i/p
q4
□
halt/accept
Lecture 16
UofH - COSC 3340 - Dr. Verma
Example of TM for {0n1n | n  0} contd.
12
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
13
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
14
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
15
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
16
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
17
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
18
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
19
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
20
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
21
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
22
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
23
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
24
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
25
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
26
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
27
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
28
Lecture 16
UofH - COSC 3340 - Dr. Verma
JFLAP SIMULATION
29
Lecture 16
UofH - COSC 3340 - Dr. Verma
Formal Definition of TM

Formally a TM M = (Q, , , , s) where,
–
–
–
–
–

Q – a finite set of states
– input alphabet not containing the blank symbol #
– the tape alphabet of M
s in Q is the start state
 : Q X   Q X  X {L, R} is the (partial) transition function.
Note:
(i) We leave out special states.
(ii) The model is deterministic but we just say TM instead of
DTM.
30
Lecture 16
UofH - COSC 3340 - Dr. Verma