turing machine

33

Upload: ayan-khan

Post on 17-Nov-2014

184 views

Category:

Engineering


10 download

DESCRIPTION

good

TRANSCRIPT

Page 1: Turing Machine
Page 2: Turing Machine

Conceptually a Turing machine, like finite automata

A Turing machine consists of a finite-state control unit and a tape that is infinite in both directions and divided into cells, each of which can hold one symbol:

At each step, the control unit performs two actions in a way dependent on:

The two actions will be: 1. either – move the read/write head one cell to the left or

right; 2. put the control unit into a new state

Page 3: Turing Machine

Turing machine will be your ultimate model for computer.In Turing machine output is very important.We know that every program has an output but this is not exactly true.

Page 4: Turing Machine

1.READ X 2.IF X=1 THEN END 3.IF X=2 THEN DIVIDE X BY 0 4.IF X>2 THEN GOTO STATEMENT 4 We shall see in a moment that the same

terminology is applied to Turing machine.

Page 5: Turing Machine

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

Read-Write head

Control Unit

Page 6: Turing Machine

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

Read-Write head

No boundaries -- infinite length

The head moves Left or Right

Page 7: Turing Machine

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

Read-Write head

The head at each transition (time step):

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

Page 8: Turing Machine

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

Example:Time 0

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

1. Reads

2. Writes

a a cb

a b k c

a

k3. Moves Left

Page 9: Turing Machine

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

a b k c

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

a k cf

1. Reads

2. Writes

bf

3. Moves Right

Page 10: Turing Machine

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

Blank symbol

head

a b ca

Head starts at the leftmost positionof the input string

Input string

Page 11: Turing Machine

1q 2qLba ,

Read Write Move Left

1q 2qRba ,

Move Right

Page 12: Turing Machine

Definition. A Turing machine is a 7-tuple (Q, , , , q0, qaccept, qreject),

where:• Q is a set of states

is a set of symbols (the alphabet)

is a set of symbols that can be written in tape, and

• q0 Q is the initial state

Page 13: Turing Machine

• qaccept is the accepting state

• qreject is the rejecting state, qreject qaccept

is a collection of transitions defined by the function:

: (Q {qaccept, qreject }) Q {, }

Page 14: Turing Machine

The machine halts in a state if there isno transition to follow

Page 15: Turing Machine

Halting Example 1:

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

1q

1q No transition from

HALT!!!

1q

Page 16: Turing Machine

1q 2q Allowed

1q 2q Not Allowed

•Accepting states have no outgoing transitions•The machine halts and accepts

Page 17: Turing Machine

Accept Input If machine halts in an accept state

Reject Input

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

string

string

Page 18: Turing Machine

Accepts the language: *a

0q

Raa ,

L,1q

Input alphabet },{ ba

Page 19: Turing Machine

aaTime 0

0q

a

0q

Raa ,

L,1q

Page 20: Turing Machine

aaTime 1

0q

a

0q

Raa ,

L,1q

Page 21: Turing Machine

aaTime 2

0q

a

0q

Raa ,

L,1q

Page 22: Turing Machine

aaTime 3

0q

a

0q

Raa ,

L,1q

Page 23: Turing Machine

aaTime 4

1q

a

0q

Raa ,

L,1q

Halt & Accept

Page 24: Turing Machine

Rejection Example

0q

Raa ,

L,1q

baTime 0

0q

a

Page 25: Turing Machine

0q

Raa ,

L,1q

baTime 1

0q

a

No possible Transition

Halt & Reject

Page 26: Turing Machine

Accepts the language: *a

0q

but for input alphabet }{aA simpler machine for same language

Page 27: Turing Machine

aaTime 0

0q

a

0q

Halt & Accept

Not necessary to scan input

Page 28: Turing Machine
Page 29: Turing Machine
Page 30: Turing Machine
Page 31: Turing Machine
Page 32: Turing Machine

Turing machine as a language recognizer.

Turing machine as a language generator.

Turing machine as a language evaluator.

Turing machine as a language decider.

Page 33: Turing Machine

ANY QUESTIONS??