Automata Theory E-content Document

download Automata Theory E-content Document

of 100

Transcript of Automata Theory E-content Document

  • 8/10/2019 Automata Theory E-content Document

    1/100

    Theory of Computation

    Prepared by

    Sasmita Kumari Nayak

    Assistant Professor, CSE Department

    Centurion institute of Technology

    Centurion University of Technology and management

  • 8/10/2019 Automata Theory E-content Document

    2/100

    Module 1

    Chapter 1

    1.1 Alphabet, languages and grammars

    Languages:A general definition of language must cover a variety of distinct categories: natural language programming languages, mathematical languages, etc. The notion of natural languages likEnglish, Hindi, etc. is familiar to us. Informally, language can be defined as a system suitable fexpression of certain ideas, facts, or concepts, which includes a set of symbols and rules tmanipulate these. The languages we consider for our discussion is an abstraction of naturalanguages. That is, our focus here is on formal languages that need precise and formadefinitions. Programming languages belong to this category. We start with some basic conceptand definitions required in this regard.

    1.2 Symbols:

    Symbols are indivisible objects or entity that cannot be defined. That is, symbols are the atoms the world of languages. A symbol is any single object such as ,a, 0, 1, #, begin, or do. Usually,characters from a typical keyboard are only used as symbols.

    1.3 Alphabets:

    An alphabet is a finite, nonempty set of symbols. The alphabet of a language is normally denote

    by . When more than one alphabets are considered for discussion, then subscripts may be use(e.g. etc) or sometimes other symbol likeG may also be introduced.Example:

    1.4 Strings or Words over Alphabet:

    A string or word over an alphabet is a finite sequence of concatenated symbols of .Example: 0110, 11, 001 are three strings over the binary alphabet { 0, 1 } .aab , abcb , b, cc are four strings over the alphabet {a , b, c }.

    It is not the case that a string over some alphabet should contain all the symbols from thalphabet. For example, the string cc over the alphabet {a , b, c } does not contain the symbols a

  • 8/10/2019 Automata Theory E-content Document

    3/100

    and b. Hence, it is true that a string over an alphabet is also a string over any superset of thalphabet.Convention: We will use small case letters towards the beginning of the English alphabet todenote symbols of an alphabet and small case letters towards the end to denote strings over aalphabet. That is, (symbols) and are strings.

    1.5 Some String Operations:

    The operations of strings are concatenation, length of a string, powers of strings, powers oalphabets and reversal.

    1.6 Concatenation:

    Let and be two strings. The concatenation

    of x and y denoted by xy, is the string . That is, the concatenationof x and y denoted by xy is the string that has a copy of x followed by a copy of y without anyintervening space between them.

    Example: Concatenation of the strings 0110 and 11 is 011011 and concatenation of the stringsgood and boy is goodboy. Note that for any stringw, we = ew = w. It is also obvious that if | x | = n and | y | = m,then | x + y | = n + m.u is a prefix ofv if v = ux for some string x.u is a suffix ofv if v = xu for some string x.u is a substring ofv if v = xuy for some strings x and y.

    1.7 Length of a string:

    The number of symbols in a string w is called its length, denoted by |w|.Example: | 011 | = 4, |11| = 2, | b | = 1It is convenient to introduce a notation e for the empty string, which contains no symbols at alThe length of the empty string e is zero, i.e., | e | = 0.Example: Consider the string 011 over the binary alphabet. All the prefixes, suffixes andsubstrings of this string are listed below.Prefixes:e, 0, 01, 011.Suffixes:e, 1, 11, 011.

    Substrings:e, 0, 1, 01, 11, 011. Note that x is a prefix (suffix or substring) to x, for any string x ande is a prefix (suffix orsubstring) to any string.A string x is a proper prefix (suffix) of string y if x is a prefix (suffix) of y. In the above example,all prefixes except 011 are proper prefixes.

  • 8/10/2019 Automata Theory E-content Document

    4/100

    1.8 Powers of Strings :

    For any string x and integer , we use to denote the string formed by sequentiallyconcatenatingn copies of x. We can also give an inductive definition of as follows:

    = e, if n = 0 ; otherwiseExample : If x = 011, then = 011011011, = 011 and

    2.1 Powers of Alphabets:

    We write (for some integerk ) to denote the set of strings of lengthk with symbols from .In other words,

    = { w | w is a string over and | w | = k }. Hence, for any alphabet, denotes the set of allstrings of length zero. That is, = { e }. For the binary alphabet { 0, 1 } we have the following.

    2.2

    The set of all strings over an alphabet is denoted by . That is,

    The set contains all the strings that can be generated by iteratively concatenating symbolsfrom any number of times.Example: If = {a, b}, then = { e, a , b, aa , ab , ba , bb , aaa , aab , aba , abb , baa }.Please note that if , then that is . It may look odd that one can proceed fromthe empty set to a non-empty set by iterated concatenation. But there is a reason for this and waccept this convention.

    2.3

    The set of all nonempty strings over an alphabet is denoted by . That is,

    Note that is infinite. It contains no infinite strings but strings of arbitrary lengths.

  • 8/10/2019 Automata Theory E-content Document

    5/100

    Reversal: For any string the reversal of the string is .

    2.4 Languages:

    A language over an alphabet is a set of strings over that alphabet. Therefore, a language L is anysubset of . That is, any is a language.Example :

    1. F is the empty language.2. is a language for any .

    2.5 Cont 3. {e} is a language for any . Note that, . Because the language F does not

    contain any string but {e} contains one string of length zero.4. The set of all strings over { 0, 1 } containing equal number of 0's and 1's.5. The set of all strings over {a , b, c} that starts witha .

    Convention : Capital letters A, B, C , L, etc. with or without subscripts are normally used todenote languages.

    2.6 Set operations on languages: Since languages are set of strings we can apply set operations to languages. Here are somsimple examples (though there is nothing new in it).

    Union : A string iff or

    Example : { 0, 11, 01, 011 } { 1, 01, 110 } = { 0, 11, 01, 011, 111 }Intersection : A string iff and .

    Example : { 0, 11, 01, 011 } { 1, 01, 110 } = { 01 }

    2.7 Complemen t :

    Usually, is the universe that a complement is taken with respect to. Thus for a language L, thecomplement is = { | }.Example : Let L = { x | | x| is even }. Then its complement is the language { | | x| is odd }.Similarly we can define other usual set operations on languages like relative complemensymmetric difference, etc.

    2.8 Reversal of a language:

    The reversal of a language L, denoted as , is defined as: .

  • 8/10/2019 Automata Theory E-content Document

    6/100

    Example : 1. Let L = {0, 11, 01, 011}. Then = { 0, 11, 10, 110 }.2. Let L = { |n is an integer }. Then = { |n is an integer }.

    3.1 Language concatenation : The concatenation of languages and is defined as

    = { xy | and }.Example : { a , ab }{ b, ba } = {ab , aba , abb , abba }. Note that ,

    1. in general.2. 3.

    3.2 Iterated concatenation of languages:

    Since we can concatenate two languages, we also repeat this to concatenate any number olanguages. Or we can concatenate a language with itself any number of times. Theoperation denotes the concatenation of L with itselfn times. This is defined formally asfollows:

    3.3 Example :Let L = { a , ab }. Then according to the definition, we have

    and so on.

    3.4 Kleene's Star operation:

    The Kleene star operation on a language L, denoted as is defined as follows:= (Unionn in N) == {x | x is the concatenation of zero or more strings from L }

    Thus is the set of all strings derivable by any number of concatenations of strings in L. It isalso useful to define

  • 8/10/2019 Automata Theory E-content Document

    7/100

    = , i.e., all strings derivable by one or more concatenations of strings in L. That is= (Unionn in N andn >0) =

    3.5 Example :

    Let L = {a , ab }. Then we have,== {e} {a , ab } {aa , aab , aba , abab } == {a , ab } {aa , aab , aba , abab }

    Note : e is in , for every language L, including. The previously introduced definition of is an instance of Kleene star.

    3.6 What is Automata?

    An automaton is an abstract computing device (or machine). There are different varieties of sucabstract machines (also called models of computation) which can be defined mathematicallSome of them are as powerful in principle as today's real computers, while the simpler ones arless powerful. (Some models are considered even more powerful than any real computers as thehave infinite memory and are not subject to physical constraints on memory unlike in reacomputers). Studying the simpler machines is still worth as it is easier to introduce somformalism used in theory.

    3.7 Features of Automaton:

    Every automaton consists of some essential features as in real computers. It has amechanism for reading input. The input is assumed to be a sequence of symbols over given alphabet and is placed on an input tape (or written on an input file). The simpleautomata can only read the input one symbol at a time from left to right but not changePowerful versions can both read (from left to right or right to left) and change the input.

    The automaton can produce output of some form. If the output in response to an inpustring is binary (say, accept or reject), then it is called anaccepter .

    3.8 Cont

    If it produces an output sequence in response to an input sequence, then it is called transducer (or automaton with output).

    The automaton may have a temporary storage, consisting of an unlimited number of celleach capable of holding a symbol from an alphabet (which may be different from theinput alphabet). The automaton can both read and change the contents of the storage cellin the temporary storage. The accusing capability of this storage varies depending on thtype of the storage.

  • 8/10/2019 Automata Theory E-content Document

    8/100

  • 8/10/2019 Automata Theory E-content Document

    9/100

    Chapter 2

    Finite Automata

    4.2 Finite AutomataAn automaton (Plural: Automata) is defined as a system where information is transmitted anused for performing some functions without direct participation of man.

    4.3 Description of Automata

    A finite automaton is a mathematical model of a system with discrete inputs and outputs. Thsystem can be in any number of internal configurations on states. The state of systemsummarizes the information concerning past input that is needed to determine the behavior of thsystem or subsequent input.Transitions are changes of states that can occur spontaneously or inresponse to inputs to the states. Though transitions usually take time, we assume that stattransitions are instantaneous (which is an abstraction).

    4.4 Cont

    Some examples of state transition systems are: digital systems, vending machines, etc. A systecontaining only a finite number of states and transitions among them is called afinite-statetransition system. Finite-state transition systems can be modeled abstractly by a mathematical model calledfiniteautomation .

    4.5 Deterministic Finite (-state) Automata

    Informally, a DFA (Deterministic Finite State Automaton) is a simple machine that reads aninput string, one symbol at a time and then, after the input has been completely read, decidewhether to accept or reject the input. As the symbols are read from the tape, the automaton cachange its state, to reflect how it reacts to what it has seen so far.

    4.6 Formal DefinitionA Deterministic Finite State Automaton (DFA) is a 5-tuple:

    Q is a finite set of states. is a finite set of input symbols or alphabet. A transition function( : Q Q) is the start state. is the set of accept or final states.

    http://en.wikipedia.org/wiki/Function_%28mathematics%29http://en.wikipedia.org/wiki/Function_%28mathematics%29
  • 8/10/2019 Automata Theory E-content Document

    10/100

    4.7 Acceptance of Strings:

    A DFA accepts a string if there is a sequence of states inQ suchthat

    1. is the start state.2. for all .3. .

    4.8 Language Accepted or Recognized by a DFA:

    The language accepted or recognized by a DFA M is the set of all strings accepted by M , and is

    denoted by i.e.The notion of acceptance can also be made more precise by extending the transition function

    5.1 Extended transition function:

    Extend (which is function on symbols) to a function on strings,i.e. .

    That is, is the state the automation reaches when it starts from the stateq and finish processing the string w.

    5.2 Cont

    Formally, we can give an inductive definition as follows:The language of the DFA M is the set of strings that can take the start state to one of theaccepting states i.e.L( M ) = { | M acceptsw }

    = { | }

    5.3 Example:

    is the start state

  • 8/10/2019 Automata Theory E-content Document

    11/100

    5.4 Cont

    It is a formal description of a DFA. But it is hard to comprehend. For example, the language othe DFA is any string over { 0, 1} having at least one 1.We can describe the same DFA by transition table or state transition diagram as following:

    5.5 Cont

    State transition diagram :

    Transition Table :

    0 1

    It is easy to comprehend the transition diagram.Explanation : We cannot reach final state w/0 or in the i/p string. There can be any no. of 0's

    at the beginning. ( The self-loop at on label 0 indicates it ). Similarly there can be any no. o0's & 1's in any order at the end of the string.

    5.6 Transition table:

    It is basically a tabular representation of the transition function that takes two arguments (a statand a symbol) and returns a value (the next state).

    Rows correspond to states, Columns correspond to input symbols,

    5.7 Cont Entries correspond to next states The start state is marked with an arrow The accept states are marked with either a star (*) or a single circle.

  • 8/10/2019 Automata Theory E-content Document

    12/100

    5.8 Cont 0 1

    6.1 (State) Transition diagram:

    A state transition diagram or simply a transition diagram is a directed graph which can bconstructed as follows:

    1. For each state inQ there is a node.

    2. There is a directed edge from nodeq to node p labeleda iff . (If there areseveral input symbols that cause a transition, the edge is labeled by the list of thesesymbols.)

    6.2 Cont

    3. There is an arrow with no source into the start state.4. Accepting states are indicated by double circle.

    6.3 Cont Here is an informal description how a DFA operates. An input to a DFA can be anystring . Put a pointer to the start state q. Read the input string w from left to right, onsymbol at a time, moving the pointer according to the transition function, . If the next symb

    of w is a and the pointer is on state p, move the pointer to .

    6.4 Cont

    When the end of the input stringw is encountered, the pointer is on some state,r . The string issaid to beaccepted by the DFA if andrejected if . Note that there is no formalmechanism for moving the pointer.A language is said to be regular if L = L( M ) for some DFA M .

    6.5 Example:

    Design a DFA which accepts the language L1 = { x {a, b }* | x ends withaa }

  • 8/10/2019 Automata Theory E-content Document

    13/100

    Figure 2: An FA accepting the strings ending withaa .

    6.6 Acceptability of a string by a finite automata:

    A string w is accepted by a finite automaton if(q0, w)=P for some P in F.this concludes that the string is accepted by the final state.

    6.7 Property:

    for all strings w and input symbols a

    (q, xy) = ( (q, x), y)(q, yx) = ( (q, y), x)

    6.8 Example:

    Let us consider a transition table as given below. Now let us consider the input string whether is accepted by a FA or not.

    0 1

    6.9 Cont

    By using the above property(q0, 1010) = (q1, 010)= (q1, 10)= (q1, 0)= q1 Here q1is the final state so it concludes that the given string is accepted by the finite automata bfinal state.

    7.1 Nondeterministic Finite Automata (NFA)

    An NFA is defined in the same way as the DFA but with the following two exceptions: Multiple next states. - Transitions.

    Multiple Next State: In contrast to a DFA, the next state is not necessarily uniquely determined by the curren

    state and input symbol in case of an NFA. (Recall that, in a DFA there is exactly one starstate and exactly one transition out of every state for each symbol in ).

  • 8/10/2019 Automata Theory E-content Document

    14/100

    This means that - in a stateq and with input symbol a - there could be one, more than oneor zero next state to go, i.e. the value of is a subset ofQ. Thus

    = which means that any one of could be the next state. The zero next state case is a special one giving = , which means that there is no

    next state on input symbol when the automata is in stateq. In such a case, we may thinkthat the automata "hangs " and the input will be rejected.

    7.2 - Transitions:

    In an -transition, the tape head doesn't do anything- it does not read and it does not moveHowever, the state of the automata can be changed - that is can go to zero, one or more

    states. This is written formally as implying that the next statecould by any one of w/o consuming the next input symbol.

    7.3 Formal definition of NFA :Formally, an NFA contains 5 tuples whereQ, , , and F bear the samemeaning as for a DFA, but , the transition function is redefined as follows:

    Where P (Q) is the power set ofQ i.e. .Acceptance of NFA: Acceptability of a string is defined as if any completed path ends with final state then; we say is accepted otherwise not accepted.

    7.4 Example:

    Obtain an NFA for a language consisting of all strings over {0, 1} containing a 1 in the third position from the end.

    Solution:

    q1, q2, q3 are initial states andq4 is the final state.

    Please note that this is an NFA as d(q2 ,0) =q3 and d(q2 ,1) =q3 .

  • 8/10/2019 Automata Theory E-content Document

    15/100

    7.5 Example:

    Sketch the NFA state diagram for M = ({q0, q1 , q2 , q3},{0,1},d,q0 ,{q3}) with the state table asgiven below.

    7.6 Solution:

    The NFA states areq0, q1, q2 andq3.

    The NFA is as shown below.

    7.7 Equivalence of NFA and DF A

    Theorem: Equivalenceof DFA and NFA

    Let L (language) be a set accepted by a nondeterministic finite automata. Then deterministic finite automata that accept L.

    Proof:

    Let M= (Q, , , q0, F) be an NFA accepting L . We can defined DFA M= (Q , , , q 0, F ). The statesof the M are all the subsets of the stateof M. That is Q=2Q .

    M will keep track in its states of all the states M could be at any given time .F is the set of allstates in Q containing a final state of M.

  • 8/10/2019 Automata Theory E-content Document

    16/100

    7.8 Cont

    An elements of Q will be denoted by {q1, q2, q3... qn}, where q1, q2, q3... qn are in Q. Notice that[q1, q2, q3... qn] is a single state of the DFA corresponding to a set of states of the NFA.

    Note that q0= [ q0]

    We can defined ([q1, q2, q3, ......, qn],a)=[ P1, P2, P3, ..., P j] if and only if ([q1, q2, q3, ......, qn],a)=[ P1, P2, P3, ...,P j]

    8.1 Cont

    that is applied to an element [q1, q2, q3, ......, qn] of Q is computed by applying to reacstate of Q represented by [q1, q2, q3, ......, qn].

    On applying to each of [q1, q2, q3... qn] and taking the unions, we get some new set of states, P1,P2, P3... P j. This new set of states has a representive, [P1, P2, P3... P j] in Q, and the element is thevalue o ([q1, q2, q3... qn],a)

    The length of input string x, then (q 0, .x)= { q1, q2, q3, ......, qn } if and only if (q0, .x)= { q1,q2, q3, ......, qn }

    8.2 Cont

    The result is trivial for X=0, since q0= [q0] and Xmust be (Null). So it is prove that for every NFA there is exist a DFA.Procedure: For NFA their exist a DFA which simulates the behaviorof NFA, i.e. if L is a setaccepted by a NFA then their exist DFA which also accepting L.

    8.3 Cont

    Let M be a NFA having M= (Q, , ,q0, F)Thenthe corresponding DFA M is M = (Q, , , q 0, F )Where Q=2Q i.e. if Q = { q0, q1}Then Q= {, [q0], [q1] [q0, q1]} = (input set) q 0=[ q0] (initial state)F=set of state having any qi F for i=0,1,2,3....... n= It is defined only for thosestates data reachable from initial states.

  • 8/10/2019 Automata Theory E-content Document

    17/100

    8.4 Example:

    For the following NFA find equivalent DFA

    8.5 Solution:

    The state table can be represented by the state diagram as given below

    First we make the starting state of NFA as the starting state of DFA. Apply 0 and 1 as input ostate q0. Now keep the outputs in 2nd and 3rd columns. Next take the new generated states whichwe placed in 2nd and 3rd columns keep them in first column and again apply 0s and 1s aRepeat the process until no new state is left.

    8.6 Cont

    Then draw the state diagram by using the above transition table of DFA.

    8.7 Example:

    Determine a deterministic Finite State Automaton from the given NFA.

  • 8/10/2019 Automata Theory E-content Document

    18/100

    M ({q0 , q1},{a, b}, , q0 ,{q1}) with the state table diagram forgiven below.

    Solution:Let M (Q , , , q , F ) be a determine. Finite state automaton (DFA),whereQ = {[q0 ], [q1 ], [q0 , q1 ], [ ]},q 0 = [q0]and F = {[q1 ], [q0 , q1 ]}Please remember that [ ] denotes a single state. Let us now proceed to determineto be definedfor the DFA.

    8.8 C ont

    It is to be noted that

    Here any subset containingq1 is the final state in DFA. This is shown as below.

  • 8/10/2019 Automata Theory E-content Document

    19/100

    9.1 NFA with -transition

    It is an NFA including transitions on the empty input that is (epsilon).

    9.2 Formal definition:

    M be a NFA with moves is denoted by a, 5 tuple notationhaving M= (Q, , , q0, F)where Q is set of states is finite set of input alphabet q0 is initial state is transition function which maps Q( { } )2Q Basically, it is a NFA with few transitions on the empty input

    9.3 -closure of a state:

    -closure (q0) is pronounced as epsilon closure of q0 is defined as the set of all states p such thatthere is a path from q0 to p with label .

    Consider the above transition diagram of NFA with-moves are-closure(q0) ={ q0, q1, q2}-closure(q1) ={ q1, q2}

    -closure(q2) ={q2}

    9.4 Cont

    We can define separate function 0 , = 0 = { 0 , 1 , 2 } rules for ofrequired of NFA.

    (q, a) = ( ( ,, )) Where , = ( )

    9.5 Construction of NFA without -moves from NFA with -moves:Theorem: Every DFA has as equivalent NFA Proof: A DFA is just a special type of an NFA . In a DFA , the transition functions is definedfrom whereas in case of an NFA it is defined from

    and bea DFA .

  • 8/10/2019 Automata Theory E-content Document

    20/100

    9.6 Cont We construct an equivalent NFA as follows.

    i. eIf andAll other elements of N are as in D.

    If then there is a sequence of states such

    that

    9.7 Cont Then it is clear from the above construction of N that there is a sequence of states

    (in N ) such that and and

    hence

    Similarly we can show the converse.

    Hence ,

    9.8 Cont

    Given any NFA we need to construct as equivalent DFA i.e. the DFA need to simulate the behavior of the NFA. For this, the DFA have to keep track of all the states where the NFA could be in at every step during processing a given input string.There are possible subsets of states for any NFA withn states. Every subset corresponds toone of the possibilities that the equivalent DFA must keep track of. Thus, theequivalent DFA will have states.

    10.1 Cont

    The formal constructions of an equivalent DFA for any NFA is given below. We first consideran NFA without transitions and then we incorporate the affects of transitions later.

    Formal construction of an equivalent DFA for a given NFA without transitions.

    10.2 Cont Given an without - moves, we construct an equivalent DFA

    as follows

  • 8/10/2019 Automata Theory E-content Document

    21/100

    i.e.

    (i.e. every subset ofQ which as an element in F is considered as a

    final state in DFA D )

    10.3 Cont for all andwhere

    That is,

    To show that this construction works we need to show that L(D)=L(N) i.e.

    Or,We will prove the following which is a stranger statement thus required.

    10.4 Proof : We will show by inductions on

    Basis: If =0, thenw =

    So, by definition.Inductions hypothesis : Assume inductively that the statement holds of length lessthan or equal to n.

    Inductive step

    Let , then with

    10.5 Cont Now,

  • 8/10/2019 Automata Theory E-content Document

    22/100

    10.6 Cont

    Now, given any NFA with -transition, we can first construct an equivalent NFA without -transition and then use the above construction process to construct an equivalent DFA , thus, proving the equivalence of NFA s and DFA s.

    10.7 Example:

    Consider the NFA given below.Transition table

    0 1

    { }

    10.8 Cont

    Since there are 3 states in the NFAThere will be states (representing all possible subset of states) in the equivalent DFA . Thetransition table of the DFA constructed by using the subset constructions process is producedhere.

    The start state of the DFA is - closuresThe final states are all those subsets that contains (since in the NFA ).

    11.1 Cont

    Let us compute one entry,

  • 8/10/2019 Automata Theory E-content Document

    23/100

    Similarly, all other transitions can be computed.

    11.2 Cont

    Corresponding transition fig. for the DFA is shown in below:

    0 1

    { }

    11.3 Cont Note that states are not accessible and hence can beremoved. This gives us the following simplified DFA with only 3 states.

    11.4 Cont

    It is interesting to note that we can avoid encountering all those inaccessible or unnecessarstates in the equivalent DFA by performing the following two steps inductively.

    1. If is the start state of the NFA, then make - closure ( ) the start state of theequivalent DFA . This is definitely the only accessible state.

  • 8/10/2019 Automata Theory E-content Document

    24/100

    2. If we have already computed a set of states which are accessible. Then .

    compute because these set of states will also be accessible.

    11.5 Cont

    Following these steps in the above example, we get the transition table given below

    0 1

    11.6 Minimization of FA:

    One important result on finite automata, both theoretically and practically, is that for any regullanguage there is a unique DFA having the smallest number of states that accepts it. Let M = < , , q0 , , F > be a DFA that accepts a language L. Then the following algorithm produces thDFA, denote it by M1, which has the smallest number of states among the DFAs that accept L.

    11.7 Procedure:

    Minimum DFA M1 is constructed from final as follows: Select one state in each set of the partitionfinal as the representative for the set. These

    representatives are states of minimum DFA M1. Let p and q be representatives i.e. states of minimum DFA M1. Let us also denote by pand q the sets of states of the original DFA M represented by p and q, respectively. Let s

    be a state in p and t a state in q. If a transition from s to t on symbol a exists in M, thenthe minimum DFA M1 has a transition from p to q on symbol a.

    11.8 Cont

    The start state of M1 is the representative which contains the start state of M. The accepting states of M1 are representatives that are in A.

    Note that the sets of final are either a subset of A or disjoint from A.Remove from M1 the dead states and the states not reachable from the start state, if there are any.Any transitions to a dead state become undefined. A state is adead state if it is not an acceptingstate and has no out-going transitions except to itself.

    12.1 Example:

    Let us try to minimize the number of states of the following DFA.Initially = { { 1 , 5 } , { 2 , 3 , 4 } }.

  • 8/10/2019 Automata Theory E-content Document

    25/100

  • 8/10/2019 Automata Theory E-content Document

    26/100

    12.5 Equivalence of Two finite state machines:

    Two finite automata over are equivalent if they accept the same set of strings over two finite automata are not equivalent, there is some stringw over satisfying the following :

    One automaton reaches a final state on application of w Whereas the other automaton reaches a non-final state.

    12.6 Cont

    Let there are two Finite Automata M and M' where number of input symbols are the same. Ttest the equivalence of two finite automata over by using comparison method.

    12.7 Comparison Method:

    (i) Make a comparison table withn + 1 columns, wheren is the number of input symbols.(ii) In the first column there will be pair of vertices (q,q') whereq M andq' M'. The first pair of vertices will be the initial states of the two machines M and M'. Second column consisof (qa, qa '). Whereqa is reachable from the initial state of the machine M for the first input, andq' a is reachable from the initial state of the machine M' for the first input. The other n 2 columnsconsist of pair of vertices from M and M' for n 1 inputs, wheren = 2, 3,n 1. We repeat theconstruction by considering the pairs in the second and subsequent columns which are not in thfirst column.

    12.8 Cont

    The row-wise construction is repeated. There are two cases:Case 1: If we reach a pair (q,q') such that q is a final state of M, andq' is a non-final state of M'or vice versa, we terminate the construction and conclude that M and M' are not equivalent.Case 2: The construction is terminated when no new element appears in the second andsubsequent columns which are not in the first column. In this case we conclude that M and M'are equivalent.

    13.1Example:

    Consider the following two DFAs M and M over {c, d} given in figure, find out

    and M are equivalent.

  • 8/10/2019 Automata Theory E-content Document

    27/100

    13.2 Solution:

    The initial states in M and M are q1 and q4 respectively. Hence first element of the first columnin the comparison table must be {q1, q4} since both q1, q4 are c-reachable from the respectiveinitial states.As we do not get a pair (q, q1), where q is a final state and q1is non final state or vice-versa atevery row, therefore M and M are equivalent. Comparison table

    13.3 Finite Automata with output

    Finite automata are primarily used in parsing for recognising languages. Input strings belonginto a given language should turn an automaton to final states and all other input strings shoulturn this automaton to states that are not final.Finite automata that additionally generate output are calledtransducers . In order to define atransducer, an output alphabet and output function should be specified in addition to the fivcomponents outlined earlier.

    13.4 Cont

    The output function can be a function of a state or a function of both state and input symbol. the output function depends on a state and input symbol, then it is called aMealy automaton . Ifthe output function depends only on a state, then it called is aMoore automaton .

    13.5 Moore Machine

    A Moore machine is a six tuplesM= (Q, ,, , , q0), where Q is a finite set of states. is a finite set of input symbols or alphabet.

    is the output alphabet.

    is the transition function( : Q Q) is the output function mapping Q into is the start or initial state.

    http://en.wikipedia.org/wiki/Function_%28mathematics%29http://en.wikipedia.org/wiki/Function_%28mathematics%29
  • 8/10/2019 Automata Theory E-content Document

    28/100

    13.6 Transition table of Moore machine

    A transition table that shows for each state and each i/p letter what state is reached next. An o/table that shows what character from is printed by each state as it is entered.

    13.8 Cont

    The transition table of moore machine as shown in below:

    13.9 Mealy Machine

    A mealy machine is a six-tuple M= (Q, ,, , ,q0), where all the symbols except have thesame meaning as in the Moore machine. is theoutput function mappingQ into.The transition table of mealy machine as shown in below:

    Mealy machine

    14.1 Example:

    Design Mealy machine for the following table and also find the output f or the string abbabaaa.

  • 8/10/2019 Automata Theory E-content Document

    29/100

  • 8/10/2019 Automata Theory E-content Document

    30/100

    14.6 Solution:

    In Moore machine every input symbol (a) we form a pair consisting of the next state and thcorresponding output and reconstruct the table for mealy machine. For example the states q0 andq1 in the next state column should be associated with output 0 and 1.

    The transition table for Mealy machine will be:

    Mealy machine

    14.7 Cont

    14.8 Example:Consider a Mealy machine described by the transition table. Construct a Moore machine whicis equivalent to the Mealy machine.

  • 8/10/2019 Automata Theory E-content Document

    31/100

    15.1 Solution:

    we look into the next state column for any state, say qi and determine the number of differentoutputs associated with qi in that column.We break qi into several different states, the number of such states being equal to the number odifferent outputs associated with qi, for example q2 is associated with two outputs 0 and 1 andstate q3 is associated only one output 1. So we will break state q2 in two parts first one for output

    0 and second one for output 1, but we cannot be break down because q1 have only one output.New Table:

    15.2 Cont

    Note: State q20 means state q2 with output 0 and state q21 means state q2 with output 1. The pair of states and outputs in the next column can be arranged as in table.

    We observe that the initial state q1,is associated with output 1. This means that with inp(null). We get an output 1, if the machine starts at state q1. Thus the Moore machine accepts zero length sequence (null sequence) which is not accepted by the Mealy machine. To overcomthis situation, either we must neglect the response of Moore machine to input , or we mnew starting q0, whose state transition are same as state q1 but output will be zero (0).

  • 8/10/2019 Automata Theory E-content Document

    32/100

  • 8/10/2019 Automata Theory E-content Document

    33/100

  • 8/10/2019 Automata Theory E-content Document

    34/100

    16.2 Formal Definition

    A regular expression R over an alphabet is of one of the following forms:1. 2. a, for some a 3. 4. (R1R2), where R1and R2 are regular expressions5. R1R2, where R1and R2 are regular expressions6. (R1)*, where R1 is a regular expression Note: it is an inductive definition - it is defined based on itself. Note: the + symbol will at times be used for union (0+1)*

    16.3 Language described by REs :

    Each describes a language (or a language is associated with every RE). We will see later thaREs are used to attribute regular languages.

    16.4 Notation : If r is a RE over some alphabet then L(r ) is the language associate withr . We can define thelanguage L(r ) associated with (or described by) a REs as follows.1. is the RE describing the empty language i.e. L( ) = .2. is a RE describing the language { } i.e. L( ) = { } .3. , a is a RE denoting the language {a} i.e . L(a) = {a} .

    16 .5 Cont

    4. If and are REs denoting language L( ) and L( ) respectively, theni) is a regular expression denoting the language L( ) = L( ) + L( )ii) is a regular expression denoting the language L( )= L( ) L( )

    iii) is a regular expression denoting the languageiv) ( ) is a regular expression denoting the language L(( )) = L( )Example : Consider the RE (0*(0+1)). Thus the language denoted by the RE is

    L(0*(0+1)) = L(0*) L(0+1) .......................by 4(ii)= L(0)* L(0) + L(1)= { , 0,00,000,........} {0} {1}= { , 0,00,000,........} {0,1}= {0, 00, 000, 0000,..........,1, 01, 001, 0001,...............}

  • 8/10/2019 Automata Theory E-content Document

    35/100

    16.7 Precedence Rule

    Consider the REab + c. The language described by the RE can be thought ofeither L(a) L(b+c) or L(ab ) L(c)as provided by the rules (of languages described by REs) givenalready. But these two represents two different languages lending to ambiguity. To remove thiambiguity we can either1) Use fully parenthesized expression- (cumbersome) or2) Use a set of precedence rules to evaluate the options of REs in some order. Like other algebrmod in mathematics.

    16.8 Precedence Rule without parenthesesIn absence of parentheses, we have the hierarchy of operations as follows: iteration (closure ostar operator), concatenation and union. For REs, the order of precedence for the operators is afollows:

    i) We perform first iteration, then concatenation and finally union (+) operator. Thishierarchy is similar to that followed for arithmetic expressions (exponentiation,multiplication and addition).

    17.1 Cont

    ii) It is also important to note that concatenation & union (+) operators are associative anunion operation is commutative.Using these precedence rule, we find that the RE ab+c represents the language L(ab ) L(c) i.e.it should be grouped as ((ab )+c).We can, of course change the order of precedence by using parentheses. For example, thlanguage represented by the REa(b+c) is L(a) L(b+c).

    Example: The REab *+b is grouped as ((a(b*))+b) which describes the language L(a)( L(b))* L(b)Example : The RE (ab )*+b represents the language ( L(a) L(b))* L(b).

    17.2 Example :

    It is easy to see that the RE (0+1)*(0+11) represents the language of all strings over {0,1} whicare either ended with 0 or 11.Example : The regular expressionr =(00)*(11)*1 denotes the set of all strings with an even

    number of 0's followed by an odd number of 1's i.e.Note : The notation is used to represent the RErr *. Similarly, represents theRE rr , denotes r , and so on.An arbitrary string over = {0,1} is denoted as (0+1)*.

    Example : Give a REr over {0,1} s.t. L(r )={ has at least one pair of consecutive 1's}

  • 8/10/2019 Automata Theory E-content Document

    36/100

    Solution: Every string in L(r ) must contain 00 somewhere, but what comes before and what goes before is completely arbitrary. Considering these observations we can write the REs a(0+1)*11(0+1)*.Example : Considering the above example it becomes clear that the RE(0+1)*11(0+1)*+(0+1)*00(0+1)* represents the set of string over {0,1} that contains th

    substring 11 or 00.17.3 Identities for Regular Expression

    Two regular expressions P and Q are equivalent if P and Q represent the same set of stringIdentities for regular expression, these are useful for simplifying regular expressions. Here wcan represent as i.e. = .

    17.4 Identity Rules

    17.5 ARDEN S THEOREM

    Let P andQ be two Regular Expression s over. If P does not contain, then for the equationR = Q + RP ----------------(1)

    has a unique (one and only one) solutionR = QP *.

    17.6 Proof:

    Now point out the statements in Arden's Theorem in General form.

    (i) P andQ are two Regular Expressions.(ii) P does not contain symbol.(iii) R = Q + RP has a solution, i.e.R = QP * (iv) This solution is the one and only one solution of the equation.

  • 8/10/2019 Automata Theory E-content Document

    37/100

    17.7 Cont

    If R = QP * is a solution of the equationR = Q + RP then by putting the value ofR in the givenequation we shall get the value

    Q + (QP*) P ( R = Q + RP) Q( + P* P ) ( ( + R * R = R * by I9) QP*

    Hence equation (1) is satisfied whenR = QP * this meansR = QP * is a solution of the equation(1). To prove uniqueness, consider equation (1). Here, replacing R byQ + RP on the R.H.S., weget the equati on.

    17.8 Cont

    From equation (1),

    18.1 Cont

    We now show that any solution of equation (1) is equivalent to QP* suppose R satisfies equation(1) than itsatisfies equation (2). Let w be a string of length I in the set R, than w the set , as P does not contain , RPi+1 has no string oflength less than I + 1 and so w is not in the set RPi+1 this means w belongs to the set

    and hence toQP *.

    18.2 Example:

    Solution:

  • 8/10/2019 Automata Theory E-content Document

    38/100

    18.3 Equivalence (of REs) with FA :A language that is accepted by some FAs are known as Regular language. The two concepts REs and Regular language are essentially same i.e. for every regular language can be develope by a RE, and for every RE there is a Regular Langauge.

    Theorem: A language is regular iff some RE describes it.

    18.4 RE to FA :

    Lemma: If L(r ) is a language described by the REr , then it is regular i.e. there is a FA suchthat L( M ) L(r ).

    18.5 Proof :

    To prove the lemma, we apply structured index on the expressionr . First, we show how toconstruct FA for the basis elements: , and for any . Then we show how to combinethese Finite Automata into Complex Automata that accept the Union, Concatenation, KleeClosure of the languages accepted by the original smaller automata.Use of NFAs is helpful in the case i.e. we construct NFAs for every REs which are represente by transition diagram only.

    18.6 Basis : If R is an elementary regular expression, NFA NR is constructed as follows.

    18.7 Induction:

    If P and Q are regular expressions with corresponding finite automata MP and MQ, then we canconstruct a finite automaton denoting P+Q in the following manner:

  • 8/10/2019 Automata Theory E-content Document

    39/100

    18.8 Cont

    The transitions at the end are needed to maintain a unique accepting state. If P and Q areregular expressions with corresponding finite automata M P and M Q, then we can construct afinite automaton denoting PQ in the following manner:

    19.1 Cont

    Finally, if P is a regular expression with corresponding finite automaton M P , then we canconstruct a finite automaton denoting P * in the following manner:

    Again, the extra transitions are here to maintain a unique accepting state. It is clear that eachfinite automaton described above accepts exactly the set of strings described by thcorresponding regular expression (assuming inductively that the submachines used in thconstruction accept exactly the set of strings described by their corresponding regulaexpressions).19.2Cont

    Since, for each constructor of regular expressions, we have a corresponding constructor of finiautomata, the induction step is proved and our proof is complete.

    We have proved that for every regular expression, there exists an equivalent nondeterministic

    finite automaton with transitions. 19.3 Example: Construct transition graph for regular expression R=(0(0|1)*)+

    Solution: 0.(0|1) *

  • 8/10/2019 Automata Theory E-content Document

    40/100

  • 8/10/2019 Automata Theory E-content Document

    41/100

    19.8 Cont

    20.1 Cont

    Note: Null move () in between q0 and q5 consider as the same state. Therefore q0 = q5.

    20.2 Transition table of NFA

  • 8/10/2019 Automata Theory E-content Document

    42/100

    20.3 Transition table of DFA

    20.4 Final transition Table:

    We can reduce state [q0, q6, qf ] and [q0, q7, qf ] because both are final states, containing final stateqf and both have same transition ( next state) at the input symbol 0 and 1.

    [q0, q6, qf ] [q0, q7, qf ]

    20.5 Final transition Diagram

    20.6 FA to RE:

    Lemma : If a language is regular, then there is a RE to describe it. i.e. if L = L( M ) for someDFA M , then there is a REr such that L = L(r ).

    Proof : We need to construct a REr such that . Since M is a DFA, it hasa finite no of states. Let the set of states of M is Q = {1, 2, 3,..., n} for some integer n. [ Note: ifthe n states of M were denoted by some other symbols, we can always rename those to indicateas 1, 2, 3,..., n ]. The required RE is constructed inductively.

  • 8/10/2019 Automata Theory E-content Document

    43/100

    20.7 Cont

    Notations :

    is a RE denoting the language which is the set of all stringsw such thatw is the label of a

    path from statei to state j in M , and that path has no intermediate state whosenumber is greater thenk . ( i & j (begining and end pts) are not considered to be "intermediate"so i and /or j can be greater thank )

    We now construct inductively, for alli, j Q starting atk = 0 and finally reachingk = n.

    20.8 Con t

    Basis: k = 0, i.e. the paths must not have any intermediate state (since all states arenumbered 1 or above). There are only two possible paths meeting the above condition:

    1. A direct transition from statei to state j.

    o = a if there is a transition from statei to state j on symbol the singlesymbola .

    o = if there are multiple transitions from statei to state j onsymbols .

    o = f if there is no transition at all from statei to state j.21.1 Cont

    2. All paths consisting of only one node i.e. wheni = j. This gives the path of length 0 (i.e.

    the RE denoting the string ) and all self loops. By simply adding to various caseabove we get the corresponding REs i.e.

    o = + a if there is a self loop on symbola in statei . o = + if there are self loops in statei as multiple

    symbols .

    o = if there is no self loop on statei. 21.2 Cont

    Induction: Assume that there exists a path from statei to state j such that there is no intermediate state

    whose number is greater thank . The corresponding Re for the label of the path is .

    21.3 Cont There are only two possible cases:

  • 8/10/2019 Automata Theory E-content Document

    44/100

    1. The path dose not go through the statek at all i.e. number of all the intermediate states areless thank . So, the label of the path from statei to state j is the language described by the

    RE .2. The path goes through the statek at least once. The path may go from i to j andk may

    appear more than once. We can break the into pieces as shown in the figure.

    21.4 Cont

    21.5 Cont

    The first part from the statei to the statek which is the first recurrence. In this path, all

    intermediate states are less thank and it starts at i and ends atk . So the RE denotesthe language of the label of path.

    The last part from the last occurrence of the statek in the path to state j. In this path also,

    no intermediate state is numbered greater thank . Hence the RE denoting thelanguage of the label of the path.

    21.6 Cont

    In the middle, for the first occurrence ofk to the last occurrence ofk , represents a loopwhich may be taken zero times, once or any number of times. And all states between twconsecutivek 's are numbered less thank .

    Hence the label of the path of the part is denoted by the RE .The label of the path fromstate i to state j is the concatenation of these 3 parts which is

  • 8/10/2019 Automata Theory E-content Document

    45/100

    21.7 Cont

    Since either case 1 or case 2 may happen the labels of all paths from statei to j is denoted by thefollowing RE

    .We can construct for alli, j {1,2,...,n} in increasing order ofk starting with the basisk =

    0 uptok = n since depends only on expressions with a small superscript (and hence will beavailable).

    21.8 Cont Assume that state 1 is the start state and are them final states where ji {1, 2, ..., n }, and . According to the convention used, the language of the automata can be denoted by the RE

    Since is the set of all strings that starts at start state 1 and finishes at final state followinthe transition of the FA with any value of the intermediate state (1, 2, ... , n) and hence accepted by the automata.

    22.1 Finding RE using Ardens Theorem (or Algebraic Methodusing Ardens Theorem)

    The following method is an extension of Ardens theorem this is used to find the reguexpression recognized by a transition system.The following rules are used for transition system:

    The transition graph does not have- moves. It has only initial state, say V1. Its vertices are V1 Vk . Vi is the regular expression representing the set of strings accepted by the system even

    though Vi is a final state.

    22. 2 Cont

    ij denotes the regular expression representing the set of labels of edges from Vi to V j,when there is no such edge,ij = . Consequently, we can get the following set ofequations V1 Vn.

  • 8/10/2019 Automata Theory E-content Document

    46/100

    If there is more than one final states then we take union of all final states equations.22.3 Example: Consider the transition system, prove that the strings recognized are

    22.4 Solution:

    The three equations for q1, q2, and q3 can be written as

    Put the value of q3 from equation (3) to equation (2)

    22 .5 Cont

    Put q2 from equation (4) to equation (1)

    22 .6 Cont

    Since q3 is a final state, the set of strings recognised by the graph is given by

    Put the value of q1

  • 8/10/2019 Automata Theory E-content Document

    47/100

    22.7 Equivalence of Two Regular expressions

    Let P and Q are two regular expressions. The regular expressions P and Q are equivalent iff therepresent the same set.

    To prove the equivalence of P and Q, We prove that the sets P and Q are the same but for nonequivalence we find a string in

    one set but not in the other. We use the identities to prove the equivalence of P and Q. We construct the corresponding FA M and M and prove that M and M are equ

    and for nonequivalence we prove that M and M are not equivalent.

    The method to be chosen depends on the problem.

    22.8 Pumping Lemma for Regular expression

    We can prove that a certain language is non regular by using a theorem called PLemma. According to this theorem every regular language must have a special prolanguage does not have this property, than it is guaranteed to be not regular. The idea behind ththeorem is that whenever a FA process a long string (longer than the number of states) andaccepts, there must be at least one state that is repeated, and the copy of the sub string of thinput string between the two occurrences of that repeated state can be repeated any number otimes with the resulting string remaining in the language.

    23.1 Theorem:

    Let L be a regular language. Then the following property holds for L.There exists a number (called, the pumping length), where, if w is any string in L of lengt

    at least k i.e. , thenw may be divided into three sub strings w = xyz, satisfying thefollowing conditions:

    1. i.e.

    2. 3.

    23.2 Proof:

    Since L is regular, there exists a DFA that recognizes it, i.e. L = L( M ) . Letthe number of states in M is n.Say, w = a1a2am, mn (q0, a1a2ai) = qi for i=1, 2, , m

    ; i.e. Q is the sequence of states in the path with path value w = a1a2am.As there are only n distinct states, at least two states in Q must coincide. Among the various paiof repeated states, we take the first pair. Let us take them as q j and qk (q j= qk ). Then j and ksatisfy the condition 0 j

  • 8/10/2019 Automata Theory E-content Document

    48/100

    23 .3 Cont

    The string w can be decomposed into 3 substrings a1a2a j, a j+1ak and ak+1am. Let x, y, zdenote these strings a1a2a j, a j+1ak and ak+1am respectively. As k n, and w=xyz.The path with the path value w in the transition diagram of M as shown in figure.

    The automaton M starts from the initial state q0. On applying the string x, it reaches q j(= qk ). Onapplying the string y, it comes back to q j(= qk ). So after application of yi for each i0, theautomaton is in the same state q j. on applying z, it reaches qm, a final state. Hence xyiz L. asevery state in Q is obtained by applying an input symbol, y .

    23.4 Application of Pumping Lemma

    This theorem can be used to prove that certain sets are not regular. There are three steps needefor proving that a given set is not regular.Step 1: Assume that L is regular. Let n be the number of states in the corresponding finiteautomaton.Step 2: Choose a string w such that . Use pumping lemma to write w = xyz, with

    and > 0 .Step 3: Find a suitable integer i such that xyiz L. This contradicts our assumption. Hence L is

    not regular.The crucial part of the procedure is to find I such that xyiz is not belong to L. In some cases we prove xyiz is not belong to L by consideringxy iz .

    23.5 Example:

    Show that L={aP|P is a prime} is not regular.Solution: Prime numbers are 2, 3, 5, 7, 11, 13, 17,

    L={aa, aaa, aaaaa, aaaaaaa,} Let y=aa ( y )

    x = , z = w= (aa)i w= (aa)i

    When i=1, w = aa which is not in LWhen i=2, w = aaaaa which is not LTherefore L= {aP|P is a prime} is not regular.

  • 8/10/2019 Automata Theory E-content Document

    49/100

    23.6 Closure properties of Regular sets

    The closure properties of regular sets are as follows: Regular sets are closed under union. Regular sets are closed under concatenation. Regular sets are closed under closure (iteration). Regular sets are closed under transpose. Regular sets are closed under intersection. Regular sets are closed under complementation.

    23.7 Theorem:

    Regular languages are closed under union operation and Kleen star operation.Proof: If L 1 and L 2 are regular, then there are regular expressions r 1 and r 2 denoting the languages L 1

    and L 2 , respectively.( r 1+ r 2) and (r 1*) are regular expressions denoting the languages L 1 L 2and L 1*.Therefore, L 1 L 2 and L 1* are regular.

    23.8 Theorem:

    Regular languages are closed under complement operation and intersection operation.Proof:Suppose that L 1 and L 2are regular over an alphabet.There is a DFA M=(Q, , , q 0, F) accepting L 1.

    Design a DFA M = (Q,, , q 0, F), where F = Q- F. Now, we have that L(M) =* - L 1. Hence, the complement of L 1 is regular.Let L 1 = * - L 1 and L 2 = * - L 2.The complement of L 1 L 2 is regular and is equal to L 1 L 2 .Hence L 1 L 2 is regular.The proof of regular languages are closed under intersection operation can be done by construa new DFA to accept the intersection. The construction is as follows.Suppose that L 1 and L 2are regular languages accepted by DFAs M 1=(Q 1, , 1, q 0 1, F 1) andM 2=(Q 2, , 2, q 0 2, F 2) such that L(M 1) = L 1 and L(M 2 )= L 2.Construct a DFA M = (Q, , , q 0, F ), where Q = Q 1 Q 2,q 0 = (q 0 1, q 0 2), F = F 1 F 2, and((p i, q s), a) = ( 1(p i, a), 2(q s, a)).

    It is not difficult to show that L(M) = L 1 L 2.

  • 8/10/2019 Automata Theory E-content Document

    50/100

    MODULE 2Chapter 4

    24.1 GRAMMAR

    IntroductionA grammar is mechanism used for describing languages. This is one of the most simple but y powerful mechanism. There are four important components in a grammatical description of language.A grammarG is defined as a quadruple.

    24.2 Cont

    Where, N is a non-empty finite set of non-terminals or variables,

    is a non-empty finite set of terminal symbols such that, is a special non-terminal (or variable) called the start symbol

    is a finite set of production rules.

    24.3Context free Grammar (CFG)A grammar is a Context free Grammar if the production of the form, onenon-terminal finite string of terminals and non-terminals.

    24.4Example:

    is a grammarWhere,

    24.5Notations used in CFG If A is any set, then A* denotes the set of all strings over A, A+ denotes A*- { }, where

    is the empty string. A, B, C, A1, A2, denote the variables. a, b, c denote the terminals. x, y, z, w, denote the strings of terminals. , , , denote the elements of (V )*.

  • 8/10/2019 Automata Theory E-content Document

    51/100

    x0 = for any symbol x in V .

    24.6Production rules and derivation languages

    The binary relation defined by the set of production rules is denoted by ,

    i.e. iff . Here contains at least one symbol from V. In other words,P is a finite set of production rules of the form ,

    where and

    24.7 Cont

    The production rules specify how the grammar transforms one string to another. In grammar no reverse substitution and no inverse operation is permitted.

    24.8 Cont

    A string of terminals and variables is called as a sentential form if . If the final string does not contain any variable, it is asentence in the language. If the final string contains a variable, it is asentential form . If A is a production where AV, then it is called as an A production. If A 1, A 2, , A m are A- productions, these productions are written as A

    1| 2|| m.

    25.1 Example:

  • 8/10/2019 Automata Theory E-content Document

    52/100

    25.2 Example:

    25.3 REGULAR GRAMMARS

    A grammar is right-linear if each production has one of the followingthree forms:

    A cB , A c, A

    Where A, B (with A = B allowed) and .

    25.4 Cont

    A grammar G is left-linear if each production has one of the following three forms.

    A Bc, A c, A A right or left-linear grammar is called aregular grammar .

    25.5 Derivation Trees

    The derivations in a CFG can be represented using trees. Such trees representing are callederivation trees . The derivation tree is also called asparse tree .

    25.6 Conditions of Derivation Trees The conditions satisfying for derivation tree of a CFG are as follows:

    Every vertex has a label which is a variable or terminal or . The root has label S.

  • 8/10/2019 Automata Theory E-content Document

    53/100

    25.7 Cont

    The label of an internal vertex is a variable. If the vertices n1, n2, , nk written with labels X1, X2, , Xk are the sons of vertex n

    with label A, then A X1, X2, , Xk is a production in P. A vertex n is a leaf if its label is a or ; n is the only son of its father if its label is.

    25.8 Left and Right Derivation Tree

    The yields of derivation tree are the concatenation of the labels of the leaves without repetition the left-to-right ordering.Left most derivationIf at each step in a derivation a production is applied to the left most variable, then the derivatiois called left most derivation.Right most derivation

    A derivation in which the right most variable is replaced at each step is said to be right moderivation.

    26.1 Example:

    Let G be a grammar . For the string00110101, find a) the left most derivation, b) the right most derivation and c) the derivation treeSolution:

    26.2 Cont

    (c) The derivation tree is shown in below which yields 00110101:

  • 8/10/2019 Automata Theory E-content Document

    54/100

    26.3 Ambiguity in CFG

    A CFG, G such that some string has two parse trees is said to be ambiguous. If there exist two omore left most derivation or right most derivation trees to derive a string from a grammar is aambiguous.

    26.4 Example:

    If G is the grammar S SbS|a, show that G is ambiguous.

    Solution: Let us consider w=abababa. Then we get two derivation trees for w as shown in below:

    26.5 Cont

    Figure: Two derivation trees of abababa

    26.6 Simplification of Context Free Grammars

    The CFG can be simplified by eliminating some symbols and productions in G which are nouseful for the derivation of sentences.

    26.7 Cont

    Here we give the construction to eliminate:1. Variables not deriving terminal strings.

    2. Symbols not appearing in any sentential form3. Null productions4. Productions of the form AB

    26.8 Variables not deriving terminal strings:

    A variable in a grammar is eliminated if there is no way of getting a terminal string from it.

  • 8/10/2019 Automata Theory E-content Document

    55/100

  • 8/10/2019 Automata Theory E-content Document

    56/100

  • 8/10/2019 Automata Theory E-content Document

    57/100

    27.8 Elimination of NULL productions:

    A context free grammar may have productions of the form A. the production A is justused to eliminate A by using production A, where A is a variable called as- production.

    28.1 Example:

    Reduce the grammar such that there are no- production, whose productions are SaS|AB,A , B , D b.

    28.2 Solution:

    Step 1: Construction of the set W of all nullable variables:

    Thus, W = W2 = {S, A, B}

    28.3 Cont

    Step 2: Construction of P:

    Here we can not erase both the nullable variables A and B in SAB as we will get S in thatcase.Hence the required grammar without null productions is G1 = ({S, A, B, D}, {a, b}, P, S}Where Pconsists of D b, S aS, S AB, S a, S A, S B.

    28.4 Elimination of Unit productions:

    A production of the form AB, A, B V N in CFG is called as unit production. The unit

    productions are eliminated from the grammar inorder to get the reduced CFG. To remove thunit productions from the CFG, the substitution method is considered. Assume that there are n- productions.

  • 8/10/2019 Automata Theory E-content Document

    58/100

    28.5 Example:

    28.6 Cont

    28.7 Normal forms for CFGs

    In a CFG, the R.H.S of a production can be any string of variables and terminals, when th productions in G satisfy certain restrictions, then G is said to be in anormal form. Here we willdiscuss two normal forms such asChomsky normal form (CNF) and Greibach normal form(GNF) .

    28.8 Chomsky normal form (CNF)

    A CFG G is in CNF if every production is of the form Aa, or A BC, and S is in G if L(G), when is in L(G), we assume that S does not appear on the R.H.S of any production.For example, consider G whose productions are SAB| , A a, and B b. Then G is in CNF.

    29.1 Reduction to CNF

    Theorem: For every CFG, there is an equivalent grammar G2 in CNF.Proof: construction of a grammar in CNFStep 1: Eliminate useless symbols, null productions and unit production.Step 2: Eliminate terminals on right hand side of productions as follows:

  • 8/10/2019 Automata Theory E-content Document

    59/100

  • 8/10/2019 Automata Theory E-content Document

    60/100

    29.7 Cont

    29.8 Cont

    30.1 Greibach Normal form (GNF)

    In GNF we put restrictions not on the length of the right sides of productions, but on the positioin which terminals and variables can appear.A CFG is said to be GNF if all the productions have the form Aa and A a, where a is aterminal and may be any number of non terminals.To convert given grammar into GNF the following two lemmas are considered.

    30.2 Lemma 1:

    Let be a CFG. Let A B be an A-production in P and B-production beB 1| 2|| i.Let G1 = (V N , , P1, S) be obtained from G by deleting the production AB from P andadding the production, A 1 | 2 || i .Then L(G) =L(G1)

    30.3 Lemma 2:

    Let be a CFG. Let the set of A-productions be AA 1|A 2||A r | 1| 2|| i. Note that Is do not start with A.

  • 8/10/2019 Automata Theory E-content Document

    61/100

  • 8/10/2019 Automata Theory E-content Document

    62/100

    31.1 Cont

    31.2 Cont

    31.3 Cont

    31.4 Cont Hence the equivalent grammar is

    Where P 1 consists of

    31.5 Closure Property of CFLs

    The closure properties of CFLs are as follows: CFLs are closed under union. CFLs are closed under concatenation. CFLs are closed under kleen closure. CFLs are not closed under intersection CFLs are not closed under complementation. CFLs are closed under substitution. CFLs are closed under homomorphism.

  • 8/10/2019 Automata Theory E-content Document

    63/100

  • 8/10/2019 Automata Theory E-content Document

    64/100

    V = V1 { S }, where S V1 P = P1 { S SS1 | }

    32.3 Example:

    L1 = {an bn | n 0} (L1)*= { a{n1} b{n1}... a{nk} b{nk} | k 0 and ni 0 for alli } L2 = { a{n2} | n 1 }, (L2)*= a*

    32.4 Theorem:

    The CFLs are closed under homomorphism. Closure under homomorphism of CFL L for every a . Suppose L is a CFL over alphabet and h is a homomorphism on.Let s be a substitution that replaces every a , by h(a). ie s(a) = {h(a)}.Then h(L) = s(L).

    h(L) ={h(a1)h(ak ) | k 0} where h(ak ) is a homomorphism for every ak .32.5 Theorem:

    The CFLs are closed under substitution. If a substitution s assigns a CFL to every symbol in the alphabet of a CFL L, then s(L) is a CFLProof:Let G = (V, , P, S) be grammar for LLet Ga= (Va, Ta, Pa, Sa) be the grammar for each a with V Va = And G= (V, T , P , S) for s(L)

    32.6 Cont

    Where,V = V VaT = union of Ta for all a P consists of

    All productions in any Pa for a In productions of P, each terminal a is replaced by Sa

    A detailed proof that this construction works is in the reader.Intuition: this replacement allows any string in La to take the place of any occurrence of a in anstring of L.

    32.7 Example:

    L = {0n1n| n 1}, generated by the grammar S0S1|01,s(0) = {an bm|m n}, generated by the grammar SaSb|A; A aA| ab,s(1)={ab, abc}, generated by the grammar S abA, A c |

  • 8/10/2019 Automata Theory E-content Document

    65/100

  • 8/10/2019 Automata Theory E-content Document

    66/100

  • 8/10/2019 Automata Theory E-content Document

    67/100

    for j : = 2 to n do /* Determine for all i */for i := 1 to n- j+1 do /* No sense in consideringi, j with for all i */

    for k := 1 to j-1 do /* try substrings of of length k */

    33.7 Cont

    The correctness of the algorithm can be proved by applying induction on j that wheneve

    the outer loop finishes for particular j, the set contains all nonterminals A that can

    derive ( for all i).

    It is easy to conclude that the time complexity of this algorithm is whereand grammar G is "fixed" in the sense that the size of the grammar is not considered ainput in measuring complexity.

    33.8 Example :

    Consider the CFG:S AB | AC

    A BC | a B CB | bC AA | b

    Let us decide the membership for the string x = baaaab using the CYK algorithm.The table for 's is shown below.

    34.1 Cont

    Word: b a a a a b

    cell i, j will contain N ij

  • 8/10/2019 Automata Theory E-content Document

    68/100

    34.2 Cont The top row is filled in by the first step of the algorithm e.g. , because is a production. We can compute the contents of the second row by using the contents of the first ro(already done) and inspecting the grammar.

    34.3 Cont For example, to compute (i.e. the set of nonterminals that derive ) we notice tha

    if or if or is a production since no such production exists,we have .

    34.4 Cont Similarly since is a production and , we put .

    Now, consider the first element of the third row, (corresponding to the string ).There are two ways to break up , and

    34.5 Cont ConsiderSince , and is a production, we put .( If we consider, the other way i.e. we find that and hence no more symbolscan be added to )

    Continuing this way we fill up thewhole table as given below

    34.6 Cont

    Figure

  • 8/10/2019 Automata Theory E-content Document

    69/100

  • 8/10/2019 Automata Theory E-content Document

    70/100

    Chapter 5

    34.8 PUSHDOWN AUTOMATA (PDA)

    Regular language can be characterized as the language accepted by finite automata. Similarlwe can characterize the context-free language as the language accepted by a class of machincalled "Pushdown Automata" (PDA). Pushdown automation is an extension of the NFA.

    35.1 FA Vs. PDA

    It is observed that FA has limited capability. (in the sense that the class of languages accepted ocharacterized by them is small). This is due to the "finite memory" (number of states) and "nexternal memory" involved with them. A PDA is simply an NFA augmented with an "externastack memory". The addition of a stack provides the PDA with a last-in, first-out memormanagement capability.

    35.2 Cont

    This "Stack" or "pushdown store" can be used to record potentially unbounded information. It due to this memory management capability with the help of the stack that a PDA can overcomthe memory limitations that prevents a FA to accept many interesting languages like

    .

    35.3 Function of PDA

    A PDA can store an unbounded amount of information on the stack, its access to the informatioon the stack is limited. It can push an element onto the top of the stack and pop off an elemefrom the top of the stack. To read down into the stack the top elements must be popped off anare lost. Due to this limited access to the information on the stack, a PDA still has somelimitations and cannot accept some other interesting languages.

    35.4 PDA Model

    (PDA model)

  • 8/10/2019 Automata Theory E-content Document

    71/100

    35.5 Components of PDA

    From the figure it has shown that, a PDA has three components: an input tape with read only head, a finite control and A pushdown store.

    35.6 Functions of Each Component

    The input head is read-only and may only move from left to right, one symbol (or cell) at a timIn each step, the PDA pops the top symbol off the stack; based on this symbol, the input symbit is currently reading, and its present state, it can push a sequence of symbols onto the stackmove its read-only head one cell (or symbol) to the right, and enter a new state, as defined by thtransition rules of the PDA.

    35.7 Cont PDA are nondeterministic, by default. That is, - transitions are also allowed in which the PDcan pop and push, and change state without reading the next input symbol or moving its readonly head. Besides this, there may be multiple options for possible next moves.

    35.8 Formal Definitions: Formally, a PDA M is a 7-tuple M =where,

    is a finite set of states, is a finite set of input symbols (input alphabets), is a finite set of stack symbols (stack alphabets),

    is a transition function from to subset of is the start state , is the initial stack symbol, and

    , is the final or accept states.

    36.1 Explanation of the transition function, :

    Transition function can be explained depending on the input a i.e. Transition function for if Transition function for if a = .

  • 8/10/2019 Automata Theory E-content Document

    72/100

    36.2 Transition function ifIf, for any , . This means intitutively thatwhenever the PDA is in state q reading input symbol a and z on top of the stack, it cannondeterministically for any i,

    go to state pop z off the stack

    36.3 Cont Push onto the stack (where ) (The usual convention is that if ,

    then will be at the top and at the bottom.) Move read head right one cell past the current symbol a.

    36.4 Transition function if a = If a = , then means intitutively that whenever thePDA is in state q with z on the top of the stack regardless of the current input symbol, it canondeterministically for any i, ,

    go to state pop z off the stack push onto the stack, and Leave its read-only head where it is.

    36.5 State transition diagram :

    A PDA can also be depicted by a state transition diagram. The labels on the arcs indicate bot

    the input and the stack operation. The transition

    for and is depicted by

    Final states are indicated by double circles and the start state is indicated by an arrow to it fromnowhere.

    36.6 Configuration or Instantaneous Description (ID):

    A configuration or an instantaneous description (ID) of PDA at any moment during itcomputation is an element of describing the current state, the portion of the inpu

  • 8/10/2019 Automata Theory E-content Document

    73/100

    remaining to be read (i.e. under and to the right of the read head), and the current stack contentOnly these three elements can affect the computation from that point on and, hence, are parts othe ID.

    36.7 Cont The start or initial configuration (or ID) on input is . That is, the PDA always startsin its start state, with its read head pointing to the leftmost input symbol and the stackcontaining only the start/initial stack symbol, .

    36.8 Cont Let A be a PDA. A move relation, denoted by , between IDs is defined as

    37.1 Language accepted by a PDA M

    There are two alternative definition of acceptance as given below. Acceptance by final state Acceptance by empty stack (or Null stack)

    37.2 Acceptance by final state: Consider the PDA . Informally, the PDA M is said to accept its input

    by final state if it enters any final state in zero or more moves after reading its entire input,

    starting in the start configuration on input .Formally, we define L(M), the language accepted by final state to be

    { | for some and }

    37.3 Acceptance by empty stack (or Null stack):

    The PDA M accepts its input by empty stack if starting in the start configuration on input ;Formally, we define N (M), the language accepted by empty stack, to be

    { | for some } Note that the set of final states, F is irrelevant in this case and we usually let the F to be theempty set i.e. F = Q.

    37.4 Example:

    Here is a PDA that accepts the language .

  • 8/10/2019 Automata Theory E-content Document

    74/100

    ,

    37.5 Cont and consists of the following transitions

    37.6 Cont

    The PDA can also be described by the adjacent transition diagram.

    Informally, whenever the PDA M sees an input a in the start state with the start symbol z othe top of the stack it pushes a onto the stack and changes state to . (to remember that it haseen the first 'a'). On state if it sees anymore a, it simply pushes it onto the stack. Note thawhen M is on state , the symbol on the top of the stack can only be a. On state if it sees thfirst b with a on the top of the stack, then it needs to start comparison of numbers of a's and b'since all the a's at the beginning of the input have already been pushed onto the stack. It start th

    process by popping off the a from the top of the stack and enters in state q3 (to remember that tcomparison process has begun). On state , it expects only b's in the input (if it sees any morein the input thus the input will not be in the proper form of anbn). Hence there is no more oinput a when it is in state . On state it pops off an a from the top of the stack for every b ithe input. When it sees the last b on state q3, then the last a from the stack will be popped off anthe start symbol z is exposed. This is the only possible case when the input (i.e. on -input) thPDA M will move to state which is an accept state.

  • 8/10/2019 Automata Theory E-content Document

    75/100

    We can show the computation of the PDA on a given input using the IDs and next moverelations. For example, following are the computation on two input strings.

    37.7 Acceptance of string

    Let the input be aabb. We start with the start configuration and proceed to the subsequent IDusing the transition function defined

    is final state. Hence, accept. So the string aabb is rightly accepted by M.We can show the computation of the PDA on a given input using the IDs and next moverelations. For example, following are the computation on two input strings.

    37.8 Cont

    i) Let the input be aabab.

    No further move is defined at this point.Hence the PDA gets stuck and the string aabab is not accepted.

    Deterministic and non-deterministic PDALike FA the PDA also may be deterministic or nondeterministic. We will discuss this one by onhere.

    38.1 Deterministic PDA (DPDA)

    A PDA is said to be deterministic if all derivations (ID) in the design has to give only singlemove.Example: To design a DPDA to accept the following language, L = {wwR | w (a, b)*}Solution:w (a, b)*

    (Using transition 1)

    (Using transition 2)

    (Using transition 3)

    (Using transition 4)

  • 8/10/2019 Automata Theory E-content Document

    76/100

    Then w = , a, b, aa, bb, ab, ba, aab, language, L = , aa, bb, abba, baab, aabbaa,

    As we know that PDA, M= (Q,, , , q0, z0, F)

    38.2 Cont can be defines as:

    1. ( q0, a, z0) = (q0, az0)2. ( q0, b, z0) = (q0, bz0)3. ( q0, a, b) = (q0, ab)4. ( q0, b, a) = (q0, ba)5. ( q0, a, a) = (q1, ) 6. ( q0, b, b) = (q1, ) 7. ( q1, a, a) = (q1, ) 8. ( q1, b, b) = (q1, ) 9. ( q0, , z0) = (q2, z0)

    10. ( q1, , z0) = (q2, z0)38.3 Cont

    PDA reaches the centre only when the input symbol and the top most symbol of push down stacare same.Let L=abba( q0, abba, z0) (q0, bba, az0) (By rule 1)

    (q0, ba, baz0) (By rule 4)(q0, a, az0) (By rule 6)(q1, , z0) (By rule 5)(q2, z0) (By rule 10)

    Hence the string is accepted by final state in DPDA.

    38.4 Non-Deterministic PDA (NPDA)

    A PDA is called as non-deterministic, if derivation generates move than one move in thedesigning of particular task.Example: To design a DPDA to accept the following language, L = {wwR | w (a, b)*}Solution: NPDA, M= (Q, , , , q0, z0, F)

    38.5 Cont can be defines as:1. ( q0, a, z0) = (q0, az0)2. ( q0, b, z0) = (q0, bz0)3. ( q0, a, b) = (q0, ab)4. ( q0, b, a) = (q0, ba)5. ( q0, a, a) = {( q0, aa), (q1, )} 6. ( q0, b, b) = {(q0, bb), (q1, )}

  • 8/10/2019 Automata Theory E-content Document

    77/100

    7. ( q1, a, a) = (q1, ) 8. ( q1, b, b) = (q1, ) 9. ( q1, , z0) = (q2, z0)

    38.6 Cont

    Let L=abba(q0, abba, z0) (q0, bba, az0) (By rule 1)

    (q0, ba, baz0) (By rule 4)(q1, a, az0) (By rule 6)(q1, , z0) (By rule 7)(q2, z0) (By rule 9)

    Hence the string is accepted by final state in NPDA.

    38.7 Pushdown Automata and CFLs

    In this section we prove that the sets accepted by PDA either by null store or final states are precisely the CFLs.

    Converting from CFL to PDA

    Theorem: if L is a language, then we can construct a PDA A accepting L by empty store i.e. L= PDA (A).Let L =L(G), where is a CFG. W constructs a PDA A as

    Where is defined by the following rules:

    38.8 Cont

    The above rules can be explained as follows:The pushdown symbols in A are variables and terminals. If the PDA reads a variable A on thetop of PDS (pushdown store or stack), it makes a-move by placing the R. H. S of any A- production (after erasing A). If the PDA reads a terminal a on PDS and if it matches with thecurrent input symbol, then the PDA erases a. In other cases the PDA halts.

    39.1 Example:

    Construct a PDA A equivalent to the following CFG: S 0BB, B 0S|1S|0. Test whether 0104 is in PDA (A).Solution: Define PDA A as follows:

  • 8/10/2019 Automata Theory E-content Document

    78/100

    39.2 Cont

    is defined by the following rules:

    39.3 Cont

    Thus 0104 is in PDA (A).

  • 8/10/2019 Automata Theory E-content Document

    79/100

    MODULE 3Chapter 6

    39.4 Turing machine

    The Turing machine (TM) is a simple mathematical model of a general purpose computer. Iother words, TM models the computing power of a computer. i.e. the TM is capable o performing any calculation, which can be performed by any computing machine.

    39.5 Cont

    Machine may take its own o/ p as i/p for further operation, hence no distinction between i/p ando/p set. The machine can choose the current location and also decide whether to move Left oRight in the memory. The o/p of the machine may also be stored in the memory and cansometimes be used as the i/p.

    39.6 Model of TM

    The model of Turing machine as shown in below:

    39.7 Function of R/w Head

    The TM can be thought of as a finite state automaton connected to a R/W (Read/Write) Head. has one tape which is divided into a number of cells. Each cell can store only one symbol. Thi/p and o/p from the finite state automaton are affected by a R/W head, Which can examine oncell at a time.

    39.8 Cont

    In one move, the machine examines the present symbol under the R/w head o the tape and th present state of an automaton to determine. A new symbol to be written on the tape in the cell under the R/W head. A motion of the R/W head along the tape, either the head moves one cell left (L) or on

    cell Right (R). The next state of the automaton. Whether to halt or not.

  • 8/10/2019 Automata Theory E-content Document

    80/100

    40.1 Formal Definition of TMThe formal definition of aTM M is a 7 tuples , where

    Q is a finite nonempty set of states. is a finite non-empty set of tape symbols, called the tape alphabet of M.

    is a finite non-empty set of input symbols, called the input alphabet of M.

    40.2 Cont is the transition function of M, is the initial or start state. is the blank symbol is the set of final state.

    40.3 Description

    So, given the current state and tape symbol being read, the transition function describes the nestate, symbol to be written on the tape, and the direction in which to move the tape head ( L anR denote left and right, respectively ).Notes:

    Herethe symbols and are same.And the blank symbol B can also denote as b. The acceptability of a string is decided by the reachability from the initial state to some

    final state. So the final states are also called the accepting states. may not be defined for some elements of Q.

    40.4 Representation of Turing machinesThe TM can be represented by using

    Instantaneous description using move relations. Transition table. Transition diagram or transition graph.

    40.5 Representation by instantaneous descriptions

    Turing machine is defined in terms of the entire input string and the current state.Definition: An ID of a TM M is a string , where is the present state of M. The entire stringis split as , the first symbol of is the current symbol a under the R/W head and has all thesubsequent symbols of the input string, and the string is the substring of the input stringformed by all the symbols to the left of a.

    40.6 ID of TM

    The instantaneous description of TM is shown in below. Let us consider the given below TM.

  • 8/10/2019 Automata Theory E-content Document

    81/100

  • 8/10/2019 Automata Theory E-content Document

    82/100

    41.3 Representation by Transition Table

    The transition function can be defined in the form of a table called as a transition table. If(q, a)= (p, y, D), we write (p, y, D) under the a-column and in the q-row. So if we get (p, y, D) in thtable, it means that y is written in the current cell, D gives the movement of the head either L oR and p denotes the new state into which the TM enters.

    41.4 Transition Table of TM

    The transition table of TM M is shown in below:

    Note: Here # denote as blank symbol.

    41.5 Representation by Transition Diagram

    A transition system is a directed labeled graph in which each vertex or node represents a statand the directed edges indicates the transition of a state and the edges are labeled with triples othe form (x, y, D), where x and y are tape symbols and D is a direction i.e. either L or R. In othwords, whenever(q, x) = (p, y, D), we find the label (x, y, D) on the arc from q to p. the initialstate is indicated by and the final state is indicated by double circle.

    41.6 Example of Transition Diagram

    The example of transition diagram of TM for the above transition table is shown in below:

  • 8/10/2019 Automata Theory E-content Document

    83/100

    41.7 The language of a Turing machine

    For the acceptability of a language in TM, at first the input string is placed on the tape and thtape head begins at the left most input symbol. If the TM enters an accepting state, then the inpis accepted, otherwise not. The set of languages we can accept using a TM is called threcursively enumerable languages or RE languages .

    41.8 Example:

    Show the IDs of the TM is shown in table if the input tape contains: a)01 and b) 1011010.

    42.1 Solution:

    a) Processing of the string 01# is as follows: q001# 0q01# 01q1# 011p

    b) Processing of the string 1011010# is as follows: q01011010# 1q1011010# 10q111010# 101q01010# 1011q1010# 10110q110# 101101q00# 1011010q0# 10110100p

    42.2 Design of Turing machines

    The objectives of designing of TM are as follows: Scan the symbol by the R/W head to know about the future. The machine remembers th

    past symbol while going to the next state. To minimize the number of state by changing the states only either when there is a

    change in the movement of the R/W head or when there is a change in the writtensymbol.

  • 8/10/2019 Automata Theory E-content Document

    84/100

  • 8/10/2019 Automata Theory E-content Document

    85/100

    42.8 TM Languages: (Recursive and Recursive Enumerablelanguage)

    The languages of Turing machines are: Recursive language Recursive enumerable language

    43.1 Recursive Language

    A language is said to be recursive if there exists a TM which will halt and accept when presentewith any input string w * only if the string is in the language otherwise it will halt and rejectthe string. It is also called asturing decidable language .A TM that always halts is called as adecider or total TM . The recursive language is also calledas recursive set or decidable .

    43.2 Recursive Enumerable language

    A language is said to be recursive enumerable if there exists a TM which will halt and accepwhen presented with any input string w* it may halt and reject or loop forever, when a stringis not in the language. It is also called asturing acceptable language .For recursive enumerable a decision problem is called partially semi-decidable, if there is recursively enumerable set. It is also called asrecursive enumerable set or semi-decidable .

    43.3 Turing Computability

    A function f with domain D is said to be turing computableif there exists some turingmachine,

    such thatFor all w D

    1. Each elementary function is computable either because it is simple or by definition.2. If a function f is computable and if another function g can be obtained by applying an

    elementary operation to f , then g is also computable.3. A function is computable if and only if it can be obtained using rule 1 and 2.

    43.4 Variants of Turing machine

    The variants of TMs are as follows: Multi-tape TM Multi head TM Multi dimensional TM Non-deterministic TM

  • 8/10/2019 Automata Theory E-content Document

    86/100

    43.5 Multi-tape Turing Machines

    A multi-tape TM is a TM with more than one tape and each with its own independentlycontrolled R/W head. Each tape is divided into cells and each cell can holding symbol of inpuThe input appears on the first tape and all other tapes hold the blank symbol. Initially the head the first tape is at the left end of the input and all other heads can be placed at any cell.

    43.6 Cont

    The advantage of multi-tape TM is that the design of some functions like copying, reversingverifying whether a string is