COSC 3340 Introduction to Theory of Computation University

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

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

Definitions l l l A configuration is a snapshot of the machine written uqv.

Definitions l l l A configuration is a snapshot of the machine written uqv. Configuration C 1 yields configuration C 2 if the Turing machine can legally go from C 1 to C 2 in a single step. Suppose: a, b, and c in , u and v in * and states qi and qj. Then, uaqibv and uqjacv are two configurations. – – – 2 uaqibv yields uqjacv if (qi, b) = (qj, c, L). handles the case where the TM moves leftward. For a rightward move, uaqibv yields uacqjv if (qi, b) = (qj, c, R). Lecture 17 Uof. H - COSC 3340 - Dr. Verma

Special Cases l Special Cases occur when the head is at one of the

Special Cases l Special Cases occur when the head is at one of the ends of the configurations. – – 3 For the left-hand end, the configurations qibv yields qjcv if the transition is left moving, and it yields cqjv for the right moving transition. For the right-hand end, the configuration uaqi is equivalent to uaqi□ because we assume that blanks follow the part of the tape represented in the configuration. Thus we can handle this case as before, with the head no longer at the right hand end. Lecture 17 Uof. H - COSC 3340 - Dr. Verma

More Definitions l l 4 The start configuration of M on input w is

More Definitions l l 4 The start configuration of M on input w is the configuration q 0 w, which indicates that the machine is in the start state q 0 with its head at the leftmost position on the tape In an accepting configuration the state of the configuration is qaccept In a rejecting configuration the state of the configurations is qreject Accepting and rejecting configurations are halting configurations and accordingly do not yield further configurations Lecture 17 Uof. H - COSC 3340 - Dr. Verma

More Definitions l A TM M accepts input w if a sequence of configurations

More Definitions l A TM M accepts input w if a sequence of configurations C 1, C 2, …, Ck exists where 1. 2. 3. l 5 C 1 is the start configuration of M on input w, Each Ci yields Ci+1, and Ck is an accepting configuration. The collection of strings that M accepts is the language of M, denoted L(M). Lecture 17 Uof. H - COSC 3340 - Dr. Verma

More Definitions l - Turing-recognizable/acceptable TM M accepts/recognizes language L if L = {w

More Definitions l - Turing-recognizable/acceptable TM M accepts/recognizes language L if L = {w | M accepts w}. Note: 3 outcomes possible, either TM accepts, rejects, or loops. l Turing-decidable: TM M decides L if (i) w L, M writes a Yes on tape and halts (ii) w L, M writes a No on tape and halts. Every decidable language is Turing-recognizable but certain Turing-recognizable language are not decidable. 6 Lecture 17 Uof. H - COSC 3340 - Dr. Verma

Example of TM for {0 n 1 n 2 n | n > 0}

Example of TM for {0 n 1 n 2 n | n > 0} l English description of how the machine works: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 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 right, else reject. Scan past 1’s and z’s until you reach 2 If 2 found, change it to z and move left, else reject. Move left scanning past 0’s, y’s, z’s and 1’s If x found move right If 0 found, loop back to step 2. If 0 not found, scan past y’s and z’s and accept. Head is on the left or start of the string. x, y and z are just variables to keep track of equality 7 Lecture 17 Uof. H - COSC 3340 - Dr. Verma

Example of TM for {0 n 1 n 2 n | n > 0}

Example of TM for {0 n 1 n 2 n | n > 0} contd. In this case we are starting from the right or at the end of a given string on the tape. Table will be very similar if we start from the left. 8 State q 0 q 0 Symbol 0 1 2 Next state action (q 1, x, R) halt/reject q 0 q 0 x y z halt/reject (q 4, y, R) halt/reject Lecture 17 Uof. H - COSC 3340 - Dr. Verma

Example of TM for {0 n 1 n 2 n | n > 0}

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

Example of TM for {0 n 1 n 2 n | n > 0}

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

Example of TM for {0 n 1 n 2 n | n > 0}

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

Example of TM for {0 n 1 n 2 n | n > 0}

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

Example of TM for {0 n 1 n 2 n | n > 0}

Example of TM for {0 n 1 n 2 n | n > 0} contd. 13 State q 5 q 5 Symbol 0 1 2 Next state action halt/reject q 5 q 5 x y z □ halt/reject Lecture 17 Uof. H - COSC 3340 - Dr. Verma

Example of TM for {0 n 1 n 2 n | n > 0}

Example of TM for {0 n 1 n 2 n | n > 0} contd. 14 Lecture 17 Uof. H - COSC 3340 - Dr. Verma

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Different way of making {0 n 1 n 2 n | n 0} 40

Different way of making {0 n 1 n 2 n | n 0} 40 Lecture 17 Uof. H - COSC 3340 - Dr. Verma