turing machine - computer action teamweb.cecs.pdx.edu/~mperkows/temp/turing-machine.pdf · turing...

Post on 25-Jul-2020

39 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

TRANSCRIPT

1

KJH, ECE-548 12/8/2002

Turing MachineTuring Machine

slides of Prof. K. J. Hintz used

2

KJH, ECE-548 12/8/2002

Turing MachineTuring Machine

• An FSM Cannot Compute a NumberComprised of an Infinite Number of DigitsSince It Itself Is Finite.

• A Finite Method Can Be Developed toCompute an Infinite Length Number

• The Method Can Be Implemented byReading and Writing Intermediate Resultsfrom/to an Assumed Infinite Memory

3

KJH, ECE-548 12/8/2002

Halting ProblemHalting Problem

• Difficulty with the Turing Machine– Not guaranteed to terminate– Don’t know when it will terminate

• Still an unsolved problem– Is there a method for analyzing a Turing

machine to determine if and when it willterminate its computation?

4

KJH, ECE-548 12/8/2002

Turing MachineTuring Machine

• Devised by Alan Turing, 1937 paper*

• Definition of Computable

• Some Problems are Not Computable

* Turing, A. M., “On Computable Numbers, with an Application to the Entscheidungsproblem“, Proceedings of the London Mathematical Society, Series 2, 42:230-265 and 43:544-546, 1937.

5

KJH, ECE-548 12/8/2002

Physical Model of TMPhysical Model of TM

6

KJH, ECE-548 12/8/2002

PropertiesProperties

• Infinitely Long Readable/Writable TapeWith Fixed Left End

• Moveable Read/Write Tape Head– Only read/write to current position

• Finite State Machine for Control– Movement of tape head +/- 1 tape position only– Symbols written to tape

7

KJH, ECE-548 12/8/2002

PropertiesProperties

• String on Tape– Left End of String at Left End of Tape– Tape Head Is Initially at Right End of String.

Left end of Tape Tape Head Initial Position

8

KJH, ECE-548 12/8/2002

TM AlternativesTM Alternatives

• Multiple Heads• Infinite Tape in Both Directions• Tape Moves, Head Stationary• Increased Number of Symbols

None of These Changes Affect the BasicComputability of Turing Machines

9

KJH, ECE-548 12/8/2002

TM Formal DefinitionTM Formal Definition

• A Turing Machine is a Quadruple

( )

{ }{ } { }

( ) { }( )

M T

Finite set of states Tape Symbols L, R

initial stateDeterministic transition function

:S S h L, R

=

∉ ∪

× → ∪ × ∪

SS

, , ,

#

Σ

Σ

Σ Σ

s

s

δ

δδ

10

KJH, ECE-548 12/8/2002

TM ConfigurationTM Configuration

• The TM Configuration is a quadruple

( ){ }( ) { }( ) { }( )

C s, t , t, t

s Current Statet Sequence of symbols to the left of the tape head *t Current read symbol under the headt Sequence of symbols to the right of the tape head

T L R

L

R

=

∈ ∪ × × × − ∪

S h Σ Σ Σ Σ Λ

Σ

* * #

11

KJH, ECE-548 12/8/2002

TM ConfigurationTM Configuration

• A Shorthand Notation( current state,

string with current head position underlined )e.g.,

( )q abbaab2 ,

12

KJH, ECE-548 12/8/2002

TM Delta FunctionTM Delta Function

{ }( ) { }( )δ : S S× → ∪ × ∪Σ Σh L, R

PresentState

Read PresentSymbol

Next State & Symbol

q1 a ( p, b )

q2 # ( p, R )

If read an a, write a b.If read a blank (#), read-only, and move right one.

13

KJH, ECE-548 12/8/2002

Two TM ExamplesTwo TM Examples

• Quantity Doubler:– State Table: head movement and write are done

in separate states– FSM: simultaneous write/move

• Odd Detector– Head movement and write are done

simultaneously

14

KJH, ECE-548 12/8/2002

TM Example, 2XTM Example, 2X

( ){ }{ }

( ) ( )( ){ }�,L,s,#,s

1,#5,4,3,2,1,0

,,,

10

0

T2x

===Σ=

Σ=

δ

δ

ss

sS

SM

Tape Head Starting Position

15

KJH, ECE-548 12/8/2002

TM Example, 2XTM Example, 2X

• Transition FunctionPS Input

# Input

1 Comment

s0 s1/L s0/L

s1 halt s2/# found a 1 to left, replace with #

s2 s3/R s3/R

16

KJH, ECE-548 12/8/2002

TM Example, 2XTM Example, 2X

PS Input#

Input1

Comment

s3 s4/1 s3/R Move to right until at right-most end of string of 1’s

s4 s5/R

s5 s0/1 s5/R

17

KJH, ECE-548 12/8/2002

# 1 1 # s0 # 1 # 1 1 # s0

# 1 1 # s1 # 1 # 1 1 # s1

# 1 # # s2 # # # 1 1 # s2

# 1 # # s3 # # # 1 1 # s3

# 1 # 1 # s4 # # 1 1 1 # s4

# 1 # 1 # s5 # # 1 1 1 # s5

# 1 # 1 1 # s0 # # 1 1 1 # s5

# 1 # 1 1 # s0 # # 1 1 1 # s5

TM Example, 2XTM Example, 2X

18

KJH, ECE-548 12/8/2002

TM Example, 2XTM Example, 2X

# # 1 1 1 1 s5

# # 1 1 1 1 s0

# # 1 1 1 1 s0

# # 1 1 1 1 s0

# # 1 1 1 1 s0

# # 1 1 1 1 s0

# # 1 1 1 1 s1

19

KJH, ECE-548 12/8/2002

FSM to Control 2x TMSimultaneous Write/MoveFSM to Control 2x TM

Simultaneous Write/Move

01

3

2

#/#,R

#/#,R

r / w, d

1/#,L

#/1,L1/1,L

1/1,L

1/1,R

#/1,R

20

KJH, ECE-548 12/8/2002

TM Example 2, Odd Det.TM Example 2, Odd Det.

( ){ }{ }

( ) ( )( ){ }�,L,s,#,s

1,#1,0

,,,

10

0

T2x

===Σ=

Σ=

δ

δ

ss

sS

SM

Tape Head Starting Position

21

KJH, ECE-548 12/8/2002

TM Example 2, Odd Det.TM Example 2, Odd Det.

• Transition FunctionPS Input

# Input

1 Comment

s0 S0/#/R S1/#/R

s1 halt s0/#/R Halts if Odd

top related