turing machine-toc

Post on 11-Apr-2017

267 Views

Category:

Education

4 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Turing Machine

Subject: TOC

CE-B

Maulik Togadiya

Introduction

Alan Turing is father of this model.  It is a machine (automaton) capable of enumerating some

arbitrary subset of valid strings of an alphabet. A Turing machine is a general example of a CPU that controls all

data manipulation done by a computer.

Turing machine

The Turing machine is a collection of following components.

Q is finite set of states. Γ is finite, non-empty set of tape alphabet symbol. Δ or b ∈ Γ is blank symbol majorly used as end marker for

inputs. ∑ is finite set of input symbol. δ is a transition or a mapping function.

Description

The Turing machine mathematically models a machine that mechanically operates on a tape. On this tape there are symbols, which the machine can read and write, one at a time, using a tape head.

The head is always over a particular square of the tape; only a finite stretch of squares is shown. The instruction to be performed (q4) is shown over the scanned square

Description

A tape divided into cells, one next to the other. Each cell contains a symbol from some finite alphabet.

A head that can read and write symbols on the tape and move the tape left and right one (and only one) cell at a time. In some models the head moves and the tape is stationary.

There is a state control, which can be in any one of a finite number states. The finite set of states is denoted by Q. The set Q contains three special states: a start state, an accept state, and a reject state.

The tape alphabet contains the blank symbol . If a cell contains , then this means that the cell is actually empty.

Instantaneous Description

Let M = {Q,∑,Γ,δ, b,F,q0} be TM then the instantaneous Description(ID) of TM can be given by a triplet or a program which is as given below-

(q0,a) (q1,A,L)

That means currently we are reading the input Symbol ‘a’ and we are in q0 state then we can go to q1 state by replacing or printing ‘a’ by A and then we must move in left direction.

Example:

Construct a TM which accept the language of ‘aba’ over ∑={a,b}.

we will assume that on the input tape the string ‘aba’ is placed like this

The tape head will read out the sequence up to the character Δ if ‘aba’ is readout TM will halt after reading Δ.

a b a Δ ……………

TM for ‘aba’

(a,a,R) (b,b,R) (a,a,R)

(Δ, Δ,S)

triplet along the edge:(input read,output to be printed,direction)

q0 q1 q2 q3

HALT

Consider the transition between start state and q1 which is (a,a,R) that is the current symbol read from the tape is a then output it as a and move the tape head to the right.

And then after transition between q1 to q2..

The TM will accept the language when it reaches to halt state

a b a Δ …..

a b a Δ ……

TM can also be represented by transition table:

In the given transition table ,we write a triplet in each raw as:

(next state , output to be printed , direction)

a b Δ start (q1,a,R) - - q1 -

(q2,b,R) -

q2 (q3,a,R) - - q3 - - (HALT, Δ,S) HALT - - -

Example:

Construct a TM for checking the palindrome of the string of even length.

Logic:The logic is that we will compare first symbol form left and

then we compare it with first symbol from right to check whether it is same.

Again we compare second symbol from left with second symbol from right. We repeat this process for all the symbol. If we found any symbol not matching, we cannot lead the machine to HALT state.

ababbaba Δ we will mark it * and move to right end in search of a.

*babbaba Δ Move right.

*babbaba Δ Move right upto Δ.

*babbaba Δ Move left and check if it is a

*babbab Δ Δ If it is replace it by Δ

*babbab Δ Move left upto *

*babbaba Δ Move right,read it

*babbaba Δ Convert it to * and move right

**abbab Δ Move right upto Δ in seach of b.

**abbab Δ Move left ,if left symbol is b convert it to Δ

**abba Δ Move left till *.

**abbaΔ goto right

**abba Δ replace a by * and move right,upto Δ

***bba Δ we will move left and check if it is a,then replace it Δ

***bba Δ it is a so replace by Δ

***bb Δ Move to left till *

***bbΔ Move right

***bb Δ Replace it by *

****b Δ Move right upto Δ

****bΔ Move left to see if it is b,if so then replace it by Δ

****Δ Move left till *

****Δ Move right and check whether it is Δ ,if so

**** Δ Goto HALT

TM for it (a,a,R)(b,b,R)

(a,*,R) (Δ ,Δ,L) (a, Δ ,L) (b,b,L)

(a,a,L)

(*,*,R)

start (Δ ,Δ ,L)

(*,*,R)

(a,a,L)

(b.b.L)

(b,*,R)

(Δ ,Δ,L) (b, Δ ,L)

(a,a,R)

(b,b,R)

q0

q1

q2

q3

q6

q5

q4

HALT

top related