CS2303-THEORY OF COMPUTATION

Presentation on theme: "CS2303-THEORY OF COMPUTATION"— Presentation transcript:

CS2303-THEORY OF COMPUTATION
&& Department of nskinfo-i education CS2303-THEORY OF COMPUTATION TURING MACHINE

TURING MACHINE

Introduction 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.

Turing Machine Model …... a1 a2 a3 …. b ….. Control unit Tape

TM is a finite automaton
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.

Transition Table δ Tape Symbols(Γ) states a b X Y B q0 - q1 q2 q3 q4
(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 (q4,B,R) q4

Definition: The Turing Machine M=(Q,Σ,Γ,δ,q0,B,F)
Q is set of finite states Σ is set of input alphabets Γ is set of tape symbols δ is transition function q is the start state B is a special symbol indicating blank character F is the set of all final states

Instantaneous Description
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

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 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

Acceptance of a language by TM
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.

Construction of Turing Machine
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.

The steps which should be followed to solve the example are:
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. 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.

Transition Diagram 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

Transducers 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 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.

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.

Storage in the State 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] q A B C

Multiple Tracks 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.

Subroutines 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.

Restricted Turing machines
We can have so many variations of Standard Turing machines. Imposing certain restrictions on TM

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.

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.

Multi-stack machines Finite Control Input Accept/reject Stack 1

A move of a multistack machine is based on:1
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 alphabet 3.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 є Γ*.

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

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.

Thank you