©Brooks/Cole, 2003 Chapter 17 Theory of Computation
©Brooks/Cole, 2003 Understand how a simple language with limited statements can solve any problem. Understand how the Turing machine can solve any problem that can be solved by a computer. Understand the Godel number and its importance in the theory of computation. After reading this chapter, the reader should be able to: O BJECTIVES Understand the halting problem as an example of a large set of problems that cannot be solved by a computer.
©Brooks/Cole, 2003 SIMPLE LANGUAGE 17.1
©Brooks/Cole, 2003 Figure 17-1 Statements in simple language
©Brooks/Cole, 2003 TURING MACHINE 17.2
©Brooks/Cole, 2003 Figure 17-2 Turing machine
©Brooks/Cole, 2003 Figure 17-3 Tape
©Brooks/Cole, 2003 Figure 17-4 Transition state
©Brooks/Cole, 2003 Table 17.1Transitional table Current State Current State A B C D Write Write # & 1 same as read blank 1 same as read 1 New State New State B C A B D B D Read Read or blank # or & 1 not 1 1 not 1 not a blank blank Move Move
©Brooks/Cole, 2003 Figure 17-5 Transition diagram for incr x
©Brooks/Cole, 2003 Table 17.2Transitional table for incr x statement Current State Current State StartIncr Forward Added Backward Write Write # 1 1 & same as read # New State New State Forward Added Backward StopIncr Read Read # 1 & any not # # Move Move
©Brooks/Cole, 2003 Figure 17-6 Steps in incr x statement
©Brooks/Cole, 2003 Figure 17-7 Transition diagram for decr x
©Brooks/Cole, 2003 Table 17.3Transitional table for decr x statement Current State Current State StartDecr Forward Delete Backward Write Write # 1 blank & same as read # New State New State Forward Delete Backward StopDecr Read Read # 1 & 1 not # # Move Move
©Brooks/Cole, 2003 Figure 17-8 Transition diagram for the loop statement
©Brooks/Cole, 2003 Table 17.4Transitional table for the loop statement Current State Current State StartLoop Check Forward … EndProcess Backward Read Read # not 1 1 not & & … any not # # Move Move none … none New State New State Check StopLoop Forward StartProcess … Backward Check Write Write # same as read 1 same as read & … same as read #
©Brooks/Cole, 2003 GODELNUMBERSGODELNUMBERS 17.2
Table 17.5Code for symbols used in the Simple Language Symbol Hex Code Hex Code Hex Code Hex Code Symbol incr decr while { } x Hex Code Hex Code A B C D E F
©Brooks/Cole, 2003 HALTINGPROBLEMHALTINGPROBLEM 17.3
Can you write a program that tests whether or not any program, represented by its Godel number, will terminate? A Classical Programming Question:
©Brooks/Cole, 2003 Figure 17-9 Step 1 in proof
©Brooks/Cole, 2003 Figure Step 2 in proof
©Brooks/Cole, 2003 Figure Step 3 in proof
©Brooks/Cole, 2003 SOLVABLE AND UNSOLVABLE PROBLEMS SOLVABLE AND UNSOLVABLE PROBLEMS 17.5
©Brooks/Cole, 2003 Figure Taxonomy of problems