Turing Machines

38
Turing Machines Chapter 3.1 1

description

Turing Machines. Chapter 3.1. Plan. Turing Machines(TMs) Alan Turing Church-Turing Thesis Definitions Computation Configuration Recognizable vs. Decidable Examples Simulator. Alan Turing. Alan Turing was one of the founding fathers of CS. - PowerPoint PPT Presentation

Transcript of Turing Machines

Page 1: Turing Machines

Turing Machines

Chapter 3.1

1

Page 2: Turing Machines

Plan• Turing Machines(TMs)– Alan Turing • Church-Turing Thesis

– Definitions• Computation• Configuration• Recognizable vs. Decidable

– Examples– Simulator

2

Page 3: Turing Machines

Alan Turing

Alan Turing was one of the founding fathers of CS.• His computer model the Turing Machine(1936) was

the inspiration for the electronic computer that came two decades later

• Was instrumental in cracking the Nazi Enigma cryptosystem in WWII

• Invented the “Turing Test” used in AI• The Turing Award. Pre-eminent award in Theoretical

CS (called the “Nobel Prize” of CS)

3

Page 4: Turing Machines

Church-Turing Thesis

• Thesis- Every effectively calculable function is a computable function

• Everything that is computable is computable by a Turing machine

• The thesis remains a hypothesis– Despite the fact that it cannot be formally proven

the Church–Turing thesis now has near-universal acceptance.

4

Page 5: Turing Machines

Turing Machine

• Most powerful machine so far…– Similar to a finite automata

1. Uses infinite tape as memory2. Can both read from and write to the tape3. Read/write head can move left/right4. Accept/reject take affect immediately

• Cannot solve all problems

Page 6: Turing Machines

Comparison with Previous Models

6

Device

Separate Input?

Read/Write Data Structure

Deterministic by default?

FA Yes None Yes

PDA Yes LIFO Stack No

TM No

1-way infinite tape. 1 cell access per

step.

Yes

Page 7: Turing Machines

Formal Definition of a TM

7

Page 8: Turing Machines

Successor Program• Sample Rules:

1. If read 1, write 0, go right, repeat.2. If read 0, write 1, HALT!3. If read “”, write 1, HALT!

• Using these rules on a tape containing the reverse binary representation of 47 we obtain:

8

Page 9: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read �“”, write 1, HALT!

9

1 1 1 1 0 1

Page 10: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

10

0 1 1 1 0 1

Page 11: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”, write 1, HALT!

11

0 0 1 1 0 1

Page 12: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

12

0 0 0 1 0 1

Page 13: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read �“”, write 1, HALT!

13

0 0 0 0 0 1

Page 14: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”, write 1, HALT!

14

0 0 0 0 1 1

Page 15: Turing Machines

Successor Program

So the successor’s output on 111101 was 000011 which is the reverse binary representation of 48.

Similarly, the successor of 127 should be 128:

15

Page 16: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”, �write 1, HALT!

16

1 1 1 1 1 1 1

Page 17: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

17

0 1 1 1 1 1 1

Page 18: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”, write 1, HALT!

18

0 0 1 1 1 1 1

Page 19: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

19

0 0 0 1 1 1 1

Page 20: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

20

0 0 0 0 1 1 1

Page 21: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

21

0 0 0 0 0 1 1

Page 22: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

22

0 0 0 0 0 0 1

Page 23: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read �“”, write 1, HALT!

23

0 0 0 0 0 0 0

Page 24: Turing Machines

Successor Program

If read 1, write 0, go right, repeat.If read 0, write 1, HALT!If read “”� , write 1, HALT!

24

0 0 0 0 0 0 0 1

Page 25: Turing Machines

Drawing the machine

• Draw the machine– Description

1. If read 1, write 0, go right, repeat.2. If read 0, write 1, HALT!3. If read “”� , write 1, HALT!

25

Page 26: Turing Machines

TM Dynamic Picture

• A string w is accepted by M if after being put on the tape then letting M run, M eventually enters the accept state. Therefore, w is an element of L(M) - the language accepted by M.

• We can formalize this notion as follows:

26

Page 27: Turing Machines

TM Formal DefinitionDynamic Picture

Suppose TM’s configuration at time t is given by uapxv where p is the current state, ua is what’s to the left of the head, x is what’s being read, and v is what’s to the right of the head.

If p,x= (q,y,R) then write:uapxv uayqv

With resulting configuration uaypv at time t+1. If, p,x= (q,y,L) instead, then write:

uapxv uqayvThere are also two special cases:

– head is forging new ground –pad with the blank symbol �– head is stuck at left end –by def. head stays put

NOTE: “” is read as “yields”

27

Page 28: Turing Machines

TM outcomesThree possibilities occur on a given input w :1. The TM M eventually enters qacc and therefore

halts and accepts. (w L(M) )2. The TM M eventually enters qrej or crashes

somewhere. M rejects w . (w L(M) )3. Neither occurs! I.e., M never halts its

computation and is caught up in an infinite loop, never reaching qacc or qrej. In this case w is neither accepted nor rejected. However, any string not explicitly accepted is considered to be outside the accepted language. (w L(M) )

28

Page 29: Turing Machines

Recognizable vs. Decidable

• Recognizable- The TM recognizes the language but doesn’t necessarily reach an accept or reject state (could loop FOREVER )

• Decidable- is recognizable and guaranteed to reach an accept or reject state (without the possibility for an infinite loop )

29

Page 30: Turing Machines

Bit-shifting example

30

Page 31: Turing Machines

31

Page 32: Turing Machines

3.7 Diagram

32

Page 33: Turing Machines

Fall 2010 Exam 2 Question 1

33

1) (25 pts) Give the full, formal description of a Turing Machine that accepts the following language: L = { w#wR | where w consists of only 0s and 1s and has length at least 1. } The input alphabet will be {0, 1, #}.The tape alphabet will include 0, 1, #, B, and any other symbols you choose to include in it. Give a simple intuitive description of what each state in the machine represents. And draw the diagram for this machine.

Page 34: Turing Machines

34

Page 35: Turing Machines

35

Page 36: Turing Machines

36

Page 37: Turing Machines

Simulator

• Accepts 4 or 5 tuples– (Start,input,NewState,

output,Direction)– (Start,input,NewState,Di

rection OR output)

• One tape• http://ironphoenix.org/

tril/tm/

37

Page 38: Turing Machines

END

38