Вы находитесь на странице: 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.


n
q q q
Automaton
, , ,
2 1

p
I
1
I
2
I
1
O
2
O
q
O

Its characteristics are now described as follows:
(i) Input: At each of the discrete instants of times t
1
, t
2
, , input values
I
1
, I
2
, , each of which can take a finite number of a fixed values from
the input alphabetL, where are applied to the input side of model shown
in the above figure.
(ii) Output: 0
1
, 0
2
, , 0
q
are the outputs of the model, each of which can take
finite numbers of fixed values from an output.
(iii) States: At any instant of time the automation can be in one of the states
q
1
, q
2
, , q
n
.
(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 input
and the state. It should be noted that at any instant of time the automaton
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 a Mealy machine.
Example: Representthe simple shift register shown below as a finite state
machine.
input Serial output Serial

The shift register shown in figure can have 2
4
= 16 states (0000, 0001, ,
1111), and one serial input and one serial output. The input alphabet is 2 =
(u, 1), and the output alphabet is = (u,1) . The above 4-bit serial shift register
can be represented as shown in figure below.
16 2 1
, ... , q , q q
1
I
1
O

It is clear that the output will depend upon both the input and the state and so it
is a Mealy machine.
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 (, 2, o, q
0
, F ),
where,
(i) is a finite nonempty set of states;
(ii) 2 is a finite nonempty set of inputs called input alphabet;
(iii) ois a function which maps 2 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) q
0
e is the initial state; and
(v) F L 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 2
-
into (i.e. maps a state and a
string of input symbols including the empty string into a state) is called indirect
transition function. We shall use the same symbol o to represent both types of
transition functions and the difference can be easily identified by nature of
mapping (symbol or a string), i.e. by the argument. ois also called the next state
function.
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 1uor 11). For example, if the
system is in state q
0
and the input 1 is applied, the system moves to state q
1
as
there is a directed edge from q
0
to q
1
with label 1u. It outputs u.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
4

0
q
1
q
0 / 0
0 / 1
0 / 0
1 / 1

Definition: A transition system is 5-tuple (, 2, o, q
0
, F), where
(a) , 2 and F are the finite nonempty set of sets, the input alphabet, and the set
of final states, respectively, as in the case of finite automata;
(b) q
0
L , and q
0
is nonempty; and
(c) ois a finite subset of 2
-
. In other words, if (q
1
, w, q
2
) is in o, it
means the following: The graph starts at the vertex q
1
, goes along a set of
edges, and reaches the vertex q
2
. The concatenation of the label of all the
edges thus encountered is w.
Definition: A transition system accepts a string w in 2
-
if
(a) there exists a path which originates from some initial state, goes along the
arrows, and terminates at some final state, and
(b) the path value obtained by concatenation of all edge-labels of the path is
equal to w.
Example: Consider the transition system shown below. Determine the initial
states, final states, and the acceptability of 1u1u11, 111u1u .
The initial states are q
0
and q
1
. There is only one final state q
3
. The path-value
of q
0
, q
0
, q
2
, q
3
is 1u1u11. As q
3
is the final state, 1u1u11 is accepted by the
transition system. But, 111u1u is not accepted by the transition system as there
is no path with path value 111u1u .
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
5

0
q
1
q
2
q
3
q
0 / 1
1 / 0
0 / 0 0 / A
0 / 1
0 / A
0 / 1011

Acceptability of A string by A finite Automaton:
Definition: A string x is accepted by a finite automaton H = (, 2, o, q
0
, F) if
o(q
0
, x) = q for some q e F. This is basically the acceptability of a string by the
final state.
Note: A final state is also called an accepting state.
Example: Consider the finite state machine whose transition function o is given in
table below (in the form of a transition table). Here, = {q
0
, q
1
, q
2
, q
3
], 2 = {u,1],
F = {q
0
] . Give the entire sequence of states for the input string 11u1u1 .
Transition function table.






States Inputs
u 1
q
1

q
2

q
3

q
0
q
2

q
3

q
0

q
1

q
1

q
0

q
3

q
2

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

( )
0
1
1
0
3
1
2
0
0
1
1
1
0
0 0
1
3
2
0
1 0
,
,
1 ,
1 0 ,
01 1 ,
101 0 ,
0101 1 , 10101 1 ,
q q q q q q q
Hence
q q
q
q
q
q
q q

= A =
|
.
|

\
|
=
|
.
|

\
|
=
|
.
|

\
|
=
|
.
|

\
|
=
|
.
|

\
|
= |
.
|

\
|
+
+
+
+
+ +
o
o
o
o
o
o o

The symbol l indicates the current input symbol being processed by the machine
and A 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 {q
0
] and the input symbol is u, what will be the next
state? From the figure it is clear that the next state will be either {q
0
]or {q
1
] . Thus
some moves of the machine cannot be determined uniquely by the input symbol
and the present state. Such machines are called nondeterministic automata.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
7

0
q
1
q
2
q
0
0
1
1 1

Definition: A nondeterministic finite automaton (NDFA) is a 5-tuple
(, 2, o, q
0
, F), where
(i) is a finite nonempty set of states;
(ii) 2 is a finite nonempty set of inputs;
(iii) o is the transition function mapping from 2 into 2

which is the
power set of , the set of all subsets of ;
(iv) q
0
e is the initial state; and
(v) F L is the set of final states.
We note that the difference between the deterministic and nondeterministic
automata is only in o. 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.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
8

0
q
1
q
2
q
3
q
4
q
0
0
0
0
1
1 1
1
1
0
A
Transition system for a nondeterministic automaton.

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

0
0
q

1
0
q

0
0
q

0
0
q
3
q
4
q
3
q
1
q
0
3
q
0 0
0
1

Hence,
o(q
0
, u1uu) = {q
0
, q
3
, q
4
]
Since q
4
is an accepting state, the input string u1uu will be accepted by the
nondeterministic automaton.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
9

Definition: A string w e 2
-
is accepted by NDFAH if o(q
0
, w) contains some
final state.
Note: As H is nondeterministic, o(q
0
, w) may have more than one state. So w is
accepted by H if a final sate is one among the possible states H can reach on
application of w.
Definition: The set accepted by an automaton H (deterministic or
nondeterministic) is the set of all input strings accepted by H. It is denoted by
I(H).
The Equivalence of DFA and NDFA:
We naturally try to find the relation between DFA and NDFA. Intuitively we now
feel that:
(i) A DFA can simulate the behavior of NDFA by increasing the number of
states. (In other words, a DFA(, 2, o, q
0
, F)can be viewed as an
NDFA(, 2, o
i
, q
0
, F) by defining o
i
(q, o) = {o(q, o)]. )
(ii) Any NDFA is a more general machine without being more powerful.
Theorem: For every NDFA, there exists a DFA which simulates the behavior of
NDFA. Alternatively, if I is the set accepted by NDFA, then there exists a DFA
which also accepts I.
Example: Construct a deterministic automaton equivalent to
H = ({q
0
, q
1
], {u,1], o, q
0
, {q
0
]). ois given by its state table below.
State table.



For the deterministic automatonH
1
,
(i) the states are subsets of {q
0
, q
1
], i.e. , |q
0
], |q
0
, q
1
], |q
1
];
(ii) |q
0
] is the initial state;
States / L u 1
- q
0

q
1

q
0

q
1

q
1

|q
0
, q
1
]
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
10

(iii) |q
0
] and |q
0
, q
1
] are the final states as these are the only states containing
q
0
; and
(iv) ois defined by the state table given by table below.
State tableof M
1
.




q
0
andq
1
appear in the rows corresponding to q
0
and q
1
and the column
corresponding to u. So, o(|q
0
, q
1
], u) = |q
0
, q
1
].
When H has n states, the corresponding finite automaton has 2
n
states. However,
we need not construct o for 2
n
states, but only for those states reachable from |q
0
].
This is because our interest is only in constructing H
1
accepting I(H). So, we start
the construction of ofor |q
0
]. We continue by considering only states appearing
earlier under input columns and constructing o for such states. We halt when no
more new states appear under the input columns.
Example: Find a deterministic acceptor equivalent to
H = ({q
0
, q
1
, q
2
], {o, b], o, q
0
, {q
2
]). ois given by its state table below.
State table.




The deterministic automatonH
1
equivalent toHis defined as follows:
H
1
= (2

, {o, b], o, |q
0
], F
i
), where F = {|q
2
], |q
0
, q
2
], |q
1
, q
2
], |q
0
, q
1
, q
2
]].
States / L 0 1

|q
0
]
|q
1
]
|q
0
, q
1
]

|q
0
]
|q
1
]
|q
0
, q
1
]

|q
1
]
|q
0
, q
1
]
|q
0
, q
1
]
States / L o b
- q
0

q
1

q
2

|q
0
, q
1
]
q
0


q
2

q
1

|q
0
, q
1
]
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
11

We start the construction by considering |q
0
] first. We get |q
2
]and |q
0
, q
1
]. Then
we construct o for |q
2
]and |q
0
, q
1
]. |q
1
, q
2
]is a new state appearing under input
columns. After constructingofor |q
1
, q
2
], we do not get any new states and so we
terminate the construction of o. The state table is given in table below.
State tableof M
1
.




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 Z(t) in the most general case is a
function of the present state q(t) and the present input x(t), i.e.
Z(t) = z(q(t), x(t))
wherez is called the output function. This generalized model is usually called
Mealy machine. If the output function Z(t)depends only on the present state and is
independent of the current input, the output function may be written as:
Z(t) = z(q(t))
This restricted model is called Moore machine. It is more convenient to use Moore
machine in automata theory. We now give the most general definitions of these
machines.
Definition: The Moore machine is a six-tuple (, 2, , o, z, q
0
) where,
(i) is a finite set of states;
(ii) 2 is the input alphabet;
States / L o b
|q
0
]
|q
2
]
|q
0
, q
1
]
|q
1
, q
2
]
|q
0
, q
1
]

