Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10 Models of Computation. What is a model? Captures the essence – the important properties – of the real thing Captures the essence – the important.

Similar presentations


Presentation on theme: "Chapter 10 Models of Computation. What is a model? Captures the essence – the important properties – of the real thing Captures the essence – the important."— Presentation transcript:

1 Chapter 10 Models of Computation

2 What is a model? Captures the essence – the important properties – of the real thing Captures the essence – the important properties – of the real thing Probably differs in scale from the real thing Probably differs in scale from the real thing Suppresses details of the real thing Suppresses details of the real thing Lacks the full functionality of the real thing Lacks the full functionality of the real thing

3 Examples Physical models Physical models Model carsModel cars DollsDolls Velcro-covered balls stuck together in a certain way to represent the molecular structure.Velcro-covered balls stuck together in a certain way to represent the molecular structure. Mathematical models Mathematical models d=rxtd=rxt Weather systemWeather system

4 Models Models Models Can be used to predict behavior of existing phenomenaCan be used to predict behavior of existing phenomena can provide environments for learning and practicing interactions with various phenomena.can provide environments for learning and practicing interactions with various phenomena. Can be used as design tools.Can be used as design tools. But, the information gained is only as good as the model used. But, the information gained is only as good as the model used.

5 A Model of Computing Agent We want to construct a model for the “ computing agent ” that will capture its fundamental properties and enable us to explore the capabilities and limitations of computation in the most general sense. We want to construct a model for the “ computing agent ” that will capture its fundamental properties and enable us to explore the capabilities and limitations of computation in the most general sense.

6 Properties of A Computing Agent We shall require that any computing agent We shall require that any computing agent Can accept inputCan accept input Can store information in and retrieve it from memoryCan store information in and retrieve it from memory Can take actions according to algorithm instructions, and that the choice of what action to take may depend on the present state of the computing agent as well as on the input item presently being processedCan take actions according to algorithm instructions, and that the choice of what action to take may depend on the present state of the computing agent as well as on the input item presently being processed Can produce outputCan produce output

7 The Turing Machine: Historical Prospective Interest in the theoretical nature of computation far predated the advent of modern computers. Interest in the theoretical nature of computation far predated the advent of modern computers. Mathematicians are interested in formalizing the nature of proof, with two goals in mind: Mathematicians are interested in formalizing the nature of proof, with two goals in mind: Guarantee the correctness of a proofGuarantee the correctness of a proof Allow for mechanical theorem provingAllow for mechanical theorem proving Leads to the study of the nature of computation procedure itself. Leads to the study of the nature of computation procedure itself. We will look at the model proposed by Alan Turing. We will look at the model proposed by Alan Turing.

8 The Turing Machine A Turing machine includes a (conceptual) tape that extends infinitely in both directions. A Turing machine includes a (conceptual) tape that extends infinitely in both directions. The tape is divided into cells, each of which contains one symbol. The tape is divided into cells, each of which contains one symbol. The symbols must come from a finite set of symbols called the alphabet. The symbols must come from a finite set of symbols called the alphabet. The alphabet always contains a special symbol b (for “ blank ” ), usually both of the symbols 0 and 1, and others. The alphabet always contains a special symbol b (for “ blank ” ), usually both of the symbols 0 and 1, and others. At any point in time, only a finite number of cells contain nonblank symbols. At any point in time, only a finite number of cells contain nonblank symbols.

9 The Turing Machine (cont’d) Example: Example: The tape will be used to hold input to the Turing machine. The tape will be used to hold input to the Turing machine. The Turing machine will write its output on the tape. The Turing machine will write its output on the tape. The tape will also serve as memory. The tape will also serve as memory..bb011bb....

10 The Turing Machine (cont’d) The rest of the Turing machine consists of a unit that reads one cell of the tape at a time and writes a symbol in that cell. The rest of the Turing machine consists of a unit that reads one cell of the tape at a time and writes a symbol in that cell. There is a finite number k of “ states ” of the machine, labeled 1,2, …,k, and at any moment, the unit is in one of these states. There is a finite number k of “ states ” of the machine, labeled 1,2, …,k, and at any moment, the unit is in one of these states. A Turing machine configuration: A Turing machine configuration:.bb011bb.... 1 (current state of the machine)

11 The Turing Machine (cont’d) The Turing machine is designed to carry out only one type of primitive operation. The Turing machine is designed to carry out only one type of primitive operation. Each time such an operation is done, three actions take place: Each time such an operation is done, three actions take place: Write a symbol in the cellWrite a symbol in the cell Go into a new stateGo into a new state Move one cell left or rightMove one cell left or right The details of the actions depend on the current state of the machine and on the contents of the tape cell currently being read (the input). The details of the actions depend on the current state of the machine and on the contents of the tape cell currently being read (the input).

12 Primitive Operation (Instruction) If you are in state I and you are reading symbol j then write symbol k onto the tape go into state s move in direction d If you are in state I and you are reading symbol j then write symbol k onto the tape go into state s move in direction d

