+ All Categories
Home > Documents > Theory of Automata(a.kaja Mohideen)

Theory of Automata(a.kaja Mohideen)

Date post: 04-Jun-2018
Category:
Upload: sammy-joshua
View: 216 times
Download: 0 times
Share this document with a friend

of 66

Transcript
  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    1/66

    VYSYA COLLEGE, SALEM-103.

    NAME : A. KAJA MOHIDEEN CLASS : I M.Sc. CS

    SUBJECT : THEORY OF AUTOMATA UNITS : 5

    AUGUST SETEMBER OCTOBER

    F!"# : 11$0%$0%

    T" : 1&$0%$0%

    UNIT ' I

    A()"#*)* T+"!

    - Introduction- Structural representation- Automata and complexity- Alphabets

    - Strings- Languages- Problems

    F!"# : 1%$0%$0%

    T" : 31$0%$0%

    UNIT ' I C"/)..

    F/) A()"#*)*

    - Introduction

    - Deterministic finite automata- Non-deterministic finite

    automata

    A22c*)"/

    - Text search- Finite automata ith !psilon

    transition

    T

    F!"# : 04$0$0%

    T" : 1$0$0%

    UNIT ' II

    R6(*! E72!88"/8

    - Finite automata and regularexpression

    - Applications of regularexpressions

    - Algebraic las of regular

    expressions- Pro"ing languages not to beregular

    - Decision properties of regularlanguages

    - !#ui"alence and minimi$ationof automata

    - %oore and %ealy machines T

    F!"# : 44$0$0%

    T" : 30$0$0%

    UNIT ' III

    C"/)7) F! G!*##*!

    - Definition- Deri"ations using a grammar- Leftmost and rightmost

    deri"ation- The language of a grammar- Sentential forms

    - Parse trees(8+ 9"/ *()"#*)*

    - Definition- Languages of a PDA- !#ui"alence of PDAs and

    &F's- Deterministic PDA

    T

    F!"# : 03$10$0%

    T" : 0;$10$0%

    UNIT ' IV

    T(!/6 M*c+/

    - Introduction- Notations- Descriptions- Transition diagrams- Languages- Turing machines and halting(

    F!"# : 10$10$0%

    T" : 1;$10$0%

    UNIT ' IV C"/)..

    - Programming techni#ues ofTuring machines

    - %ultitape Turing machines- )estricted Turing machines- Turing machines and

    computers T

    F!"# : 40$10$0%

    T" : 31$10$0%

    UNIT ' V

    I/)!*c)*

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    2/66

    U N I T - I

    =+*) 8 )+ 2(!2"8 "> 8)(9/6 *()"#*)* )+"!? "! 5 #*!@8

    =+*) 8 )+ /9 )" 8)(9 A()"#*)* )+"!?

    Automata theory is the study of abstract computing de"ices( There are se"eral reasons hy the study ofautomata and complexity is an important part of the core of computer science(

    I/)!"9(c)"/ )" F/) A()"#*)*

    Finite automata are a useful model for many important *inds of hardare and softare( Let us list some ofthe most important *inds+

    Softare for designing and chec*ing the beha"ior of digital circuits( The ,lexical analy$er of a typical compiler. that is. the compiler component that brea*s the input

    text into logical units. such as identifiers. *eyords and punctuations( Softare for scanning large bodies of text. such as collections of eb pages. to find occurrences

    of ords. phrases. or other patterns(

    Softare for "erifying systems of all types that ha"e a finite number of distinct states. such ascommunications protocols or protocols for secure exchange of information(

    There are many systems or components. contains finite number of ,states( The purpose of a state is toremember the rele"ant portion of the system/s history( The ad"antage of ha"ing only a finite number ofstates is that e can implement the system ith a fixed set of resources(

    E7*#2

    The simplest finite automaton is an on0off sitch( The de"ice remembers hether it is the ,on state or the,off state. and it allos the user to press a button hose effect is different. depending on the state of the

    sitch( That is. if the sitch is in the off state. then pressing the button changes it to the on state. and if thesitch is in the on state. then pressing the same button turns it to the off state(

    Fig+ A finite automaton modeling an on0off sitch

    As for all finite automata. the states are represented by circles1 in this example. e ha"e named the states onand off( Arcs beteen states are labeled by ,inputs. hich represent external influences on the system(2ere. both arcs are labeled by the input Push. hich represents a user pushing the button( The intent of theto arcs is that hiche"er state the system is in. hen the push input is recei"ed it goes to the other state( thestate in hich the system is placed initially is called as the ,start state.( In our example. the start state is off.and e con"eniently indicate the start state by the ord Start and an arro leading to that state(

    S)!(c)(!* R2!8/)*)"/8:

    There are to important notations that are not automaton-li*e. but play an important role in the study ofautomata and their applications(

    G!*##*!8

    ">

    >

    "

    /

    push

    push

    start

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    3/66

    These are useful models hen designing softare that processes data ith a recursi"e structure( The best *non example is a ,parser. the component of a compiler that deals ith the recursi"ely

    nested features of the typical programming language. such as expressions-arithmetic. conditional and soon(

    For instance. a grammatical rule li*e ! ! 3 ! states that an expression can be formed by ta*ing anyto expressions and connecting them by a plus sign1 this rule is typical of ho expressions of real

    programming languages are formed(

    R6(*! E72!88"/8

    These also denote the structure of data. especially text strings( The style of these expressions differsignificantly from that of grammars( The 4NI5-style regular expression 67A-89 7a-$9 : 79 7A-89 7A-89/represents capitali$ed ords folloed by a space and to capital letters( This expression represents patternsin text that could be a city and state. e(g(. Ithaca N;( It misses multiord city names. such as Palo alto &A.hich could be captured by the more complex expression

    6hat can a computer do at all? This study is called ,decidability. and the problems that can be sol"ed

    by computer are called ,decidable( >hat can a computer do efficiently? This study is called ,intractability. and the problems that can be

    sol"ed by a computer using no more time than some sloly groing function of the si$e of the input arecalled ,tactable(

    G )+ c/)!* c"/c2)8 "> A()"#*)* )+"!. "!

    E72*/ *

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    4/66

    It is often useful to classify strings by their length. that is. the number of positions for symbols in the string(For instance. has length ( The standard notation for the length of a string is J J(

    For eg(. J J B H and J J B(

    "!8 "> */ A2+*e define @*to be the set of strings of length *. each of hose symbols is in @(

    !g+ Note that @BCE. regardless of hat alphabet @ is( That is. is the only string hose length is (If @ B C. E.

    then @BC. E.

    @ B C...E.@H B C . ......E G((

    There is a slight confusion beteen @ and @( The former is an alphabet1 its members and are symbols(

    The latter is a set of strings1 its members are the strings and . each of hich is of length (

    The set of all strings o"er an alphabet is denoted by :(

    For instance. C. E

    :

    B C. . . . . . . . G( E( That is :B ( ( ( The set of nonempty strings from alphabet is denoted by 3( Thus the e#ui"alences are

    o 3B HG(o :B 3CE

    C"/c*)/*)"/ "> 8)!/68

    Let x and y be strings( Then xy denote the concatenation of x and y. that is. the string formed by ma*ing acopy of x and folloing it by a copy of y( If x is the string composed of i symbols

    x B aaGGGG(aiand y is the string composed of K symbols

    y B bbGGGG(bK.then xy is the string of length i3K1

    xy B aaGG(aibbGG(bK(E6: Let x B and y B ( Then xy B and yx B (

    For any string . the e#uations B B

    L*/6(*68

    A set of strings chosen from some @:. is called a language. denoted by L(

    The language can be expressed as L @:(

    For any programming language. the legal programs are a subset of the possible strings that can beformed from the alphabet of the language( This alphabet is a subset of the AS&II characters(

    For example consider the folloing languages+

    o The language of all strings consisting of n /s folloed by n /s. for some n 1C. ...GGGE(

    o The set of strings of /s and /s ith an e#ual number of each+

    C. . . . . .GG(Eo The set of binary numbers hose "alue is a prime+ C. . . . . GGG(E

    o @: is a language for any alphabet @(

    o . the empty language. is a language o"er any alphabet(o CE. the language consisting of only the empty string. is also a language o"er any alphabet(

    Notice that B CE1 the former has no strings and the latter has one string(!"

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    5/66

    In automata theory. a problem is the #uestion of deciding hether a gi"en string is a member of someparticular language( A ,problem can be expressed as a membership in a language( If @ is an alphabet. andL is a language o"er @. then the problem L is+ 'i"en a string in @:. decide hether or not is in L( E6: The problem of testing can be expressed by the language Lpconsisting of all binary strings hose

    "alue as a binary number is a prime( That is. gi"en a string of /s and /s say ,yes if the string is thebinary representation of a prime and say ,no if not(

    ne potentially unsatisfactory aspect of our definition of ,problem is that one commonly thin*s ofproblems not as decision #uestions but as re#uests to compute or transform some input( The techni#ue ofshoing one problem hard by using its supposed efficient algorithm to sol"e efficiently another problemthat is already *non to be hard is called a ,reduction of the second problem to the first(

    E72*/ / 9)* * )+ DFA

    The ,language of the DFA is the set of all strings that the DFA accepts(

    Suppose a.aGGGGanis a se#uence of input symbols( >e start out ith the DFA in its start state. # o(

    The transition function . say e can rite this language as+

    L B C 0 is of the form xy for some strings x and y consisting of /s and /s only E

    Another e#ui"alent description. using parameters x and y to the left of the "ertical bar. is+

    Cxy0x are any strings /s and /sE

    !xamples of strings in the language include . . and ( !xamples of strings not in the languageinclude . and (

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    6/66

    S#2! N")*)"/8 >"! DFA8

    Specifying a DFA as a fi"e-tuple ith a detailed description of the transition function is both tedious andhard to read( There are to preferred notations for describing automata+

    ( A transition diagram hich is a graph

    ( A transition table. hich is a tabular listing of the functions. hich by implication tell us the set ofstates and the input alphabet(

    T!*/8)"/ D*6!*#8:A transition diagram for a DFA A B (/c)"/ )" 8)!/68:

    In terms of the transition diagram. the language of a DFA is the set of labels along all the paths that leadfrom the start state to any accepting state(

    >e define an extended transition function that describes hat happens hen e start in any state and follo

    any se#uence of inputs( If is our transition function. then the extended transition function constructed from

    ill be (The extended transition function is a function that ta*es a state # and a string and returns astate p O the state that the automaton reaches hen starting in state # and processing the se#uence of inputs

    ( >e define by induction on the length of the input string. as follos+

    # # #: # # #

    # # #

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    7/66

    BASIS e no *noalmost ho to specify the DFA for language L( It is

    A B

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    8/66

    dashed line( Thus. after seeing an e"en number of /s. e are alays to the left. in state #or #. hile afterseeing an odd number of /s e are to the right. in state # or #H(

    >e can also represent this DFA by a transition table(

    2ere. e illustrate the construction of (Suppose the input is ( Since this string has e"en number of/s and /s both. e expect it is in the language( Thus. e expect

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    9/66

    The folloing fige ha"e shon hat happens hen teautomaton of fighen the third input. a. occurs. e must consider transitions from both # and #( >e find that#goes only to #on . hile #goes only to #( Thus. after reading . the NFA is in states # and #(Since #is an accepting state. the NFA accepts (2oe"er. the input is not finished( The fourth input. a.causes #/s thread to die. hile #goes to both #and #(The last input. a. sends #to # and #to #(Sincee are again in an accepting state. is accepted(

    D>/)"/ "> N"/9)!#/8)c F/) A()"#*)*:

    An NFA is represented essentially li*e a DFA+

    A B here+( M is a finite set of states

    ( is a finite set of input symbolsH( #a member of M. is the start state( F. a subset of M. is the set of final

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    10/66

    >e need to extend the transition function of an NFA to a function that ta*es a state # and a string ofinput symbols . and returns the set of states that the NFA is in if it starts in state # and processes the string(

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    11/66

    start state of D is the set containing only the start state of N( The other components of D are constructed asfollos(

    MDis the set of subsets of MN 1 i(e(. MDis the poer set of MN( Note that if MNhas n states. then MDill ha"e nstates( Note all these states are accessible from the start state of M (Inaccessible statescan be ,thron aay. so effecti"ely. the number of states of D may much smaller than n(

    FDis the set of subsets S of MNsuch that S FN( That is. FDis all sets of N/s states thatinclude at least one accepting state of N(

    For each set SMNand for each input symbol a in .De can in"ent ne names for these states eg(. A for . for C#E etc(. The DFA transition table defines exactly the same automaton but ma*es clear the point that theentries in the table are single states of the DFA(

    0 1

    A A A

    B E B

    0 1 0 C#. #E C#E

    1 C#E4

    0, 1 C#. #E C#. #E

    0, 4 C#. #E C#E

    1, 4 C#E0, 1, 4 C#. #E C#. #E

    Subset &onstruction from NFA

    #

    #

    #

    Start

    .

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    12/66

    C A D

    D A A

    E E F

    F E B

    G A D

    H ! F

    )enaming the States

    f the right states in table- starting in the start state . e can only reach states . ! and F( The other fi"estates are inaccessible from the start state( Those states are remo"ed and the table is reconstructed and theDFA diagram is dran ith that table as shon in the figure(

    E72*/ +" )" >/9 8)!/6 / * )7)? "!

    E72*/ )+ 8)28 /"9 / >/9/6 * 8)!/6 / * )7)? 10 #*!@8

    A common problem in the age of the eb and other on-line text repositories is the folloing( 'i"en a set ofords. find all documents that contain one of those ords( The search engine uses a particular technology.called in"erted indexes. here for each ord appearing on the eb a list of all the places here that ordoccurs is stored( %achines ith "ery large amounts of main memory *eep the most common of these listsa"ailable. alloing many people to search for documents at once(

    In"ented-index techni#ues do not ma*e use of finite automata. but they also ta*e "ery large amounts of main

    memory *eep the most common of these lists a"ailable. alloing many people to search for documents atonce( In"erted-index techni#ues do not ma*e use of finite automata. but they also ta*e "ery large amounts oftime for cralers to copy the eb and set up the indexes( There are a number of related applications that areunsuited for in"erted indexes. but are good applications for automaton-based techni#ues( The characteristicsthat ma*e an application suitable for searches that use automata are+

    ( The repository on hich the search is conducted is rapidly changing( For eg+a= !"eryday. nes analysts ant to search the day/s on-line nes articles for rele"ant topics(

    For eg(. a financial analyst might search for certain stoc* tic*er symbols or names ofcompanies(

    b= A ,shopping robot ants to search for the current prices charged for the items that its clientsre#uest( The robot ill retrie"e current catalog pages for the eb and then search those pagesfor ords that suggest a price for a particular item(

    ( The documents to be searched cannot be cataloged( For eg(. Ama$on(com does not ma*e it easy forcralers to find all the pages for all the boo*s that the company sells( )ather. these pages aregenerated ,on the fly in response to #ueries( 2oe"er. e could send a #uery for boo*s on a certaintopic. say ,finite automata. and then search the pages retrie"ed for certain ords. eg(. ,excellent ina re"ie portion(

    C"/8)!(c) */ NFA >"! )7) 8*!c+? "!

    G * 8+"!) /") "/ )7) 8*!c+ >"! /"/ 9)!#/8)c >/) *()"#*)*? 5 #*!@8

    Suppose e are gi"en a set of ords. hich e shall call the *eyords. and e ant to find occurrences ofany these ords( In applications such as these. a useful ay to proceed is to design a non-deterministic finiteautomaton. hich signals. by entering an accepting state. that it has seen one of the *eyord( The text of a

    C#.

    #E

    C#.

    #E

    C#EStart

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    13/66

    document is fed. one character at a time to this NFA. hich then recogni$es occurrences of the *eyords inthis text( There is a simple form to an NFA that recogni$es a set of *eyords(

    = There is a start state ith a transition to itself on e"ery input symbol. e(g(. e"ery printable AS&IIcharacter if e are examining text( Intuiti"ely. the start state represents a ,guess that e ha"enot yet begun to see one of the *eyords. e"en if e ha"e seen some letters of one of theseords(

    = For each *eyord aaGGGa*. there are * states. say ##. GG((#*( There is a transition fromthe start state to #on symbol a. a transition from #to #on symbol a. and so on( The state #*isan accepting state and indicates that the *eyord aaGGG(a*has been found(

    E6., suppose e ant to design an NFA to recogni$e occurrences of the ords eb and ebay( The transition

    diagram for the NFA designed using the rule abo"e is in fig((Q( State is the start state. and e use tostand for the set of all printable AS&II characters( States through ha"e the Kob of recogni$ing eb. hilestates through R recogni$e ebay(

    f course the NFA is not a program( >e ha"e to maKor choices for an implementation of this NFA(( >rite a program that simulates this NFA by computing the set of states it is in after reading each

    input symbol( The simulation as suggested in fig NFA )" DFA (8/6 )7) 8*!c+? "!

    G 8+"!) /")8 "/ c"/!8"/ "> NFA >!"# DFA >"!# "> )7) 8*!c+8? 5 #*!@8

    >hen e apply the subset construction to an NFA that as designed from a set of *eyords. e find thatthe number of states of the DFA is ne"er greater than the number of states of the NFA( The rules forconstructing the set of NFA states is as follos.

    a= If #is the start state of the NFA. then C#E is one of the states of the DFA(b= Suppose p is one of the NFA states. and it is reached from the start state along a path hose symbols

    are aaGG((am( Then one of the DFA states is the set of NFA consisting of+

    ( #( p

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    14/66

    H( !"ery other state of the NFA that is reachable from #by folloing a path hose labels are asuffix of aaG((am. that is. any se#uence of symbols of the form aKaK3GGGGG((am(

    Fig -T!*/8)"/8:>e shall begin ith an informal treatment of -NFA/s. using transition diagrams ith alloed as a label(

    In the examples to follo. thin* of the automaton as accepting those se#uences of labels along paths fromthe start state to an accepting state( 2oe"er. each along a path is ,in"isible1 i(e(. it contributes nothing tothe string along the path(

    E7*#2

    The folloing figure is an -NFA that accepts decimal numbers consisting of+( An optional 3 or O sign(( A string of digits(H( A decimal point. and( Another string of digits( !ither this string of digits. or the string

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    15/66

    f particular interest is the transition from #to #on any of . 3 or -( Thus. state #represents the situation in hich e ha"e seen the sign if there is one. but none of the

    digits are decimal point(

    State #represents the situation here e ha"e Kust seen the decimal point. and may or may not ha"eseen prior digits(

    In # e ha"e definitely seen at least one digit. but not the decimal point(

    Thus. the interpretation of #His that e ha"e seen a decimal point and at least one digit. either beforeor after the decimal point(

    T+ >"!#* N")*)"/ >"! */ -NFA:>e may represent an -NFA exactly as e do an NFA. ith one exception+ the transition function mustinclude information about transitions on ( Formally. e represent an -NFA A by A B

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    16/66

    in"ol"ed. and p is in !&LS!"! -NFA8 10 #*!@8The -closure allos us to explain easily hat the transitions of an -NFA loo* li*e hen gi"en a se#uenceof inputs( >e can define hat it means for an -NFA to accept its input(

    Suppose that !Be first define . the extended transition function. toreflect hat happens on a se#uence of inputs(

    The intent is that

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    17/66

    ( Letk

    i A= < pi.a= be the set Cr.r.GGG(rmE(That is. follo all transitions labeled a from states ecan

    reach from # along paths labeled x( The rK/s by folloing -labeled arcs in stepb( &omputek

    i A=

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    18/66

    Let us eliminate -transitions from the -NFA of the abo"e figure. hich e shall call ! in hat follos(From !. e construct an DFA D. hich is shon in the folloing figure( Imagine that for each state shon

    in fig(( there are additional transitions from any state to on any input symbols for hich a transition is

    not indicated( Also. the state has transitions to itself on all input symbols ..G(((

    Since the start state of ! is #. the start state of D is !&LS! U/) -1

    U N I T - II

    D>/ !6(*! 72!88"/ )+ 7*#2. "!

    G * /") "/ !6(*! 72!88"/8. 10

    #*!@8

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    19/66

    The algebraic description of the language is called as ,regular expressions( )egular expressions offer adeclarati"e ay to express the strings e ant to accept( Thus. regular expressions ser"e as the inputlanguage for many systems that process strings( !xamples include+

    Search commands

    Lexical analy$er generators

    T+ "2!*)"!8 "> R6(*! E72!88"/8:

    )egular expressions denote languages( For a simple example. the regular expression : 3

    :

    denotes thelanguage consisting of all strings that are either a single folloed by any number of /s or a single folloed by any number of /s( efore describing the regular-expression notation. e need to learn the threeoperations on languages that the operators of regular expressions represent( These operations are+

    ( The (/"/of to languages L and %. denoted L %. is the set of strings that are in either L or%. or both( For eg(. if LBC..E and %BC.E. then L% B C...E(

    ( The c"/c*)/*)"/of languages L and % is the set of strings in L and concatenating it ith anystring in %( This operator is denoted either ith a dot or ith no operator at all(

    For eg(. if LBC..E and %BC.E. thenL(%. or Kust L% is C.....E(

    The first three strings in L% are the strings in L concatenated ith ( Since is the identity forconcatenation. the resulting strings are the same as the strings of L( 2oe"er. the last three stringsin L% are formed by ta*ing each string in L and concatenating it ith the second string in %.hich is it ith the second string in %. hich is (For instance. from L concatenated ith from % gi"es us for L%(

    H( The c"8(!of a language L is denoted L:and represents the set of those strings that can beformed by ta*ing any number of strings from L. possibly ith repetitions and concatenating all ofthem( For instance. if LBC.E. then L:is all strings of /s and /s( If LBC.E. then L :consists of

    those strings of /s and /s such that the /s come in pairs( e(g(. . and but not or(

    B(9/6 R6(*! E72!88"/8:Algebras of all *inds start ith some elementary expressions. usually constants or "ariables( Algebras thenallo us to construct more expressions by applying a certain set of operators to these elementary expressionsand to pre"iously constructed expressions( >e can describe the regular expressions recursi"ely. as follos(In this definition e not only describe hat the legal regular expressions are. but for each regular expression!. e describe the language it represents. hich e denote L

    BASIS

    The basis consists of three parts(

    ( The constants and are regular expressions. denoting the languages CE and respecti"ely( Thatis. L

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    20/66

    ( If ! is a regular expression. then

    !c9/c "> R6(*!-E72!88"/ "2!*)"!8:

    Li*e other algebras. the regular expression operators ha"e an assumed order of ,precedence hich meansthat operators are associated ith their operands in particular order( For instance. e *no that xy3$ groupsthe product xy before the sum. so it is e#ui"alent to the parameteri$ed expression e build expressions that describe sets of strings that label certain paths in the DFA/s transition diagram(2oe"er. the paths are alloed to pass through only a limited subset of the states( In an inducti"e definitionof these expressions. e start ith the simplest expressions that describe paths that are not alloed to gothrough any state1 i(e(. the expressions e generate at the end represent all possible paths(

    E7*#2: Let us con"ert the DFA to a regular expression( This DFA accepts all strings that ha"e at leastone in them( To see hy. note that the automaton goes from the start state to accepting state as soon asit sees an input ( The automaton then stays in state on all input se#uences(

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    21/66

    from the DFA. the basis expressions can be constructed as shon in the table(

    For instance. R =D: Suppose LBL< ) = for a regular expression )( >e sho that LBL

    BASIS

    There are three parts to the basis as shon in the figure(

    Parte then reachthe accepting state of one of these automata.folloing a path labeled by some string in L

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    26/66

    ( Directly from the start state to the accepting state along a path labeled hich is in L

    !6(*! 72!88"/8. "!

    E72*/ )+ A6

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    27/66

    Li*e arithmetic expressions. the regular expressions ha"e a number of las that or* for them( %any ofthese are similar to the las for arithmetic. if e thin* of union as addition and concatenation asmultiplication(

    C"##()*))

    &ommutati"ity is the property of here the order of its operands can be sitched and gets the same result(An example for arithmetic is gi"en as x3y B y3x(

    L3% B %3L( This la. the commutati"e la for union. says that e may ta*e the union of tolanguages in either order(

    A88"c*))

    Associati"ity is the property of an operator that allos us to group the operands hen the operator is applied

    tice( For eg(. the associati"e la of multiplication is

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    28/66

    L*8 /"/6 c"8(!8:

    There are a number of las in"ol"ing the closure operators as gi"en belo

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    29/66

    E72*/ R6(*! L*/6(*68 e can con"ert any of the four representations for regular languages to any of the other threerepresentations( >hile there are algorithms for any of the con"ersions. sometimes e are interested not onlyin the possibility of ma*ing a con"ersion. but in the amount of time it ta*es(

    C"/!)/6 NFA8 )" DFA8

    >hen e start ith either an NFA or -NFA and con"ert it to a DFA. the time can be exponential inthe number of states of the NFA(

    First. computing the -closure of n states ta*es

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    30/66

    INDUCTION &ompute the set of reachable states from each state( If the set contains any acceptingstate. then the language is nonempty otherise it is empty(

    The folloing recursi"e rules tell hether a regular expression denotes the empty language(

    BASIS denotes the empty language1 and a for any input symbol a do not(INDUCTION Suppose ) is a regular expression( There are four cases to consider. corresponding to

    the ays that ) could be constructed( ) B ) 3 )( Then L

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    31/66

    o For String . they go to states and '. and both states are non-accepting(

    o Li*eise. string doesn/t distinguish A from '. because they go to F and !. respecti"ely.

    and both are non-accepting(

    o 2oe"er. distinguishes A from '. because e can sho CA('E is distinguishable on the next round. since on input they go to F and !.respecti"ely. and e already established that the pairC!.FE is distinguishable(

    The three remaining pairs. hich are therefore e#ui"alent pairs. are CA.!E. C.2Eand CD.FE(

    For eg(. consider hy e cannot infer that CA.!E is a distinguishable pair( n input . A and ! go to and 2. respecti"ely. and C.2E has not yet been shon distinguishable( n input . A and ! bothgo to F. so there is no hope of distinguishing them that ay(

    The other to pairs. C.2E and CD.FE ill ne"er be distinguished because they each ha"e identicaltransitions on and identical transitions on (

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    32/66

    Thus. the table-filling algorithm steps ith the table as shon in figure. hich is the correctdetermination of e#ui"alent and distinguishable states(

    T8)/6 E(*/c "> R6(*! L*/6(*68

    The table-filling algorithm gi"es us an easy ay to test if to regularlanguages are the same( Suppose languages L and % are each representedin some ay. eg(. one by a regular expression and one by an NFA(&on"ert each representation to a DFA( No. imagine one DFA hosestates are the union of the states of the DFA/s for L and %( Technically.this DFA has to start states. but actually the start state is irrele"ant asfar as testing state e#ui"alence is concerned. so ma*e any state the lonestart state(

    No. test if the start states of the to original DFA/s are e#ui"alent.using the table-filling algorithm( If they are e#ui"alent. then LB% and if

    not. then L%(

    E7*#2: &onsider the to DFA/s in the figure( !ach DFA accepts the emptystring and all strings that end in 1 that is the language of regular expression

    3e can imagine that the figure represents a single DFA. ith fi"e statesA through !( If e apply the table-filling algorithm to that automaton. the result isas shon in the figure(

    To see ho the table is filled out. e start by placing x/s in all pairs of states hereexactly one of the states is accepting( It turns out that there is no more to do( Thefour remaining pairs.CA.&E.CA.DE.C&.DE and C.!E are all e#ui"alent pairs( ;ou should chec* that no moredistinguishable pairs are disco"ered in the inducti"e part of the table-filling algorithm( For instance. ith the

    table as in fig((. e can/t distinguish the pair CA.DE because on they go to themsel"es and on they goto the pair C.!E. hich has not yet been distinguished( Since A and & are found e#ui"alent by this test. andthose states ere the start states of the to original automata. e conclude that these DFA/s do accept thesame language(

    E72*/ * DFA8. 10 #*!@8

    For each DFA e can find an e#ui"alent DFA that has a fe states as any DFA accepting the samelanguage( The central idea behind the minimi$ation of DFA/s is that the notion of state e#ui"alence lets us

    partition the states into bloc*s such that+( All the states in a bloc* are e#ui"alent( No to states chosen from to different bloc*s are e#ui"alent(

    E7*#2

    &onsider the first DFA and the table of the pre"ious #uestion. here e determined the statee#ui"alences and distinguishabilities for the states in the DFA( The partition of the states intoe#ui"alent bloc*s is

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    33/66

    &onsider the first DFA. The start state is CA.!E.sinceA as the start state of the DFA( The only acceptingstate is C&E. since & is the only accepting state ofDFA( The transitions of the folloing figure properlyreflect the transitions of original DFA( For instance. ithas a transition on input from CA.!E to C.2E( If eexamine the original DFA. e find that both A and !go to F on input . so the selection of the successor ofCA.!E on input is also correct( &hec* that all of theother transitions are also proper(

    =!) 8+"!) /")8 "/ M""! */9 M* #*c+/8.

    "! 10

    #*!@8

    E72*/ M""! */9 M* #*c+/8.

    ne limitation of the finite automaton as e ha"e

    defined it is that its output is limited to a binary signal+ ,accept 0 ,don/t accept( %odel in hich the outputis chosen form some other alphabet ha"e been considered (There are to distinct approaches1 the output maybe associated ith the state

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    34/66

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    35/66

    ( There is a finite set of "ariables also called sometimes non-terminals or syntactic categories( !ach"ariable represents a language that is a set of strings(

    H( ne of the "ariables represents the language being defined1 it is called the start symbol( ther"ariables represent auxiliary classes of strings that are used to help define the language of startsymbol(

    ( There is a finite set of productions or rules the represents the recursi"e definition of a language( !achproduction consist of

    e need to "ariables in thisgrammar one e call !. represents the expressions( It is the start symbol and represents the language ofexpressions e are defining( The other "ariable I represents the identifier( The regular expression for thelanguage is

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    36/66

    )ule e shall refer to this procedure as!c(!8 />!/c(

    E7*#2:

    Let us consider some of the inferences e ma*e using the grammar for expression

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    37/66

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    38/66

    If ') 8/)/)* >"!#? 5 #*!@8

    Deri"ations from the start symbol produce strings that ha"e a special role( >e call these ,sentential forms(

    That is if 'B

    ! !:!

    I:! a:!Additionally the deri"ation

    ! !:! !:

    !:

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    39/66

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    40/66

    ( There is a parse tree ith root A and yield (In fact. except for the use of recursi"e inference. hich e only defined for terminal strings all the otherconditions - the existence of deri"ations. leftmost or rightmost deri"ations. and parse trees are alsoe#ui"alent if is a string that has some "ariables( That is each are in that diagrams indicates that e pro"ea theorem that says if meets the condition at the trail. then it meets the condition at the head of the arc(

    F!"# I/>!/c )" T!8:-

    Let 'B

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    41/66

    F!"# D!*)"/8 )" Rc(!8 I/>!/c8

    >hene"er there is a deri"ation A for some &F'. then the fact that is in the language of A isdisco"ered in the recursi"e inference procedure( Suppose that e ha"e a deri"ation

    A 5.5.GGG(5* (Then e can brea* into pieces B..GGG(( (* such that 5i i( Note that if 5iis a terminal. theniB5i. and the deri"ation is $ero steps(

    If 5iis a "ariable. e can obtain the deri"ation of 5i iby starting ith the deri"ation A andstripping aay(

    All the position of the sentential forms that are either to the left or right of the positions that arederi"ed from 5i(

    All the steps are not rele"ant to the deri"ation of ifrom 5i(

    E72*/ )+ >"!#* 9>/)"/ "> 2(8+ 9"/ *()"#*)*? "!

    G 8+"!) /")8 "/ )+ 9>/)"/ "> 2(8+ 9"/ *()"#*)*? 5 #*!@8

    ur formal definition or notation for pushdon automation

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    42/66

    H( DA? "!

    E72*/ DA )+ !>!/c )" 6!*2+c* /")*)"/8 */9 98c!2)"/8? 15 #*!@8

    The transition diagram of a finite automation ill ma*e the aspects of the beha"ior of a gi"en PDA clearer(So e introduce and use the transition diagram for PDA/s in hich+

    ( The node corresponds to the states of a PDA(( An arro labeled start indicates the start state and doubly circled states are accept in. as for finite

    automation(H( The arcs correspond to transitions of the PDA in the folloing sense( An arc labeled a. x0 P from

    state # to state p means that s

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    43/66

    E7*#2

    Let us consider the action of the PDA of example abo"e on the input ( Since # is the start state and $is the start symbol. the initial ID is DA? "!

    G * /") "/ */6(*68 "> DA? 10 M*!@8

    The PDA accepts its input by consuming it and entering an accepting state( >e call this approach,acceptance by final start( There is a second approach to defining for any PDA the language ,acceptance byempty stac* that is the set of strings that cause the PDA to empty its stac* starting from the initial string(

    Acc2)*/c "> F/* S)*)Let pBe shall use a stac*symbol 8 to count the difference beteen the numbers of its seen so far. and

    the number of e/s( This simple one state PDA is suggested by the transition diagram as follos(

    The PDA is defined as. PNB C C#E.Ci.eE.C8E. n. #. 8=The abo"e PDA can be changed as follos to accept the string by reaching the final state(

    F/* S)*) )" E#2) S)*c@From each accepting state e ha"e to add one more transition to a ne non-accepting state(

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    44/66

    E72*/ )+ (*/c "> DAS */9 CFGS? "!

    =!) )+ 8#*!)8 e call A^ the

    tail of the left sentential form( If a left sentential form consists of terminals only. then its tail is .

    The idea behind the construction of a PDA form a grammar is to ha"e the PDA simulate the se#uence of leftsentential forms that the grammar uses to generate a gi"en terminal string ( The trail of each sententialform xA^ appears on the stac*. ith A at the top( At that time. x ill be ,represented by our ha"ingconsumed x from the input. lea"ing hate"er of follos its prefix x( That is if B xy. then y ill remainon the input(

    Suppose the PDA is in an IDhate"er terminalsappear at the beginning of `^ need to be remo"ed. to expose the next "ariables ate the top of the stac*( Theseterminals are compared against the next input symbols. to ma*e sure our guesses at the leftmost deri"ationof input string are correct. if not. this branch of the PDA dies deri"ation of . then e shall e"entuallyreach the left-sentential form ( At that point. all the symbols on the stac* ha"e either been expanded ormatched against the input( The stac* is empty and e accept by empty stac*(

    Let 'B

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    45/66

    PBhere transition function is defined by

    ( For each "ariable A.

    G * /") "/ D)!#/8)c (8+9"/ A()"#*)* DDA? 10 M*!@8

    D8c(88 DDA

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    46/66

    This PDA is clearly deterministic( It ne"er has a choice of mo"e in the same state. using the same input and

    stac* symbol( As for choices beteen using a real input symbol or . the -transition it ma*es is from # to

    # ith 8at the top of the stac*( 2oe"er. in state #. there are no other mo"es hen 8 is at the stac* top(

    R6(*! L*/6(*68 */9 D)!#/8)c DAS:

    The DPDA/s accept a class of languages that is beteen the regular languages and the &FL/s( >e shall firstpro"e that he DPDA language include all the regular languages( If e ant the DPDA to accept by emptystac*. then e find that our language recogni$ing capability is rather limited( Say that language L has the

    prefix property if there are no to different strings x and y in L such that x is a prefix of y(

    !xample+ That is . it is not possible for there to be to strings c)and xcx). one of hich is a prefix of the

    other. unless they are the same string( To see hy suppose c)is a prefix of xcx). and x( Then mustbe shorter than x( Therefore the c in c)comes in position here xcx)has a or 1 it is a position in thefirst x( That point ultraist the assumption that c)is a prefix of xcx)(

    n the other hand. there are some "ery simple languages that do not ha"e the prefix property( &onsider CE :.that is the set of all string of /s( &learly there are pairs of strings in this language one of hich is a prefix ofthe other( So this language does not ha"e a prefix property( In fact of any to strings. one is a prefix of theother. although the condition is stronger than e need to establish that the prefix property does not hold(

    DDAS */9 C"/)7) F! L*/6(*68:

    To see the language Lcris not regular. suppose it ere and use the pumping lemma( If n is a constant of thepumping lemma. then consider the string Bncn. hich is in Lcr( >hen e pump this string. it is the firstgroup of /s hose length must change. so e get in L crstrings that ha"e the ,center mar*er not in thecenter( Since these strings are not in Lcre ha"e a contradiction and conclude that Lcris not regular(n the other hand. there are &FL/s li*e Lcr that cannot be LB

    n

    n

    ( 2oe"er if it sees

    m

    m

    for some mn. P must notaccept( Since its stac* is empty. it cannot remember hat arbitrary integer n as. and must fail to recogni$eLcrcorrectly. our conclusion is that+

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    47/66

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    48/66

    F The set of finite or accepting state. a subset of M(I/8)*/)*/"(8 D8c!2)"/8

    The string 5 5 G(5i- # 5i5i3(( 5n is used to describe the transition in Turing machines( # is the state of the Turing machine(( The tape head is scanning the ithsymbol from the left(H( 55((5nis the portion of the tape beteen the leftmost and the rightmost nonblan*(( The mo"es of the Turing machine are described by notation( And. or ill be used

    to indicate $ero. one. or more mo"es of the T%(

    E7*#2:

    Let us design a Turing machine ill accept the language C nn J nBE( Initially. it is gi"en a finite se#uenceof /s and /s on its tape. preceded and folloed by infinity of blan*s( Alternately. the T% ill change a to an 5 and then a to a ;. until all /s and /s ha"e been matched(

    In more details. starting at the left end of the input. it repeatedly changes a to an 5 and mo"es to the righto"er hate"er /s and ;/s it sees. until it comes to a (It changes the to a ;. and mo"es left. o"er ;/s and/s . until it finds an 5( At that point. it loo*s for a immediately to the right. and if it finds one. changing itto 5 and repeats the process. changing a matching to a ;(

    The formal specification of the T% is %Bhere isgi"en by the table in figure

    T!*/8)"/ D*6!*#8

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    49/66

    A transition diagrams consists of a set of nodes corresponding to the states of the T%( An arc from state # tostate p is labeled by one or more items of the form 5 0 ; D. here 5 and ; are tape symbols. and D is adirection. either L or )( Start state is represented by the ord ,start and an arro entering that state(Accepting states indicated by double circles( This. the only information about the T% one cannot readdirectly from the diagram is the symbol used for the blan*( >e shall assume that symbol is unless e stateotherise( The transition diagram for the pre"ious example is gi"en belo(

    E7*#2

    In this example e shall sho ho a Turing machine might compute the function .hich is called minusor proper subtraction and is defined by mn Bmax

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    50/66

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    51/66

    (

    A Turing machine subroutine is a set of states that perform some useful process( This set of states includes astart state and another state that temporarily has no mo"es. and that ser"es as the ,return state to pass

    control to hate"er other set of sates called the subroutine( The ,call of a subroutine occurs hene"erthere is a transition to its initial state( Since the T% has no mechanism for remembering a ,return address.that is. a state to go to after it finishes. should our design of a T% call for one subroutine to be called fromse"eral states. e can ma*e copies of the subroutine. using a ne set of states for each copy( The ,calls aremade to the start states of different copies of the subroutine. and each copy ,returns to a different state(

    E7*#2: >e shall design a T% to implement the function ,multiplication( That is. our T% ill start ithm n on its tape. and ill end ith mn on the tape( An outline of the strategy is+

    ( The tape ill in general ha"e one nonblan* string of the form i n *nfor some *(( In one basic step. e change a in the first group to and add n /s to the last group. gi"ing us a

    string of the form i- nhen the first group of /s completely changed to blan*s. there ill be mn /s in thelast group(

    ( The final step is to change the leading n to blan*s. and e are done(

    The heart of this algorithm is a subroutine. hich e call copy( This subroutine implements step

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    52/66

    This subroutine mar*s the first ith an 5. mo"es right in state # until it finds a blan*. copies the

    there. and mo"es left in state #Hto find the mar*er 5(

    It repeats this cycle until in state # it finds a instead of a ( At that point. it uses state #to change

    the 5/s bac* to /s and ends inn state # ( The complete multiplication Turing machine starts in state # ( The first thing it does is go. in se"eral

    steps. from ID #omnto ID m-#n( The transitions needed are shon in the portion of figure to

    the left of the subroutine call1 these transitions in"ol"e states #and #Qonly(

    The purpose of state #.#R and # is to ta*e control after copy has Kust copRied a bloc* of n /s and isin ID m-*n*n( !"entually. these states bring us to state #om-*

    n(

    At that point the cycle starts again and copy is called to copy the bloc* of n /s again( As anexception in state #R the T% may find that all m /s ha"e been changed to blan*s(

    In that case. a transition to state #occurs( This state. ith the help of state #. changes the leadingn to blan*s and enters the halting state #(

    At this point. the T% is in ID #mn

    and its Kob is done(

    =!) 8+"!) /")8 "/ E7)/8"/8 )" )+ B*8c T(!/6 M*c+/. "!

    E72*/ )+ *!"(8 #"98 "> B*8c T(!/6 M*c+/. 10 M*!@8

    Nondeterministic Turing machine. an extension of the basic model that is alloed to ma*e any of a finite setof choices of mo"e in a gi"en situation( This extension also ma*es ,programming Turing machines easier.

    but adds no language-defining poer to the basic model(

    M())*2 T(!/6 M*c+/8

    The de"ice has a finite control and some finite number of tapes( !ach tape

    is di"ided into cells. and each cell can hold any symbol of the finite tapealphabet( As in the single tape T%. the set of tape symbols includes a

    blan*. and has a subset called the input symbols. of hich the blan* is nota member( The set of states includes an initial state and some acceptingstates( Initially+

    ( The input. a finite se#uence of input symbols is placed on thefirst tape(

    ( All other cells of all the tapes hold the blan*(H( The finite control is in the initial state(( The head of the first tape is at the left end of the input(( All other tape heads are at some arbitrary cell(

    A mo"e of the multitape T% depends on the state and the symbol scanned by each of the tape heads( In onemo"e the multitape T% does the folloing+

    ( The control enters a ne state. hich could be the same as the pre"ious state(

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    53/66

    ( n each tape. a ne tape symbol is ritten on the cell scanned( Any of these symbols may bethe same as the symbol pre"iously there(

    H( !ach of the tape heads ma*es a mo"e. hich can be left. right or stationary( The heads mo"eindependently. so different heads may mo"e in different directions. and some may not mo"e atall(

    %ultitape Turing machines li*e one-tape T%/s accept by entering an accepting state(

    E(*/c "> O/-T*2 */9 M())*2 TM8

    )ecursi"ely enumerable languages are defined to be those accepted by a one-tape T%( %ultitape T%/saccept all the recursi"ely enumerable languages. since a one tape T% is multitape T%(

    R(///6 T# */9 )+ M*/-T*28-)"-"/ C"/8)!(c)"/

    The running time of T% % on input is the number of steps that % ma*es before halting( If % doesn/t halton . then the running time of % on is infinite( The time complexity of T% % is the function T

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    54/66

    First. e restrict the tapes of the T% to beha"e li*e stac*s( Then. e further restrict the tapes to be,counters that is. they can only represent one integer. and the T% can only distinguish a count of fromany non$ero count(

    T(!/6 M*c+/8 )+ S#-/>/) T*28

    >e can assume the tape is semi-infinite that is there are no cells to the left of the initial head position( In thenext theorem. e shall gi"e a construction that shos a T% ith a semi-infinite tape can simulate onehose tape is. li*e our original T% model. infinite in both directions(

    The tric* behind the construction is to use to trac*s on thesemi-infinite tape( The upper trac* represents the cells of theoriginal T% that are at or to the right of the initial head position(The loer trac* represents the positions but in re"erse order(The exact arrangement is suggested in figure(

    The upper trac* represents cells 5.5.G(.here 5is the initial position of the head 5.5. and so on. are thecells to right( &ells 5-.5- and so on( )epresent cells to the left of the initial position( !nd mar*er and

    pre"ents the head of the semi-infinite T% from accidentally falling off the left end of the tape(

    >e can ma*e one more restriction to our Turing machine it ne"er rites a blan*( This simple restriction.coupled ith the restriction that the tape is only semi-infinite means that the tape is at all times a prefix ofnonblan* symbols folloed by infinity of blan*s( Further. the se#uence of non blan*s alays begins at theinitial tape position(

    M() 8)*c@ #*c+/

    >e no consider a class of machines called ,countermachines( These machines ha"e only the ability to store afinite number of integers

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    55/66

    >e add one capability that simplifies input processing by this deterministic machine+ e assume there is aspecial symbol . called the end-mar*er that appears only at the end of the input and is not part of that input(The presence of the end mar*er allos us to *no hen e ha"e consumed all the a"ailable input. e shallsee in the next theorem ho the end mar*er ma*es it easy for the multistac* machine to simulate a Turingmachine( Notice that the con"entional T% needs no special end mar*er. because the first blan* ser"es tomar* the end of the input(

    C"(/)! M*c+/8

    A counter machine may be thought of in on of to ays+= The counter machine has the same structure as the multistac* machine. but in place of each stac* is a

    counter( &ounters hold any nonnegati"e integer. but e can only distinguish beteen $ero andnon$ero counters( That is. the mo"e of the counter machine depends on its states. input symbol. andhich. if any. of the counters are $ero( In one mo"e the counter machine can+a= &hange state(

    b= Add or subtract from any of its counters independently( 2oe"er. a counter is not alloed tobecome negati"e. so it cannot subtract from a counter that is currently (

    = A counter machine may also be regarded as a restricted multistac* machine( The restrictions are asfollos+a= There are only to stac* symbols. hich e shall refer to as 8e may replace 8 only by a string of the form 5

    i8for some iB(d= >e may replace 5 only by 5i for some iB( That is. 8 appears only on the bottom of each

    stac*. and all other stac* symbols. if any. are 5(>e shall use definition

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    56/66

    ( A Turing machine can simulate a computer.and can do so in an amount of time that is atmost some polynomial in the number of stepsta*en by the computer(

    S#(*)/6 * T(!/6 M*c+/ e can thus arrange that the dis*s are placed in to stac*s asshon in the figure(

    ne stac* holds the data in cells of the Turing machine tape that are located significantly to the left of thetape of the tape head( And the other stac* holds data significantly to the right of the tape head( If the tapehead of the T% mo"es sufficiently far to the left that it reaches cells that are not represented by the dis*

    currently mounted in the computer then it prints a message ,sap left the currently mounted dis* isremo"ed by a human operator and placed on the top of the right stac*( The dis* on top of the left stac* ismounted in the computer. and computation resumes(

    Similarly. if the T%/s tape head reaches cells so far to the right that these cells are not represented by themounted dis*. then a ,sap right message is printed( The human operator mo"es the currently mounteddis* to the top of the left stac*. and mounts the dis* on top of the right stac* in the computer( If either stac*is empty hen the computer as*s that a dis* from that stac* be mounted. then the T% has entered an all-

    blan* region of the tape( In that case. the human operator must go toe the store and by a first dis* to mount(

    S#(*)/6 * C"#2()! e ha"e used a code in hich addresses ofmemory ords. in numerical order. alternate ith the contents are ritten in binary( The mar*er symbols :and are used to ma*e it easy to find the ends of addresses and contents. and to tell hether a binary string isam address or contents(

    The second tape is the ,instruction counter( This tape holds one integer in binary. hich represents one of

    the memory locations on tape ( The "alue stored in this location ill be interpreted as the next computerinstruction to be executed(

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    57/66

    The third tape holds a ,memory address or the contents of that address after the address has been located ontape ( To execute an instruction. the T% find the contents of one or more memory addresses that holds datain"ol"ed in the computation( ur T% ill simulate the instruction cycle of the computer. as follos(

    ( Search the first tape for an address that matches the instruction number on tape ( >e start at the on the first tape. and mo"e right. comparing each address ith the contents of tape (

    ( >hen the instruction address is found. examine its "alue( Let us assume that hen a ord is aninstruction. its first fe bits represent the action to be ta*en hile thereare many languages. that are context free. including some e ha"e seen that are not regular languages. thereare also some simple-to-describe languages that are not context free( An example of a non-context free

    language isCnnn $ n E the set of strings consisting of e#ual groups of /s. /s and /s(

    A ,finite state control. reads input. one symbol at a

    time( The pushdon automation is alloed toobser"e the symbol at the top of the stac* and to

    base its transition on its current state. the input

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    58/66

    symbol. and the symbol at the top of the stac*( Alternati"ely. it ma*es a ,spontaneous transition. using asits input instead of an input symbol( In one transition. the pushdon automation

    ( &onsumes from the input the symbol that it uses in the transition( If is used for the input then no inputsymbol is consumed(

    ( 'oes to a ne state. hich may us may not be the same as the pre"ious state(

    H( )eplace the symbol at the top of the stac* by any string( The string could be . hich &orresponds to apop of the stac*( It could be the same symbol that appeared at the top of the stac* pre"iously that is nochange to the stac* is made(

    E7*#2:Let us consider the language Lr B C)J is in hile in state #. e read symbols and store them on the stac*. by pushing a copy of each input

    symbol on to the stac*(H( At anytime. e may guess that e ha"e seen the middle that is the end of ( At this time ill beon the stac* ith the right end of at the top and the left end at the bottom( >e signify this choice

    by spontaneously going to state #( Since the automation is non deterministic e actually ma*e bothguesses( >e guess e ha"e seen the end of . but e also slay in static go and continue to read inputand store them on the stac*(

    ( nce in state #. e compare input symbols ith the symbol at the top of the stac*( If they match. econsume the input symbol. pop the stac*. and proceed( If they do not match. e ha"e guessed rong.our guessed as not folloed by )( This branch dies. although other branches of the nondeterministic automation may sur"i"e and read to acceptance(

    ( If e empty the stac*. then e ha"e ended seen some input folloed by )( >e accept the output

    that as read up to this point(

    E/9 "> U/) -&U N I T - V

    E72*/ )+ c"/c2) "> /)!*c)*

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    59/66

    There are nodes. hich are numbered - in this example graph( And there are edges beteen some pairs ofnodes( !ach edge has a eight. hich is an integer( A spanning tree is a subset of the edges such that allnodes are connected through these edges( ;et there are no cycles( An example of a spanning tree is shon

    by bold edges( A minimum-eight spanning tree has the least possible total edge eight of all spanningtrees(

    There is a ell-*non ,greedy algorithm. called jrus*al/s Algorithm. for finding a %>ST( 2ere is aninformal outline of the *ey ideas+

    ( %aintain for each node the connected component in hich the node appears. using hate"er edgesof the tree ha"e been selected so far( Initially. no edges are selected. so e"ery node is in it/s aconnected component by itself(

    ( &onsider the loest-eight edge that has not yet been considered1 brea* ties any ay you li*e( If thisedge connects to nodes that are currently in different connected components then+

    o Select that edge for the spanning tree. and

    o %erge the to connected components in"ol"ed(

    H( &ontinue considering edges until either all edges ha"e been considered. or the number of edgesselected for the spanning tree is one less that the number of nodes( Note that in the latter case. allnodes must be in one connected component and e can stop considering edges(

    E7*#2:In the graph e first consider the edgehether in fact e"erything that can be done in polynomial time by a NT% can in fact aredone by DT% in polynomial time. perhaps ith a higher-degree polynomial(

    T+ T!*/6 8*8#*/ 2!"ST. a graph ith integer eights on the edges such as that offig and a eight limit >( the #uestion as*ed is hether the graph as a ,2amilton circuit of total eight atmost >( A 2amilton circuit is a set of edges ith each node appearing exactly once( Note that the number ofedges on a 2amilton circuit must e#ual the number of nodes in the graph(

    E7*#2:The graph of fig actually has only one 2amilton circuit the cycle is QH or more. the anser is ,yes. and if >QH the anser is,no(

    2oe"er. the TSP on four-node graph is decepti"ely simple. since there can ne"er be more than todifferent 2amilton circuits once e account for the different nodes at hich the same cycle can start. and forthe direction in hich e tra"erse the cycle( In m-node graphs. the number of distinct cycles gros as

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    60/66

    ith the desired eight limit >. or to find one if e are unluc*y in the order in hich e consider thecycles( n the other hand . if e had a nondeterministic computer. e could guess a permutation of thenodes. and compute the total eight for the cycle of nodes in that order( If there ere a real computer thatas nondeterministic. no branchA similar amount of time( Thus. a single Otape NT% can sol"e the TSP in econclude that the TSP is in NP(

    "/"#* 'T# R9(c)"/8

    ur principal methodology for pro"ing that a problem P cannot be sol"ed in polynomial time

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    61/66

    D8c!

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    62/66

    length. there is no need to distinguish beteen the length of an expression/s code and the number ofpositions in the expression itself(

    N-C"#2)/88 "> )+ SAT 2!"e no pro"e ,coo*/s Theorem. the fact that SAT is NP-complete( To pro"e a problem is NP-complete. e need first to sho that it is in NP( Then. e must sho that e"ery language in NP reduces tothe problem in #uestion( In general. e sho the second part by offering a polynomial O time reduction fromsome other NP-complete problem at right no1 e don/t *no any NP-complete problems to reduce toSAT( Thus. the only strategy a"ailable is to reduce absolutely e"ery problem in NP to Sat(

    E72*/ )+ C"#2#/)8 "> L*/6(*68 / N? "! 10 M*!@8

    =!) 8+"!) /")8 "/ )+ c"#2#/)8 "> */6(*68 / N?

    The class of languages P is closed under complementation for a simple argument hy. let L be in P and let% be a T% for L( %odify % as follos. to accept L( Introduce a ne accepting state # and ha"e the neT% transition to # hene"er % halts in a state that is not accepting( %a*e the former accepting states of %

    be non accepting( Then the modified T% accepts L. and runs in the same amount of time that % does. iththe possible addition of one mo"e( Thus. L is in P if L is(

    It is not *non hether NP is closed under complementation( It appears not. hoe"er. and inparticular e expect that hene"er a language L is NP complete. then its complement is not in NP(

    T+ C*88 "> L*/6(*68 C"-N

    &o-NP is the set of languages hose complements are in NP( >e obser"ed at the beginning ofsection that e"ery language in P has its complement also in P. and therefore in NP( n the other hand. e

    belie"e that none of the NP-complete problems ha"e their complements in NP. and therefore no NP-complete problem is in co-NP( Li*eise. e belie"e the complements( 2oe"er. e should bear in mindthat. should P turn out to e#ual NP. then all three classes are actually the same(

    E7*#2:&onsider the complement of the language SAT hich is surely a member of 6&o-NP e shall

    refer to this complement as 4SAT include all those that code oolean expressions that are not satisfiable(2oe"er. also in 4SAT are those strings that do not code "alid oolean expressions . because surely noneof those strings that do not code "alid oolean expressions. because surely none of those strings are in SAT(>e belie"e that 4SAT is not in NP but there is no proof(

    N-C"#2) !"

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    63/66

    Let us assume that PB NP( It is still possible that the situation regarding co-NP is not exactly assuggested by figure( ecause e could ha"e NP and are in NP. and yet not be able to sol"e them indeterministic polynomial time( 2oe"er. the fact that e ha"e not been able to find e"en one NP complete

    problem hose complement hose complement is in NP is strong e"idence that NPB co-NP. as e pro"e inthe next theorem()efer the theorem NPBco-NP if and only if there is some NP-complete problem hose complement is in

    NP(

    =!) 8+"!) /")8 "/ !" S */9 NS 2!"(8

    9>/9 c*888?

    Initially. e shall distinguish beteen the languages accepted by deterministic and nondeterministicT%/s ith a polynomial space bound. but e shall soon see that these to classes of languages are thesame(

    There are complete problems P for polynomial space in the sense that all problems in this class are

    reducible in polynomial time to P( Thus. if P is in P or in NP. then all languages ith polynomial spacebounded T%/s are in P or NP respecti"ely( >e shall offer one example of such a problem+ ,#uantifiedoolean formulas(

    "/"#*-S2*c T(!/6 M*c+/8

    A polynomial-space-bounded Turing machine is suggested( There is some polynomial p

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    64/66

    An essential property of polynomial-space-bounded T%/s is that they can ma*e only an exponential numberof mo"es before they must repeat an ID( >e need this fact to pro"e other interesting facts about PS. andalso to sho that PS contains only recursi"e languages1 i(e(. languages ith algorithms( Note that there isnothing in the definition of PS or NPS that re#uires the T% to halt( It is possible that the T% cycles fore"er.ithout lea"ing a polynomial si$ed region of its tape(

    D)!#/8)c */9 N"/9)!#/8)c "/"#* S2*c

    Since the comparison beteen P and NP seems so difficult. it is surprising that the same comparisonbeteen PS and NPS is easy+ they are the same classes of languages( The proof in"ol"es simulating anondeterministic T% that has a polynomial space bound p /")

    END

    ELSE $ /9(c) 2*!) $BEGIN

    FOR *c+ 2"88

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    65/66

    It is important to obser"e that. although reach calls itself tice. it ma*es and therefore only one of

    the calls is acti"e at a time( n. until at some point the third argument becomes ( At that point. reach canapply the basis step. and needs no more recursi"e calls( It tests if IB or I-. returning T)4! if either holdsand FALS! if neither does( Figure suggests hat the stac* of the DT% D loo*s li*e hen there are as manyacti"e calls to reach as possible. gi"en an initial mo"e count of m(

    >hile it may appear that many calls to reach are possible. and the tape of can become "ery long. eshall sho that it cannot become ,too long( That is. if started ith a mo"e count of m. there can only belog m stac* frames on the tape at any one time( Since Theorem assures us that the NT% N cannot ma*emore than cp

  • 8/13/2019 Theory of Automata(a.kaja Mohideen)

    66/66

    E/9 "> U/) -5


Recommended