|q
0
, q
1
]
|q
0
]
|q
2
]
|q
0
, q
1
]
|q
1
, q
2
]
|q
0
, q
1
]
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
12

(iii) is the output alphabet;
(iv) o is the transition function 2 into ;
(v) z is the output function mapping into ; anu
(vi) q
0
is the initial state.
Definition:aMealy machine is a six-tuple (, 2, , o, z, q
0
), where all the symbols
except zhave the same meaning as in the Moore machine.z is the output function
mapping 2into .
For example, the table below gives a Moore machine. The initial state q
0
is marked
with an arrow. The table defines o and z.
A Moore machine.
Piesent state Next state o 0utput
z o = u o = 1
- q
0

q
1

q
2

q
3

q
3
q
1
q
2
q
3
q
1
q
2
q
3
q
0
u
1
u
u

For the input string u111, the transition of states is given by q
0
- q
3
- q
0
-
q
1
- q
2
. The output string uuuu1. For the input string ,the output is z(q
0
) = u.
Tiansition table shown below, foi example, uesciibes a Nealy machine. (Note:
Foi the input stiing uu11 , the tiansition of states is given by q
1
- q
3
- q
2
-
q
4
- q
3
, and the output string u1uu. In the case of a Mealy machine, we get an
output only on the application of an input symbol. So for the input string A, the
output is only A. It may be observed that in the case of Moore machine, we get
z(q
0
) foi the input stiing A.




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

A Mealy machine.
Piesent state
Next state
o = u o = 1
State 0utput State 0utput
- q
1

q
2

q
3

q
4

q
3
q
1
q
2
q
4
u
1
1
1
q
2
q
4
q
1
q
3
u
u
1
u

Note: An FA can be converted into a Moore machine by introducing = {u,1] and
definingz(q) = 1ifq e F andz(q) = uifq e F.
For aMoore machine if the input string is of length n, the output string is of length
n +1. The first output is z(q
0
) for all output strings. In the case of Mealy machine
if the input string is of length n, the output string is also of the same length n.
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.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
14

Piesent state
Next state
o = u o = 1
State 0utput State 0utput
- q
1

q
2

q
3

q
4

q
3
q
1
q
2
q
4
u
1
1
1
q
2
q
4
q
1
q
3
u
u
1
u

At 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 q

, and determine the number of different outputs associated with q

in that
column.
We split q

into several different states, the number of such states being equal to
the number of different outputs associated with q

. For example, in this problem,


q
1
is associated with one output 1 and q
2
is associated with two different outputs
uand 1. Similarly, q
3
and q
4
are associated with the outputs uand u, 1,
respectively. So, we split q
2
into q
20
and q
21
. Similarly, q
4
into q
40
and q
41
. Now
the above table can be reconstructed for the new states as shown in table below.
State table.
Piesent state
Next state
o = u o = 1
State 0utput State 0utput
- q
1

q
20

q
21

q
3

q
40

q
41

q
3
q
1
q
1

q
21

q
41
q
41
u
1
1
1
1
1
q
20
q
40
q
40

q
1

q
3
q
3
u
u
u
1
u
u

The pair of states and outputs in the next state column can be rearranged as given
in table below.
Revised state table.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
15

Piesent state Next state o 0utput
z o = u o = 1
- q
1

q
20

q
21

q
3

q
40

q
41

q
3
q
1
q
1

q
21

q
41
q
41
q
20
q
40
q
40

q
1

q
3
q
3
1
u
1
u
u
1

The revised state table gives the Moore machine. Here we observe that the initial
state q
1
is associated with output 1. This means that with input A we get an output
of 1, if the machine starts at state q
1
. 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 A, or we must add a new starting state q
0
, whose state transitions are
identical with those of q
1
but whose output is u. So the above revised table is
transformed to table shown below.
Moore machine.
Piesent state Next state o 0utput
z o = u o = 1
- q
0

q
1

q
20

q
21

q
3

q
40

q
41

q
3
q
3
q
1

q
1

q
21

q
41
q
41
q
20
q
20
q
40

q
40

q
1

q
3
q
3
u
1
u
1
u
u
1

From the foregoing procedure it is clear that if we have m-output, n -stotc
Mealy machine, the corresponding m- outputMoore machine has no more than
mn +1 states.
Procedure for Transforming a Moore Machine to Corresponding Mealy
Machine:
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
16

We modify the acceptability of input string by a Moore machine by neglecting the
response of the Moore machine to input A. We thus define that Mealy machineH
and Moore machineH
i
are equivalent if for all input strings w, the relation
bZ
M
(w) = Z
M
| (w)is satisfied, where b is the output of Moore machine for its
initial state. We give the following result: Let H
1
= (, 2, , o, z, q
0
) be a Moore
machine. Then the following procedure may be adopted to construct an equivalent
Mealy machineH
2
.
Construction:
(a) We have to define the output function z
i
for Mealy machine as a function of
present state and input symbol. We define z
i
by:
z
i
(q, o) = z(o(q, o)) orollstotcs q onJ input symbol o.
(b) thetransition function is the same as that of the given Moore machine.
Example: Construct a Mealy machine which is equivalent to the Moore machine
given in table below.
Moore machine.
Piesent state Next state o 0utput
z o = u o = 1
- q
0

q
1

q
2

q
3

q
3
q
1
q
2
q
3
q
1
q
2
q
3
q
0
u
1
u
u

We must follow the reverse procedure of converting Mealy machine into Moore
machine. In the case of Moore machine, for every input symbol we form the
pairconsisting of the next state and the corresponding output and reconstruct the
table for Mealy machine. For example, the states q
3
and q
1
in the next state column
should be associated with outputs uand 1, respectively. The transition table for
Mealy machine in given in table below.
Mealy machine.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
17

Piesent state
Next state
o = u o = 1
State 0utput State 0utput
- q
0

q
1

q
2

q
3

q
3
q
1
q
2
q
3
u
1
u
u
q
1
q
2
q
3
q
0
1
u
u
u

Note: 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 corresponding Mealy machine.
Moore machine.
Piesent state Next state o 0utput
z o = u o = 1
- q
1

q
2

q
3

q
1
q
1
q
1
q
2
q
3
q
3
u
u
1

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






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

Transition table.
Piesent state
Next state
o = u o = 1
State 0utput State 0utput
- q
1

q
2

q
3

q
1
q
1
q
1
u
u
u
q
2
q
3
q
3
u
1
1

In this table the rows corresponding to q
2
and q
3
are identical. So we can delete
one of the two states, i.e., q
2
or q
3
. We delete q
3
, and the reconstructed table
shown below.
Mealy machine.
Piesent state
Next state
o = u o = 1
State 0utput State 0utput
- q
1

q
2

q
1
q
1
u
u
q
2
q
2
u
1

We have deleted q
3
-row and replaced q
3
by q
2
in the other rows.
Minimization of Finite Automata:
Now, we can construct an automaton with minimum number of states equivalent to
a given automaton H.
As our interest lies only in strings accepted by H, what really matters is whether a
state is a final state or not. We define some relations in .
Definition: Two states q
1
and q
2
are equivalent (uenoteu by q
1
q
2
) if both
o(q
1
, x)and o(q
2
, x) are final states, or both of them are nonfinal states for all
x e 2
-
.
As it is difficult to construct o(q
1
, x) and o(q
2
, x) for all x e 2
-
, there are infinite
number of strings in 2
-
.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
19

Definition: Two states q
1
and q
2
are k -cqui:olcnt (k u) if both o(q
1
, x) and
o(q
2
, x) are final states or both nonfinal states for all strings x of length k or less.
In particular, any two final states are u -cqui:olcnt and any two nonfinal states
are also u -cqui:olcnt.
Two states q
1
and q
2
are (k +1) -cqui:olcnt if
(a) they are k -cqui:olcnt;
(b) o(q
1
, o)ando(q
2
, o) are also k -cqui:olcnt for every o e 2.
Construction of Minimum Automaton:
Step 1: (Construction of n
0
). By definition of u -equivalence, n
0
= {
1
0
,
2
0
],
where Q
1
0
is the set of all final states and
2
0
= -
1
0
.
Step 2: (Construction of n
k+1
from n
k
). Let

k
be any subset in n
k
. If q
1
and q
2
are
in

k
, they are (k + 1) - cqui:olcnt provided o(q
1
, o) and o(q
2
, o) are
k - cqui:olcnt. Find out whether o(q
1
, o) and o(q
2
, o) are in the same
equivalence class in n
k
for every o e 2. If so, q
1
andq
2
are (k +1) -cqui:olcnt.
In this way,

k
is further divided into (k +1) -cqui:olcnccclasses. Repeat this
for every

k
in n
k
to get all the elements of n
k+1
.
Step 3: Constructn
n
forn = 1,2, until n
n
= n
n+1
.
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 n
n
. The state table is obtained by replacing a state q by the
corresponding equivalence class |q].
Example: Construct a minimum state automaton equivalent to the finite automaton
given in figure below.


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

0
q
1
q 2
q
3
q
5
q
6
q
7
q
4
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

1
0
= F = {q
2
],
2
0
= -
1
0

States / L u 1
- q
0

q
1

q
2

q
3

q
4

q
5

q
6

q
7

q
1

q
6

q
0

q
2

q
7

q
2

q
6

q
6

q
5

q
2

q
2

q
6

q
5

q
6

q
4

q
2

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

