Monograph TOC BDA
Monograph TOC BDA
ENGINEERING (UIE)
i i
SEMESTER : Sixth
SUBJECT NAME :
i Theory of Computation
i i
SUBJECT CODE
i : CST-390 ii
Vision
To ibecome ia iprominent idepartment iof iComputer iScience i& iEngineering iproducing icompetent
iprofessionals iwith iresearch iand iinnovation iskills, iinculcating imoral ivalues iand isocietal
iconcerns.
Mission
Provide ilearning iambience ito igenerate iinnovative iand iproblem isolving iskills iwith
iprofessionalism
Create ifacilities iand iexpertise iin iadvanced icomputer itechnology ithereby ipromote
iresearch
Enhance iIndustry iInstitute iInteraction iprogram ito iget iacquainted iwith icorporate iculture
Induce iethical ivalues iand ispirit iof isocial icommitment
PEO1 Have a bright career as Big Data Analyst, Big Data Engineer, Data Scientist, Data Architect,
Researcher, or Entrepreneur and be able to adapt to the evolving technical challenges and the
changing career opportunities. Learn to effectively communicate ideas in oral written or
graphical form and to promote collaboration with other members of engineering teams
PEO2 Analyze a problem, identify and define the computing requirements appropriate to its solution
in addition to the ability to design, implement and evaluate a computer based system, process,
component, or programs to meet desired needs. Be able to continue to demonstrate the
professional skills and communicative abilities necessary to be competent employees, assume
leadership roles and have career success and satisfaction.
PEO3 Function effectively as a member or a leader of a diverse team under different environments.
Multidisciplinary work can be carried by the team.
PEO4 Have the agility to readily adapt to changing environments by continuously learning new state
of the art technologies
PEO5 Inculcate characteristics needed for leadership roles, professional ethics, excellence and active
participation in a successful career while working in an interdisciplinary team
At ithe iend iof ithe iB.E. i(CSE) i– igraduates iwill ibe iable ito
PO1 Engineering iKnowledge: iAn iability ito iapply iknowledge iof iscience, imathematical
ifoundations, ialgorithmic iprinciples, iand icomputer iscience iand iengineering itheorems iin ithe
PO2 Problem ianalysis: iHoned iskill iset icomprising iof ievolutionary itools iand itechniques
iapplicable iin icomputing i& iengineering ipractice.
PO3 Design/Development iof isolutions: iTo iRecognize, iUnderstand ithe ireal iworld iproblems iand ito
ideploy iand iexecute iengineering isolutions ifor isustainable ieco isystem.
PO4 Investigations iof icomplex iproblems: iAbility ito iharness idesign iand idevelopment iprinciples
iin ithe iconstruction iof iverifying icomplex ihardware iand isoftware isystems.
PO5 Modern itool iusage: iAn iability ito icome iforward iwith ilateral i& iefficient isolutions iusing
imodern itools ifor icomputing i& iengineering ibased iproblems.
PO6 The iEngineer iand isociety: iAn ieducational iideology ito iassess ithe ilocal i& iglobal iimpact iof
icomputing iand iengineering isolutions ion iindividuals, iorganizations iand isociety.
PO7 Environment iand iSustainability: iAn iability ito idevelop ia icomputer-based isystem, iprocess,
icomponent, ior iprogram ito imeet ithe idesired ineeds, iwithin irealistic iconstraints isuch ias
isustainability i
PO8 Ethics: iAn iability ito ichallenge iand isolve iprofessional, iinterpersonal, iethical, isecurity i&
isocial iissues ialong iwith iability ito iperform iresponsibilities i& iduties i
PO9 Individual iand iteamwork: iAn iability ito iparticipate ieffectively iin imulti-disciplinary iteams i
PO10 Communication: iThe iability ito iwork iin iProfessional ienvironment iand ito icommunicate
ieffectively iwith ipeers i
PO11 Project imanagement iand iFinance: iDemonstrate iknowledge iand iunderstanding iof ithe
iengineering iand imanagement iprinciples iand iapply ithese ito ione’s iown iwork, ias ia imember iand
ileader iin ia iteam, ito imanage iprojects iand iin imultidisciplinary ienvironments.
PO12 Lifelong iLearning: iThe iknowledge iby irecognizing i iprofessional idevelopment iby ipursuing
ipost igraduate istudies ior iface icompetitive iexaminations ithat ioffer ichallenging iand irewarding
Students iwill ibe iable ito iexplain ithe iapplication iof igrammars iand idescriptors ito icompiler idesign
II
iand iparsing.
Students iwill ibe iable ito irelate ipractical iproblems ito ilanguages, iautomata, icomputability iand
III
icomplexity.
Finite iautomata i: i iConcept iof iBasic iMachines, iProperties iand iLimitations iof iFinite iState iMachines,
iDeterministic iFinite iAutomata(DFA), iNon-Deterministic iFinite iAutomata(NFA), iEquivalence iof iDFA iand
iNDFA i, iNon-Deterministic iFinite iautomata iwith iΛ-Transitions, iConversion iof iNFA ito iDFA. iMyhill- iNerode
Finite iAutomata iwith ioutput: iDesign iof iMoore iand iMealy iMachines. iEquivalence iof iMoore iand iMealy
iMachines.
Regular iexpression: iRegular iLanguages iand iRegular iExpressions, iDefinitions iand ioperators, iKleen’s
iTheorem, iArden’s iMethod, iConversion iof iRegular iexpression ito iDeterministic iand iNon iDeterministic
Properties iof iRegular isets: iThe iPumping iLemma ifor iRegular isets, iApplication iof ithe iPumping iLemma,
iClosure iProperties iof iRegular iSets. i
Context iFree iGrammars: iExamples iand iDefinitions, iDesign iof iCFG, iDerivation itrees iand iambiguity,
iAn iUnambiguous iCFG ifor iAlgebraic iExpressions. iSimplified iforms iand iNormal iforms: iRemoval iof
iuseless isymbols iand iunit iproduction, iRemoval iof iΛ-moves, iChomsky iNormal iForm i(CNF),
iGriebach iNormal iForm i(GNF), iClosure iProperties iof icontext ifree ilanguages. i i i
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii ii
Pushdown iAutomata: iIntroduction iand iDefinition iof iPush-Down iAutomaton, iBasic iStructure, iLanguage
iacceptability iby iPDA, iDesign iof iPDA, iConversion iof iPDA ito iCFG, iConversion iof iCFG ito iPDA. i
Turing iMachines: iIntroduction, iDefinitions iand iExamples, iRepresentation, iLanguage iAcceptability, iDesign iof
iTuring iMachines, iDeterministic iand iNon- iDeterministic iTuring iMachines. i
Decidability iand iUndecidability: iA iNon-recursive iLanguage iand ian iUnsolvable iProblem, iPCP iProblem iand
iMPCP iProblem, iThe iHalting iProblem, iIntroduction ito iRecursively iEnumerable iand iRecursive iLanguages.
Text iBooks:
1. iMartin iJ.C., i“Introduction ito iLanguages iand iTheory iof iComputation”, iTata iMcGraw-Hill
rd
iPublishing iCompany i Limited, i3 i
Edition.
2. Hopcroft iJ.E. iand iUllman iJ.D., i“Introduction ito iAutomata iTheory iLanguages iand
iComputation”, iNarosa iPublications.
CO1
3 3 2 3 2 2 2 2 2 2 1 2
i TOC CST-390 CO2
3 3 2 3 2 2 2 2 2 2 1 2
CO3
3 2 3 3 2 2 2 1 2 2 1 2
TOC(CST-390)
UNIT-1
Purpose iof isubject
• Construction iof iformal i imathematical imodels iwhich ican ireflect ithe ireal iworld icomputers.
• To iunderstand ithe idifference ibetween ian ialgorithm iand ia icomputation.
• Understanding ifundamentals ibehind idesigning iof icomputer ilanguages.
• To igain iknowledge iabout icapabilities iand ilimitations iof icomputers.
An iautomaton iwith ia ifinite inumber iof istates iis icalled ia iFinite iAutomaton i(FA) ior iFinite iState iMachine
i(FSM).
Present iState Next iState ifor iInput i0 Next iState ifor iInput i1
A A B
B C A
C B C
Its igraphical irepresentation iwould ibe ias ifollows i−
In iNDFA, ifor ia iparticular iinput isymbol, ithe imachine ican imove ito iany icombination iof ithe istates iin ithe
imachine. iIn iother iwords, ithe iexact istate ito iwhich ithe imachine imoves icannot ibe idetermined. iHence, iit iis
icalled iNon-deterministic iAutomaton. iAs iit ihas ifinite inumber iof istates, ithe imachine iis icalled iNon-
ibecause iin icase iof iNDFA, ifrom ia istate, itransition ican ioccur ito iany icombination iof iQ istates)
q0 iis ithe iinitial istate ifrom iwhere iany iinput iis iprocessed i(q0 i∈ iQ).
F iis ia iset iof ifinal istate/states iof iQ i(F i⊆ iQ).
Graphical iRepresentation iof ian iNDFA i− i(same ias iDFA)
An iNDFA iis irepresented iby idigraphs icalled istate idiagram.
The ivertices irepresent ithe istates.
The iarcs ilabeled iwith ian iinput ialphabet ishow ithe itransitions.
The iinitial istate iis idenoted iby ian iempty isingle iincoming iarc.
The ifinal istate iis iindicated iby idouble icircles.
Example
Let ia inon-deterministic ifinite iautomaton ibe i→
Q i= i{a, ib, ic}
∑ i= i{0, i1}
q0 i= i{a}
F={c}
The itransition ifunction iδ ias ishown ibelow i−
Present iState Next iState ifor iInput i0 Next iState ifor iInput i1
A a, ib B
B C a, ic
C b, ic C
Its igraphical irepresentation iwould ibe ias ifollows i−
The itransition ifrom ia istate iis ito ia isingle iparticular The itransition ifrom ia istate ican ibe ito imultiple inext
inext istate ifor ieach iinput isymbol. iHence iit iis icalled istates ifor ieach iinput isymbol. iHence iit iis icalled inon-
ideterministic. deterministic.
Empty istring itransitions iare inot iseen iin iDFA. NDFA ipermits iempty istring itransitions.
Backtracking iis iallowed iin iDFA In iNDFA, ibacktracking iis inot ialways ipossible.
A istring iis iaccepted iby ia iDFA, iif iit itransits ito ia ifinal A istring iis iaccepted iby ia iNDFA, iif iat ileast ione iof iall
istate. ipossible itransitions iends iin ia ifinal istate.
Acceptor i(Recognizer)
An iautomaton ithat icomputes ia iBoolean ifunction iis icalled ian iacceptor. iAll ithe istates iof ian iacceptor iis ieither
iaccepting ior irejecting ithe iinputs igiven ito iit.
Classifier
A iclassifier ihas imore ithan itwo ifinal istates iand iit igives ia isingle ioutput iwhen iit iterminates.
Transducer
An iautomaton ithat iproduces ioutputs ibased ion icurrent iinput iand/or iprevious istate iis icalled ia itransducer.
iTransducers ican ibe iof itwo itypes i−
Mealy iMachine i− iThe ioutput idepends iboth ion ithe icurrent istate iand ithe icurrent iinput.
Moore iMachine i− iThe ioutput idepends ionly ion ithe icurrent istate.
Acceptability iby iDFA iand iNDFA
A istring iis iaccepted iby ia iDFA/NDFA iiff ithe iDFA/NDFA istarting iat ithe iinitial istate iends iin ian iaccepting istate
i(any iof ithe ifinal istates) iafter ireading ithe istring iwholly.
A istring iS iis iaccepted iby ia iDFA/NDFA i(Q, i∑, iδ, iq0, iF), iiff
δ*(q0, iS) i∈ iF
The ilanguage iL iaccepted iby iDFA/NDFA iis
{S i| iS i∈ i∑* iand iδ*(q0, iS) i∈ iF}
A istring iS′ iis inot iaccepted iby ia iDFA/NDFA i(Q, i∑, iδ, iq0, iF), iiff
δ*(q0, iS′) i∉ iF
The ilanguage iL′ inot iaccepted iby iDFA/NDFA i(Complement iof iaccepted ilanguage iL) iis
{S i| iS i∈ i∑* iand iδ*(q0, iS) i∉ iF}
Example
Let ius iconsider ithe iDFA ishown iin iFigure i1.3. iFrom ithe iDFA, ithe iacceptable istrings ican ibe iderived.
Strings iaccepted iby ithe iabove iDFA i− i{0, i00, i11, i010, i101, i...........}
Strings inot iaccepted iby ithe iabove iDFA i− i{1, i011, i111, i........}
Problem iStatement
Let iX i= i(Qx, i∑, iδx, iq0, iFx) ibe ian iNDFA iwhich iaccepts ithe ilanguage iL(X). iWe ihave ito idesign ian iequivalent iDFA
iY i= i(Qy, i∑, iδy, iq0, iFy) isuch ithat iL(Y) i= iL(X). iThe ifollowing iprocedure iconverts ithe iNDFA ito iits iequivalent iDFA
i−
Algorithm
Input: An iNDFA
Output: equivalent iDFA
Step i1 Create istate itable ifrom ithe igiven iNDFA.
Step i2 Create ia iblank istate itable iunder ipossible iinput ialphabets ifor ithe iequivalent iDFA.
Step i3 Mark ithe istart istate iof ithe iDFA iby iq0 i(Same ias ithe iNDFA).
Step i4 Find iout ithe icombination iof iStates i{Q0, iQ1,... i, iQn} ifor ieach ipossible iinput ialphabet.
Step i5 Each itime iwe igenerate ia inew iDFA istate iunder ithe iinput ialphabet icolumns, iwe ihave ito iapply
istep i4 iagain, iotherwise igo ito istep i6.
Step i6 The istates iwhich icontain iany iof ithe ifinal istates iof ithe iNDFA iare ithe ifinal istates iof ithe iequivalent
iDFA.
Example
The iNDFA itable iis ias ifollows i−
Q δ(q,0) δ(q,1)
A {a,b,c,d,e} {d,e}
B {c} {e}
C ∅ {b}
D {e} ∅
E ∅ ∅
Let ius iconsider ithe iNDFA ishown iin ithe ifigure ibelow.
Using iabove ialgorithm, iwe ifind iits iequivalent iDFA. iThe istate itable iof ithe iDFA iis ishown iin ibelow.
Q δ(q,0) δ(q,1)
A {a,b,c,d,e} {d,e}
{d,e} E ∅
{b,d,e} {c,e} E
E ∅ ∅
D E ∅
{c,e} ∅ B
B C E
C ∅ B
The istate idiagram iof ithe iDFA iis ias ifollows i−
DFA iMinimization iusing iMyhill-Nerode iTheorem
Algorithm
Input: DFA
Output: Minimized iDFA
Step i1 Draw ia itable ifor iall ipairs iof istates i(Qi, iQj) inot inecessarily iconnected idirectly i[All iare iunmarked
iinitially]
Step i2 Consider ievery istate ipair i(Qi, iQj) iin ithe iDFA iwhere iQi i∈ iF iand iQj i∉ iF ior ivice iversa iand imark ithem.
i[Here iF iis ithe iset iof ifinal istates].
Step i3 Repeat ithis istep iuntil iwe icannot imark ianymore istates i−
If ithere iis ian iunmarked ipair i(Qi, iQj), imark iit iif ithe ipair i{δ(Qi, iA), iδ i(Qi, iA)} iis imarked ifor isome
iinput ialphabet.
Step i4 Combine iall ithe iunmarked ipair i(Qi, iQj) iand imake ithem ia isingle istate iin ithe ireduced iDFA.
Example
Let ius iuse iabove ialgorithm ito iminimize ithe iDFA ishown ibelow.
A
B
F
Step i2 i− iWe imark ithe istate ipairs i−
A b c d e f
C ✔ ✔
D ✔ ✔
E ✔ ✔
F ✔ ✔ ✔
Step i3 i− iWe iwill itry ito imark ithe istate ipairs, iwith igreen icolored icheck imark, itransitively. iIf iwe iinput i1 ito
istate i‘a’ iand i‘f’, iit iwill igo ito istate i‘c’ iand i‘f’ irespectively. i(c, if) iis ialready imarked, ihence iwe iwill imark ipair i(a,
if). iNow, iwe iinput i1 ito istate i‘b’ iand i‘f’; iit iwill igo ito istate i‘d’ iand i‘f’ irespectively. i(d, if) iis ialready imarked,
A b c d e f
C ✔ ✔
D ✔ ✔
E ✔ ✔
F ✔ ✔ ✔ ✔ ✔
After istep i3, iwe ihave igot istate icombinations i{a, ib} i{c, id} i{c, ie} i{d, ie} ithat iare iunmarked.
We ican irecombine i{c, id} i{c, ie} i{d, ie} iinto i{c, id, ie}
Hence iwe igot itwo icombined istates ias i− i{a, ib} iand i{c, id, ie}
So ithe ifinal iminimized iDFA iwill icontain ithree istates i{f}, i{a, ib} iand i{c, id, ie}
DFA iMinimization iusing iEquivalence iTheorem
If iX iand iY iare itwo istates iin ia iDFA, iwe ican icombine ithese itwo istates iinto i{X, iY} iif ithey iare inot
idistinguishable. iTwo istates iare idistinguishable, iif ithere iis iat ileast ione istring iS, isuch ithat ione iof iδ i(X, iS) iand
iδ i(Y, iS) iis iaccepting iand ianother iis inot iaccepting. iHence, ia iDFA iis iminimal iif iand ionly iif iall ithe istates iare
idistinguishable.
Algorithm
Step i1 All ithe istates iQ iare idivided iin itwo ipartitions i− ifinal istates iand inon-final istates iand iare idenoted
th
iby iP0. iAll ithe istates iin ia ipartition iare i0 equivalent. iTake ia icounter ik iand iinitialize iit iwith i0.
Step i2 Increment ik iby i1. iFor ieach ipartition iin iPk, idivide ithe istates iin iPk iinto itwo ipartitions iif ithey iare ik-
distinguishable. iTwo istates iwithin ithis ipartition iX iand iY iare ik-distinguishable iif ithere iis ian iinput iS
isuch ithat iδ(X, iS) iand iδ(Y, iS) iare i(k-1)-distinguishable.
Step i3 If iPk i≠ iPk-1, irepeat iStep i2, iotherwise igo ito iStep i4.
Step i4 Combine ikth iequivalent isets iand imake ithem ithe inew istates iof ithe ireduced iDFA.
Example
Let ius iconsider ithe ifollowing iDFA i−
Q δ(q,0) δ(q,1)
A B C
B A D
C E F
D E F
E E F
F F F
Let ius iapply iabove ialgorithm ito ithe iabove iDFA i−
P0 i= i{(c,d,e), i(a,b,f)}
P1 i= i{(c,d,e), i(a,b),(f)}
P2 i= i{(c,d,e), i(a,b),(f)}
Hence, iP1 i= iP2.
There iare ithree istates iin ithe ireduced iDFA. iThe ireduced iDFA iis ias ifollows i−
The iState itable iof iDFA iis ias ifollows i−
Q δ(q,0) δ(q,1)
Mealy iMachine
A iMealy iMachine iis ian iFSM iwhose ioutput idepends ion ithe ipresent istate ias iwell ias ithe ipresent iinput.
It ican ibe idescribed iby ia i6 ituple i(Q, i∑, iO, iδ, iX, iq0) iwhere i−
Q iis ia ifinite iset iof istates.
∑ iis ia ifinite iset iof isymbols icalled ithe iinput ialphabet.
O iis ia ifinite iset iof isymbols icalled ithe ioutput ialphabet.
δ iis ithe iinput itransition ifunction iwhere iδ: iQ i× i∑ i→ iQ
X iis ithe ioutput itransition ifunction iwhere iX: iQ i→ iO
q0 iis ithe iinitial istate ifrom iwhere iany iinput iis iprocessed i(q0 i∈ iQ).
The istate idiagram iof ia iMealy iMachine iis ishown ibelow i−
Moore iMachine
Moore imachine iis ian iFSM iwhose ioutputs idepend ion ionly ithe ipresent istate.
A iMoore imachine ican ibe idescribed iby ia i6 ituple i(Q, i∑, iO, iδ, iX, iq0) iwhere i−
Q iis ia ifinite iset iof istates.
∑ iis ia ifinite iset iof isymbols icalled ithe iinput ialphabet.
O iis ia ifinite iset iof isymbols icalled ithe ioutput ialphabet.
δ iis ithe iinput itransition ifunction iwhere iδ: iQ i× iΣ i→ iQ
X iis ithe ioutput itransition ifunction iwhere iX: iQ i× iΣ i→ iO
q0 iis ithe iinitial istate ifrom iwhere iany iinput iis iprocessed i(q0 i∈ iQ).
The istate idiagram iof ia iMoore iMachine iis ishown ibelow i−
Output idepends iboth iupon ipresent Output idepends ionly iupon ithe ipresent istate.
istate iand ipresent iinput.
Generally, iit ihas ifewer istates ithan Generally, iit ihas imore istates ithan iMealy iMachine.
iMoore iMachine.
Output ichanges iat ithe iclock iedges. Input ichange ican icause ichange iin ioutput ichange ias isoon ias
ilogic iis idone.
Mealy imachines ireact ifaster ito iinputs. In iMoore imachines, imore ilogic iis ineeded ito idecode ithe
ioutputs isince iit ihas imore icircuit idelays.
Moore iMachine ito iMealy iMachine
Algorithm i4
Input: Moore iMachine
Output: Mealy iMachine
Step i1 Take ia iblank iMealy iMachine itransition itable iformat.
Step i2 Copy iall ithe iMoore iMachine itransition istates iinto ithis itable iformat..
Step i3 Check ithe ipresent istates iand itheir icorresponding ioutputs iin ithe iMoore iMachine istate itable; iif
ifor ia istate iQi ioutput iis im, icopy iit iinto ithe ioutput icolumns iof ithe iMealy iMachine istate itable
Example
Let ius iconsider ithe ifollowing iMoore imachine i−
Next iState
Present iState Output
a=0 a=1
→a d b 1
B a d 0
C c c 0
D b a 1
Now iwe iapply iAlgorithm i4 ito iconvert iit ito iMealy iMachine.
Step i1 i& i2
Next iState
→A D B
B A D
C C C
D B A
Step i3
Next iState
⇒A D 1 B 0
B A 1 D 1
C C 0 C 0
D B 0 A 1
Mealy iMachine ito iMoore iMachine
Algorithm i5
Input: Mealy iMachine
Output: Moore iMachine
Step i1 Calculate ithe inumber iof idifferent ioutputs ifor ieach istate i(Qi) ithat iare iavailable iin ithe istate itable
iof ithe iMealy imachine.
Step i2 If iall ithe ioutputs iof iQi iare isame, icopy istate iQi. iIf iit ihas in idistinct ioutputs, ibreak iQi iinto in istates
ias iQin iwhere in i= i0, i1, i2.......
Step i3 If ithe ioutput iof ithe iinitial istate iis i1, iinsert ia inew iinitial istate iat ithe ibeginning iwhich igives i0
ioutput.
Example
Let ius iconsider ithe ifollowing iMealy iMachine i−
Next iState
→a D 0 B 1
B A 1 D 0
C C 1 C 0
D B 0 A 1
Here, istates i‘a’ iand i‘d’ igive ionly i1 iand i0 ioutputs irespectively, iso iwe iretain istates i‘a’ iand i‘d’. iBut istates i‘b’
iand i‘c’ iproduce idifferent ioutputs i(1 iand i0). iSo, iwe idivide ib iinto ib0, ib1 iand ic iinto ic0, ic1.
Next iState
Present iState Output
a=0 a=1
→A D B1 1
B0 A B 0
B1 A D 1
C0 C1 C0 0
C1 C1 C0 1
D B0 A 0
UNIT-2
Regular iExpressions
A iRegular iExpression ican ibe irecursively idefined ias ifollows i−
ε iis ia iRegular iExpression iindicates ithe ilanguage icontaining ian iempty istring. i(L i(ε) i= i{ε})
φ iis ia iRegular iExpression idenoting ian iempty ilanguage. i(L i(φ) i= i{ i})
x iis ia iRegular iExpression iwhere iL={x}
If iX iis ia iRegular iExpression idenoting ithe ilanguage iL(X) iand iY iis ia iRegular iExpression idenoting ithe
ilanguage iL(Y), ithen
o X i+ iY iis ia iRegular iExpression icorresponding ito ithe ilanguage iL(X) i∪ iL(Y) iwhere iL(X i+ iY) i= iL(X)
i∪ iL(Y).
o X i. iY iis ia iRegular iExpression icorresponding ito ithe ilanguage iL(X) i. iL(Y) iwhere iL(X.Y)= iL(X) i.
iL(Y)
* * * *
o R iis ia iRegular iExpression icorresponding ito ithe ilanguage iL(R ) iwhere iL(R ) i= i(L(R))
If iwe iapply iany iof ithe irules iseveral itimes ifrom i1 ito i5, ithey iare iRegular iExpressions.
Some iRE iExamples
Regular iExpressions Regular iSet
(a i+ ib)* Set iof istrings iof ia’s iand ib’s iof iany ilength iincluding ithe inull istring. iSo iL=
i{ iε, i0, i1,00,01,10,11,…….}
(a i+ ib)*abb Set iof istrings iof ia’s iand ib’s iending iwith ithe istring iabb, iSo iL i= i{abb,
iaabb, ibabb, iaaabb, iababb, i…………..}
(11)* Set iconsisting iof ieven inumber iof i1’s iincluding iempty istring, iSo iL= i{ε,
i11, i1111, i111111, i……….}
(aa)*(bb)*b Set iof istrings iconsisting iof ieven inumber iof ia’s ifollowed iby iodd inumber
iof ib’s i, iso iL= i{b, iaab, iaabbb, iaabbbbb, iaaaab, iaaaabbb, i…………..}
(aa i+ iab i+ iba i+ ibb)* String iof ia’s iand ib’s iof ieven ilength ican ibe iobtained iby iconcatenating
iany icombination iof ithe istrings iaa, iab, iba iand ibb iincluding inull, iso
Regular iSets
Any iset ithat irepresents ithe ivalue iof ithe iRegular iExpression iis icalled ia iRegular iSet.
Properties iof iRegular iSets
Property i1 iThe iunion iof itwo iregular iset iis iregular.
Proof i−
Let ius itake itwo iregular iexpressions
RE1 i= ia(aa)* iand iRE2 i= i(aa)*
So, iL1= i{a, iaaa, iaaaaa,.....} i(Strings iof iodd ilength iexcluding iNull)
and iL2={ iε, iaa, iaaaa, iaaaaaa,.......} i(Strings iof ieven ilength iincluding iNull)
L1 i∪ iL2 i= i{ iε, ia, iaa, iaaa, iaaaa, iaaaaa, iaaaaaa,.......}
(Strings iof iall ipossible ilengths iexcluding iNull)
RE i(L1 i∪ iL2) i= ia* i(which iis ia iregular iexpression iitself)
Hence, iproved.
Property i2. iThe iintersection iof itwo iregular iset iis iregular.
Proof i−
Let ius itake itwo iregular iexpressions
RE1 i= ia(a*) iand iRE2 i= i(aa)*
So, iL1 i= i{ ia, iaa, iaaa, iaaaa, i....} i(Strings iof iall ipossible ilengths iexcluding iNull)
L2 i={ iε, iaa, iaaaa, iaaaaaa,.......} i(Strings iof ieven ilength iincluding iNull)
L1 i∩ iL2 i= i{ iaa, iaaaa, iaaaaaa,.......} i(Strings iof ieven ilength iexcluding iNull)
RE i(L1 i∩ iL2) i= iaa(aa)* iwhich iis ia iregular iexpression iitself.
Hence, iproved.
Property i3. iThe icomplement iof ia iregular iset iis iregular.
Proof i−
Let ius itake ia iregular iexpression i−
RE i= i(aa)*
So, iL i= i{ε, iaa, iaaaa, iaaaaaa, i.......} i(Strings iof ieven ilength iincluding iNull),
Complement iof iL iis iall ithe istrings ithat iis inot iin iL.
So, iL’ i= i{a, iaaa, iaaaaa, i.....} i(Strings iof iodd ilength iexcluding iNull)
RE i(L’) i= ia(aa)* iwhich iis ia iregular iexpression iitself.
Hence, iproved.
Property i4. iThe idifference iof itwo iregular iset iis iregular.
Proof i−
Let ius itake itwo iregular iexpressions i−
RE1 i= ia i(a*) iand iRE2 i= i(aa)*
So, iL1= i{a, iaa, iaaa, iaaaa, i....} i(Strings iof iall ipossible ilengths iexcluding iNull)
L2 i= i{ iε, iaa, iaaaa, iaaaaaa,.......} i(Strings iof ieven ilength iincluding iNull)
L1 i– iL2 i= i{a, iaaa, iaaaaa, iaaaaaaa, i....}
(Strings iof iall iodd ilengths iexcluding iNull)
RE i(L1 i– iL2) i= ia i(aa)* iwhich iis ia iregular iexpression.
Hence, iproved.
Property i5. iThe ireversal iof ia iregular iset iis iregular.
Proof i−
We ihave ito iprove iLR iis ialso iregular iif iL iis ia iregular iset.
Let, iL= i{01, i10, i11, i10}
RE i(L)= i01 i+ i10 i+ i11 i+ i10
LR i= i{10, i01, i11, i01}
RE i(LR)= i01 i+ i10 i+ i11 i+10 iwhich iis iregular
Hence, iproved.
Property i6. iThe iclosure iof ia iregular iset iis iregular.
Proof i−
If iL i= i{a, iaaa, iaaaaa, i.......} i(Strings iof iodd ilength iexcluding iNull)
i.e., iRE i(L) i= ia i(aa)*
L*= i{a, iaa, iaaa, iaaaa i, iaaaaa,……………} i(Strings iof iall ilengths iexcluding iNull)
RE i(L*) i= ia i(a)*
Hence, iproved.
Property i7. iThe iconcatenation iof itwo iregular isets iis iregular.
Proof i−
Let iRE1 i= i(0+1)*0 iand iRE2 i= i01(0+1)*
Here, iL1 i= i{0, i00, i10, i000, i010, i......} i(Set iof istrings iending iin i0)
and iL2 i= i{01, i010,011,.....} i(Set iof istrings ibeginning iwith i01)
Then, iL1 iL2 i= i{001,0010,0011,0001,00010,00011,1001,10010,.............}
Set iof istrings icontaining i001 ias ia isubstring iwhich ican ibe irepresented iby ian iRE: i(0 i+ i1)*001(0 i+ i1)*
Hence, iproved.
Identities iRelated ito iRegular iExpressions
Given iR, iP, iL, iQ ias iregular iexpressions, ithe ifollowing iidentities ihold i−
∅ i= iε
*
*
ε i= iε
*
R+ i= iRR i= iR*R
* *
R*R i= iR
* * *
(R ) i= iR
*
RR i= iR*R
(PQ)*P i=P(QP)*
(a i+ ib)* i= i(a*b*)* i= i(a* i+ ib*)* i= i(a i+ ib*)* i= ia*(ba*)*
R i+ i∅ i= i∅ i+ iR i= iR i(The iidentity ifor iunion)
R iε i= iε iR i= iR i(The iidentity ifor iconcatenation)
∅ iL i= iL i∅ i= i∅ i(The iannihilator ifor iconcatenation)
R i+ iR i= iR i(Idempotent ilaw)
L i(M i+ iN) i= iLM i+ iLN i(Left idistributive ilaw)
(M i+ iN) iL i= iML i+ iNL i(Right idistributive ilaw)
ε i+ iRR* i= iε i+ iR*R i= iR*
Arden's iTheorem
In iorder ito ifind iout ia iregular iexpression iof ia iFinite iAutomaton, iwe iuse iArden’s iTheorem ialong iwith ithe
iproperties iof iregular iexpressions.
Statement i−
Let iP iand iQ ibe itwo iregular iexpressions.
If iP idoes inot icontain inull istring, ithen iR i= iQ i+ iRP ihas ia iunique isolution ithat iis iR i= iQP*
Proof i−
R i= iQ i+ i(Q i+ iRP)P i[After iputting ithe ivalue iR i= iQ i+ iRP]
= iQ i+ iQP i+ iRPP
When iwe iput ithe ivalue iof iR irecursively iagain iand iagain, iwe iget ithe ifollowing iequation i−
R i= iQ i+ iQP i+ iQP2 i+ iQP3…..
R i= iQ i(ε i+ iP i+ iP2 i+ iP3 i+ i…. i)
R i= iQP* i[As iP* irepresents i(ε i+ iP i+ iP2 i+ iP3 i+ i….) i]
Hence, iproved.
Assumptions ifor iApplying iArden’s iTheorem i−
The itransition idiagram imust inot ihave iNULL itransitions
It imust ihave ionly ione iinitial istate
Method
Step i1 i− iCreate iequations ias ithe ifollowing iform ifor iall ithe istates iof ithe iDFA ihaving in istates iwith iinitial istate
iq1.
Solution
Here ithe iinitial istate iis iq2 iand ithe ifinal istate iis iq1.
The iequations ifor ithe ithree istates iq1, iq2, and q3 are as follows −
i i i i i i
q1 i= iq1a i+ iq3a i+ iε i(ε imove iis ibecause iq1 iis ithe iinitial istate0
q2 i= iq1b i+ iq2b i+ iq3b
q3 i= iq2a
Now, iwe iwill isolve ithese ithree iequations i−
q2 i= iq1b i+ iq2b i+ iq3b
= iq1b i+ iq2b i+ i(q2a)b i(Substituting ivalue iof iq3)
= iq1b i+ iq2(b i+ iab)
= iq1b i(b i+ iab)* i(Applying iArden’s iTheorem)
q1 i= iq1a i+ iq3a i+ iε
= iq1a i+ iq2aa i+ iε i(Substituting ivalue iof iq3)
= iq1a i+ iq1b(b i+ iab*)aa i+ iε i(Substituting ivalue iof iq2)
= iq1(a i+ ib(b i+ iab)*aa) i+ iε
= iε i(a+ ib(b i+ iab)*aa)*
= i(a i+ ib(b i+ iab)*aa)*
Hence, ithe iregular iexpression iis i(a i+ ib(b i+ iab)*aa)*.
Problem
Construct ia iregular iexpression icorresponding ito ithe iautomata igiven ibelow i−
Solution
Here ithe iinitial istate iis iq1 iand ithe ifinal istate iis iq2
Now iwe iwrite idown ithe iequations i−
q1 i= iq10 i+ iε
q2 i= iq11 i+ iq20
q3 i= iq21 i+ iq30 i+ iq31
Now, iwe iwill isolve ithese ithree iequations i−
q1 i= iε0* i[As, iεR i= iR]
So, iq1 i= i0*
q2 i= i0*1 i+ iq20
So, iq2 i= i0*1(0)* i[By iArden’s itheorem]
Hence, ithe iregular iexpression iis i0*10*.
Grammar
A igrammar iG ican ibe iformally iwritten ias ia i4-tuple i(N, iT, iS, iP) iwhere
N ior iVN iis ia iset iof iNon-terminal isymbols
T ior i∑ iis ia iset iof iTerminal isymbols
S iis ithe iStart isymbol, iS i∈ iN
P iis iProduction irules ifor iTerminals iand iNon-terminals
Example
Grammar iG1 i−
({S, iA, iB}, i{a, ib}, iS, i{S i→ iAB, iA i→ ia, iB i→ ib})
Here,
S, iA, iand iB iare iNon-terminal isymbols;
a iand ib iare iTerminal isymbols
S iis ithe iStart isymbol, iS i∈ iN
Productions, iP i: iS i→ iAB, iA i→ ia, iB i→ ib
Example
Grammar iG2 i−
({S, iA}, i{a, ib}, iS,{S i→ iaAb, iaA i→aaAb, iA i→ iε i} i)
Here,
S iand iA iare iNon-terminal isymbols.
a iand ib iare iTerminal isymbols.
ε iis ian iempty istring.
S iis ithe iStart isymbol, iS i∈ iN
Production iP i: iS i→ iaAb, iaA i→ iaaAb, iA i→ iε
Derivations ifrom ia iGrammar
Strings imay ibe iderived ifrom iother istrings iusing ithe iproductions iin ia igrammar. iIf ia igrammar iG ihas ia
iproduction iα i→ iβ, iwe ican isay ithat ix iα iy iderives ix iβ iy iin iG. iThis iderivation iis iwritten ias i−
x iα iy i⇒G ix iβ iy
Example
Let ius iconsider ithe igrammar i−
G2 i= i({S, iA}, i{a, ib}, iS, i{S i→ iaAb, iaA i→ iaaAb, iA i→ iε i} i)
Some iof ithe istrings ithat ican ibe iderived iare i−
S i⇒ iaAb iusing iproduction iS i→ iaAb
⇒ iaaAbb iusing iproduction iaA i→ iaAb
⇒ iaaaAbbb iusing iproduction iaA i→ iaAb
⇒ iaaabbb iusing iproduction iA i→ iε
Representation iTechnique
Root ivertex i− iMust ibe ilabeled iby ithe istart isymbol.
Vertex i− iLabeled iby ia inon-terminal isymbol.
Leaves i− iLabeled iby ia iterminal isymbol ior iε.
If iS i→ ix1x2 i…… ixn iis ia iproduction irule iin ia iCFG, ithen ithe iparse itree i/ iderivation itree iwill ibe ias ifollows i−
There iare itwo idifferent iapproaches ito idraw ia iderivation itree i−
Top-down iApproach i−
Starts iwith ithe istarting isymbol iS
Goes idown ito itree ileaves iusing iproductions
Bottom-up iApproach i−
Starts ifrom itree ileaves
Proceeds iupward ito ithe iroot iwhich iis ithe istarting isymbol iS
Derivation ior iYield iof ia iTree
The iderivation ior ithe iyield iof ia iparse itree iis ithe ifinal istring iobtained iby iconcatenating ithe ilabels iof ithe
ileaves iof ithe itree ifrom ileft ito iright, iignoring ithe iNulls. iHowever, iif iall ithe ileaves iare iNull, iderivation iis
iNull.
Example
Let ia iCFG i{N,T,P,S} ibe
N i= i{S}, iT i= i{a, ib}, iStarting isymbol i= iS, iP i= iS i→ iSS i| iaSb i| iε
One iderivation ifrom ithe iabove iCFG iis i“abaabb”
S i→ iSS i→ iaSbS i→ iabS i→ iabaSb i→ iabaaSbb i→ iabaabb
Example
If iin iany iCFG ithe iproductions iare i−
S i→ iAB, iA i→ iaaA i| iε, iB i→ iBb| iε
the ipartial iderivation itree ican ibe ithe ifollowing i−
If ia ipartial iderivation itree icontains ithe iroot iS, iit iis icalled ia isentential iform. iThe iabove isub-tree iis ialso iin
isentential iform.
Rightmost iderivation i− iA irightmost iderivation iis iobtained iby iapplying iproduction ito ithe irightmost
ivariable iin ieach istep.
Example
Let iany iset iof iproduction irules iin ia iCFG ibe
X i→ iX+X i| iX*X i|X| ia
over ian ialphabet i{a}.
The ileftmost iderivation ifor ithe istring i"a+a*a" imay ibe i−
X i→ iX+X i→ ia+X i→ ia+ iX*X i→ ia+a*X i→ ia+a*a
The istepwise iderivation iof ithe iabove istring iis ishown ias ibelow i−
The irightmost iderivation ifor ithe iabove istring i"a+a*a" imay ibe i−
X i→ iX*X i→ iX*a i→ iX+X*a i→X+a*a i→ ia+a*a
The istepwise iderivation iof ithe iabove istring iis ishown ias ibelow i−
And iif iin ia icontext-free igrammar iG, iif ithere iis ia iproduction iis iin ithe iform iX i→ iaX iwhere iX iis ia inon-terminal
iand i‘a’ iis ia istring iof iterminals, iit iis icalled ia iright irecursive iproduction. iThe igrammar ihaving ia iright
BasiciStructureiofiPDA
A ipushdown iautomaton iis ia iway ito iimplement ia icontext-free igrammar iin ia isimilar iway iwe idesign iDFA ifor
i a iregular igrammar. iA iDFA ican iremember ia ifinite iamount iof iinformation, ibut ia iPDA ican iremember ian
i infinite iamount iof iinformation.
Basically ia ipushdown iautomaton iis i−
"Finite istate imachine" i+ i"a istack"
A ipushdown iautomaton ihas ithree icomponents i−
an iinput itape,
a icontrol iunit, iand
a istack iwith iinfinite isize.
The istack ihead iscans ithe itop isymbol iof ithe istack.
A istack idoes itwo ioperations i−
Push i− ia inew isymbol iis iadded iat ithe itop.
Pop i− ithe itop isymbol iis iread iand iremoved.
A iPDA imay ior imay inot iread ian iinput isymbol, ibut iit ihas ito iread ithe itop iof ithe istack iin ievery itransition.
A iPDA ican ibe iformally idescribed ias ia i7-tuple i(Q, i∑, iS, iδ, iq0, iI, iF) i−
Q iis ithe ifinite inumber iof istates
∑ iis iinput ialphabet
S iis istack isymbols
δ iis ithe itransition ifunction i− iQ i× i(∑ i∪ i{ε}) i× iS i× iQ i× iS*
q0 iis ithe iinitial istate i(q0 i∈ iQ)
I iis ithe iinitial istack itop isymbol i(I i∈ iS)
F iis ia iset iof iaccepting istates i(F i∈ iQ)
The ifollowing idiagram ishows ia itransition iin ia iPDA ifrom ia istate iq1 ito istate iq2, ilabeled ias ia,b i→ ic i−
This imeans iat istate iq1, iif iwe iencounter ian iinput istring i‘a’ iand itop isymbol iof ithe istack iis i‘b’, ithen iwe ipop
i ‘b’, ipush i‘c’ ion itop iof ithe istack iand imove ito istate iq2.
TerminologiesiRelateditoiPDA
Instantaneous iDescription
The iinstantaneous idescription i(ID) iof ia iPDA iis irepresented iby ia itriplet i(q, iw, is) iwhere
q iis ithe istate
w iis iunconsumed iinput
s iis ithe istack icontents
Turnstile iNotation
The i"turnstile" inotation iis iused ifor iconnecting ipairs iof iID's ithat irepresent ione ior imany imoves iof ia iPDA.
i The iprocess iof itransition iis idenoted iby ithe iturnstile isymbol i"⊢".
Consider ia iPDA i(Q, i∑, iS, iδ, iq0, iI, iF). iA itransition ican ibe imathematically irepresented iby ithe ifollowing
i turnstile inotation i−
(p, iaw, iTβ) i⊢ i(q, iw, iαb)
This iimplies ithat iwhile itaking ia itransition ifrom istate ip ito istate iq, ithe iinput isymbol i‘a’ iis iconsumed, iand ithe
i top iof ithe istack i‘T’ iis ireplaced iby ia inew istring i‘α’.
Note i− iIf iwe iwant izero ior imore imoves iof ia iPDA, iwe ihave ito iuse ithe isymbol i(⊢*) ifor iit.
PDAi&iContext-FreeiGrammar
If ia igrammar iG iis icontext-free, iwe ican ibuild ian iequivalent inondeterministic iPDA iwhich iaccepts ithe
i language ithat iis iproduced iby ithe icontext-free igrammar iG. iA iparser ican ibe ibuilt ifor ithe igrammar iG.
Also, iif iP iis ia ipushdown iautomaton, ian iequivalent icontext-free igrammar iG ican ibe iconstructed iwhere
L(G) i= iL(P)
In ithe inext itwo itopics, iwe iwill idiscuss ihow ito iconvert ifrom iPDA ito iCFG iand ivice iversa.
Algorithm ito ifind iPDA icorresponding ito ia igiven iCFG
Input i− A iCFG, iG= i(V, iT, iP, iS)
Output i− Equivalent iPDA, iP= i(Q, i∑, iS, iδ, iq0, iI, iF)
Step i1 Convert ithe iproductions iof ithe iCFG iinto iGNF.
Step i2 The iPDA iwill ihave ionly ione istate i{q}.
Step i3 The istart isymbol iof iCFG iwill ibe ithe istart isymbol iin ithe iPDA.
Step i4 All inon-terminals iof ithe iCFG iwill ibe ithe istack isymbols iof ithe iPDA iand iall ithe iterminals iof
ithe iCFG iwill ibe ithe iinput isymbols iof ithe iPDA.
Step i5 For ieach iproduction iin ithe iform iA i→ iaX iwhere ia iis iterminal iand iA, iX iare icombination iof
i terminal iand inon-terminals, imake ia itransition iδ i(q, ia, iA).
Problem
Construct ia iPDA ifrom ithe ifollowing iCFG.
G i= i({S, iX}, i{a, ib}, iP, iS)
where ithe iproductions iare i−
S i→ iXS i| iε i, iA i→ iaXb i| iAb i| iab
Solution
Let ithe iequivalent iPDA,
P i= i({q}, i{a, ib}, i{a, ib, iX, iS}, iδ, iq, iS)
where iδ i−
δ i(q, iε i, iS) i= i{(q, iXS), i(q, iε i)}
δ(q, iε i, iX) i= i{(q, iaXb), i(q, iXb), i(q, iab)}
δ(q, ia, ia) i= i{(q, iε i)}
δ(q, i1, i1) i= i{(q, iε i)}
Algorithm ito ifind iCFG icorresponding ito ia igiven iPDA
Input i− A iCFG, iG= i(V, iT, iP, iS)
Output Equivalent iPDA, iP i= i(Q, i∑, iS, iδ, iq0, iI, iF) isuch ithat ithe inon- iterminals iof ithe igrammar iG
i− iwill ibe i{Xwx i| iw,x i∈ iQ} iand ithe istart istate iwill ibe iAq0,F.
Step i1 For ievery iw, ix, iy, iz i∈ iQ, im i∈ iS iand ia, ib i∈ i∑, iif iδ i(w, ia, iε) icontains i(y, im) iand i(z, ib, im)
icontains i(x, iε), iadd ithe iproduction irule iXwx i→ ia iXyzb iin igrammar iG.
Step i2 For ievery iw, ix, iy, iz i∈ iQ, iadd ithe iproduction irule iXwx i→ iXwyXyx iin igrammar iG.
Step i3 iFor iw i∈ iQ, iadd ithe iproduction irule iXww i→ iε iin igrammar iG.
Turing Machine :A Turing Machine is an accepting device which accepts the languages (recursively
i i i i i i i i i i i i i
i enumerable iset) igenerated iby itype i0 igrammars. iIt iwas iinvented iin i1936 iby iAlan iTuring.
Definition
A iTuring iMachine i(TM) iis ia imathematical imodel iwhich iconsists iof ian iinfinite ilength itape idivided iinto icells
i on iwhich iinput iis igiven. iIt iconsists iof ia ihead iwhich ireads ithe iinput itape. iA istate iregister istores ithe istate iof
i the iTuring imachine. iAfter ireading ian iinput isymbol, iit iis ireplaced iwith ianother isymbol, iits iinternal istate iis
i changed, iand iit imoves ifrom ione icell ito ithe iright ior ileft. iIf ithe iTM ireaches ithe ifinal istate, ithe iinput istring iis
i accepted, iotherwise irejected.
A iTM ican ibe iformally idescribed ias ia i7-tuple i(Q, iX, i∑, iδ, iq0, iB, iF) iwhere i−
Q iis ia ifinite iset iof istates
X iis ithe itape ialphabet
∑ iis ithe iinput ialphabet
δ iis ia itransition ifunction; iδ i: iQ i× iX i→ iQ i× iX i× i{Left_shift, iRight_shift}.
q0 iis ithe iinitial istate
B iis ithe iblank isymbol
F iis ithe iset iof ifinal istates
Comparison iwith ithe iprevious iautomation
The ifollowing itable ishows ia icomparison iof ihow ia iTuring imachine idiffers ifrom iFinite i
Automaton iand iPushdown iAutomaton.
Machine Stack iData iStructure Deterministic?
Here ithe itransition i1Rq1 iimplies ithat ithe iwrite isymbol iis i1, ithe itape imoves iright, iand ithe inext istate iis iq1.
i Similarly, ithe itransition i1Lq2 iimplies ithat ithe iwrite isymbol iis i1, ithe itape imoves ileft, iand ithe inext istate iis
i q2.
TimeiandiSpaceiComplexityiofiaiTuringiMachine
For ia iTuring imachine, ithe itime icomplexity irefers ito ithe imeasure iof ithe inumber iof itimes ithe itape imoves
i when ithe imachine iis iinitialized ifor isome iinput isymbols iand ithe ispace icomplexity iis ithe inumber iof icells iof
i the itape iwritten.
Time icomplexity iall ireasonable ifunctions i−
T(n) i= iO(n ilog in)
TM's ispace icomplexity i−
S(n) i= iO(n)
Non-Deterministic iTuring iMachine i:In ia iNon-Deterministic iTuring iMachine, ifor ievery istate iand
i symbol, ithere iare ia igroup iof iactions ithe iTM ican ihave. iSo, ihere ithe itransitions iare inot ideterministic.
i The icomputation iof ia inon-deterministic iTuring iMachine iis ia itree iof iconfigurations ithat ican ibe
i reached ifrom ithe istart iconfiguration.
An iinput iis iaccepted iif ithere iis iat ileast ione inode iof ithe itree iwhich iis ian iaccept iconfiguration,
i otherwise iit iis inot iaccepted. iIf iall ibranches iof ithe icomputational itree ihalt ion iall iinputs, ithe inon-
deterministic iTuring iMachine iis icalled ia iDecider iand iif ifor isome iinput, iall ibranches iare irejected,
i the iinput iis ialso irejected.
A inon-deterministic iTuring imachine ican ibe iformally idefined ias ia i6-tuple i(Q, iX, i∑, iδ, iq0, iB, iF)
i where i−
Q iis ia ifinite iset iof istates
X iis ithe itape ialphabet
∑ iis ithe iinput ialphabet
δ iis ia itransition ifunction;
δ i: iQ i× iX i→ iP(Q i× iX i× i{Left_shift, iRight_shift}).
q0 iis ithe iinitial istate
B iis ithe iblank isymbol
F iis ithe iset iof ifinal istates
TuringMachineHaltingProblem
i i i
Problem i− iDoes ithe iTuring imachine ifinish icomputing iof ithe istring iw iin ia ifinite inumber iof isteps? iThe
i answer imust ibe ieither iyes ior ino.
Proof i− iAt ifirst, iwe iwill iassume ithat isuch ia iTuring imachine iexists ito isolve ithis iproblem iand ithen iwe iwill
i show iit iis icontradicting iitself. iWe iwill icall ithis iTuring imachine ias ia iHalting imachine ithat iproduces ia i‘yes’
i or i‘no’ iin ia ifinite iamount iof itime. iIf ithe ihalting imachine ifinishes iin ia ifinite iamount iof itime, ithe ioutput
i comes ias i‘yes’, iotherwise ias i‘no’. iThe ifollowing iis ithe iblock idiagram iof ia iHalting imachine i−
Now iwe iwill idesign ian iinverted ihalting imachine i(HM)’ ias i−
The ifollowing iis ithe iblock idiagram iof ian i‘Inverted ihalting imachine’ i−
Further, ia imachine i(HM)2 iwhich iinput iitself iis iconstructed ias ifollows i−
Multi-tape iTuring iMachines ihave imultiple itapes iwhere ieach itape iis iaccessed iwith ia iseparate ihead. iEach
i head ican imove iindependently iof ithe iother iheads. iInitially ithe iinput iis ion itape i1 iand iothers iare iblank. iAt
i first, ithe ifirst itape iis ioccupied iby ithe iinput iand ithe iother itapes iare ikept iblank. iNext, ithe imachine ireads
i consecutive isymbols iunder iits iheads iand ithe iTM iprints ia isymbol ion ieach itape iand imoves iits iheads.
A iMulti-tape iTuring imachine ican ibe iformally idescribed ias ia i6-tuple i(Q, iX, iB, iδ, iq0, iF) iwhere i−
Note i− iEvery iMulti-tape iTuring imachine ihas ian iequivalent isingle-tape iTuring imachine.
Multi-track iTuring imachines, ia ispecific itype iof iMulti-tape iTuring imachine, icontain imultiple
itracks ibut ijust ione itape ihead ireads iand iwrites ion iall itracks. iHere, ia isingle itape ihead ireads in
isymbols ifrom in itracks iat ione istep. iIt iaccepts irecursively ienumerable ilanguages ilike ia inormal
A iMulti-track iTuring imachine ican ibe iformally idescribed ias ia i6-tuple i(Q, iX, i∑, iδ, iq0, iF) iwhere i−
δ(Qi, i[a1, ia2, ia3,....]) i= i(Qj, i[b1, ib2, ib3,....], iLeft_shift ior iRight_shift)
Note i− iFor ievery isingle-track iTuring iMachine iS, ithere iis ian iequivalent imulti-track iTuring iMachine
iM isuch ithat iL(S) i= iL(M).
In ia iNon-Deterministic iTuring iMachine, ifor ievery istate iand isymbol, ithere iare ia igroup iof iactions
ithe iTM ican ihave. iSo, ihere ithe itransitions iare inot ideterministic. iThe icomputation iof ia inon-
deterministic iTuring iMachine iis ia itree iof iconfigurations ithat ican ibe ireached ifrom ithe istart
iconfiguration.
An iinput iis iaccepted iif ithere iis iat ileast ione inode iof ithe itree iwhich iis ian iaccept iconfiguration,
iotherwise iit iis inot iaccepted. i If iall ibranches iof ithe icomputational itree ihalt ion iall iinputs, ithe inon-
deterministic iTuring iMachine iis icalled ia iDecider iand iif ifor isome iinput, iall ibranches iare irejected,
ithe iinput iis ialso irejected.
A inon-deterministic iTuring imachine ican ibe iformally idefined ias ia i6-tuple i(Q, iX, i∑, iδ, iq0, iB, iF)
iwhere i−