13 Shorthand Notation for Turing Machine Instructions Five components: Five components: Current stateCurrent state Current symbolCurrent symbol Next symbolNext symbol Next stateNext state Direction of moveDirection of move (current state, current symbol, next symbol, next state, direction of move) (current state, current symbol, next symbol, next state, direction of move)

14 Example (1,0,1,2,R) (1,0,1,2,R).bb011bb.... 1 (current state of the machine).bb111bb.... 2 (current state of the machine)

15 More on Turing Machine Instructions What if we have (1,0,1,2,R) and (1,0,0,3,L) What if we have (1,0,1,2,R) and (1,0,0,3,L) Avoid ambiguity by requiring that a set of instructions for a Turing machine can never contain two different instructions of the form (i,j,-,-,-) and (i,j,-,-,-) Avoid ambiguity by requiring that a set of instructions for a Turing machine can never contain two different instructions of the form (i,j,-,-,-) and (i,j,-,-,-) If there is no instruction that applies to the current state-current symbol for the machine, then the machine halts. If there is no instruction that applies to the current state-current symbol for the machine, then the machine halts. Conventions about initial configuration: Conventions about initial configuration: The start-up will always be state 1The start-up will always be state 1 The machine will be reading the leftmost nonblank cell on the tape.The machine will be reading the leftmost nonblank cell on the tape.

16 Example 1. (1,0,1,2,R) 2. (1,1,1,2,R) 3. (2,0,1,2,R) 4. (2,1,0,2,R) 5. (2,b,b,3,L).bb011bb.... 1

17 Example (cont’d).bb111bb.... 2.bb101bb.... 2.bb100bb.... 2.bb100bb.... 3

18 Turing Machine as a Computing Agent The Turing machine can: The Turing machine can: Read symbols on its tape.Read symbols on its tape. Write symbols on its tape and, by moving around over the tape, can go back and read those symbols at a later time.Write symbols on its tape and, by moving around over the tape, can go back and read those symbols at a later time. The present state and symbol determine the appropriate instructionThe present state and symbol determine the appropriate instruction If the Turing machine halts, what is written on the tape at that time can be considered output.If the Turing machine halts, what is written on the tape at that time can be considered output.

19 Summary A Turing machine is a general computing machine. A Turing machine is a general computing machine. It has no limit on the amount of memory. It has no limit on the amount of memory.

20 A Model of An Algorithm An algorithm is a collection of instructions intended for a computing agent to follow. An algorithm is a collection of instructions intended for a computing agent to follow. Requirements: Requirements: Be a well-ordered collectionBe a well-ordered collection Consists of unambiguous and effectively computable operationsConsists of unambiguous and effectively computable operations Halts in a finite amount of timeHalts in a finite amount of time Produce a resultProduce a result Does an arbitrary collection of Turing machine instructions satisfy all the requirements? Does an arbitrary collection of Turing machine instructions satisfy all the requirements?

21 Turing Machine Examples Bit converter Bit converter (1,0,1,1,R) and (1,1,0,1,R)(1,0,1,1,R) and (1,1,0,1,R) A state diagram is a visual representation of a Turing machine algorithm where circles represent states, and arrows represent transitions from one state to another. A state diagram is a visual representation of a Turing machine algorithm where circles represent states, and arrows represent transitions from one state to another. Along each transition arrow, we show three things: Along each transition arrow, we show three things: The input symbol that causes the transitionThe input symbol that causes the transition The corresponding outputThe corresponding output The direction of moveThe direction of move

22 A Parity Bit Machine Odd parity bit: will be set so that the number of 1s in the whole string of bits, including the parity bit, is odd. Odd parity bit: will be set so that the number of 1s in the whole string of bits, including the parity bit, is odd. (1,1,1,2,R): even parity state reading 1, change state(1,1,1,2,R): even parity state reading 1, change state (1,0,0,1,R):even parity state reading 0, don ’ t change state(1,0,0,1,R):even parity state reading 0, don ’ t change state (2,1,1,1,R): odd parity state reading 1, change state(2,1,1,1,R): odd parity state reading 1, change state (2,0,0,2,R):odd parity state reading 0, don ’ t change state(2,0,0,2,R):odd parity state reading 0, don ’ t change state (1,b,1,3,R): end of string in even parity state, write 1 and go to state 3(1,b,1,3,R): end of string in even parity state, write 1 and go to state 3 (2,b,0,3,R): end of string in even parity state, write 1 and go to state 3(2,b,0,3,R): end of string in even parity state, write 1 and go to state 3

23 Unary Incrementing Unary representation of numbers: NumberTuring machine tape representation 01 111 2111 Unary representation of numbers: NumberTuring machine tape representation 01 111 2111 Incrementing (algorithm 1): Incrementing (algorithm 1): (1,1,1,1,R): pass to the right over 1s(1,1,1,1,R): pass to the right over 1s (1,b,1,2,R): Add a single one at the right hand side of the string(1,b,1,2,R): Add a single one at the right hand side of the string.bb111bb....