So,
n
0
= |{q
2
], {q
0
, q
1
, q
3
, q
4
, q
5
, q
6
, q
7
]|
{q
2
]inn
0
cannot be further portioned. So,
1
i
= {q
2
]. Consider q
0
and q
1
e
2
0
. The
entries under u -column corresponding to q
0
and q
1
are q
1
andq
6
; they lie in
2
0
.
The entries under 1 -column are q
5
and q
2
, where q
2
e
1
0
and q
5
e
2
0
.
Therefore, q
0
and q
1
are not 1 -cqui:olcnt. Similarly, q
0
is not 1 -cqui:olcnt
to q
3
, q
5
and q
7
.
Now, consider q
0
and q
4
. The entries under u - column are q
1
and q
7
. Both are in

2
0
. The entries under 1 - column are q
5
and q
5
. So, q
0
and q
4
are 1 -
cqui:olcnt. Similarly, q
0
is 1 -cqui:olcntto q
6
. {q
0
, q
4
, q
6
]is a subset in n
1
.
So,
2
i
= {q
0
, q
4
, q
6
].
Repeat the construction by considering q
1
and any one of the states q
3
, q
5
, q
7
. The
state q
1
are not 1 -cqui:olcnt to q
3
or q
5
but 1 -cqui:olcntto q
7
. Hence,
3
i
=
{q
1
, q
7
]. The elements left over in
2
0
are q
3
and q
5
. By considering the entries
under u -columnand 1 -column, we see that q
3
and q
5
are 1 -cqui:olcnt.
So
4
i
= {q
3
, q
5
]. Therefore,
n
1
= |{q
2
], {q
0
, q
4
, q
6
], {q
1
, q
7
], {q
3
, q
5
]|
{q
2
]is also in n
2
as it cannot be poitioneu fuithei. Now the entiies unuei
u -column coiiesponuing to q
0
and q
4
areq
1
and q
7
, and these lie in the same
equivalence class in n
1
. The entries under 1 -column are q
5
and q
5
. So q
0
and
q
4
are 2 - cqui:olcnt. But q
0
and q
6
are not 2 - cqui:olcnt. Hence,{q
0
, q
4
, q
6
]
is portioned into {q
0
, q
4
]and {q
6
]. q
1
andq
7
are 2 -cqui:olcnt. q
3
andq
5
are also
2 -cqui:olcnt. Thus,
n
2
= |{q
2
], {q
0
, q
4
], {q
6
], {q
1
, q
7
], {q
3
, q
5
]|
q
0
andq
4
are S -cqui:olcnt. Also, q
3
andq
5
are S -cqui:olcnt. Therefore,
n
3
= |{q
2
], {q
0
, q
4
], {q
6
], {q
1
, q
7
], {q
3
, q
5
]|
As n
2
= n
3
, wheie n
2
gives the equivalence classes, the minimum state
automaton is
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
22

H
i
= (
i
, {u,1], o
i
, q
0
i
, F
i
)
wheie,

i
= {|q
2
], |q
0
, q
4
], |q
6
], |q
1
, q
7
], |q
3
, q
5
]]
q
0
i
= |q
0
, q
4
], F
i
= |q
2
]
anuo
i
is given in table below.
Transition table of minimum state automaton.




The tiansition uiagiam foi the minimum state automaton is given in figuie
below.
| |
4 0
, q q
| |
5 3
, q q
| |
7 1
, q q
| |
2
q
| |
6
q
0
0
0
0
0
1
1
1
1
1

States / L u 1
|q
0
, q
4
]
|q
1
, q
7
]
|q
2
]
|q
3
, q
5
]
|q
6
]
|q
1
, q
7
]
|q
6
]
|q
0
, q
4
]
|q
2
]
|q
6
]
|q
3
, q
5
]
|q
2
]
|q
2
]
|q
6
]
|q
0
, q
4
]
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
23

Alphabets:
An alphabet is an atomic, finite anu nonempty set of symbols. We use the
convention Lfoi analphabet. Foi example,
- 2 = {o, b, , z], set of all lowei case letteis.
- 2 = {u, 1], set of binaiy symbols.
- 2 = {u, 1, 2, , 9], set of numeiic symbols.
- 2 = {u, 1, 2, , 9, o, b, , z], set of alphanumeiic symbols.
Strings:
A stiing is the finite oiueiing of symbols chosen fiom some alphabet L. Foi
example, obc, ocb,bco, obco, aie some of the stiings fiom the alphabet
2 = {o, b, c]. Note that o, b, anu c aie alsothe stiings fiom the alphabet
{o, b, c]. When we wiite o, b, anu c as the elements of L then theseiefeis as
symbols not stiings. The stiings can be usually classifieu by theii length, that
is, thenumbei of occuiiences of the symbols in the stiing. The stanuaiu
uenotation foi the length ofthe stiing xis |x|. Foi example, | obc | = Sanu
| o | = 1.
A stiing of zeio occuiiences of symbols is calleu cmpty stringoi null string.
We uenote itby e(ieau as epsilon) such that |e| = u. Thus, eis a stiing chosen
fiom any alphabet L whatsoevei.
Power of L:
Foi any alphabet L, the powei of Li.e., L
k
wheie k is any positive integei
expiesses the set of allstiings of length k foimeu ovei L. Foi example, let =
{u, 1]then
- L
0
= {e]
- L
1
= {u, 1]
- L
2
= {uu, u1, 1u, 11]
- .
- L
k
= {uuu, u 1, 1u, 11, ], each stiing is of length
k.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
24


The set of all possible stiings ovei L is uenoteu by L
-
, wheie opeiatoi * is
calleu asKleenyclosuie opeiatoi anu the meaning ofL
-
is given by,
L
-
= L
0
U L
1
U L
2
U
Foi example, if L = {u, 1], then using the pievious uefinitions of L
0
, L
1
, L
2
,
we have,
L
-
= {e] U {u, 1], {uu, u1, 1u, 11] U {uuu, uu1, u1u, u11, 1uu, ] U
= {e, u, 1, uu, u1, 1u, 11, uuu, uu1, u1u, u11, 1uu, ]
(this set contains infinite many stiings)
Fiom the set L
-
, if we excluue the empty stiing (e) then we have a set of
nonemptystiings ovei alphabet L.That we uenoteu by L
+
(wheie + is calleu
Positiveclosuie opeiatoi).
Theiefoie,
L
+
= L
-
-{e], i.e.,|L
1
U L
2
U ]
Conveisely, we say L
-
= L
+
U {e]
Languages:
A language is the set of stiings chosen fiom L
-
, foi any alphabet L. If I is the
language ovei Lthen I L L
-
. Bence, language I may contains infinite many
stiings. Since languages aie set ofstiings, thus new languages can be
constiucteu using set opeiations viz., union, inteisections,uiffeience, anu
complement. Foi example, the complement of the language I ovei alphabet
Lis given by
I
i
= L
-
-I,
wheieL
-
contains all possible set of stiings foimeu ovei Lthat we take the
univeisal set.Bence, setI
i
contains all those stiings of L
-
that aie not in the set
I.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
25

A new language can also be constiucteu using concatenation opeiation ovei
stiings. Letx anu y aie two stiings then concatenation of x anu y is the stiing
xy, that is 'string x ollowcJ by string y'. Foi example, let x is the stiing of n
symbols i.e., o
1
o
2
o
3
o
n
anuy is the stiingof m symbols i.e., b
1
b
2
b
3
b
m
,
then xy is the stiing of (n + m) symbols i.e., o
1
o
2
o
3
o
n
b
1
b
2
b
3
b
m
.
Note that concatenation is not commutative, such that xy = yxuntil x = y. 0n
theothei siue concatenation is associative, such that foi any stiings x, y, anu z,
(xy)z = x(yz). Thisallows us to concatenate the stiings without iestiicting
the oiuei in which vaiious concatenationopeiations aie to be peifoimeu.
We can also apply the concatenation opeiation ovei set of stiings calleu
languages. Foiexample, let languages aie I
1
L L
-
anu I
2
L L
-
, then theie
concatenation is I
1
I
2
, i.e.,
I
1
I
2
= {xy | x e I
1
onJ y e I
2
]
Consiuei an example, LetI
1
= {e]anu I
2
= {uu, u1, 1u, 11], then
I
1
I
2
= {e]{uu, u1, 1u, 11] = {e uu, e u1, e 1u, e 11] = {uu, u1, 1u, 11],
i.e.,|e x = x, or ony string x].
- Remembei, concatenation of two null stiings oi language containing
null stiings onlyis a null stiing, i.e.,
e e = e
- If language set I
1
is empty i.e., I
1
= { ]oi , then concatenation of I
1
I
2

will iemainempty foi any language I
2
. Foi example, let I
2
=
{ob, bc, obc], then
I
1
I
2
= {ob, bc, obc] = { ]oi
- If both, I
1
= anu I
2
= , then I
1
I
2
= .
Stiings, by uefinition, aie finite but the language contains infinite numbei of
stiings. Sothe impoitant constiaint of these languages is to specify them in the
ways that aie finite. Foiexample, let L = {o], then
L
-
= I = {e, o, oo, ooo, (infinite many stiings)]. The infinitestiings of the
language I can be equivalently iepiesenteu in a finite way as, I = {o]
-
.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
26

Consiueianothei illustiation, wheie language I = {u, 1]
-
U {o]{b]
-
. Then the
language can be constiucteu,eithei by concatenating an aibitiaiy numbei of
stiings, each is eithei uoi 1, oi byconcatenating the stiing a with an aibitiaiy
numbei of copies of the stiing b. Similaily alanguage I = {u x u | x e
{o, b]
-
]that contains the stiings x anu auu u to each enu wheie x is
anaibitiaiy stiing foimeu using oanu b.
- Since, we have
I
0
= {e],
I
1
= I,
I
2
= II = I
1
I,
I
3
= I
2
I,
.
I
k
= I
k-1
I,
.

