Turing Machine

Post on 17-Nov-2014

180 Views

Category:

Engineering

10 Downloads

Preview:

Click to see full reader

DESCRIPTION

good

Transcript

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

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.

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.

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

Read-Write head

Control Unit

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

Read-Write head

No boundaries -- infinite length

The head moves Left or Right

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

Read-Write head

The head at each transition (time step):

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

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

Example:Time 0

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

1. Reads

2. Writes

a a cb

a b k c

a

k3. Moves Left

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

a b k c

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

a k cf

1. Reads

2. Writes

bf

3. Moves Right

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

Blank symbol

head

a b ca

Head starts at the leftmost positionof the input string

Input string

1q 2qLba ,

Read Write Move Left

1q 2qRba ,

Move Right

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

• 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 {, }

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

Halting Example 1:

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

1q

1q No transition from

HALT!!!

1q

1q 2q Allowed

1q 2q Not Allowed

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

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

Accepts the language: *a

0q

Raa ,

L,1q

Input alphabet },{ ba

aaTime 0

0q

a

0q

Raa ,

L,1q

aaTime 1

0q

a

0q

Raa ,

L,1q

aaTime 2

0q

a

0q

Raa ,

L,1q

aaTime 3

0q

a

0q

Raa ,

L,1q

aaTime 4

1q

a

0q

Raa ,

L,1q

Halt & Accept

Rejection Example

0q

Raa ,

L,1q

baTime 0

0q

a

0q

Raa ,

L,1q

baTime 1

0q

a

No possible Transition

Halt & Reject

Accepts the language: *a

0q

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

aaTime 0

0q

a

0q

Halt & Accept

Not necessary to scan input

Turing machine as a language recognizer.

Turing machine as a language generator.

Turing machine as a language evaluator.

Turing machine as a language decider.

ANY QUESTIONS??

top related