![Page 1: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/1.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/2.jpg)
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](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/3.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma3
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 4: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/4.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma4
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 5: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/5.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma5
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 6: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/6.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma6
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 7: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/7.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma7
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 8: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/8.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma8
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 9: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/9.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma9
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 10: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/10.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma10
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 11: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/11.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma11
Example of TM for {0n1n | n > 0} contd.
![Page 12: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/12.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma12
JFLAP SIMULATION
![Page 13: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/13.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma13
JFLAP SIMULATION
![Page 14: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/14.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma14
JFLAP SIMULATION
![Page 15: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/15.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma15
JFLAP SIMULATION
![Page 16: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/16.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma16
JFLAP SIMULATION
![Page 17: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/17.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma17
JFLAP SIMULATION
![Page 18: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/18.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma18
JFLAP SIMULATION
![Page 19: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/19.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma19
JFLAP SIMULATION
![Page 20: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/20.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma20
JFLAP SIMULATION
![Page 21: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/21.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma21
JFLAP SIMULATION
![Page 22: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/22.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma22
JFLAP SIMULATION
![Page 23: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/23.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma23
JFLAP SIMULATION
![Page 24: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/24.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma24
JFLAP SIMULATION
![Page 25: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/25.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma25
JFLAP SIMULATION
![Page 26: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/26.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma26
JFLAP SIMULATION
![Page 27: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/27.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma27
JFLAP SIMULATION
![Page 28: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/28.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma28
JFLAP SIMULATION
![Page 29: COSC 3340: Introduction to Theory of Computation](https://reader036.vdocument.in/reader036/viewer/2022062803/5681474c550346895db48fe7/html5/thumbnails/29.jpg)
Lecture 16 UofH - COSC 3340 - Dr. Verma29
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.