ThenI
-
= I
0
U I
1
U I
2
U U I
k
U
0i, I
-
= I
k
k=1

Similaily we uenote I
+
by,
I
+
= I
k
= I I
-
k=1
oi I
-
I
Example:Constiuct a BFA that accepts the stiing having the alphabet pattein
u11.
We constiuct the BFA ovei set of alphabets L = {u, 1] by assuming q
0
is the
initial statethen,

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

1. Fiom the state q
0
onwaius theie must be a consumption of stiing u11
(which isnecessaiy a substiing oi substiing containing pattein founu in
all acceptable stiing).
0 1 1
0
q
1
q
2
q
3
q

2. Any stiing staiting with symbol u followeu by any numbei of us befoie
the patteinu11 is accepteu s.t. {u11, uu11, uuu11, ]. So theie must be a
iepetitive tiansitionaic in the state q
1
on symbol u.
0 1 1
0
q
1
q
2
q
3
q
0

(fiom the state q
1
the last symbol seen was u)
S. Similaily, any stiing staiting with symbol 1 anu followeu by any numbei
of 1s befoiethe pattein u11 is accepteu s.t.
{1u11, 11u11, 111u11, ]. So theie must beiepetitions of symbol 1
on state q
0
.
0 1 1
0
q
1
q
2
q
3
q
1

4. Combining 2 anu S we get the following BFA.
0 1 1
0
q
1
q
2
q
3
q
1 0

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

S. If the stiing containing u1 followeu by pattein u11, then fiom the state
q
2
theie is anaic ietuin to state q
1
on input symbol u, so the automata
ieach to its accepteu stateq
3
aftei ieauing the pattein u11.
0 1 1
0
q
1
q
2
q
3
q
1 0
0

(fiom the state q
2
last two symbol seen weie u1)
6. Aftei the pattein u11 the stiing might contain any numbei of us oianu
1s, foi thattheie is a iepetitive aic on state q
3
ovei symbol u oi 1.
(Figuie shownbelow)
0 1 1
0
q
1
q
2
q
3
q
1 0
0
1 , 0

In this automaton we obseiveu that theie is one anu only one exit on each
symbol fiomeach state. Bue to this fact automaton is Beteiministic.
Finally, the BFAH = ({q
0
, q
1
, q
2
, q
3
], {u, 1], o, q
0
, {q
3
]); wheie o'saie shown
in thetiansition table:






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

Transition table.





Example:uive a BFA that accepts the language ovei alphabet o anu the
stiing containszeiomultiples of 4 o's. 0i,
Constiuct the BFA that accepts the stiings of the set
{e, oooo, oooooooo, ].
Let H be a BFA anu {q
0
] is the initial state.
1. If fiist symbol is null stiing (e) then initial state (q
0
) is the final state also
so state uiagiam will be,
0
q

2. Fiom the state q
0
onwaius theie is a consumption of 4consecutiveos
followeu by nonemoie such sets of os, i.e.,
0
q
1
q
2
q
3
q
a
a a a

So the final BFAH = ({q
0
, q
1
, q
2
, q
3
], {o], o, q
0
, {q
0
]) shown in Figuie above;
anu the tiansition function o is given in the tiansition table below.


States Input symbol
0 1
q
1

q
2

q
3

q
0
q
1

q
1

q
1

q
3

q
0

q
2

q
3

q
3

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

Transition table.
States Input symbol
o
q
0

q
1

q
2

q
3
q
1
q
2

q
3
q
0

6 -head u a DFA:
Insteau of uefining the behavioi of tiansition function ovei a single symbol
(alphabet), whichis a mapping of a state with a input symbol anu ietuins a
state i.e., o: S - , it is alsoiequiieu to know the behavioi of the
tiansition function ovei an aibitiaiy stiing (s.t. automatanot only ieau a
single symbol but a sequence of symbols oi stiing)) such
chaiacteiisticsincluue in the uefinition of -heau.
Definition:
Assume, if a stiing is uefineu ovei set of alphabet Lthen set of possible stiing
is in L
-
, then -heauis uefineu as:

`
Q
-
- Q
oi we say that -heau is the tiansition function that map a state( Q) with a
stiing ( L
-
) anuietuins a state ( Q).
Let automata H is in state q, aftei ieauing the stiing xautomaton ieaches to
state p. So, the behavioi of -heauovei stiingx is given as,
o
`
(q, x) = p
wheiex is a stiing might be of single alphabet.
Properties of 6 -head of a DFA:
Fiom any state q,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
31

1. If input stiing is a null stiing (e) then automaton state iemains
unchangeu i.e.,
o
`
(q, e) = q , v q e
If the stiing is of single symbol stiing oi of length one then - heau anu
oaie same i.e.,assume stiing x = o then,
o
`
(q, x) = o(q, o) = p

2. If stiing is not of single symbol stiing then assume stiing x is foimeu by
alphabet oanu substiingy, i.e., x = oy, then
o
`
(q, o, y) = o
`
(o(q, o), y)

Foi example if x = 1u11 then o = 1 anu iemaining stiing = u11.
Beie o(q, o) = p anu assume that aftei ieauing the iemaining substiing y
automataieaches to state rtheno
`
(q, x) = r.
Example: A BFAH = ({q
0
, q
1
], {o], o, q
0
, {q
1
]) has following tiansition
chaiacteiistics:
0
q
1
q
a
a

Check behavioi of the BFA ovei stiing ooo.
Assume autometei is in initial state {q
0
]. Now check the behavioui of BFAH
ovei thestiing ooo, i.e.,
o
`
(q
0
, ooo) = o
`
(o(q
0
, o), oo)
= o
`
(q
1
, oo)
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
32

= o
`
(o(q
1
, o), o)
= o
`
(q
0
, o)
= o
`
(q
0
, o e)
= o
`
(o(q
0
, o), e)
= o
`
(q
1
, e)
= {q
1
]
Since state (q
1
) is an accepteu state, theiefoie stiing ooo is accepteu by
BFAH.
Example:Constiuct the BFA accepting the set of stiing having both ouu
numbei of osanu bs.
The following BFAH accepts ouu no. of osanu bs, wheie,
H = ({q
0
, q
1
, q
2
, q
3
], {o, b], o, q
0
, {q
2
])anu tiansition function shown in the
tiansitiontable below.
Transition table.
States Input symbol
o b
q
0

q
1

q
2

q
3
q
1
q
0

q
3

q
2

q
3

q
2
q
1

q
1


Now we uefine the moves of BFA ovei the stiing oboobb (ouu numbei of os
anu bs both)which must be acceptable oi aftei ieauing the whole stiing
automata ieaches to the final state{q
2
].
So, computeo
`
(q
0
, oboobb):
1. o
`
(q
0
, oboobb) = o
`
(o(q
0
, o), boobb)
= o
`
(q
1
, boobb )
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
33

2. o
`
(q
1
, boobb ) = o
`
(o(q
1
, b), oobb)
= o
`
(q
2
, oobb )
S. o
`
(q
2
, oobb ) = o
`
(o(q
2
, o), obb)
= o
`
(q
3
, obb )
4. o
`
(q
3
, obb ) = o
`
(o(q
3
, o), bb)
= o
`
(q
2
, bb )
S. o
`
(q
2
, bb ) = o
`
(o(q
2
, b), b)
= o
`
(q
1
, b )
6. o
`
(q
1
, b ) = o
`
(q
1
, b e ) = o
`
(o(q
1
, b), e)
= o
`
(q
2
, e )
7. o
`
(q
2
, e ) = o(q, e)
= {q
2
]
wheie{q
2
] is the accepteu state of BFAH.
Language of a DFA:
Aftei knowing the behavioi of the automata ovei an aibitiaiy stiing anu
finally ovei the set ofstiing we can easily uefine the language of a BFA. Let
automata H be a BFA then languageaccepteu by H is I
M
wheie,
I
M
= |x | x e
-
onJ o
`
(q
0
, x) e F|
Alteinatively, we say that any aibitiaiy stiing x fiom the set L
-
will be the
language ofBFAH if fiom initial state aftei ieauing the complete stiing x it
ieaches to final state. Now wesee that if Lis the set of alphabet then set of all
possible stiing foimeu ovei Lis L
-
. In the setL
-
theie exists two possible class
of languages, i.e.,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
34

wheieI
M
contains those set of stiings that aie accepteu by automaton H, anu
iemainingstiing (2
-
I
M
) aie those that aie uiscaiueu oi iejecteu by H.
Bence, I
M
anu2
-
I
M
aie twouisjoint sets which nevei meet with iefeience
to a paiticulai automaton H, i.e.,
I
M
r (2
-
I
M
) =
Note: Set I
M
contains infinitely many stiings oi a language of a BFA contains
infinite numbei ofstiings but an automaton has a finite amount of space that
is only available space to allocate to finite oiinfinitely long stiings. Bence,
theie is a mechanism useu to uesciibe an infinitely long stiing into a finite
numbei of symbols.
6 -head u a NDFA:
Like -heau of BFA, -heau of NBFA uefines the behavioi of the tiansition
function ovei anaibitiaiy stiing. Assume that if the stiing is uefineu ovei
alphabetL, then set of all possiblestiings aie L
-
. The -heau is uefineu as,
o
`
: L
-
- P()
Thus, -heau is the tiansition function which is a mapping of a state
(e )anu a stiingof input symbols (e L
-
) to powei set of oi P().
Properties of 6 -head of a NDFA:
Fiom any state q, the behavioi of -heau ovei stiing x is ueteimineu as
follows:
1. If x is a null stiing (e) then,
o
`
(q, e) = {q];
such that if input symbol is a null stiing then state iemains unchangeu.
2. If stiing x is composeu of twomoie symbols, then uecompose stiing x
into substiingy anu a single symbol o such that, x = yothen,
o
`
(q, x) = o
`
(q, yo);
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
35


= o(o
`
(q, y), o)
Fuithei, assume that o
`
(q, y) = {p
1
, p
2
, p
3
, , p

], that is, fiom the state


q NBFAmight be ieaches to these possible states aftei consuming the stiing
y, that is shown in figuie below,

q
y
y
y
1
p
2
p
i
p
a
a
a
1
r
2
r
j
r

Thus, o(o
`
(q, y), o) = o({p
1
, p
2
, p
3
, , p

], o);
= o(p
1
, o) U o(p
2
, o) U o(p
3
, o) U U o(p

, o)
= _o(p
k
, o)

