COSC 3340 Introduction to Theory of Computation University

  • Slides: 30
Download presentation
COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 16

COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 16 1 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

Turing Machine (TM) . . . Bi-direction Read/Write Finite State control 2 Lecture 16

Turing Machine (TM) . . . Bi-direction Read/Write Finite State control 2 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

Historical Note l Proposed by Alan Turing in 1936 in: On Computable Numbers, with

Historical Note l 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 Uof. H - COSC 3340 - Dr. Verma

Turing Machine (contd. ) l Based on (q, ), q – current state, –

Turing Machine (contd. ) l 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 l 4 Some (q, ) combinations may not have any moves. In this case the machine halts. Lecture 16 Uof. H - COSC 3340 - Dr. Verma

Turing Machine (contd. ) l l We can design TM’s for computing functions from

Turing Machine (contd. ) l l We can design TM’s for computing functions from strings to strings We can design TM’s to decide languages – l 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 Uof. H - COSC 3340 - Dr. Verma

Example of TM for {0 n 1 n | n > 0} l English

Example of TM for {0 n 1 n | n > 0} l 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 Uof. H - COSC 3340 - Dr. Verma

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

Example of TM for {0 n 1 n | n > 0} contd. Head is on the left or start of the string. 7 State q 0 q 0 Symbol 0 1 x Next state action (q 1, x, R) halt/reject q 0 y (q 3, y, R) Lecture 16 Uof. H - COSC 3340 - Dr. Verma

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

Example of TM for {0 n 1 n | n > 0} contd. Head is on the left or start of the string. 8 State q 1 q 1 Symbol 0 1 x Next state action (q 1, 0, R) (q 2, y, L) halt/reject q 1 y (q 1, y, R) Lecture 16 Uof. H - COSC 3340 - Dr. Verma

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

Example of TM for {0 n 1 n | n > 0} contd. Head is on the left or start of the string. 9 State q 2 q 2 Symbol 0 1 x Next state action (q 2, 0, L) halt/reject (q 0, x, R) q 2 y (q 2, y, L) Lecture 16 Uof. H - COSC 3340 - Dr. Verma

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

Example of TM for {0 n 1 n | n > 0} contd. Head is on the left or start of the string. 10 State q 3 q 3 Symbol 0 1 x Next state action halt/reject q 3 y □ (q 3, y, R) (q 4, □, R) Lecture 16 Uof. H - COSC 3340 - Dr. Verma

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

Example of TM for {0 n 1 n | n > 0} contd. Head is on the left or start of the string. 11 State q 4 q 4 Symbol 0 1 x Next state action illegal i/p q 4 y □ illegal i/p halt/accept Lecture 16 Uof. H - COSC 3340 - Dr. Verma

Example of TM for {0 n 1 n | n 0} contd. 12 Lecture

Example of TM for {0 n 1 n | n 0} contd. 12 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 13 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 13 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 14 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 14 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 15 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 15 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 16 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 16 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 17 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 17 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 18 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 18 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 19 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 19 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 20 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 20 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 21 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 21 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 22 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 22 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 23 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 23 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 24 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 24 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 25 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 25 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 26 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 26 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 27 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 27 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 28 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 28 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 29 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

JFLAP SIMULATION 29 Lecture 16 Uof. H - COSC 3340 - Dr. Verma

Formal Definition of TM l Formally a TM M = (Q, , s) where,

Formal Definition of TM l Formally a TM M = (Q, , s) where, – – – l 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 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 Uof. H - COSC 3340 - Dr. Verma