theory of finite automata

Upload: imran-ul-ashraf

Post on 05-Apr-2018

240 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Theory of Finite Automata

    1/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    1

    The Theory of Finite Automata

    Definition of An automaton:

    An automaton is defined as a system where energy, materials and information are

    transformed, transmitted and used for performing some functions without direct

    participation of man. Examples are automatic machine tools, automatic packing

    machines and automatic photo printing machines.

    In computer science the term automaton means discrete automaton and is

    defined in a more abstract way as shown in figure below.

    nqqq

    Automaton

    ,,, 21

    pI

    1I

    2I

    1O

    2O

    qO

    Its characteristics are now described as follows:

    (i) Input: At each of the discrete instants of times , , , input values, , , each of which can take a finite number of a fixed values fromthe input alphabet, where are applied to the input side of model shownin the above figure.

    (ii) Output: , , , are the outputs of the model, each of which can takefinite numbers of fixed values from an output.

    (iii) States: At any instant of time the automation can be in one of the states, , , .(iv) State relation: The next state of an automaton at any instant of time is

    determined by the present state and the present input.

    (v) Output relation: Output is related to either state only or to both the inputand the state. It should be noted that at any instant of time the automaton

  • 7/31/2019 Theory of Finite Automata

    2/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    2

    is in some state. On reading an input symbol, the automaton moves to a

    next state which is given by the state relation.

    Note: An automaton in which the output depends only on the input is called an

    automaton without a memory. An automaton in which the output depends on

    the states also is called automaton with a finite memory. An automaton in

    which the output depends only on the states of the machines is called a Moore

    machine. An automaton in which the output depends on the state and the input

    at any instant of time is called aMealy machine.

    Example: Representthe simple shift register shown below as a finite state

    machine.

    inputSerial outputSerial

    The shift register shown in figure can have 2 16 states (0000, 0001, ,1111), and one serial input and one serial output. The input alphabet is 0, 1, and the output alphabet is 0,1 . The above 4-bitserial shift registercan be represented as shown in figure below.

    1621 , ... , q, qq1

    I1

    O

    It is clear that the output will depend upon both the input and the state and so it

    is aMealy machine.

  • 7/31/2019 Theory of Finite Automata

    3/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    3

    In general, any sequential machine behavior can be represented by an

    automaton.

    Description of A finite Automaton:

    Analytically, a finite automaton can be represented by a 5-tuple ,,,, ,where,

    (i) is a finite nonempty set of states;(ii) is a finite nonempty set of inputs called input alphabet;(iii) is a function which maps into and is usually called direct

    transition function. This is the function which describes the change of

    states during the transition. This mapping is usually represented by a

    transition table or a transition diagram.

    (iv) is the initial state; and(v) is the set of final states. It is assumed here that there may be more

    than one final state.

    Note: The transition function which maps into (i.e. maps a state and astring of input symbols including the empty string into a state) is called indirect

    transition function. We shall use the same symbol to represent both types oftransition functions and the difference can be easily identified by nature ofmapping (symbol or a string), i.e. by the argument. is also called the next statefunction.

    Transition Systems:

    A transition graph or a transition system is a finite directed labeled graph in

    which each vertex (or node) represents a state and the directed edges indicate

    the transition of a state and the edges are labeled with input/output.

    A typical transition system is shown in figure below. In the figure, the initial

    state is represented by a circle with an arrow pointing towards it, the final state

    by two concentric circles, and the other states are represented by just a circle.

    The edges are labeled by input/output (e.g. by 1/0or 1/1). For example, if thesystem is in state and the input 1 is applied, the system moves to state asthere is a directed edge from to with label 1/0. It outputs 0.

  • 7/31/2019 Theory of Finite Automata

    4/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    4

    0q 1q

    0/00/1

    0/0

    1/1

    Definition: A transition system is 5-tuple

    ,,,

    , , where

    (a), and are the finite nonempty set of sets, the input alphabet, and the setof final states, respectively, as in the case of finite automata;

    (b) , and is nonempty; and(c)is a finite subset of . In other words, if , , is in , it

    means the following: The graph starts at the vertex , goes along a set ofedges, and reaches the vertex . The concatenation of the label of all theedges thus encountered is .

    Definition: A transition system accepts a string in if(a) there exists a path which originates from some initial state, goes along thearrows, and terminates at some final state, and

    (b)the path value obtained by concatenation of all edge-labels of the path isequal to .

    Example: Consider the transition system shown below. Determine the initial

    states, final states, and the acceptability of 101011, 111010 .The initial states are and . There is only one final state . The path-valueof, , , is 101011. As is the final state, 101011 is accepted by thetransition system. But, 111010 is not accepted by the transition system as thereis no path with path value 111010 .

  • 7/31/2019 Theory of Finite Automata

    5/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    5

    0q 1q

    2q

    3q

    0/1

    1/0

    0/0 0/

    0/1

    0/

    0/1011

    Acceptability of A string by A finite Automaton:

    Definition: A string is accepted by a finite automaton ,,,, if, for some . This is basically the acceptability of a string by thefinal state.

    Note: A final state is also called an accepting state.

    Example: Consider the finite state machine whose transition function is given intable below (in the form of a transition table). Here, , , , , 0,1, . Give the entire sequence of states for the input string 110101 .

    Transition function table.

    States Inputs0 1

  • 7/31/2019 Theory of Finite Automata

    6/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    6

    0

    1

    1

    0

    3

    1

    2

    0

    0

    1

    1

    1

    0

    00

    1

    3

    2

    0

    10

    ,

    ,

    1,

    10,

    011,

    1010,

    01011,101011,

    qqqqqqq

    Hence

    qq

    q

    q

    q

    q

    qq

    The symbol

    indicates the current input symbol being processed by the machine

    and is the empty string.Nondeterministic Finite State Machines:

    We explain the concept of nondeterministic finite automaton using a transition

    diagram shown below.

    If the automaton is in a state and the input symbol is 0, what will be the nextstate? From the figure it is clear that the next state will be either or . Thussome moves of the machine cannot be determined uniquely by the input symbol

    and the present state. Such machines are called nondeterministic automata.

  • 7/31/2019 Theory of Finite Automata

    7/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    7

    0q 1q

    2q

    0

    0

    1

    1 1

    Definition: A nondeterministic finite automaton (NDFA) is a 5-tuple,,,, , where(i) is a finite nonempty set of states;(ii)

    is a finite nonempty set of inputs;

    (iii) is the transition function mapping from into 2 which is thepower set of, the set of all subsets of;

    (iv) is the initial state; and(v) is the set of final states.

    We note that the difference between the deterministic and nondeterministic

    automata is only in . For deterministic automaton (DFA), the outcome is a state,i.e. an element of

    ; for nondeterministic automaton the outcome is a subset of

    .

    Consider, for example, the nondeterministic automaton whose transition diagram is

    given in figure below.

  • 7/31/2019 Theory of Finite Automata

    8/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    8

    0q 1q 2q

    3q 4q

    0

    0

    0

    0

    1

    1 1

    1

    1

    0

    Transition system for a nondeterministic automaton.

    The sequence of states for the input string 0100 is given in figure below.0q

    00q

    10q

    00q

    00q

    3q

    4q

    3q1q

    0

    3q

    0 0

    0

    1

    Hence,

    ,0100 , , Since is an accepting state, the input string 0100 will be accepted by thenondeterministic automaton.

  • 7/31/2019 Theory of Finite Automata

    9/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    9

    Definition: A string is accepted by NDFA if , contains somefinal state.

    Note: As is nondeterministic, , may have more than one state. So isaccepted by if a final sate is one among the possible states can reach onapplication of.Definition: The set accepted by an automaton (deterministic ornondeterministic) is the set of all input strings accepted by . It is denoted by.The Equivalence of DFA and NDFA:

    We naturally try to find the relation between DFA andNDFA. Intuitively we now

    feel that:

    (i) ADFA can simulate the behavior ofNDFA by increasing the number ofstates. (In other words, a DFA,,,, can be viewed as an

    NDFA,,, , by defining , , . (ii) AnyNDFA is a more general machine without being more powerful.

    Theorem: For every NDFA, there exists a DFA which simulates the behavior ofNDFA. Alternatively, if is the set accepted by NDFA, then there exists a DFAwhich also accepts .Example: Construct a deterministic automaton equivalent to , , 0,1, , , . is given by its state table below.

    State table.

    For the deterministic automaton,(i) the states are subsets of , , i.e. , , , , ;(ii) is the initial state;

    States /

    0

    1

    ,

  • 7/31/2019 Theory of Finite Automata

    10/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    10

    (iii) and , are the final states as these are the only states containing

    ; and

    (iv) is defined by the state table given by table below.State tableof.

    and appear in the rows corresponding to and and the columncorresponding to 0. So, , , 0 , .When has states, the corresponding finite automaton has 2 states. However,we need not construct for 2 states, but only for those states reachable from .This is because our interest is only in constructing accepting . So, we startthe construction of for . We continue by considering only states appearingearlier under input columns and constructing

    for such states. We halt when no

    more new states appear under the input columns.

    Example: Find a deterministic acceptor equivalent to , , , , , , , . is given by its state table below.State table.

    The deterministic automatonequivalent tois defined as follows: 2 , , , , , , where , , , , , , , .

    States / 0 1, ,

    , ,

    States /

    ,

    ,

  • 7/31/2019 Theory of Finite Automata

    11/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    11

    We start the construction by considering first. We get and , . Thenwe construct

    for

    and

    , .

    , is a new state appearing under input

    columns. After constructingfor , , we do not get any new states and so weterminate the construction of . The state table is given in table below.State tableof.

    Mealy and Moore Models:

    The finite automata which we considered earlier have binary output, i.e. they

    accept the string or do not accept the string. This acceptability was decided on the

    basis of reachability of the final state by the initial state. Now, we remove this

    restriction and consider the model where the outputs can be chosen from some

    other alphabet. The value of the output function

    in the most general case is a

    function of the present state and the present input , i.e. , where is called the output function. This generalized model is usually called

    Mealy machine. If the output function depends only on the present state and isindependent of the current input, the output function may be written as:

    This restricted model is calledMoore machine. It is more convenient to useMoore

    machine in automata theory. We now give the most general definitions of these

    machines.

    Definition: TheMoore machine is a six-tuple ,,,, , where,(i) is a finite set of states;(ii) is the input alphabet;

    States / , ,

    , ,

    , , ,

  • 7/31/2019 Theory of Finite Automata

    12/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    12

    (iii) is the output alphabet;(iv)

    is the transition function

    into

    ;

    (v) is the output function mapping into ; and(vi) is the initial state.Definition:aMealy machine is a six-tuple ,,,, ,, where all the symbolsexcept have the same meaning as in theMoore machine. is the output functionmapping into .For example, the table below gives aMoore machine. The initial state is markedwith an arrow. The table defines

    and

    .A Moore machine.Present state Next state Output 0 1

    0100

    For the input string 0111, the transition of states is given by . The output string 00001. For the input string ,the output is 0.Transition table shown below, for example, describes a Mealy machine. Note:For the input string 0011 , the transition of states is given by , and the output string 0100. In the case of a Mealy machine, we get anoutput only on the application of an input symbol. So for the input string , theoutput is only

    . It may be observed that in the case ofMoore machine, we get

    for the input string .

  • 7/31/2019 Theory of Finite Automata

    13/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    13

    A Mealy machine.

    Present stateNext state

    0 1State Output State Output

    0111

    0010Note: AnFA can be converted into aMoore machine by introducing

    0,1and

    defining 1if and 0if .For aMoore machine if the input string is of length , the output string is of length 1. The first output is for all output strings. In the case ofMealy machineif the input string is of length , the output string is also of the same length .Procedure for Transforming a Mealy Machine into a Moore Machine:

    We develop procedures for transforming a Mealy machine into a Moore machine

    and vice versa so that for a given input string the output strings are the same(except for the first symbol) in both the machines.

    Example: Consider the Mealy machine described by the transition table given in

    table below. Construct a Moore machine which is equivalent to the Mealy

    machine.

    Mealy machine.

  • 7/31/2019 Theory of Finite Automata

    14/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    14

    Present state

    Next state

    0 1State Output State Output

    0111

    0010At the first stage we develop the procedure so that both machines accept exactly

    the same set of input sequences. We look into the next state column for any state,

    say , and determine the number of different outputs associated with in thatcolumn.We split into several different states, the number of such states being equal tothe number of different outputs associated with . For example, in this problem, is associated with one output 1 and is associated with two different outputs0and 1. Similarly, and are associated with the outputs 0and 0, 1,respectively. So, we split into and . Similarly, into and . Nowthe above table can be reconstructed for the new states as shown in table below.

    State table.

    Present state

    Next state 0 1State Output State Output

    011111

    000100

    The pair of states and outputs in the next state column can be rearranged as given

    in table below.

    Revised state table.

  • 7/31/2019 Theory of Finite Automata

    15/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    15

    Present state Next state Output

    0 1

    101001

    The revised state table gives the Moore machine. Here we observe that the initial

    state is associated with output 1. This means that with input we get an outputof 1, if the machine starts at state . Thus this Moore machine accepts a zero-length sequence (null sequence) which is not accepted by the Mealy machine. To

    overcome this situation, either we must neglect the response of a Moore machine

    to input , or we must add a new starting state , whose state transitions areidentical with those of but whose output is 0. So the above revised table istransformed to table shown below.

    Moore machine.

    Present state Next state Output 0 1

    0101001

    From the foregoing procedure it is clear that if we have , Mealy machine, the corresponding Moore machine has no more than 1 states.Procedure for Transforming a Moore Machine to Corresponding Mealy

    Machine:

  • 7/31/2019 Theory of Finite Automata

    16/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    16

    We modify the acceptability of input string by aMoore machine by neglecting the

    response of the Moore machine to input

    . We thus define thatMealy machine

    and Moore machine are equivalent if for all input strings , the relation is satisfied, where is the output of Moore machine for itsinitial state. We give the following result: Let ,,,, , be a Mooremachine. Then the following procedure may be adopted to construct an equivalent

    Mealy machine.Construction:

    (a)We have to define the output function

    forMealy machine as a function ofpresent state and input symbol. We define by:, , .

    b thetransition function is the same as that of the givenMoore machine.Example: Construct a Mealy machine which is equivalent to the Moore machine

    given in table below.

    Moore machine.

    Present state Next state Output 0 1

    0100

    We must follow the reverse procedure of converting Mealy machine into Moore

    machine. In the case ofMoore machine, for every input symbol we form the

    pairconsisting of the next state and the corresponding output and reconstruct the

    table forMealy machine. For example, the states and in the next state columnshould be associated with outputs 0and 1, respectively. The transition table for

    Mealy machine in given in table below.

    Mealy machine.

  • 7/31/2019 Theory of Finite Automata

    17/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    17

    Present state

    Next state

    0 1State Output State Output

    0100

    1000Note: We can reduce the number of states in any model by considering states with

    identical transitions. If two states have identical transitions (i.e. the rows

    corresponding to these two states are identical), then we can delete one of them.

    Example: Consider the Moore machine described by the transition table given

    below. Construct the correspondingMealy machine.

    Moore machine.

    Present state Next state Output 0 1 001

    We construct the transition table shown below by associating the output with the

    transitions.

  • 7/31/2019 Theory of Finite Automata

    18/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    18

    Transition table.

    Present state

    Next state

    0 1State Output State Output

    000

    011

    In this table the rows corresponding to

    and

    are identical. So we can delete

    one of the two states, i.e., or . We delete , and the reconstructed tableshown below.Mealy machine.

    Present state

    Next state 0 1State Output State Output

    00 01We have deleted and replaced by in the other rows.Minimization of Finite Automata:

    Now, we can construct an automaton with minimum number of states equivalent to

    a given automaton .As our interest lies only in strings accepted by , what really matters is whether astate is a final state or not. We define some relations in .Definition: Two states and are equivalent denoted by if both, and , are final states, or both of them are nonfinal states for all .As it is difficult to construct , and , for all , there are infinitenumber of strings in

    .

  • 7/31/2019 Theory of Finite Automata

    19/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    19

    Definition: Two states and are 0 if both , and

    , are final states or both nonfinal states for all strings

    of length

    or less.

    In particular, any two final states are 0 and any two nonfinal statesare also 0.Two states and are 1 if

    (a) they are ;(b) , and, are also for every .

    Construction of Minimum Automaton:

    Step 1: (Construction of ). By definition of 0equivalence, , ,where Q is the set of all final states and .Step 2: (Construction offrom ). Let be any subset in . If and arein , they are 1 provided , and , are. Find out whether , and , are in the sameequivalence class in for every . If so, andare 1 .In this way, is further divided into 1 classes. Repeat thisfor every in to get all the elements of.Step 3: Constructfor 1,2, .Step 4: (Construction of minimum automaton). For the required minimum state

    automaton, the states are the equivalence classes obtained in step 3, i.e. the

    elements of . The state table is obtained by replacing a state by thecorresponding equivalence class .Example: Construct a minimum state automaton equivalent to the finite automaton

    given in figure below.

  • 7/31/2019 Theory of Finite Automata

    20/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    20

    0q

    1q 2q

    3q

    5q 6q

    7q4

    q

    0 0

    0

    0

    0

    0

    0

    0

    1 1

    1

    1

    1

    1

    1

    1

    It will be easier if we construct the transition table as shown below.

    Transition table

    By applying step 1, we get ,

    States/ 0 1

  • 7/31/2019 Theory of Finite Automata

    21/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    21

    So,

    , , , , , , , in cannot be further portioned. So, . Consider and . Theentries under 0 corresponding to and are and; they lie in .The entries under 1 are and , where and .Therefore, and are not 1. Similarly, is not 1to , and .Now, consider and . The entries under 0 are and . Both are in. The entries under 1 are and . So, and are 1 . Similarly, is 1to . , , is a subset in .So, , , .Repeat the construction by considering and any one of the states , , . Thestate are not 1 to or but 1to . Hence, , . The elements left over in are and . By considering the entriesunder 0and 1, we see that and are 1.So

    , . Therefore,

    , , , , , , , is also in as it cannot be portioned further. Now the entries under0column corresponding to and areand , and these lie in the sameequivalence class in . The entries under 1 are and . So andare 2. But and are not 2. Hence,, , is portioned into , and . and are 2. and are also2

    . Thus,

    , , , , , , , andare 3. Also, andare 3. Therefore,

    , , , , , , , As , where gives the equivalence classes, the minimum stateautomaton is

  • 7/31/2019 Theory of Finite Automata

    22/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    22

    , 0,1, , ,

    where, , , , , , , , , ,

    and is given in table below.Transition table of minimum state automaton.

    The transition diagram for the minimum state automaton is given in figurebelow.

    40,qq

    53 , qq

    71, qq

    2q

    6q

    0

    0

    0

    0

    0

    1

    1

    1

    1

    1

    States /

    0

    1

    , , , , ,

    , ,

  • 7/31/2019 Theory of Finite Automata

    23/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    23

    Alphabets:

    An alphabet is an atomic, finite and nonempty set of symbols. We use theconvention for analphabet. For example, , , , , set of all lower case letters. 0, 1, set of binary symbols. 0,1 ,2 ,,9, set of numeric symbols. 0,1 ,2 ,,9 , , ,,, set of alphanumeric symbols.

    Strings:

    A string is the finite ordering of symbols chosen from some alphabet . Forexample, , ,, , are some of the strings from the alphabet ,,. Note that , , and are alsothe strings from the alphabet,,. When we write , , and as the elements of then theserefers assymbols not strings. The strings can be usually classified by their length, thatis, thenumber of occurrences of the symbols in the string. The standarddenotation for the length ofthe string is ||. For example, | | 3and

    | | 1.A string of zero occurrences of symbols is called or .We denote itby read as epsilon such that ||0. Thus, is a string chosenfrom any alphabet whatsoever.Power of:For any alphabet , the power of i.e., where is any positive integerexpresses the set of allstrings of length formed over . For example, let0, 1then

    0, 1 00,01,10,11 0 0 0 , 0 1 , 1 0 , 1 1 , , each string is of length.

  • 7/31/2019 Theory of Finite Automata

    24/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    24

    The set of all possible strings over is denoted by , where operator * iscalled as operator and the meaning of is given by,

    For example, if 0,1, then using the previous definitions of , , ,we have, 0, 1, 00,01,10,11 000,001,010,011,100,

    ,0,1,00,01,10,11,000,001,010,011,100, this set contains infinite many stringsFrom the set , if we exclude the empty string then we have a set ofnonemptystrings over alphabet .That we denoted by where is calledoperator.Therefore,

    , i.e., Conversely, we say Languages:A language is the set of strings chosen from , for any alphabet . If is thelanguage over then . Hence, language may contains infinite manystrings. Since languages are set ofstrings, thus new languages can be

    constructed using set operations viz., union, intersections,difference, andcomplement. For example, the complement of the language over alphabetis given by ,

    where contains all possible set of strings formed over that we take theuniversal set.Hence, setcontains all those strings of that are not in the set.

  • 7/31/2019 Theory of Finite Automata

    25/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    25

    A new language can also be constructed using concatenationoperation over

    strings. Let and are two strings then concatenation of and is the string, that is . For example, let is the string of symbols i.e., and is the stringof symbols i.e., ,then is the string of symbols i.e., .Note that concatenation is not commutative, such that until . Ontheother side concatenation is associative, such that for any strings , , and , . Thisallows us to concatenate the strings without restrictingthe order in which various concatenationoperations are to be performed.

    We can also apply the concatenation operation over set of strings calledlanguages. Forexample, let languages are and , then thereconcatenation is , i.e., |

    Consider an example, Let and 00, 01, 10, 11, then 00,01,10,11 00, 01, 10, 11 00,01,10,11,

    i.e., , . Remember, concatenation of two null strings or language containingnull strings onlyis a null string, i.e.,

    If language set is empty i.e., or , then concatenation of will remainempty for any language . For example, let ,,, then ,, or

    If both, and , then .Strings, by definition, are finite but the language contains infinite number ofstrings. Sothe important constraint of these languages is to specify them in theways that are finite. Forexample, let , then ,,,, ininite many strings. The infinitestrings of the

    language can be equivalently represented in a finite way as,

    .

  • 7/31/2019 Theory of Finite Automata

    26/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    26

    Consideranother illustration, where language 0, 1 . Then the

    language can be constructed,either by concatenating an arbitrary number ofstrings, each is either 0or 1, or byconcatenating the string a with an arbitrarynumber of copies of the string . Similarly alanguage 0 0 | , that contains the strings and add 0 to each end where isanarbitrary string formed using and . Since, we have

    ,

    , , ,

    ,

    Then Or, Similarly we denote by,

    or

    Example:Construct a DFA that accepts the string having the alphabet pattern011.We construct the DFA over set of alphabets 0, 1 by assuming is theinitial statethen,

  • 7/31/2019 Theory of Finite Automata

    27/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    27

    1. From the state onwards there must be a consumption of string 011

    which isnecessary a substring or substring containing pattern found inall acceptable string.0 1 1

    0q 1q 2q 3q 2. Any string starting with symbol 0 followed by any number of 0 beforethe pattern011 is accepted s.t. 011,0011,00011,. So there must be arepetitive transitionarc in the state on symbol 0.

    0 1 1

    0q 1q 2q 3q

    0

    from the state the last symbol seen was 0

    3. Similarly, any string starting with symbol 1 and followed by any numberof 1 beforethe pattern 011 is accepted s.t.1011,11011,111011,. So there must berepetitions of symbol 1on state .

    0 1 1

    0q 1q 2q 3q

    1

    4.

    Combining 2 and 3 we get the following DFA.

    0 1 10q 1q 2q 3q

    1 0

  • 7/31/2019 Theory of Finite Automata

    28/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    28

    5. If the string containing 01 followed by pattern 011, then from the state

    there is anarc return to state on input symbol 0, so the automatareach to its accepted state after reading the pattern 011.0 1 1

    0q 1q 2q 3q

    1 0

    0 from the state last two symbol seen were 016. After the pattern 011 the string might contain any number of 0s or/and1s, for thatthere is a repetitive arc on state q over symbol 0 or 1.Figure shownbelow

    0 1 1

    0q 1q 2q 3q

    1 0

    0

    1,0

    In this automaton we observed that there is one and only one exit on eachsymbol fromeach state. Due to this fact automaton is Deterministic.Finally, the DFA , , , , 0, 1, , , ; where are shownin thetransition table:

  • 7/31/2019 Theory of Finite Automata

    29/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    29

    Transition table.

    Example:

    Give aDFA

    that accepts the language over alphabet and thestring containszero/multiples of 4 . Or,Construct the DFA that accepts the strings of the set,,,.Let be a DFA and is the initial state.

    1. If first symbol is null string then initial state is the final state alsoso state diagram will be,0q

    2. From the state onwards there is a consumption of 4consecutivefollowed by none/more such sets of , i.e.,0q 1q 2q 3q

    a

    a a a

    So the final DFA , , , , , , , shown in Figure above;and the transition function is given in the transition table below.

    States Input symbol0 1

  • 7/31/2019 Theory of Finite Automata

    30/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    30

    Transition table.

    States Input symbol

    :Instead of defining the behavior of transition function over a single symbolalphabet, whichis a mapping of a state with a input symbol and returns astate i.e., :, it is alsorequired to know the behavior of thetransition function over an arbitrary string s.t. automatanot only read asingle symbol but a sequence of symbols or string suchcharacteristicsinclude in the definition of head.Definition:

    Assume, if a string is defined over set of alphabet then set of possible stringis in , then headis defined as: Q Q

    or we say that head is the transition function that map a state Q with astring andreturns a state Q.Let automata is in state , after reading the string automaton reaches tostate . So, the behavior of headover string is given as,, where is a string might be of single alphabet.Properties of of a DFA:From any state ,

  • 7/31/2019 Theory of Finite Automata

    31/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    31

    1. If input string is a null string then automaton state remains

    unchanged i.e., , , If the string is of single symbol string or of length one then head andare same i.e.,assume string then,

    , , 2. If string is not of single symbol string then assume string is formed by

    alphabet and substring, i.e., , then , , , , For example if 1011 then 1 and remaining string 011.Here , and assume that after reading the remaining substring automatareaches to state then, .Example: A DFA , ,,,, has following transition

    characteristics:0q 1q

    a

    a

    Check behavior of the DFA over string .Assume autometer is in initial state . Now check the behaviour ofDFAover thestring , i.e.,, , ,

    ,

  • 7/31/2019 Theory of Finite Automata

    32/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    32

    , ,

    , , , , ,

    Since state is an accepted state, therefore string is accepted byDFA.Example:Construct the DFA accepting the set of string having both oddnumber of and .The following DFA accepts odd no. of and , where, , , , ,,,,, and transition function shown in thetransitiontable below.

    Transition table.

    States Input symbol

    Now we define the moves ofDFA over the string odd number of and bothwhich must be acceptable or after reading the whole stringautomata reaches to the final state.So, compute,:

    1. , , , ,

  • 7/31/2019 Theory of Finite Automata

    33/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    33

    2. , , ,

    , 3. , , , ,

    4. , , , ,

    5.

    , , , , 6. , , , ,

    , 7. , ,

    where is the accepted state ofDFA.Language of a DFA:

    After knowing the behavior of the automata over an arbitrary string andfinally over the set ofstring we can easily define the language of a DFA. Letautomata be a DFA then languageaccepted by is where,

    | , Alternatively, we say that any arbitrary string from the set will be thelanguage ofDFA if from initial state after reading the complete string itreaches to final state. Now wesee that if is the set of alphabet then set of allpossible string formed over is . In the set there exists two possible classof languages, i.e.,

  • 7/31/2019 Theory of Finite Automata

    34/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    34

    where contains those set of strings that are accepted by automaton , and

    remainingstring

    are those that are discarded or rejected by .Hence, and are twodisjoint sets which never meet with referenceto a particular automaton , i.e.,

    Note: Set contains infinitely many strings or a language of a DFA containsinfinite number ofstrings but an automaton has a finite amount of space thatis only available space to allocate to finite orinfinitely long strings. Hence,

    there is a mechanism used to describe an infinitely long string into a finitenumber of symbols. :Like head ofDFA, head ofNDFA defines the behavior of the transitionfunction over anarbitrary string. Assume that if the string is defined overalphabet, then set of all possiblestrings are . The head is defined as,

    : Thus, head is the transition function which is a mapping of a state and a stringof input symbols to power set of or .Properties of of a NDFA:

    From any state , the behavior of head over string is determined asfollows:

    1.

    If is a null string then,, ;such that if input symbol is a null string then state remains unchanged.2. If string is composed of two/more symbols, then decompose string into substring and a single symbol such that, then,

    , ,;

  • 7/31/2019 Theory of Finite Automata

    35/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    35

    , , Further, assume that , , , , , , that is, from the state NDFAmight be reaches to these possible states after consuming the string, that is shown in figure below,

    q

    y

    y

    y

    1p

    2p

    ip

    a

    a

    a

    1r

    2r

    jr

    Thus, , , , , , , , ; , , , , ,

    , , ,

  • 7/31/2019 Theory of Finite Automata

    36/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    36

    Example:Consider a NDFAshown in figure below. Check its nature of

    acceptance over the string 101101.0 1 1

    0q 1q 2q 3q

    1,01,0

    The above NDFA can be defined as,

    , , , ,0,1,,, ;where are shown in the following transition table,Transition table.

    States nput symbol 0 1

    ,

    Then we check the behavior of over the string 101101, from the startingstate .

    1. ,101101 , 1,01101 ,01101

    2. ,01101 , 0,1101 , ,11013. , ,1101 ,1101 ,11014. ,1101 , 1,101

    ,101

  • 7/31/2019 Theory of Finite Automata

    37/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    37

    5. ,101 , 1, 01

    , 016. , 01 , 0, 1 , , 1

    7. , , 1 , , 1 , 1 , 1

    , 1, , 1, , , ,

    So we find none of these states is an acceptable state.

    8.

    ,1101 , 1,101 ,1019. ,101 , 1, 01

    , 0110. , 01 , 0, 1

    , 111. , 1 , 1 , 1, ,

    ; which is an acceptable state

    Hence,NDFA

    will move over the string 101101 according to following paths,

  • 7/31/2019 Theory of Finite Automata

    38/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    38

    0q 0q0q0q 0q 0q 0q

    1q

    1q

    2q

    3q 3q 3q2q

    1

    1

    1

    1

    11

    1

    1 0 0

    0

    0

    0

    Therefore, the only acceptable path from starting state is shown by darkline. Alongto this path

    NDFA

    reaches to the acceptable state at the end ofthe string 101101.Language of a NDFA:

    After determining the behavior of the NDFA over an arbitrary string, we caneasily define thelanguage of a NDFA. Let Nbe a NDFA i.e., ,,,, ,then language accepted by NDFA is, where,

    |

    ,

    . .

    ,

    It means, language contains an arbitrary string , chosen from the set ofpossiblestrings such that NDFA, after reading the string from the initialstate reaches to thestate that is in power set of , such that its relationwith set is not disjoint. That is, at leastone state is common between setand .Example: Consider a NDFA shown in figure below, and defined as

    ,

    ,

    ,

    ,0,1,,

    ,

    . Test the string 10101which is not in thelanguage of.

  • 7/31/2019 Theory of Finite Automata

    39/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    39

    0 1 1

    0q 1q 2q 3q

    1,01,0

    Assign string 10101 to , if is a language of where , i.e., 0, 1,then afterreading the string , NDFA reaches to its final state, i.e. any statethat belongs to the powerset of which contains the final state . Now wecan construct the moves ofNDFA over thestring 10101, that is shown infigure below.

    0q 0q0q0q 0q 0q

    1q

    1q

    2q

    2q

    1

    1

    111 0 0

    0

    0

    0

    Since, ,10101 or or , so none of the set contains state . Hence,,10101 . It concludes that string 10101 is not accepted byNDFA

    .

  • 7/31/2019 Theory of Finite Automata

    40/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    40

    Finite Automata with Moves:

    We have seen so far that a finite automaton of either deterministic ornondeterministic whichchanges their state transitions only over known inputsymbols. Experience shows that theremight be a need of state transitionsover no input symbol. It means, there are few states in thefinite automatonsuch that it skips between these states without consumption of anyinputsymbol. For this purpose, we introduce a new symbol epsilon thathas a dimension and ofzero length, which is also called a nullstring.

    Now we will discuss the nature of finite automata specifically, over null string. Sinceautomata changes their state/s over null string so these transitionsoccurs over no symbol. Inother words,. For example, automata is instate and its state changes to over symbol .q p

    So it shows a spontaneous transition of state from state to state known as.This characteristic provides additional flexibility to the finiteautomaton. Hence, a finiteautomaton with moves is more powerful thaneither from Nondeterministic or deterministicfinite automata.Non Deterministic Finite Automata (NDFA) with moves:A non deterministic finite automaton with is an extension ofNDFA. When some of thetransitions in the NDFA are such

    that, there are few transition/s ofNDFA

    are definedover null string thenNDFA is called NDFAwith. It provides additional flexibility totheNDFA so that automaton skips between states spontaneously. Let be anNDFAwith ,whose tuples definition is given as,

    ,, , , where,, holds similar meaning as an NDFA and the transitionfunction isdefined as follows,

  • 7/31/2019 Theory of Finite Automata

    41/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    41

    :

    where, is the partial mapping of a state with an input symbol includingthat returns to thestate that are in the power set of . As we said earlier, thetransitions over are also knownas .For example, a NDFA with is shown in figure below, where set ofstates , , and set of alphabet 0,1,2. The transitionfunctions are shown in the transition table below.

    0q 1q 2q

    0 12

    NDFAwith.

    States Input symbols

    0 1 2 :

    As we discussed previously that transition function gives the behavior of aNDFAwith over a single symbol including a null string .Whereas, headshows the nature ofNDFA with over a string.We will now discuss the role of headover various possiblestrings, i.e., If string is a null string then,

  • 7/31/2019 Theory of Finite Automata

    42/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    42

    ,

    / / which is also called as ;For example, consider the NDFA with in the previous example, sowe can find,

    ,

    ,

    ,

    ;Similarly, , ;and,

    ; Assume a string . ., , then further assume that string is form by a

    substring and a symbol , . . , . , then, , , ,;or,

    , , ,;Thus, in general if is the set of states, then

    If string contains a single symbol , then, ,

    Similarly for a string ,

  • 7/31/2019 Theory of Finite Automata

    43/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    43

    , ,

    If string contains a single symbol then,

    , , , , , ,

    For the NDFA with shown in the previous example, , 0can becomputed as follows,, 0 , 0 , , 0

    , , , 0 , 0 , 0 , 0 , , ; computed previously

    Note: If we compare the result obtained by and on same symbol we findthat, , 0 , 0and , 0 , , so both aredifferent. Hence, we conclude that, , 0 , 0.

    Assume that,, , , , paths that may end with one or more / from 1 Let, , , , ,

  • 7/31/2019 Theory of Finite Automata

    44/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    44

    then,

    , Hence, , , ,

    Similarly we can compute , 1 as,

    , 1 , 1 , , 1 , , , 1

    , 1 , 1 , 1

    , ; computed as previouslyLanguage of NDFA with :In the previous section we have defined so far the nature of an NDFA with over anarbitrary string. Collection of all those strings over whichNDFAwith reaches to itsfinal state will be in its language set. Letdenotes the language of NDFA with ,where is defined as,

    | , Alternatively for an string , which is formed over alphabet will be in thelanguage such thatwhile accepting the string automaton is in the of state/s returned by whoseintersection with the set of finalstates will not be empty. Alternatively, over returns at least oneaccepting state that is in final set of state .

  • 7/31/2019 Theory of Finite Automata

    45/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    45

    Method of Conversion from NDFA with to NDFA:Theorem: If be a NDFAwith , then there exists a NDFAwithout i.e., where is the language of and isthe language of .Example:Consider the that is shown in figure below, here , , , 0,1,2, and is given as follows:

    0q 1q 2q

    0 12

    The definition of transition functions for NDFA over each symbol of cover all thedefinition of transition functions for NDFA with including /s. Since,/ cannot be the part of forNDFA

    ; hence all / arcs can be replaced byeither of the symbolof . This is because, the flexibility of spontaneous skip between states over no symbol . For example,, 0 , 0

    , , 0 , , , 0

    , 0 , 0 , 0

    , , ; computed as previously

  • 7/31/2019 Theory of Finite Automata

    46/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    46

    Hence, we say that on symbol 0 the state of the automaton will be either

    or or. That is the requirement of theNDFA

    . So, transition functionfor NDFA is given as, , 0 , 0In general for any input symbol , we have

    , , It states that the behavior of both automatons and are same on same

    input symbol.Hence, It concludes that in general if is the language of athen language of a NDFA is also i.e., Hence, , 0 , 0 , , Similarly

    , 1 , 1 , , 2 , 2 and so on.Therefore, the transition table for the given NDFA will be looks like,

    NDFA transition table.States Input symbols

    0 1 2 , , , , The transition diagram for NDFA is shown in figure below.

  • 7/31/2019 Theory of Finite Automata

    47/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    47

    0q

    1q

    2q

    0

    1

    2

    1,0

    2,1

    2,1,0

    Equivalence of NDFAwith to DFA:

    We have seen that automaton NDFA

    with is an extension of anNDFA in terms offlexibility. Since, in the previous sections, we have seenthe equivalence betweenNDFAwith and NDFA and theequivalence between NDFAand DFA. Therefore, it concludes that, there existsan equivalence between NDFAwith and the DFA a static nature offinite automata. This equivalence is shown in figure below.

    Nmoves

    NDFA with

    (N)NDFA

    (M)DFA

  • 7/31/2019 Theory of Finite Automata

    48/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    48

    Let , , , , , then construct an equivalent DFA where is

    definedas, ,,, , .Now the relationship between corresponding tuples are as follows, . Both automatons operate on same set of alphabet . Starting state ofDFA which is . So, starting stateofDFA will bethe set of state containing state . Set of final state , i.e. .

    Now we compute the transition functions forDFA

    over input symbol as,Let , , , and , , , , Then, , , , , .Example: Construct a DFA from given NDFA as shown in figure below.

    0q 1q 2q

    0 12

    For the given NDFA with we assume that equivalent DFA ,,,, whose tuples are determine as,

    , , , , , , , , , , , , which is a powerset of . 0,1,2.

    Starting state ofDFA is where, , , . All states of the set that contains as one of the state are consideredas finalstate/s. The transition functions ofDFA are determine as follows,

    Since starting state is , , hence,

  • 7/31/2019 Theory of Finite Automata

    49/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    49

    , , , 0 , , , , 0

    , , , , 0 , , , , 0 , , , 0 , 0 , 0 , 0

    , , and, , , 1 , 1 , 1 , 1

    , and, , , 2 , 2 , 2 , 2

    Now compute transitions from new state

    ,

    and

    as,, , 0 , , , 0 , , ,0 , , 0 , , 0

    , 0 , 0

  • 7/31/2019 Theory of Finite Automata

    50/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    50

    , , 1 , , 1 , 1 , 1

    , , , 2 , , 2 , 2 , 2

    Now compute transitions from the state ., 0 , , 0

    , 0

    , 1 , , 1 , 1

    , 2 , , 2

  • 7/31/2019 Theory of Finite Automata

    51/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    51

    , 2

    Further we havent got any new state so procedure stops and we obtainthe transitiondiagram ofDFA that is shown in figure below.

    A B

    C

    0 1

    2

    1,0

    2,1,0

    1

    22 0

    Example: Construct an equivalent DFA for given NDFA with shown in figure below.

    A B

    0

    1

    0

    C

    D

    0

  • 7/31/2019 Theory of Finite Automata

    52/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    52

    Let equivalent DFA ,,,, . So the tuples of are obtain

    according as, ,,,,, , , , , , , , , , , which is a power set of . 0, 1 Starting state ofDFA is the which is equal to , , . All states of the set that contain as one of the state are consideredas finalstates ofDFA.

    Transition functions ofDFA

    are as follows:Find the of all the states, i.e., , , , and , i.e., , , ; , ; ;

    ;Since, Starting state is , , ; so find over from this state onwards,, , , 0 , , , 0 , , , , 0 , , , , 0

    , , , , 0 , , , 0 , 0 , 0 , 0

    , ,

  • 7/31/2019 Theory of Finite Automata

    53/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    53

    , , , ; new state

    , , , 1 , 1 , 1 , 1

    ;, , , , 0 , , , , 0

    , 0 , 0 , 0 , 0 A C D

    , , , , , ; arepeated state

    , , , , 1 , , , , 1 , 1 , 1 , 1 , 1 B

    , ; a new state

    , , 0 , , 0

    , 0 , 0 C D

    , ; a new state, , 1 , , 1

  • 7/31/2019 Theory of Finite Automata

    54/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    54

    , 1 , 1

    ;

    , , 0 , , 0 , 0 , 0

    D ; a new state

    , , 1 , , 1 , 1 , 1

    B , ; a repeated state

    , 0 , 0

    ; a new state

    , 1 , 1 ;

    Further there is no new state generated so we stop the process and finally weobtain theDFA shown in figure below.

  • 7/31/2019 Theory of Finite Automata

    55/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    55

    ABD

    ABCD BD

    CD

    D

    00

    0

    0

    0

    1

    1,0

    1

    1

    1

    1

    Note: The nature of the state is such that, when automaton reaches to thisstate then it willdisappear or it never returns back.

  • 7/31/2019 Theory of Finite Automata

    56/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    56

    Regular Expressions

    Introduction to Regular Expressions:In the previous lectures we have studied that the power of a finite automatonis given by thelanguage it accepts, that contains finite or infinite many strings.So, is there any convenientway to express these set of strings? In the nextlectures we shall focus our attention to the descriptionof a language by analgebraic expression called as regular expression. The operationsused in theformation of regular expressions are union, concatenation, and Kleeny

    closure.The language generated by a regular expression is called regularlanguage. Regular expressionsare capable to defining all and only the regularlanguages. The significance of the symbolsused to represent the regularexpression is different than the symbol used to specify thestrings. So, we usebold symbols in representing the regular expressions while for the stringweuses the symbols as usual.Regular language is the language depictedexpressed by the regular expression.Definition of Regular Expression:

    In arithmetic, we can use the operations and to build up expressionssuch as 5 3 4 . Similarly, we can use the regular operations to buildup expressions describing languages, which are called regular expressions.An example is: 0 10. The value of the arithmetic expression is thenumber 32. The value of a regular expression is a language. In this case thevalue is the language consisting of all strings starting with a 0 or a 1 followedby any number of 0. We get this result by dissecting the expression into its

    parts. First, the symbols 0 and 1 are shorthand for the sets 0and 1. So0 1means 0 1. The value of this part is the language 0,1. Thepart 0means 0, and its value is the language consisting of all stringscontaining any number of 0. Second, like the symbol in algebra, theconcatenation symbol often is implicit in regular expressions.Thus 0 10 actually is shorthand for 0 1 0. The concatenationattaches the strings from the two parts to obtain the value of the entireexpression.

  • 7/31/2019 Theory of Finite Automata

    57/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    57

    Regular expressions have an important role in computer science applications.

    In applications involving text, users may want to search for strings thatsatisfy certain patterns. Regular expressions provide a powerful method fordescribing such patterns.Assume the set of alphabets , , , , , and be a regularexpressiondefined over and let the language generated by the regularexpression be , then thebasis regular expressions are,

    1. is the regular expression corresponding to the symbol for

    1 . Thelanguage generated by regular expression will be i.e., , for 1 .2. is a regular expression corresponding to the null string , and thelanguage generated by the regular expression will be i.e.,

    3. is the regular expression corresponding to the nonexistence of anyinput symbol and the language generated by the regular expression

    will be i.e., Above definition of regular expression can be extended further bydefining its behaviorover set of operators union , concatenation, and Kleeny closure i.e.,4. If and are two regular expressions, and their languages are and respectively, then will also be a regular expression

    and it generates thelanguage . This property of regularexpression is known as additionproperty of regular expressions.5. If and are two regular expressions, and their languages are and respectively, then will also be a regular expressionand it generates thelanguage . This property of regularexpression is known as concatenation property of regularexpressions.

  • 7/31/2019 Theory of Finite Automata

    58/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    58

    6. If be a regular expression, and its language is , then will also

    be a regular expression and it denotes the language

    or

    .This property of regularexpression is called Kleeny closure propertyof regular expression where, is Kleeny closure of language ,i.e.,Let then

    where language contains null string

    For example, if is the regular expression then its language will begiven by where, then, ,,,,,

    7. Nothing else is regular expression.In the definition of regular expression we have discussed the natureof regular expressionover following operators i.e., addition or union Concatenation, and Kleeny closure

  • 7/31/2019 Theory of Finite Automata

    59/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    59

    So for the study of regular expressions over these operators and the

    language generatedby these composite regular expressions, theprecedence of operators is important, i.e., , , is the sequence ofprecedence from higher to lower.Example: Let 00,10 and 0,1,00 then addition of twolanguages is, 0,1,00,10If ,00,10 then its addition with language L will be,

    ,0,1,00,10

    The concatenation of and is given as, 000,001,0000,100,101,1000 and concatenation with is, 0,1,00,000,001,0000,100,101,1000 .Example:In the following instances we assume that the alphabet is 0,1.

    010 | 1. 1 | 1. 001 | 001 . 101 | 0 1. | . | . 0 1 1 0 01,10. 00 1 1 0 1 | .

    0 1 01 1. 0 1 ,0 ,1 ,01. 1 . .

  • 7/31/2019 Theory of Finite Automata

    60/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    60

    Example: Now we discuss various regular expressions formed over

    0, 1 and see theimportance of operators precedence while weenumerate the language from the composite regular expression.a is a regular expression, which generates the language 0,1.Because, 0 and 1 and the addition of language i.e., 0, 1; which is either 0 or 1.b is a regular expression, which generates the language0,01,011,0111,. Here, we assume regular expression , and so 0 and ,1,11,111,,. Therefore, thelanguage generated by concatenation of regular expressions will be i.e., 0,01,011,0111,,c is a regular expression, that generates the language which isthe union of set of all strings formed by regular expressions or i.e.,, where 0 and ,1,11, 111, hence,

    ,0 ,1 ,11,111,.d is a regular expression, so its language is the set of all stringsformed using symbol 0 or 1. Here we assume regular expression then 0,1. Therefore, where ; . 0,1 0, 1; . 0 , 1 0,100,01,10,11; . 0, 1 00,01,10,11 000,001,010,011,100,101,110,111; and so on.

    Hence,

    ,0,1,00,01,10,11,000, or set of all possible stringsformed over symbols 0 & 1 including the null string.e is a regular expression and its language will be . Since, , 0, 00, 000, ; 1; again1; and ,0,00,000, therefore , ,0,00,11,0,00, 11 when first and last regularexpression produces , 011,0011, when first regular expressionproducesmultiple 0 and last regular expression produces , 110,1100,

  • 7/31/2019 Theory of Finite Automata

    61/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    61

    when first regular expression produces andlast regular expression

    produces multiple 0, 0110,01100,,00110,001100,,.Hence, language contains all strings of 0 having two consecutive 1.f For the regular expression the languagewill be the set of all strings formed over 0 and 1 consisting of pattern 101.Since the presence of regular expression first and last produces all thestrings of 0 and 1 including but the essential part of all the strings mustbe the presence of the substring 101 which is produced by the concatenation

    of regular expression 2, 3 and 4.Note that if the regular expression is constructed for the language consistingof the string , then its regular expression will be denoted by .In the previous example we saw how regular languages are to be generatedfrom the given regular expressions. In the next example we will see how theregular expressions are constructed from given regular languages.Equivalence of Regular Expression and Finite Automata:

    Every language which is accepted by either deterministic finite automatonDFA or nondeterministic finite automaton NDFA with or without is known as regular language. It means that there exists a set ofregular expressions that generates the strings of this class of language. So, ifa language is regular then certainly it can be expressed by regularexpression/s and conversely this language must be the outcome from somefinite automaton as shown in figure below.

    Alternatively we may say that,1. A regular expression can be expressed in some form of finite automataeither DFA/NDFA/NDFA with i.e., from Regular Expression toFinite Automata.2. The acceptance power language of finite Automata can be expressed byregular expression i.e., from Finite automata to Regular Expression.

  • 7/31/2019 Theory of Finite Automata

    62/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    62

    Now we study in detail about the points 1 and 2 such that the method of

    construction offinite automaton from given regular expression andconversely the determination of regular expression from finite automaton.What we have discussed so far it can be easily verified bystudy of thefollowing theorems.Language

    Regular

    Expression

    Regular

    Automata

    Finite

    DFA NDFA

    moves

    withNDFA

    Construction of NDFA with from Regular Expression:Theorem:If be a regular expression and its language is then thereexists a NDFA with i.e., . Provided that hasonly one final state and there is no outgoing arc from the final state.Example: Construct the NDFA with for regular expression

  • 7/31/2019 Theory of Finite Automata

    63/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    63

    Assume , where is formed by theconcatenation of four regular expressions i.e., where ; ; and . Now weconstruct theNDFA with for using the previous theorem in the followingsteps,

    Construction of the automaton for is the addition of twoautomatons accepting the union of language and i.e., Let it be

    a

    b

    '

    N

    Now regular expression is concatenated with regular expression so, automaton will be constructed, i.e., , thus will be obtain as,

  • 7/31/2019 Theory of Finite Automata

    64/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    64

    a

    b

    ''

    N

    a

    Next, regular expression is concatenated with , so againconcatenation construction of with automaton that accept Thus we obtain .

    a

    b

    '''

    N

    a

    b

  • 7/31/2019 Theory of Finite Automata

    65/65

    Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010

    Do the concatenation construction with the previous automaton

    to the newly constructed automaton

    for regular expression so we obtain the final NDFA with .Since will be,

    ''''

    N

    b

    a