k=1

= |r
1
, r
2
, , r
]
|
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
36

Example:Consider a NBFAshown in figuie below. Check its natuie of
acceptance ovei the stiing 1u11u1.
0 1 1
0
q
1
q
2
q
3
q
1 , 0
1 , 0

The above NBFA can be uefineu as,
N = ({q
0
, q
1
, q
2
, q
3
], {u, 1], o, q
0
, {q
3
]);
wheieos aie shown in the following tiansition table,
Transition table.
States Input symbol
u 1
q
0

q
1

q
2

q
3
|q
0
, q
1
]


q
3

q
0
q
2

q
3

q
3


Then we check the behavioi of N ovei the stiing 1u11u1, fiom the staiting
state q
0
.
1. o
`
(q
0
, 1u11u1) = o
`
(o(q
0
, 1), u11u1)
= o
`
(q
0
, u11u1)
2. o
`
(q
0
, u11u1) = o
`
(o(q
0
, u), 11u1)
= o
`
({q
0
, q
1
], 11u1)
S. o
`
({q
0
, q
1
], 11u1) = o
`
(q
0
, 11u1) U o
`
(q
1
, 11u1)
4. o
`
(q
0
, 11u1) = o
`
(o(q
0
, 1), 1u1)
= o
`
(q
0
, 1u1)
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
37

S. o
`
(q
0
, 1u1) = o
`
(o(q
0
, 1), u1)
= o
`
(q
0
, u1)
6. o
`
(q
0
, u1) = o
`
(o(q
0
, u), 1)
= o
`
({q
0
, q
1
], 1)
7. o
`
({q
0
, q
1
], 1) = o
`
({q
0
, q
1
], 1 e)
= o
`
(q
0
, 1 e) U o
`
(q
1
, 1 e)
= o
`
(o(q
0
, 1), e) U o
`
(o(q
1
, 1), e)
= o
`
(q
0
, e) U o
`
(q
2
, e)
= q
0
U q
2

= {q
0
, q
2
]
So we finu none of these states is an acceptable state.
8. o
`
(q
1
, 11u1) = o
`
(o(q
1
, 1), 1u1)
= o
`
(q
2
, 1u1)
9. o
`
(q
2
, 1u1) = o
`
(o(q
2
, 1), u1)
= o
`
(q
3
, u1)
1u. o
`
(q
3
, u1) = o
`
(o(q
3
, u), 1)
= o
`
(q
3
, 1)
11. o
`
(q
3
, 1) = o
`
(q
3
, 1 e)
= o
`
(o(q
3
, 1), e)
= o
`
(q
3
, e)
= q
3
; (which is an acceptable state)
Bence, NBFAwill move ovei the stiing 1u11u1 accoiuing to following paths,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
38

0
q
0
q
0
q
0
q
0
q
0
q
0
q
1
q
1
q
2
q
3
q
3
q
3
q
2
q
1
1
1
1
1 1
1
1
0 0
0
0
0

Theiefoie, the only acceptable path fiom staiting state q
0
is shown by uaik
line. Alongto this path NBFA ieaches to the acceptable state q
3
at the enu of
the stiing 1u11u1.
Language of a NDFA:
Aftei ueteimining the behavioi of the NBFA ovei an aibitiaiy stiing, we can
easily uefine thelanguage of a NBFA. Let N be a NBFA i.e., N = (, 2, o, q
0
, F),
then language accepteu by NBFA isI
N
, wheie,
I
N
= |x | x e 2
-
onJo
`
(q
0
, x) e P() s. t. o
`
(q
0
, x) r F = |
It means, language I
N
contains an aibitiaiy stiing x, chosen fiom the set of
possiblestiings L
-
such that NBFA, aftei ieauing the stiing x (fiom the initial
state q
0
) ieaches to thestate that is in powei set of , such that its ielation
with set F is not uisjoint. That is, at leastone state is common between set
Fanu P().
Example: Consider a NBFA shown in figuie below, anu uefineu as
N = ({q
0
, q
1
, q
2
, q
3
], {u, 1], o, q
0
, q
3
). Test the stiing 1u1u1which is not in the
language ofN.



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

0 1 1
0
q
1
q
2
q
3
q
1 , 0
1 , 0

Assign stiing 1u1u1 to x, if x is a language of N (wheie x e 2
-
, i.e., L = {u, 1]),
then afteiieauing the stiing x, NBFA ieaches to its final state, i.e. any state
that belongs to the poweiset of which contains the final state q
3
. Now we
can constiuct the moves of NBFA ovei thestiing x = 1u1u1, that is shown in
figuie below.

0
q
0
q
0
q
0
q
0
q
0
q
1
q
1
q
2
q
2
q
1
1
1 1 1 0 0
0
0
u
0


Since, o
`
(q
0
, 1u1u1) = oi q
0
oi q
2
, so none of the set contains state q
3
. Bence,
o
`
(q
0
, 1u1u1) r q
3
= . It concluues that stiing 1u1u1 is not accepteu by
NBFAN.





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

Finite Automata with s Moves:
We have seen so fai that a finite automaton of eithei ueteiministic oi
nonueteiministic whichchanges theii state tiansitions only ovei known input
symbols. Expeiience shows that theiemight be a neeu of state tiansitions
ovei no input symbol. It means, theie aie few states in thefinite automaton
such that it skips between these states without consumption of any
inputsymbol. Foi this puipose, we intiouuce a new symbol epsilon (e) that
has a uimension anu ofzeio length, which is also calleu a null stiing.
Now we will uiscuss the natuie of finite automata specifically, ovei null stiing
(e). Sinceautomata changes theii states ovei null stiing so these tiansitions
occuis ovei no symbol. Inothei woius, automata skip between states
spontaneously. Foi example, automata is instate q anu its state changes to q
ovei symbol e.
q p
c

So it shows a spontaneous tiansition of state fiom state q to state p known as
e - tronsition.This chaiacteiistic pioviues auuitional flexibility to the finite
automaton. Bence, a finiteautomaton with emoves is moie poweiful than
eithei fiom Nonueteiministic oi ueteiministicfinite automata.
Non Deterministic Finite Automata (NDFA) with s moves:
A non ueteiministic finite automaton with e -mo:cs is an extension of
NBFA. When some of thetiansitions in the NBFA aie e -tronsitionssuch
that, theie aie few tiansitions of NBFA aie uefineuovei null stiing then
NBFA is calleu NBFAwithe -mo:cs. It pioviues auuitional flexibility to
theNBFA so that automaton skips between states spontaneously. Let N
s
be an
NBFAwith e -mo:cs,whose tuples uefinition is given as,
N
s
= (, 2, o
s
, q
0
, F)
wheie, L, q
0
onJ F holus similai meaning as an NBFA anu the tiansition
function oisuefineu as follows,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
41

o
s
: (X U {e]) - P()
wheie, o
s
is the paitial mapping of a state with an input symbol incluuing
ethat ietuins to thestate that aie in the powei set of . As we saiu eailiei, the
tiansitions ovei eaie also knownas e -tronsitions.
Foi example, a NBFA with e -mo:cs is shown in figuie below, wheie set of
states = {q
1
, q
2
, q
3
]anu set of alphabet L = {u, 1, 2]. The tiansition
functions aie shown in the tiansition table below.

0
q
1
q
2
q
0 1
2
c c

aNDFAwiths - muves.
States

Input symbols
e u 1 2
- q
0
q
1
q
0

q
1
q
2
q
1

q
2
q
2

6
s
-head:
As we uiscusseu pieviously that tiansition function o
s
gives the behavioi of a
NBFAwith e - mo:cs ovei a single symbol incluuing a null stiing (e).
Wheieas, o
s
-heaushows the natuie ofNBFA with e - mo:cs ovei a stiing.
We will now uiscuss the iole of o
s
-heau ovei vaiious possiblestiings, i.e.,
- If stiing is a null stiing (e)then,

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

o
s
(q, e) = {q] U _
Sct o oll tbosc stotcs tbot con bc rcocbcJ rom
stotc q Jircctly or inJircctly olong ony potb
wbosc tronsitions orc e - tronsitions
_
which is also calleu as e -closurc (q);
Foi example, consiuei the NBFA with e -mo:csin the pievious example, so
we can finu,
e -closurc (q
0
) = {q
0
] U {q
1
, q
2
]
= {q
0
, q
1
, q
2
];
Similaily, e -closurc (q
1
) = {q
1
] U {q
2
]
= {q
1
, q
2
];
anu, e -closurc (q
2
) = {q
2
] U {]
= {q
2
];
- Assume a stiing x i. c., x = e, then fuithei assume that stiing x is foim by a
substiingy anu a symbol o, i. c. , x = y . o, then
o
`
s
(q, x) = o
`
s
(q, y o) = o
s
(o
`
s
(q, y), o);
oi,
o
`
s
(q, x) = e -closurc |o
s
(o
`
s
(q, y), o)];
Thus, in geneial ifp is the set of states, then
e -closurc (p) = _ e -closurc (q)
v q c p

