Top Banner
www.nskinfo.com && www.nsksofttch.com Department of nskinfo-i education CS2303-THEORY OF COMPUTATION 1 TURING MACHINE
27

CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Mar 29, 2015

Download

Documents

Iris Emberton
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: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

www.nskinfo.com && www.nsksofttch.comDepartment of nskinfo-i education

CS2303-THEORY OF COMPUTATION

1

TURING MACHINE

Page 2: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.
Page 3: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Turing machine is a modified version of the PDA and it is much more powerful than PDA.

Instead of using stack as in PDA ,the TM uses the tape to store the symbols.

The TM is a generalized machine which can recognize all types of languages like the type 3 grammar to the type 0 grammar.

Introduction

Page 4: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

…... a1 a2 a3 …. b b b …..

Control unit

Turing Machine Model

Read-write head

Tape

Page 5: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Components are:1.Tape: which is used to store information

and is divide into cells.

2.Read-Write Head: read or write into the location it is pointing to.

3.Control Unit: the reading from or writing into tape is controlled by this unit consulting the transition table.

TM is a finite automaton

Page 6: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Transition Table

δ Tape Symbols(Γ)

states a b X Y B

q0 (q1,X,R) - - (q3,Y,R) -

q1 (q1,a,R) (q2,Y,R) - (q1,Y,R) -

q2 (q2,a,L) - (q0,X,R) (q2,Y,L) -

q3 - - - (q3,Y,R) (q4,B,R)

q4 - - - - -

Page 7: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Q is set of finite states Σ is set of input alphabets Γ is set of tape symbols δ is transition function q0 is the start state B is a special symbol indicating

blank character F is the set of all final states

Definition: The Turing MachineM=(Q,Σ,Γ,δ,q0,B,F)

Page 8: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Unlike the id described in PDA, in TM ,the id is defined on the whole string (not on the string to be scanned) and the current state of the machine.

An id of TM is a string αqβ,where q is the current state,αβ is the string made from tape symbols.

Initial id :qαβ

Final id :αβqB

Instantaneous Description

Page 9: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

The formal definition of ‘move’ for TM is : Let M=(Q,∑,Γ,δ,q₀,B,F)be a TM. Let the ID of M be a₁a₂a₃. . . ak-1qakak+1. . .an

where aj ε Г for 1≤j≤n, qεQ is the current state and ak as the next symbol to be scanned.

If there is a transition δ(q,ak)=(p,b,R) then the move of machine M will be

a₁a₂a₃..ak-1qakak+1..an|-* a₁a₂a₃..ak-1b p ak+1..a

If there is a transition δ(q,ak)=(p,b,L) then move of machine M will be

a₁a₂a₃..ak-1qakak+1..an|-* a₁a₂a₃.. p ak-lbak+1..an

Page 10: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Let M=(Q,∑,Γ,δ,q₀,B,F)be a TM. The language L(M) accepted by M is defined as:

L(M)={w|q₀w|-*α₁pα₂ where wε∑*,pεF and α₁,α₂εΓ*}

where q₀w is the initial ID and α₁pα₂ is the final ID. The set of all those words w in ∑* which causes

M to move from start state q₀ to the final state p.

A language is said to be recursively enumerable, if it is accepted by a TM.

Acceptance of a language by TM

Page 11: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Eg: Construct a turing machine to accept the language L={0ⁿ1ⁿ|n≥1}. Ans: The language accepted by TM should

have n number of 0’s followed by n number of 1’s.

General procedure: Let q₀ be the start state and let the read-write head points to the first

symbol of the string to be scanned.

Construction of Turing Machine

Page 12: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

The steps which should be followed to solve the example are:

1. Replace the left most 0 by X and change the state to q₁ and then move the read-write head towards right. This is because, after a zero is replaced , we have to replace to the corresponding 1 so that number of zeroes matches with number of 1’s.

2. Search for the leftmost 1 and replace it by the symbol Y and move towards left (so as to obtain the leftmost 0 again).Steps 1 and 2 are repeated.

