Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which reads the input tape. A state register stores the state of the Turing machine. After reading an input symbol, it is replaced with another symbol, its internal state is changed, and it moves from one cell to the right or left. If the TM reaches the final state, the input string is accepted, otherwise rejected.
(9818099198) Call Girls In Noida Sector 14 (NOIDA ESCORTS)
TOA.docx
1. A TuringMachine is an acceptingdevice whichacceptsthe languages(recursivelyenumerable set)
generatedbytype 0 grammars.It was inventedin1936 by AlanTuring.
Definition
A TuringMachine (TM) is a mathematical model whichconsistsof aninfinite lengthtape dividedinto
cellsonwhichinputisgiven.Itconsistsof a headwhichreadsthe inputtape.A state registerstores
the state of the Turing machine.Afterreadinganinputsymbol,itisreplacedwithanothersymbol,
itsinternal state ischanged,andit movesfromone cell tothe right or left.If the TM reachesthe
final state,the inputstringisaccepted,otherwise rejected.
A TM can be formallydescribedasa7-tuple (Q,X,∑, δ, q0, B, F) where −
Q is a finite setof states
X isthe tape alphabet
∑ is the inputalphabet
δ isa transitionfunction;δ:Q × X → Q × X × {Left_shift,Right_shift}.
q0 is the initial state
B is the blanksymbol
F isthe setof final states
Comparisonwiththe previousautomaton
The followingtable shows acomparisonof how a Turingmachine differsfromFiniteAutomatonand
PushdownAutomaton.
2. Machine Stack Data Structure Deterministic?
Finite Automaton N.A Yes
PushdownAutomaton Last In FirstOut(LIFO) No
TuringMachine Infinite tape Yes
Example of Turingmachine
Turingmachine M = (Q,X, ∑, δ, q0, B, F) with
Q = {q0, q1, q2, qf}
X = {a,b}
∑ = {1}
q0 = {q0}
B = blanksymbol
F = {qf }
δ isgivenby−
Tape alphabetsymbol PresentState ‘q0’ PresentState ‘q1’ PresentState ‘q2’
a 1Rq1 1Lq0 1Lqf
b 1Lq2 1Rq1 1Rqf
Here the transition1Rq1 impliesthatthe write symbol is1,the tape movesright,and the nextstate
isq1. Similarly,the transition1Lq2 impliesthatthe write symbol is1,the tape movesleft,andthe
nextstate isq2.
Time and Space Complexityof aTuringMachine
For a Turing machine,the time complexityreferstothe measure of the numberof timesthe tape
moveswhenthe machine isinitializedforsome inputsymbolsandthe space complexityisthe
numberof cellsof the tape written.
Time complexityall reasonable functions−
4. Turingmachine wasinventedin1936 byAlanTuring.It is an acceptingdevice whichaccepts
Recursive Enumerable Language generatedbytype 0grammar.
There are variousfeaturesof the Turingmachine:
It has an external memorywhichremembersarbitrarylongsequence of input.
It has unlimitedmemorycapability.
The model hasa facilitybywhichthe inputatleftor righton the tape can be readeasily.
The machine can produce a certainoutputbasedon itsinput.Sometimesitmaybe requiredthatthe
same inputhas to be usedto generate the output.Sointhismachine,the distinctionbetweeninput
and outputhas beenremoved.Thusacommon setof alphabetscanbe usedforthe Turing machine.
Formal definitionof Turingmachine
A Turingmachine can be definedasacollectionof 7 components:
Q: the finite setof states
∑: the finite setof inputsymbols
T: the tape symbol
q0: the initial state
F: a set of final states
B: a blanksymbol usedasa endmarkerfor input
δ: a transitionormappingfunction.
The mappingfunctionshowsthe mappingfromstatesof finite automataandinputsymbol onthe
tape to the nextstates,external symbolsandthe directionformovingthe tape head.Thisisknown
as a triple or a program forturingmachine.
(q0, a) → (q1, A,R)
That meansinq0 state,if we readsymbol 'a' thenit will goto state q1, replaceda byX and move
aheadright(Rstandsfor right).
5. Example:
ConstructTM for the language L ={0n1n} where n>=1.
Solution:
We have alreadysolvedthisproblembyPDA.InPDA,we have a stack to rememberthe previous
symbol.The mainadvantage of the Turingmachine iswe have a tape headwhichcan be moved
forwardor backward,and the inputtape can be scanned.
The simple logicwhichwe will applyisreadouteach '0' mark itby A and thenmove aheadalong
withthe inputtape and findout1 convertitto B. Now,repeatthisprocessforall a's andb's.
Nowwe will see howthisturingmachine workfor0011.
The simulationfor0011 can be shownas below:
or 0011 can be shownas below:
TuringMachine
Now,we will see howthisturingmachine will worksfor0011. Initially,state isq0and headpointsto
0 as:
TuringMachine
The move will be δ(q0,0) = δ(q1,A,R) whichmeansitwill goto state q1, replaced0 by A andhead
will move tothe rightas:
6. TuringMachine
The move will be δ(q1,0) = δ(q1,0, R) whichmeansitwill notchange any symbol,remaininthe
same state and move to the rightas:
TuringMachine
The move will be δ(q1,1) = δ(q2,B, L) whichmeansitwill goto state q2, replaced1 by B and head
will move toleftas:
TuringMachine
Nowmove will be δ(q2,0) = δ(q2,0, L) whichmeansitwill notchange anysymbol,remaininthe
same state and move to leftas:
TuringMachine
The move will be δ(q2,A) = δ(q0,A,R), itmeanswill goto state q0, replacedA by A andheadwill
move to the rightas:
TuringMachine
The move will be δ(q0,0) = δ(q1,A,R) whichmeansitwill goto state q1, replaced0 by A,and head
will move torightas:
TuringMachine
The move will be δ(q1,B) = δ(q1,B, R) whichmeansitwill notchange any symbol,remaininthe
same state and move to rightas:
TuringMachine
The move will be δ(q1,1) = δ(q2,B, L) whichmeansitwill goto state q2, replaced1 by B and head
will move toleftas:
7. TuringMachine
The move δ(q2,B) = (q2,B, L) whichmeansit will notchange anysymbol,remaininthe same state
and move toleftas:
TuringMachine
Nowimmediatelybefore BisA that meansall the 0?s are marketby A. Sowe will move rightto
ensure thatno 1 ispresent.The move will be δ(q2,A) =(q0, A,R) whichmeansitwill goto state q0,
will notchange anysymbol,andmove to rightas:
TuringMachine
The move δ(q0,B) = (q3,B, R) whichmeansitwill goto state q3, will notchange any symbol,and
move to rightas:
TuringMachine
The move δ(q3,B) = (q3,B, R) whichmeansitwill notchange any symbol,remaininthe same state
and move toright as:
TuringMachine
The move δ(q3,Δ) = (q4, Δ, R) whichmeansitwill goto state q4 whichis the HALT state and HALT
state is alwaysanaccept state for any TM.
TuringMachine
The same TM can be representedbyTransitionDiagram: