Presentation is loading. Please wait.

Presentation is loading. Please wait.

Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation - Turing Machines Dale Roberts, Lecturer.

Similar presentations


Presentation on theme: "Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation - Turing Machines Dale Roberts, Lecturer."— Presentation transcript:

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

2 Dale Roberts 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 1. a tape that extends infinitely in both directions 2. the tape is divided into cells, each cell can carry a symbol. 3. the symbols comes from a finite set of symbols called the alphabet 4. the alphabet consists of symbols : b (blank), 0, 1, and special symbols X, Y, $ 5. the tape serve as memory 6. has a finite number of k states, 1, …k..bb011bb. 1

3 Dale Roberts Turing Machine actions depend on two inputs: 1. The current state of the machine 2. 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: 3. write a symbol to cell 4. go into a new state 5. move one cell left or right

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

5 Dale Roberts 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... 1 1/0 0/1

6 Dale Roberts 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 1 b... Unary Representation for TM 12 b/1 R 1/1 Halt 2 in unary representation 3 in unary representation s1 s2

7 Dale Roberts Example: Adding of two non-zero numbers (unary representation) Initial Setup.. b 1 1 1 b 1 1 b.. 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 12 1/b R 3 R 4 b/1 R 5 b/b R 1/1 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... S4... b b b 1 1 1 1 b...

8 Dale Roberts 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 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... 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... 12 b/1 R 3 b/b L 4 1/b L 5 L 1/1 RR

9 Dale Roberts 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.. 12 1/b R 3 R 4 b/1 R 1/1 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 1 1 1 1 1 b b... S4 (halt)


Download ppt "Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 230 Models of Computation - Turing Machines Dale Roberts, Lecturer."

Similar presentations


Ads by Google