Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Graphical representation –Formal.

Similar presentations


Presentation on theme: "1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Graphical representation –Formal."— Presentation transcript:

1 1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Graphical representation –Formal Definition –Equivalence to C++

2 2 Overview So far, we have worked with C ++ as our computational model Historically, much of the material we have just covered is usually presented with the Turing machine model of computation –We now define this computational model –Note, it is as powerful (general) as C ++

3 3 Language Recognition Problems We define Turing machines with language recognition problems as our focus –Decision problems are general –Decision problems can be formulated as languages with language recognition problems

4 4 Components of Computational Models Memory Data Types Operations Graphical Representation Formal Definition

5 5 Memory Random Access Memory Model –We have been assuming a random access memory computational model for C ++ –Time to access next memory location is independent of previously accessed memory location Sequential Access Memory Model –Memory is stored on a tape broken up into cells –Tape head scans currently accessed cell

6 6 Illustration Tape Head Time to access a particular cell is dependent on current tape head location...

7 7 Data Types C ++ has many data types –integers –reals –characters –allows definition of new data types Turing machine –just characters –Alphabet will typically be just {a,b} or {0,1}

8 8 Illustration... a baabab Tape Head

9 9 Operations C ++ has a complex operation set –some operations change memory –other operations control flow of execution Turing machine operation set –Memory operations read a character write a character tape head movement –simple control flow switch statements goto statements

10 10 Illustration... a baabab Tape Head 1 switch(current tape cell) { case a: write b; move tapehead left 1 cell; goto 7; case b: write a; move tapehead right 1 cell; goto 4; case EOF: return YES; } 2 switch(current tape cell) {...

11 11 Sample Program 1 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 2; case b: write b; move tapehead right 1 cell; goto 2; case EOF: return YES; } 2 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 1; case b: write b; move tapehead right 1 cell; goto 1; case EOF: return NO; } Claim –The Turing machine computational model is as powerful as C ++ –Any language which can be solved by a C ++ program can be solved by a Turing machine

12 12 Example 1 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 2; case b: write b; move tapehead right 1 cell; goto 2; case EOF: return YES; } 2 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 1; case b: write b; move tapehead right 1 cell; goto 1; case EOF: return NO; } Run this program on input aabbaa

13 13 Computation 1 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 2; case b: write b; move tapehead right 1 cell; goto 2; case EOF: return YES; } 2 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 1; case b: write b; move tapehead right 1 cell; goto 1; case EOF: return NO; } Input: aabbaa Line 1, tape=aabbaa$ Line 2, tape=aabbaa$ Line 1, tape=aabbaa$ Line 2, tape=aabbaa$ Line 1, tape=aabbaa$ Line 2, tape=aabbaa$ Line 1, tape=aabbaa$ Output yes –$ is EOF

14 14 Configurations What is the functional definition of a configuration? What needs to be recorded in configurations for this new programming language? –Current instruction –Tape contents –Tape head location Line 1, tape=aabbaa$ Line 2, tape=aabbaa$ Line 1, tape=aabbaa$ Line 2, tape=aabbaa$ Line 1, tape=aabbaa$ Line 2, tape=aabbaa$ Line 1, tape=aabbaa$ Return yes –$ is EOF

15 15 Graphical Representation 1 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 2; case b: write b; move tapehead right 1 cell; goto 2; case EOF: return YES; } 2 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 1; case b: write b; move tapehead right 1 cell; goto 1; case EOF: return NO; } 1 2 a;a;R b;b;R a;a;R b;b;R Color coded. Still missing one thing.

16 16 Formal Definition Turing machine M = (Q, , , q 0, , A) –Q: set of states Example Q = {1,2} –  : input alphabet Example  = {a,b} –  : tape alphabet Example  = {a,b,$ (EOF)} –q 0 : initial state Example q 0 = 1 –A: accepting states Example A = {1} 1 2 a;a;R b;b;R a;a;R b;b;R

17 17 Formal Definition continued  : transition function –Example  St. Inp NS Upd Move 1 a 2 a R 1 b 2 b R 2 a 1 a R 2 b 1 b R 1 2 a;a;R b;b;R a;a;R b;b;R

18 18 Defining 4 types of inputs Y(M) or L(M): the set of strings TM M halts on in an accepting state N(M): the set of strings TM M halts on in a rejecting (non-accepting) state C(M): the set of strings TM M crashes on –may run off end of tape in some TM models I(M): the set of strings TM M infinite loops on

19 19 Solvable, half-solvable, and unsolvable problems A TM M half-solves language recognition problem L if and only if Y(M) = L A TM M solves language recognition problem L if and only if M half-solves L and N(M) = L C The set of problems solvable problems defined by Turing machines is identical to the set of solvable problems defined by C++ programs. Likewise for half-solvable problems


Download ppt "1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –Graphical representation –Formal."

Similar presentations


Ads by Google