cosc 3340: introduction to theory of computation

30
Lecture 16 UofH - COSC 3340 - Dr. Ve rma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 16

Upload: shelley-reese

Post on 03-Jan-2016

22 views

Category:

Documents


0 download

DESCRIPTION

COSC 3340: Introduction to Theory of Computation. University of Houston Dr. Verma Lecture 16. Turing Machine ( TM ). Bi-direction Read/Write. Finite State control. Historical Note. Proposed by Alan Turing in 1936 in: - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma1

COSC 3340: Introduction to Theory of Computation

University of Houston

Dr. Verma

Lecture 16

Page 2: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma2

Turing Machine (TM)

. . .

Finite State

control

Bi-directionRead/Write

Page 3: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma3

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).

Page 4: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma4

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

Some (q, ) combinations may not have any moves. In this case the machine halts.

Page 5: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma5

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!

Page 6: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma6

Example of TM for {0n1n | n > 0}

English description of how the machine works:1. Look for 0’s2. If 0 found, change it to x and move right, else reject3. Scan past 0’s and y’s until you reach 14. If 1 found, change it to y and move left, else reject.5. Move left scanning past 0’s and y’s6. If x found move right7. If 0 found, loop back to step 2.8. If 0 not found, scan past y’s and accept.

Head is on the left or start of the string.

x and y are just variables to keep track of equality

Page 7: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma7

Example of TM for {0n1n | n > 0} contd.

State Symbol Next state action

q0 0 (q1, x, R)

q0 1 halt/reject

q0 x halt/reject

q0 y (q3, y, R)

Head is on the left or start of the string.

Page 8: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma8

Example of TM for {0n1n | n > 0} contd.

State Symbol Next state action

q1 0 (q1, 0, R)

q1 1 (q2, y, L)

q1 x halt/reject

q1 y (q1, y, R)

Head is on the left or start of the string.

Page 9: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma9

Example of TM for {0n1n | n > 0} contd.

State Symbol Next state action

q2 0 (q2, 0, L)

q2 1 halt/reject

q2 x (q0, x, R)

q2 y (q2, y, L)

Head is on the left or start of the string.

Page 10: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma10

Example of TM for {0n1n | n > 0} contd.

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)

Head is on the left or start of the string.

Page 11: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma11

Example of TM for {0n1n | n > 0} contd.

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

Head is on the left or start of the string.

Page 12: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma12

Example of TM for {0n1n | n 0} contd.

Page 13: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma13

JFLAP SIMULATION

Page 14: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma14

JFLAP SIMULATION

Page 15: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma15

JFLAP SIMULATION

Page 16: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma16

JFLAP SIMULATION

Page 17: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma17

JFLAP SIMULATION

Page 18: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma18

JFLAP SIMULATION

Page 19: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma19

JFLAP SIMULATION

Page 20: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma20

JFLAP SIMULATION

Page 21: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma21

JFLAP SIMULATION

Page 22: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma22

JFLAP SIMULATION

Page 23: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma23

JFLAP SIMULATION

Page 24: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma24

JFLAP SIMULATION

Page 25: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma25

JFLAP SIMULATION

Page 26: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma26

JFLAP SIMULATION

Page 27: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma27

JFLAP SIMULATION

Page 28: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma28

JFLAP SIMULATION

Page 29: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma29

JFLAP SIMULATION

Page 30: COSC 3340: Introduction to Theory of Computation

Lecture 16 UofH - COSC 3340 - Dr. Verma30

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.