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 –Formal Definition –Equivalence.

Similar presentations


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

1 1 Lecture 13 Turing machine model of computation –Sequential access memory (tape) –Limited data types and instructions –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 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 1-way infinite tape broken up into cells –Tape head scans currently accessed cell –Tape head begins computation at leftmost 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} We also have an implicitly defined blank character B

8 8 Illustration... B baabBB Tape Head The first cell will always be a blank. Then the input will appear. Then an infinite series of blanks

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... B baabBB 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 B: write B; keep tapehead stationary; 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 B: write B; move tapehead right 1 cell; goto 2; } 2 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 3; case b: write b; move tapehead right 1 cell; goto 3; case B: write B; keep tapehead stationary; return YES; } 3 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 B: write B; keep tapehead stationary; return NO; }

12 12 Church-Turing Thesis The Turing machine computational model is a general model of computation What this means –Turing machines are as general as any other model of computation including C ++ –Any language/problem that can be solved by a C ++ program can be solved by a Turing machine

13 13 Example 1 switch(current tape cell) { case B: write B; move tapehead right 1 cell; goto 2; } 2 switch(current tape cell) { case a: write a; move tapehead right 1 cell; goto 3; case b: write b; move tapehead right 1 cell; goto 3; case B: write B; keep tapehead stationary; return YES; } 3 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 B: write B; keep tapehead stationary; return NO; } Run this program on input aabbaa

14 14 Computation 1 switch(current tape cell) { case B: write B; right; goto 2; } 2 switch(current tape cell) { case a: write a; Right; goto 3; case b: write b; right; goto 3; case B: write B; stay; return YES; } 3 switch(current tape cell) { case a: write a; right; goto 2; case b: write b; right; goto 2; case B: write B; stay; return NO; } Input: aabbaa Line 1, tape=Baabbaa Line 2, tape=Baabbaa Line 3, tape=Baabbaa Line 2, tape=Baabbaa Line 3, tape=Baabbaa Line 2, tape=Baabbaa Line 3, tape=Baabbaa Line 2, tape=BaabbaaB Output yes

15 15 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=Baabbaa Line 2, tape=Baabbaa Line 3, tape=Baabbaa Line 2, tape=Baabbaa Line 3, tape=Baabbaa Line 2, tape=Baabbaa Line 3, tape=Baabbaa Line 2, tape=BaabbaaB Output yes

16 16 Formal Definition Turing machine M = (Q, , , q 0,  ) –Q: set of states Example Q = {1,2,3} –  : input alphabet Example  = {a,b} –  : tape alphabet Example  = {a,b,B} –q 0 : initial state Example q 0 = 1 1 switch(current tape cell) { case B: write B; right; goto 2; } 2 switch(current tape cell) { case a: write a; Right; goto 3; case b: write b; right; goto 3; case B: write B; stay; return YES; } 3 switch(current tape cell) { case a: write a; right; goto 2; case b: write b; right; goto 2; case B: write B; stay; return NO; }

17 17 Formal Definition continued  : transition function –Example  St. Inp NS Upd Move 1 B 2 B R 2 a 3 a R 2 b 3 b R 2 B yes B S 3 a 2 a R 3 b 2 b R 3 B no B S 1 switch(current tape cell) { case B: write B; right; goto 2; } 2 switch(current tape cell) { case a: write a; Right; goto 3; case b: write b; right; goto 3; case B: write B; stay; return YES; } 3 switch(current tape cell) { case a: write a; right; goto 2; case b: write b; right; goto 2; case B: write B; stay; return NO; }

18 18 Defining 4 types of inputs Y(M) or L(M): the set of strings TM M returns yes on N(M): the set of strings TM M returns no on C(M): the set of strings TM M crashes on –may run off end of tape in some TM models –may stop in a state without explicitly saying yes or no 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 –Formal Definition –Equivalence."

Similar presentations


Ads by Google