If stiing contains a single symbol o, then
o
s
(p, o) = _ o
s
(q, o)
v q c p

Similaily foi a stiing x,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
43

o
s
(p, x) = _ o
`
s
(q, o)
v q c p

If stiing contains a single symbol o then,
o
`
s
(q, o) = o
`
s
(q, e o) = o
s
(o
`
s
(q, e), o)
= e -closurc |o
s
(o
`
s
(q, e), o)]
Foi the NBFA with e -mo:cs shown in the pievious example, o
`
s
(q
0
, u)can be
computeu as follows,
o
`
s
(q
0
, u) = o
`
s
(q
0
, e u)
= o
s
(o
`
s
(q
0
, e), u)
= e - closurc |o
s
({q
0
, q
1
, q
2
], u)]
= e - closurc |o
s
(q
0
, u) U o
s
(q
1
, u) U o
s
(q
2
, u)]
= e - closurc |{q
0
] U U ]
= e - closurc |{q
0
]]
= {q
0
, q
1
, q
2
]; |computeu pieviously]
Note:
- If we compaie the iesult obtaineu by o
s
anu o
`
s
on same symbol we finu
that, o
s
(q
0
, u) = {q
0
] = o
`
s
(q
0
, u)anu o
`
s
(q
0
, u) = {q
0
, q
1
, q
2
] so both aie
uiffeient. Bence, we concluue that, o
s
(q
0
, u) = o
`
s
(q
0
, u).
- Assume that,
o
`
s
(q, y) = {p
1
, p
2
, , p
k
] U paths that may enu with one oi moie
e - tronsitions fiom p

(or i = 1 to k)
Let,
_ 6
s
(p
|
, a) = {r
1
, r
2
, , r
m
]
v q e p
U |thuse states that an reah Irum r
j
by s -transtttun|
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
44

then,
o
`
s
(q, x) = _ e -closurc(r
]
)
m
v ]=1

Bence, o
`
s
(q, x) = e -closurc |o
s
(o
`
s
(q, y), o)]

Similaily we can compute o
`
s
(q
0
, 1) as,
o
`
s
(q
0
, 1) = o
`
s
(q
0
, e 1)
= o
s
(o
`
s
(q
0
, e), 1)
= e - closurc |o
s
({q
0
, q
1
, q
2
], 1)]
= e -closurc |o
s
(q
0
, 1) U o
s
(q
1
, 1) U o
s
(q
2
, 1)]
= e -closurc |U {q
1
] U ]
= e -closurc |{q
1
]]
= {q
1
, q
2
]; |computeu as pieviously]
Language of NDFA with s -muves:
In the pievious section we have uefineu so fai the natuie of an NBFA with
e - mo:cs ovei anaibitiaiy stiing. Collection of all those stiings ovei which
NBFAwith e -mo:cs ieaches to itsfinal state will be in its language set. Let
I
Ns
uenotes the language of NBFA with e - mo:cs,wheie I
Ns
is uefineu as,
I
Ns
= |x | x e 2
-
onJ o
`
s
(q
0
, x) r F = |
Alteinatively foi an stiing x, which is foimeu ovei alphabet Lwill be in the
language such thatwhile accepting the stiing x automaton is in the
e - closurc of states ietuineu by o
`
s
whoseinteisection with the set of final
states F will not be empty. Alteinatively, o
`
s
-bcoJ ovei xietuins at least one
accepting state that is in final set of state F.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
45

Method of Conversion from NDFA with s -muves to NDFA:
Theorem: If N
s
be a NBFAwith e - mo:cs, then theie exists a NBFAN
(without e -mo:cs) i.e.,I
Ns
= I
N
(wheie I
Ns
is the language of N
s
anu I
N
is
the language of N).
Example:Consiuei the N
s
that is shown in figuie below, heie
s
= {q
0
, q
1
, q
2
],
L = {u, 1, 2], F
s
= {q
2
]anu o is given as follows:

0
q
1
q
2
q
0 1
2
c c

The uefinition of tiansition functions ofoi NBFA (ovei each symbol of L)
covei all theuefinition of tiansition functions o
s
foi NBFA with e -mo:cs
incluuing e -tronsitions. Since,e - tronsitions cannot be the pait of ofoi
NBFA; hence all e -tronsitions aics can be ieplaceu byeithei of the symbol
of L. This is because, the flexibility of spontaneous skip between e -
tronsitionstates ovei no symbol (e). Foi example,
o
`
s
(q
0
, u) = o
`
s
(q
0
, e u)
= o
s
(o
`
s
(q
0
, e), u)
= e - closurc |o
`
s
({q
0
, q
1
, q
2
], u)]
= e -closurc |o
s
(q
0
, u) U o
s
(q
1
, u) U o
s
(q
2
, u)]
= e -closurc |{q
0
] U U ]
= e -closurc |{q
0
]]
= {q
0
, q
1
, q
2
]; |computeu as pieviously]
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
46

Bence, we say that on symbol u the state of the automaton will be eithei {q
0
]
oi {q
1
] oi{q
2
]. That is the iequiiement of the NBFA. So, tiansition function
ofoi NBFA is given as,
o(q
0
, u) = o
`
s
(q
0
, u)
In geneial foi any input symbol o e L, we have
o(q
0
, o) = o
`
s
(q
0
, o)
It states that the behavioi of both automatons N
s
anu N aie same on same
input symbol.Bence, It concluues that in geneial if I
Ns
is the language of a
N
s
then language of a NBFAN is also I
N
i.e.,
I
N
= I
Ns

Bence,
o(q
0
, u) = o
`
s
(q
0
, u) = {q
0
, q
1
, q
2
]
Similaily
o(q
0
, 1) = o
`
s
(q
0
, 1) = {q
1
, q
2
]
o(q
0
, 2) = o
`
s
(q
0
, 2) = {q
2
]
anu so on.
Theiefoie, the tiansition table foi the given NBFA will be looks like,
aNDFA transition table.
States

Input symbols
u 1 2
- q
0
{q
0
, q
1
, q
2
] {q
1
, q
2
] q
2
q
1
{q
1
, q
2
] q
2
q
2
q
2

The tiansition uiagiam foi NBFA is shown in figuie below.

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


0
q
1
q
2
q
0
1
2
1 , 0
2 , 1
2 , 1 , 0

Equivalence of NDFAwith s -muves to DFA:
We have seen that automaton NBFAwith e -mo:cs is an extension of an
NBFA (in teims offlexibility). Since, in the pievious sections, we have seen
the equivalence betweenNBFAwith e -mo:cs anu NBFA anu the
equivalence between NBFAanu BFA. Theiefoie, it concluues that, theie exists
an equivalence between NBFAwith e -mo:cs anu the BFA a static natuie of
finite automata. This equivalence is shown in figuie below.

( )

N
moves NDFA with
(N) NDFA
(M) DFA

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

Let N
s
= (
s
, 2, o
s
, {q
0
]
s
, F
s
), then constiuct an equivalent BFAH wheie H is
uefineuas,H = (, 2, o
s
, q
0
, F).
Now the ielationship between coiiesponuing tuples aie as follows,
- L P(
s
) .
- Both automatons opeiate on same set of alphabet L.
- Staiting state of BFA which is q
0
= e -closurc {q
0
]
s
. So, staiting state
of BFA will bethe set of state containing state {q
0
]
s
.
- Set of final state F L , i.e. F r F
s
= .
- Now we compute the tiansition functions ofoi BFA ovei input symbol
o (or v o e 2)as,
Let R = {q
1
, q
2
, , q

]anu o(q
]
, o)

v ]=1
= {p
1
, p
2
, , p
k
]
Then, o(R, o) =U e -closurc ({p
1
, p
2
, , p
k
]).
Example: Constiuct a BFA fiom given NBFA (as shown in figuie below.)
0
q
1
q
2
q
0 1
2
c c

Foi the given NBFA with e -mo:cs we assume that equivalent BFAH =
(, 2, o, q
0
, F)whose tuples aie ueteimine as,
- L |, q
0
, q
1
, q
2
, {q
0
, q
1
], {q
0
, q
2
], {q
1
, q
2
], {q
0
, q
1
, q
2
]]which is a powei
set of
s
.
- L = {u, 1, 2].
- Staiting state of BFA is q
0
wheie, q
0
= e -closurc (q
0
) = {q
0
, q
1
, q
2
].
- All states of the set that contains q
2
as one of the state aie consiueieu
as finalstates.
- The tiansition functions of BFA aie ueteimine as follows,
Since staiting state is {q
0
, q
1
, q
2
] hence,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
49

o({q
0
, q
1
, q
2
], u) = o(o
`
({q
0
, q
1
, q
2
], e), u)
= e -closurc jo
s
[o
`
s
(q
0
, e) U o
`
s
(q
1
, e) U o
`
s
(q
2
, e) , u[
= e -closurc |o({q
0
, q
1
, q
2
] U {q
1
, q
2
] U q
2
), u]
= e -closurc |o({q
0
, q
1
, q
2
]), u]
= e -closurc |o(q
0
, u) U o(q
1
, u) U o(q
2
, u)]
= e -closurc |q
0
U U ]
= e -closurc |q
0
]
= {q
0
, q
1
, q
2
] A
anuo({q
0
, q
1
, q
2
], 1) = e -closurc |o(q
0
, 1) U o(q
1
, 1) U o(q
2
, 1)]
= e -closurc |U q
1
U ]
= e -closurc |q
1
]
= {q
1
, q
2
] B
anuo({q
0
, q
1
, q
2
], 2) = e -closurc |o(q
0
, 2) U o(q
1
, 2) U o(q
2
, 2)]
= e - closurc |U U q
2
]
= e -closurc |q
2
]
= q
2
C
Now compute tiansitions fiom new state {q
1
, q
2
] anu q
2
as,
o({q
1
, q
2
], u) = o(o
`
({q
1
, q
2
], e), u)
= e -closurc jo [o
`
(q
1
, e) U o
`
(q
2
, e) , u[
= e -closurc |o({q
1
, q
2
] U q
2
, u)]
= e -closurc |o({q
1
, q
2
], u)]
= e -closurc |o(q
1
, u) U o(q
2
, u)]
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
50

