Title: COSC 3340: Introduction to Theory of Computation
1COSC 3340 Introduction to Theory of Computation
- University of Houston
- Dr. Verma
- Lecture 16
2Turing Machine (TM)
. . .
Bi-direction Read/Write
Finite State control
3Turing 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 - Some (q, ?) combinations may not have any moves.
In this case the machine halts.
4Turing Machine (contd.)
- We can design TMs for computing functions from
strings to strings - We can design TMs to decide languages
- using special states accept/reject or by writing
Y/N on tape. - We can design TMs to accept languages.
- if TM halts string is accepted
- Note there is a big difference between language
decision and acceptance!
5Example of TM for 0n1n n gt 0
- English description of how the machine works
- Look for 0s
- If 0 found, change it to x and move right, else
reject - Scan past 0s and ys until you reach 1
- If 1 found, change it to y and move left, else
reject. - Move left scanning past 0s and ys
- If x found move right
- If 0 found, loop back to step 2.
- If 0 not found, scan past ys and accept.
Head is on the left or start of the string.
x and y are just variables to keep track of
equality
6Example of TM for 0n1n n gt 0 contd.
Head is on the left or start of the string.
State Symbol Next state action
q0 0 (q1, x, R)
q0 1 halt/reject
q0 x halt/reject
q0 y (q3, y, R)
7Example of TM for 0n1n n gt 0 contd.
Head is on the left or start of the string.
State Symbol Next state action
q1 0 (q1, 0, R)
q1 1 (q2, y, L)
q1 x halt/reject
q1 y (q1, y, R)
8Example of TM for 0n1n n gt 0 contd.
Head is on the left or start of the string.
State Symbol Next state action
q2 0 (q2, 0, L)
q2 1 halt/reject
q2 x (q0, x, R)
q2 y (q2, y, L)
9Example of TM for 0n1n n gt 0 contd.
Head is on the left or start of the string.
State Symbol Next state action
q3 0 halt/reject
q3 1 halt/reject
q3 x halt/reject
q3 y (q3, y, R)
q3 ? (q4, ?, R)
10Example of TM for 0n1n n gt 0 contd.
Head is on the left or start of the string.
State Symbol Next state action
q4 0 illegal i/p
q4 1 illegal i/p
q4 x illegal i/p
q4 y illegal i/p
q4 ? halt/accept
11Example of TM for 0n1n n gt 0 contd.
12JFLAP SIMULATION
13JFLAP SIMULATION
14JFLAP SIMULATION
15JFLAP SIMULATION
16JFLAP SIMULATION
17JFLAP SIMULATION
18JFLAP SIMULATION
19JFLAP SIMULATION
20JFLAP SIMULATION
21JFLAP SIMULATION
22JFLAP SIMULATION
23JFLAP SIMULATION
24JFLAP SIMULATION
25JFLAP SIMULATION
26JFLAP SIMULATION
27JFLAP SIMULATION
28JFLAP SIMULATION
29Formal 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.