1 / 9

Models of Computation - Turing Machines

Department of Computer and Information Science, School of Science, IUPUI. Models of Computation - Turing Machines. CSCI 230. Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu. . . b. b. 0. 1. 1. b. b. . 1. The Turing Machine (TM).

aldon
Download Presentation

Models of Computation - Turing Machines

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Department of Computer and Information Science,School of Science, IUPUI Models of Computation - Turing Machines CSCI 230 Dale Roberts, Lecturer Computer Science, IUPUI E-mail: droberts@cs.iupui.edu

  2. . . b b 0 1 1 b b . 1 The Turing Machine (TM) • Turing Machine is a model of computing agent. • It is a pencil-and-paper type model that captures the essential features of a computing agent. • A Turing machine consists of • a tape that extends infinitely in both directions • the tape is divided into cells, each cell can carry a symbol. • the symbols comes from a finite set of symbols called the alphabet • the alphabet consists of symbols : b (blank), 0, 1, and special symbols X, Y, $ • the tape serve as memory • has a finite number of k states, 1, …k

  3. Turing Machine actions depend on two inputs: • The current state of the machine • content of cell currently being read (input) • A Turing machine can do only one operation at a time. Each time an operation is done, three actions may take place: • write a symbol to cell • go into a new state • move one cell left or right

  4. output input 0/1 1 2 W R R Your movement State: where you are now. . . . . b b b b 0 1 1 1 1 1 b b b b . . 12 1 The Turing Machine (TM) Example: Assume a Turing machine (TM) instruction: if you are in state 1 and you are reading symbol 0 then write symbol 1 onto tape go into state 2 move right State Transition: current state action (direction) Written as: (1,0,1,R,2) next state output input

  5. 1/0 1 0/1 The Turing Machine (TM) Example: Design a Turing Machine which will invert the string of binary digits • if the input string is 10110 then the output string should be 01001 • let us draw a state diagram • The TM instruction sets will be (1,0,1,R,1) (1,1,0,R,1) Let the initial configuration be: ... b 1 0 1 1 0 b ... ... b 1 0 1 1 0 b ... ... b 0 0 1 1 0 b ... ... b 0 1 1 1 0 b ... ... b 0 1 0 1 0 b ... ... b 0 1 0 0 0 b ... ... b 0 1 0 0 1 b ...

  6. 1/1 b/1 1 2 Halt R s1 s1 s1 s1 s2 Unary Representation for TM Unary representation is used in order to do any arithmetic operations on a TM. • Unary representation looks as follows 0  1 1  11 2  111 3  1111 4  11111 Example: Design a Turing Machine to add 1 to any number • start in state 1 • if the state is 1 and current input is 1, write 1 and move right and stay in state 1 • if the current state is 1 and current input is b, write 1 and move to state 2 and move right and HALT • TM instructions: (1,1,1,R,1) (1,b,1,R,2) state 2 does not exist, so halt Let the initial configuration be: ... b 1 1 1 b ... ... b 1 1 1 b ... ... b 1 1 1 b ... ... b 1 1 1 b ... ... b 1 1 1 b ... ... b 1 1 1 1 b ... 2 in unary representation 3 in unary representation

  7. 1/1 1/1 1/b 1/b b/1 b/b Halt 1 2 3 4 5 R R R R Example: Adding of two non-zero numbers (unary representation) Initial Setup . . b 1 1 1 b 1 1 b . . Answer should be: . . b b b 1 1 1 1 b . . (1,1,b,R,2): Erase leftmost 1 and move right (2,1,b,R,3): Erase second 1 and move right (3,1,1,R,3): pass over any 1’s until a blank is found (3,b,1,R,4): write 1 over the blank (4,1,1,R,4): pass over remaining 1’s (4,b,b,R,5): halt S1... b 1 1 1 b 1 1 b... S2... b b 1 1 b 1 1 b... S3... b b b 1 b 1 1 b... S3... b b b 1 b 1 1 b... S4... b b b 1 1 1 1 b... S4... b b b 1 1 1 1 b... S4... b b b 1 1 1 1 b...

  8. 1/1 1/1 R R b/1 b/b 1/b 1/b 1 2 3 4 5 R L L L Example: Add two numbers, 2 + 3 • initial setup would: a ‘b’ separate the two numbers. ... b 1 1 1 b 1 1 1 1 b ... 2 3 • and the expected answer is ... b 1 1 1 1 1 1 b ... 5 • The TM instruction sets will be (1,1,1,R,1) (1,b,1,R,2) (2,1,1,R,2) (2,b,b,L,3) (3,1,b,L,4) (4,1,b,L,5) Let the initial configuration be: S1... b 1 1 1 b 1 1 1 1 b... S1... b 1 1 1 b 1 1 1 1 b... S1... b 1 1 1 b 1 1 1 1 b... S1... b 1 1 1 b 1 1 1 1 b... S2... b 1 1 1 1 1 1 1 1 b... S2... b 1 1 1 1 1 1 1 1 b... S2... b 1 1 1 1 1 1 1 1 b... S2... b 1 1 1 1 1 1 1 1 b... S2... b 1 1 1 1 1 1 1 1 b... S3... b 1 1 1 1 1 1 1 1 b... S4... b 1 1 1 1 1 1 1 b b... S5... b 1 1 1 1 1 1 b b b...

  9. Example: Add two numbers, 2 + 3 try (1,1,b,R,2) (2,1,b,R,3) (3,1,1,R,3) (3,b,1,R,4) if an initial configuration is b b 1 1 1 b 1 1 1 1 b b .. 1/1 R 1/b 1/b b/1 1 2 3 4 R R R S1... b b 1 1 1 b 1 1 1 1 b b... S2... b b b 1 1 b 1 1 1 1 b b... S3... b b b b 1 b 1 1 1 1 b b... S3... b b b b 1 b 1 1 1 1 b b... S3... b b b b 1 1 1 1 1 1 b b... S4 (halt)

More Related