= e -closurc |U ]
=
o({q
1
, q
2
], 1) = e -closurc |o({q
1
, q
2
], 1)]
= e -closurc |o(q
1
, 1) U o(q
2
, 1)]
= e -closurc |q
1
U ]
= e -closurc |q
1
]
= {q
1
, q
2
] B
o({q
1
, q
2
], 2) = e -closurc |o({q
1
, q
2
], 2)]
= e -closurc |o(q
1
, 2) U o(q
2
, 2)]
= e - closurc |U q
2
]
= e -closurc |q
2
]
= q
2
C
Now compute tiansitions fiom the state q
2
.
o(q
2
, u) = o(o
`
(q
2
, e), u)
= e -closurc |o(q
2
, u)]
= e -closurc |]
=
o(q
2
, 1) = o(o
`
(q
2
, e), 1)
= e -closurc |o(q
2
, 1)]
= e -closurc |]
=
o(q
2
, 2) = o(o
`
(q
2
, e), 2)
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
51

= e -closurc |o(q
2
, 2)]
= e -closurc |q
2
]
= q
2
C
Fuithei we havent got any new state so pioceuuie stops anu we obtain
the tiansitionuiagiam of BFA that is shown in figuie below.

A
B
C u
0 1
2
1 , 0
2 , 1 , 0
1
2 2 0

Example: Constiuct an equivalent BFA foi given NBFA with e -mo:cs
(shown in figuie below.)
A B
0
1
0
C
D
c c
0

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

Let equivalent BFAH = (, 2, o, q
0
, F). So the tuples of H aie obtain
accoiuing as,
- L |4, A, B, C, D, {AB], {AC], {AD], {BC], {BD], {CD], {ABC], {ABD], {BCD], {ACD], {ABCD]]
which is a powei set of
s
.
- L = {u, 1].
- Staiting state of BFA is the e -closurc (A)which is equal to {A, B, ].
- All states of the set that contain {] as one of the state aie consiueieu
as finalstates of BFA.
- Tiansition functions of BFA aie as follows:
Finu the e - closurc of all the states, i.e., A, B, C, anu , i.e.,
e - closurc (A) = {A, B, ];
e - closurc (B) = {B, ];
e - closurc (C) = {C];
e - closurc () = {];
Since, Staiting state is {A, B, ]; so finu oovei Lfiom this state onwaius,
o({A, B, ], u) = o({A, B, ], e u)
= e -closurc jo [o
`
(A, e) U o
`
(B, e) U o
`
(, e) , u[
= e -closurc jo [o
`
(A, e) U o
`
(B, e) U o
`
(, e) , u[
= e -closurc |o({A, B, ] U {B, ] U {]), u]
= e -closurc |o({A, B, ]), u]
= e -closurc |o(A, u) U o(B, u) U o(, u)]
= e -closurc |A U C U ]
= e -closurc (A) U e -closurc (C) U e - closurc ()
= {A, B, ] U C U
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
53

={A, B, C, ]; new state
o({A, B, ], 1) = e -closurc |o(A, 1) U o(B, 1) U o(, 1)]
= e - closurc |U U ]
= e -closurc ()
= ;
o({A, B, C, ], u) = e -closurc |o({A, B, C, ], u)]
= e -closurc |o(A, u) U o(B, u) U o(C, u) U o(, u)]
= e -closurc |A U C U U B]
= e -closurc (A) U e -closurc (C) U e - closurc ()
= {A, B, ] U C U
={A, B, C, ]; aiepeateu state
o({A, B, C, ], 1) = e -closurc |o({A, B, C, ], 1)]
= e -closurc |o(A, 1) U o(B, 1) U o(C, 1) U o(, 1)]
= e -closurc |U U B U ]
= e -closurc (B)
= { B, ]; a new state
o({B, ], u) = e -closurc |o({B, ], u)]
= e -closurc |o(B, u) U o(, u)]
= e -closurc |C U B]
= e -closurc (C) U e -closurc ()
= { C, ]; a new state
o({B, ], 1) = e -closurc |o({B, ], 1)]
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
54

= e -closurc |o(B, 1) U o(, 1)]
= e -closurc |U ]
= e -closurc ()
= ;
o({C, ], u) = e -closurc |o({C, ], u)]
= e - closurc |o(C, u) U o(, u)]
= e -closurc |U B]
= e -closurc ()
= ; a new state
o({C, ], 1) = e -closurc |o({C, ], 1)]
= e - closurc |o(C, 1) U o(, 1)]
= e -closurc |B U ]
= e -closurc (B)
= {B, ]; a iepeateu state
o(, u) = e -closurc |o(, u)]
= e -closurc ()
= ; a new state
o(, 1) = e -closurc |o(, 1)]
= e -closurc ()
= ;

Fuithei theie is no new state geneiateu so we stop the piocess anu finally we
obtain theBFA shown in figuie below.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
55

ABD
ABCD
BD
CD
D u
0
0
0
0
0
1
1 , 0
1
1
1
1

Note: The natuie of the state is such that, when automaton ieaches to this
state then it willuisappeai oi it nevei ietuins back.








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

Regular Expressions
Introduction to Regular Expressions:
In the pievious lectuies we have stuuieu that the powei of a finite automaton
is given by thelanguage it accepts, that contains finite oi infinite many stiings.
So, is theie any convenientway to expiess these set of stiings. In the next
lectuies we shall focus oui attention to the uesciiptionof a language by an
algebiaic expiession calleu as iegulai expiession. The opeiationsuseu in the
foimation of iegulai expiessions aie union, concatenation, anu Kleeny
closuie.The language geneiateu by a iegulai expiession is calleu iegulai
language. Regulai expiessionsaie capable to uefining all anu only the iegulai
languages. The significance of the symbolsuseu to iepiesent the iegulai
expiession is uiffeient than the symbol useu to specify thestiings. So, we use
bolu symbols in iepiesenting the iegulai expiessions while foi the stiingwe
uses the symbols as usual.Regulai language is the language uepicteu
(expiesseu) by the iegulai expiession.
Definition of Regular Expression:
In aiithmetic, we can use the opeiations + anu to builu up expiessions
such as (S + S) 4 . Similaily, we can use the iegulai opeiations to builu
up expiessions uesciibing languages, which aie calleu iegulai expiessions.
An example is: (u U 1)u
-
. The value of the aiithmetic expiession is the
numbei S2. The value of a iegulai expiession is a language. In this case the
value is the language consisting of all stiings staiting with a u oi a 1 followeu
by any numbei of us. We get this iesult by uissecting the expiession into its
paits. Fiist, the symbols u anu 1 aie shoithanu foi the sets {u]anu {1]. So
(u U 1)means ({u] U {1]). The value of this pait is the language {u,1]. The
pait u
-
means {u]
-
, anu its value is the language consisting of all stiings
containing any numbei of us. Seconu, like the symbol in algebia, the
concatenation symbol () often is implicit in iegulai expiessions.
Thus (u U 1)u
-
actually is shoithanu foi (u U 1) u
-
. The concatenation
attaches the stiings fiom the two paits to obtain the value of the entiie
expiession.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
57

Regulai expiessions have an impoitant iole in computei science applications.
In applications involving text, useis may want to seaich foi stiings that
satisfy ceitain patteins. Regulai expiessions pioviue a poweiful methou foi
uesciibing such patteins.
Assume the set of alphabets S = {o
1
, o
2
, o
3
, , o
n
], anu r be a iegulai
expiessionuefineu ovei L anu let the language geneiateu by the iegulai
expiession r be I(r), then thebasis iegulai expiessions aie,
1. o

is the iegulai expiession coiiesponuing to the symbol o

e foi
v i = 1 to n. Thelanguage geneiateu by iegulai expiession o

will be
I(o

) i.e., (o

) = {o

], foi v i = 1 to n .
2. e is a iegulai expiession coiiesponuing to the null stiing (e), anu the
language geneiateu by the iegulai expiession e will be I(e) i.e.,
I(e) = {e]
S. is the iegulai expiession coiiesponuing to the nonexistence of any
input symbol anu the language geneiateu by the iegulai expiession
will be I() i.e.,
I() =
Above uefinition of iegulai expiession can be extenueu fuithei by
uefining its behavioiovei set of opeiatois union (+), concatenation
(), anu Kleeny closuie (-) i.e.,
4. If r
1
anu r
2
aie two iegulai expiessions, anu theii languages aie I(r
1
)
anu I(r
2
) iespectively, then (r
1
+r
2
) will also be a iegulai expiession
anu it geneiates thelanguage (r
1
) U I(r
2
). This piopeity of iegulai
expiession is known as auuitionpiopeity of iegulai expiessions.
S. If r
1
anu r
2
aie two iegulai expiessions, anu theii languages aie I(r
1
)
anu I(r
2
) iespectively, then (r
1
r
2
) will also be a iegulai expiession
anu it geneiates thelanguage I(r
1
) I(r
2
). This piopeity of iegulai
expiession is known as concatenation piopeity of iegulai
expiessions.
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
58

6. If r be a iegulai expiession, anu its language is I(r), then r
-
will also
be a iegulai expiession anu it uenotes the language I(r
-
) oi I(r)
-
.
This piopeity of iegulaiexpiession is calleu Kleeny closuie piopeity
of iegulai expiession wheie, I(r
-
) is Kleeny closuie of language I,
i.e.,
Let I(r
-
) = I
-

then
I
-
= _I

v >0
= I
0
U I
1
U I
2
U U I

U I
+1
U
wheie I
0
= {e] |language contains null stiing]
I
1
= I I
0
= I {e] = I
I
2
= I I
1

I
3
= I I
2

.
I

= I I
-1

.
Foi example, if o is the iegulai expiession then its language will be
given by I(o)wheie, I(o) = {o] then,
I(o)
-
= {e, o, oo, ooo, , ]
7. Nothing else is iegulai expiession.
In the uefinition of iegulai expiession we have uiscusseu the natuie
of iegulai expiessionovei following opeiatois i.e.,
- + (auuition) oi U(union)
- (Concatenation), anu
- -(Kleeny closuie)
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
59

So foi the stuuy of iegulai expiessions ovei these opeiatois anu the
language geneiateuby these composite iegulai expiessions, the
pieceuence of opeiatois is impoitant, i.e., -, , + is the sequence of
pieceuence fiom highei to lowei.

Example: Let I
1
= {uu, 1u] anu I
2
= {u, 1, uu] then auuition of two
languages is, I
1
U I
2
= {u, 1, uu, 1u]
If I
1
i
= {e, uu, 1u] then its auuition with language L
2
will be,
I
1
i
U I
2
= {e, u, 1, uu, 1u]
The concatenation of I
1
anu I
2
is given as,
I
1
I
2
= {uuu, uu1, uuuu, 1uu, 1u1, 1uuu] anu concatenation with I
1
i
is,
I
1
i
I
2
= {u, 1, uu, uuu, uu1, uuuu, 1uu, 1u1, 1uuu] .
Example:
In the following instances we assume that the alphabet is {u,1].
u
-
1u
-
= {| contoins o singlc 1].

-
1
-
= {| bos ot lcost onc 1].

-
uu1
-
= {| contoins tbc string uu1 os o substring].
1
-
(u1
+
)
-
= {| c:cry u in is ollowcJ by ot lcost onc 1].
()
-
= {| is o string o c:cn lcngtb].
()
-
= {| tbc lcngtb o is o multiplc o tbrcc].
u1 U 1u = {u1,1u].
u
-
u U 1
-
1 U u U 1 = {| storts onJ cnJs witb tbc somc symbol].
(u U e)1
-
= u1
-
U1
-
.
(u U e)(1 U e) = {e, u, 1, u1].
1
-
= .

-
= {e].


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

Example: Now we uiscuss vaiious iegulai expiessions foimeu ovei
L = {u, 1] anu see theimpoitance of opeiatois pieceuence while we
enumeiate the language fiom the composite iegulai expiession.
(a) ( + 1) is a iegulai expiession, which geneiates the language {u, 1].
Because, L( ) = {u] anu L(1) = {1] anu the auuition of language i.e.,
L( + 1) = L() U L(1) = {u, 1]; (which is eithei u oi 1).
(b) ( 1
-
) is a iegulai expiession, which geneiates the language
{u, u1, u11, u111, ]. Beie, we assume iegulai expiession r
1
= , anu
r
2
= 1
-
so L(r
1
) = {u] anu L(r
2
) = {e, 1, 11, 111, , ]. Theiefoie, the
language geneiateu by concatenation of iegulai expiessions r
1
r
2
will be
L(r
1
r
2
) i.e.,
L(r
1
r
2
) = L(r
1
) L(r
2
) = {u, u1, u11, u111, , ]
(c) ( +1
-
) is a iegulai expiession, that geneiates the language which is
the union of set of all stiings foimeu by iegulai expiessions oi 1
-
i.e.,
L() U L(1
-
), wheie I() = {u] anu L(1
-
) = {e, 1, 11, 111, ] hence,
L() U L(1
-
) = {e, u, 1, 11, 111, ].
(u) ( +1)
-
is a iegulai expiession, so its language is the set of all stiings
foimeu using symbol u oi 1. Beie we assume iegulai expiession
r = ( + 1) then L(r) = {u, 1]. Theiefoie, L(r)
-
= I
-
= I
0
U I
1
U I
2
U
I
3
wheie I
0
= {e]; I
1
= I . I
0
= e {u,1] = {u, 1]; I
1
= I . I
1
= {u, 1]
{u, 1] = {uu, u1, 1u, 11];I
3
= I . I
2
= {u, 1] {uu, u1, 1u,11] =
{uuu, uu1, u1u, u11, 1uu, 1u1, 11u, 111]; anu so on.
Bence, I
-
= {e, u, 1, uu, u1, 1u, 11, uuu, ] oi set of all possible stiings
foimeu ovei symbols us & 1s incluuing the null stiing.
(e) (
-
1 1
-
) is a iegulai expiession anu its language will be
L(
-
1 1
-
). Since, L(
-
) = {e, u, uu, uuu, ]; L(1) = {1]; again
L(1) = {1]; anu L(
-
) = {e, u, uu, uuu, ] theiefoie ,L(
-
1 1
-
) =
{e, u, uu, ] {1] {1] {e, u, uu, ] = {11 (when fiist anu last iegulai
expiession piouuces e), u11, uu11, (when fiist iegulai expiession
piouucesmultiple us anu last iegulai expiession piouuces e), 11u, 11uu,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
61

(when fiist iegulai expiession piouuces eanulast iegulai expiession
piouuces multiple us), u11u, u11uu, , uu11u, uu11uu, , ].
Bence, language contains all stiings of us having two consecutive 1s.
(f) Foi the iegulai expiession ( +1)
-
1 1 ( +1)
-
the language
will be the set of all stiings foimeu ovei us anu 1s consisting of pattein 1u1.
Since the piesence of iegulai expiession fiist anu last piouuces all the
stiings of us anu 1s incluuing e but the essential pait of all the stiings must
be the piesence of the substiing 1u1 which is piouuceu by the concatenation
of iegulai expiession 2nJ, SrJ anu 4tb.
Note that if the iegulai expiession is constiucteu foi the language consisting
of the stiing x, then its iegulai expiession will be uenoteu by x.
In the pievious example we saw how iegulai languages aie to be geneiateu
fiom the given iegulai expiessions. In the next example we will see how the
iegulai expiessions aie constiucteu fiom given iegulai languages.
Equivalence of Regular Expression and Finite Automata:
Eveiy language which is accepteu by eithei ueteiministic finite automaton
(BFA) oi nonueteiministic finite automaton (NBFA) with oi without
e -mo:cs is known as iegulai language. It means that theie exists a set of
iegulai expiessions that geneiates the stiings of this class of language. So, if
a language is iegulai then ceitainly it can be expiesseu by iegulai
expiessions anu conveisely this language must be the outcome fiom some
finite automaton as shown in figuie below.
Alteinatively we may say that,
1. A iegulai expiession can be expiesseu in some foim of finite automata
eithei BFANBFANBFA with e -mo:cs(i.e., fiom Regulai Expiession to
Finite Automata).
2. The acceptance powei (language) of finite Automata can be expiesseu by
iegulai expiession (i.e., fiom Finite automata to Regulai Expiession).
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
62

Now we stuuy in uetail about the points 1 anu 2 such that the methou of
constiuction offinite automaton fiom given iegulai expiession anu
conveisely the ueteimination of iegulai expiession fiom finite automaton.
What we have uiscusseu so fai it can be easily veiifieu bystuuy of the
following theoiems.
Language
Regular
Expression
Regular
Automata
Finite
DFA NDFA
moves
with NDFA
c



Construction of NDFA with s -muves from Regular Expression:
Theorem:If r be a iegulai expiession anu its language is I(r) then theie
exists a NBFA with e -mo:cs N
s
i.e., I(N
s
) = I(r). (Pioviueu that N
s
has
only one final state anu theie is no outgoing aic fiom the final state).
Example: Constiuct the NBFA with e -mo:cs foi iegulai expiession
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
63

(a + h) a h
-
(a + h)
-

Assume r = (a + h) a h
-
(a + h)
-
, wheie r is foimeu by the
concatenation of foui iegulai expiessions i.e., r = r
1
r
2
r
3
r
4
wheie
r
1
= (a + h); r
2
= a; r
3
= h
-
anu r
4
= (a + h)
-
. Now weconstiuct the
NBFA with e -mo:cs foi r using the pievious theoiem in the following
steps,
Step 1: Constiuction of the automaton foi r
1
= (a +h) is the auuition of two
automatons accepting the union of language {a] anu {h] i.e., (Let it be N
s
i
)
c
c
c
c
a
b
'
c
N

Step 2: Now iegulai expiession r
1
is concatenateu with iegulai expiession
r
2
= a so, automaton N
s
ii
will be constiucteu, i.e., I(N
s
ii
) = I(N
s
i
) I(o), thus
N
s
ii
will be obtain as,
Dr. O. Ismail EEC301 lectures all rights reserved. Sept., 2010
64

c
c
c
c
a
b
' '
c
N
a c

Step S: Next, iegulai expiession r
1
r
2
is concatenateu with r
3
= h
-
, so again
concatenation constiuction of I(N
s
ii
) with automaton that accept I(r
3
).
Thus we obtain N
s
iii
.
c
c
c
c
a
b
' ' '
c
N
a c
b
c
c
c
c
c

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

Step 4: Bo the concatenation constiuction with the pievious automaton
N
s
iii
to the newly constiucteu automaton N
s
iiii
(foi iegulai expiession
r
4
= (a + h)
-
so we obtain the final NBFA with e -mo:cs N
s
.
Since N
s
iii
will be,
' ' ' '
c
N
c
c
c
c
b
c
c
c
a

Вам также может понравиться