24 Incrementing: Algorithm 2 (1,1,1,1,L): pass to the left over 1s (1,1,1,1,L): pass to the left over 1s (1,b,1,2,L): Add a single 1 at the left-hand end of the string (1,b,1,2,L): Add a single 1 at the left-hand end of the string 2 steps vs. n+2 steps 2 steps vs. n+2 steps.bb111bb....

25 Unary Addition Machine (1,1,b,2,R): erase the leftmost 1 and move right (1,1,b,2,R): erase the leftmost 1 and move right (2,1,b,3,R): erase the second 1 and move right (2,1,b,3,R): erase the second 1 and move right (3,1,1,3,R):pass over any 1s until a blank is found (3,1,1,3,R):pass over any 1s until a blank is found (3,b,1,4,R):write a 1 over the blank and halt. (3,b,1,4,R):write a 1 over the blank and halt.

26 The Church-Turing Thesis If there is an algorithm to do a symbol manipulation task, then there is a Turing machine to do that task. If there is an algorithm to do a symbol manipulation task, then there is a Turing machine to do that task. If we find a symbol manipulation task that no Turing machine can perform, then there is no algorithm for this task. If we find a symbol manipulation task that no Turing machine can perform, then there is no algorithm for this task. Turing machines define the limits of Computability. Turing machines define the limits of Computability.

27 Unsolvable Problems Example: (1,0,1,2,R) (1,1,0,2,R) (2,0,0,2,R) (2,b,b,2,L) Example: (1,0,1,2,R) (1,1,0,2,R) (2,0,0,2,R) (2,b,b,2,L) … b11bbb … 2 … b11bbb … 2 … b1bbb … 1 … b1bbb … 1

28 The Halting Problem Formal statement: Decide, given any collection of Turing machine instructions together with any initial tape contents, whether that Turing machine will ever halt if started on that tape. Formal statement: Decide, given any collection of Turing machine instructions together with any initial tape contents, whether that Turing machine will ever halt if started on that tape. The halting problem is unsolvable, and we will prove it by contradiction. The halting problem is unsolvable, and we will prove it by contradiction.

29 Proof Assume that P is a Turing machine that solves the halting problem. Assume that P is a Turing machine that solves the halting problem. On the initial for P we will have to put a description of a collection T of Turing machine instructions, as well as the initial tape content t on which those instructions run. On the initial for P we will have to put a description of a collection T of Turing machine instructions, as well as the initial tape content t on which those instructions run. … T*btbbb … (T* symbolize the binary form of T) … T*btbbb … (T* symbolize the binary form of T)

30 Proof (cont’d) P will give us an answer P will give us an answer Yes, halts (1)Yes, halts (1) No, never halts (0)No, never halts (0) When begun on a tape containing T* and t, When begun on a tape containing T* and t, P halts with 1 on its tape exactly when T eventually halts when begun on tP halts with 1 on its tape exactly when T eventually halts when begun on t P halts with 0 on its tape exactly when T never halts when begun on tP halts with 0 on its tape exactly when T never halts when begun on t Refer to Figure 10.10 Refer to Figure 10.10

31 Proof (cont’d) Let ’ s imagine adding more instructions to P to create a new machine Q that behaves just like P except that when it reaches this sme configuration, it moves forever to the right on the tape instead of halting. (Refer to Figure 10.11) Let ’ s imagine adding more instructions to P to create a new machine Q that behaves just like P except that when it reaches this sme configuration, it moves forever to the right on the tape instead of halting. (Refer to Figure 10.11) Example: Pick some state not in P, say 52, and add two new instructions to P: Example: Pick some state not in P, say 52, and add two new instructions to P: (9,1,1,52,R)(9,1,1,52,R) (52,b,b,52,R)(52,b,b,52,R)

32 Proof (cont’d) Finally, create a new machine S which first makes a copy of what appears on its input. Finally, create a new machine S which first makes a copy of what appears on its input. After S is finished with its copying job, it uses the same instruction as machine Q. After S is finished with its copying job, it uses the same instruction as machine Q. What happens when machine S is run on a tape that contains S*, the binary representation of S? What happens when machine S is run on a tape that contains S*, the binary representation of S? S first makes a copy of S* and then turn the computation over to Q, which is now running on a tape containing S* and S*. S first makes a copy of S* and then turn the computation over to Q, which is now running on a tape containing S* and S*.

33 Proof (cont’d) S* S*bS* S Input output Never halts exactly when S eventually halts on S* Halts with 0 on tape exactly when S never halts on S* Contradiction!

34 Practical Unsolvable Problems No C++ program can be written to decide whether any given C++ program always stops eventually, no matter what input. No C++ program can be written to decide whether any given C++ program always stops eventually, no matter what input. No C++ program can be written to decide whether any two C++ programs are equivalent. No C++ program can be written to decide whether any two C++ programs are equivalent. No C++ program can be written to decide whether any given C++ program on any given input will ever produce some specific output. No C++ program can be written to decide whether any given C++ program on any given input will ever produce some specific output.


Download ppt "Chapter 10 Models of Computation. What is a model? Captures the essence – the important properties – of the real thing Captures the essence – the important."

Similar presentations


Ads by Google