Top Banner
1 Turing Machines
55

1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

Mar 29, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

1

Turing Machines

Page 2: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

2

A Turing Machine

............Tape

Read-Write head

Control Unit

Page 3: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

3

The Tape

............

Read-Write head

No boundaries -- infinite length

The head moves Left or Right

Page 4: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

4

............

Read-Write head

The head at each time step:

1. Reads a symbol 2. Writes a symbol 3. Moves Left or Right

Page 5: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

5

............

Example:Time 0

............Time 1

1. Reads

2. Writes

a a cb

a b k c

a

k3. Moves Left

Page 6: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

6

............Time 1

a b k c

............Time 2

a k cf

1. Reads

2. Writes

bf

3. Moves Right

Page 7: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

7

The Input String

............

Blank symbol

head

a b ca

Head starts at the leftmost positionof the input string

Input string

Page 8: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

8

............

Blank symbol

head

a b ca

Input string

Remark: the input string is never empty

Page 9: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

9

States & Transitions

1q 2qLba ,

Read Write Move Left

1q 2qRba ,

Move Right

Page 10: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

10

Example:

1q 2qRba ,

............ a b ca

Time 1

1qcurrent state

Page 11: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

11

............ a b caTime 1

1q 2qRba ,

............ a b cbTime 2

1q

2q

Page 12: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

12

............ a b caTime 1

1q 2qLba ,

............ a b cbTime 2

1q

2q

Example:

Page 13: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

13

............ a b caTime 1

1q 2qRg,

............ ga b cbTime 2

1q

2q

Example:

Page 14: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

14

Determinism

1q

2qRba ,

Allowed Not Allowed

3qLdb ,

1q

2qRba ,

3qLda ,

No lambda transitions allowed

Turing Machines are deterministic

Page 15: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

15

Partial Transition Function

1q

2qRba ,

3qLdb ,

............ a b ca

1q

Example:

No transitionfor input symbol c

Allowed:

Page 16: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

16

Halting

The machine halts if there areno possible transitions to follow

Page 17: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

17

Example:

............ a b ca

1q

1q

2qRba ,

3qLdb ,

No possible transition

HALT!!!

Page 18: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

18

Final States

1q 2q Allowed

1q 2q Not Allowed

• Final states have no outgoing transitions

• In a final state the machine halts

Page 19: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

19

Acceptance

Accept Input If machine halts in a final state

Reject Input

If machine halts in a non-final state or If machine enters an infinite loop

Page 20: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

20

Turing Machine Example

A Turing machine that accepts the language:

*aa

0q

Raa ,

L,1q

Page 21: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

21

aaTime 0

0q

a

0q

Raa ,

L,1q

Page 22: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

22

aaTime 1

0q

a

0q

Raa ,

L,1q

Page 23: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

23

aaTime 2

0q

a

0q

Raa ,

L,1q

Page 24: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

24

aaTime 3

0q

a

0q

Raa ,

L,1q

Page 25: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

25

aaTime 4

1q

a

0q

Raa ,

L,1q

Halt & Accept

Page 26: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

26

Rejection Example

0q

Raa ,

L,1q

baTime 0

0q

a

Page 27: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

27

0q

Raa ,

L,1q

baTime 1

0q

a

No possible Transition

Halt & Reject

Page 28: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

28

Infinite Loop Example

0q

Raa ,

L,1q

Lbb ,

A Turing machine for language *)(* babaa

Page 29: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

29

baTime 0

0q

a

0q

Raa ,

L,1q

Lbb ,

Page 30: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

30

baTime 1

0q

a

0q

Raa ,

L,1q

Lbb ,

Page 31: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

31

baTime 2

0q

a

0q

Raa ,

L,1q

Lbb ,

Page 32: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

32

baTime 2

0q

a

baTime 3

0q

a

baTime 4

0q

a

baTime 5

0q

a

Infinite

loop

Page 33: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

33

Because of the infinite loop:

•The final state cannot be reached

•The machine never halts

•The input is not accepted

Page 34: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

34

Another Turing Machine Example

Turing machine for the language }{ nnba

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

Page 35: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

35

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

ba

0q

a bTime 0

Page 36: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

36

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

bx

1q

a b Time 1

Page 37: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

37

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

bx

1q

a b Time 2

Page 38: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

38

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

2q

a b Time 3

Page 39: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

39

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

2q

a b Time 4

Page 40: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

40

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

0q

a b Time 5

Page 41: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

41

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

1q

x b Time 6

Page 42: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

42

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

1q

x b Time 7

Page 43: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

43

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx x y

2q

Time 8

Page 44: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

44

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx x y

2q

Time 9

Page 45: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

45

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

0q

x y Time 10

Page 46: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

46

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

3q

x y Time 11

Page 47: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

47

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

3q

x y Time 12

Page 48: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

48

0q 1q 2q3qRxa ,

Raa ,Ryy ,

Lyb ,

Laa ,Lyy ,

Rxx ,

Ryy ,

Ryy ,4q

L,

yx

4q

x y

Halt & Accept

Time 13

Page 49: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

49

If we modify the machine for the language }{ nnba

we can easily construct a machine for the language }{ nnn cba

Observation:

Page 50: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

50

Formal Definitionsfor

Turing Machines

Page 51: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

51

Transition Function

1q 2qRba ,

),,(),( 21 Rbqaq

Page 52: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

52

1q 2qLdc ,

),,(),( 21 Ldqcq

Transition Function

Page 53: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

53

Turing Machine:

),,,,,,( 0 FqQM

States

Inputalphabet

Tapealphabet

Transitionfunction

Initialstate

blank

Finalstates

Page 54: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

54

Page 55: 1 Turing Machines. 2 A Turing Machine...... Tape Read-Write head Control Unit.

Assignment (10%)Form a group consist <= 4 members.Find the implementation/usage/ function/benefit of:

1.FA/NFA2.Content Free Language/Grammar3.Pushdown Automata4.Turing Machine

Due date: during next week class55