Page 13: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

The transitions are represented as follows:

δ(q₀, 0)= (q₁, X, R) δ (q₁, 0)= (q₁, 0, R) δ (q₁, Y)= (q₁, Y, R) δ (q₁, 1)= (q₂, Y, L) δ (q₂, Y)= (q₂, Y, L) δ (q₂, 0)= (q₂, 0, L) δ (q₂, X)= (q₀, X, R) δ (q₀, Y)= (q₃, Y, R) δ (q₃, Y)= (q₃, Y, R) δ (q₃, B)= (q₄, B, R)

Transition Diagram

Page 14: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

A transducer accepts some input and transform that input into the desired output.

The transducer for a Turing machine is a function f defined by

f(w)=w'w is input before computation & w' is output

after computation such that

q₀w |-* qf w' for qf ε F

Transducers

Page 15: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

transducers contd… Let M=(Q,Σ,δ,q₀,B,F) be a Turing Machine.

The function f is Turing computable if and only if

q₀w |-* qf w' for qf ε F and w ε Γ*

The arithmetic operations such as addition, subtraction etc., including the common mathematical functions are Turing computable.

Page 16: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Programming techniques for Turing Machine

• More complex operations can be achieved using Turing Machines.

• The “interospective” ability of both TM and computer programs is what enables us to prove problems undecidable.

Page 17: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

We use finite control to hold a finite amount of data

state storage q- control state A,B,C- data elements The state of the machine is thought of as a

tuple [q,A,B,C]

Storage in the State

q

A B C

Page 18: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Another useful “trick” is to think of the tape of a TM as composed of several tracks.

Each track can hold one symbol and the tape alphabet of the TM consists of tuples, with one component for each “track”.

A multitrack Turing Machine is a specific type of Multi-tape Turing Machine.

Multiple Tracks

Page 19: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

It helps to think of TM as built from a collection of interacting components or “subroutines”.

This set of states includes start state & another temporary state.

The “call” of a subroutine occurs when there is a transition to its initial state.

Subroutines

Page 20: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Restricted Turing machines

We can have so many variations of Standard Turing machines.

Imposing certain restrictions on TM

Page 21: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

1.Turing machine with semi-infinite tape In the standard turing machine,there was no

boundary specified for the left side as well as right side of the tape.

In this type, we restrict the read/write head to move only in one direction.

From the fig it is clear that,there are no cells to the left hand side of initial head position.

. . . . . . .

Page 22: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Multi-stack machines Generalizations of the PDAs TMs can accept languages that are not

accepted by any PDA with one stack. A k-stack machine is a deterministic

PDA with k stacks. It obtains its input from an input source

rather than having the input placed in a tape.

It has a finite control, which is in one of a finite set of states.

It has a finite stack alphabet, which it uses for all its stacks.

Page 23: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Multi-stack machines

FiniteControl

Stack 1

Stack 2

Stack 3

Input Accept/reject

Page 24: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

A move of a multistack machine is based on:1.The state of the finite control

2.The input symbol read, which is chosen from the finite input alphabet3.The top stack symbol on each stack

In one move:• a multistack machine can change to a new state q є Q

• and replace the top symbol of each stack with a string of zero or more stack symbols X є Γ*.

Page 25: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Counter machines

Can be thought in one of two ways. Same structure as multistack machine. Each stack in the machine is replaced

by a counter. Counter hold any nonnegative integer. The move of a machine depends on the 1.current state 2.current input symbol 3.if one of the value of the counter is

zero

Page 26: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

Also be regarded as a restricted multistack machine.• Only two stack symbols say Z0 and X

• Z0 is initially on each stack

• May replace Z0 only by a string of the form XiZ0 for some i ≥ 0

• Replace X only by Xi for some i ≥ 0. That is, Z0 appears only on the bottom of each stack and all other symbols, if any, are X.

Page 27: CS2303-THEORY OF COMPUTATION 1. Turing machine is a modified version of the PDA and it is much more powerful than PDA. Instead of using stack as in.

THANK YOU