Example

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 9

Theory of Computation

Example (1) Let us assume that we are given to construct a DFA that accepts any
combinations of string of a, b, c. That means the string can start with a or b or c.
After any symbol, any of the other symbols can come in any combination and all
strings are accepted. One solution to this is the DFA given by

But it is not clear as to how any combinations of a, b, c will come. In this case, an
NFA with move plays its role as represented by the transition diagram given below.
Now it is clear that the string can start with a or b or c. And for the transitions from
any state, we can move to any other state with no input. So, if c comes after ‘a’, we
can go from q0 to q2 easily with no input. The same thing can occur for all the other
states. The corresponding NFA is given by
Theory of Computation

Conversion of an NFA with moves to DFA.


Let us assume that in the NFA we want to remove the move which exists
between the states S1 and S2. This can be removed in the following way.
(i) Find all the transitions those start from the state S2.
(ii) Duplicate all these transitions starting from the state S1, keeping the edge
label the same.
(iii) If S1 is the initial state also make S2 as the initial state.
(iv) If S2 is the final state, also make S1 as the final state.
Example (2) Convert the following NFA with moves to an equivalent DFA
without move.
Answer. Three moves existing in the following transition diagram are
Discrete Mathematics
from q0 to q1, from q1 to q2 and from q0 to q2 . These transitions are removed
step by step.

Step 1:
(i). Between the states q0 and q1, there is a move. If we want to remove that
transition, we have to find all the edges starting from q1.The edges are q1 to q1 for
input 1 and q1 to q2 for input .
(ii). All these transitions starting from the state q0 are duplicated, keeping the edge
label the same. q0 is the initial state, so we make q1 also an initial state. The
modified transition diagram is given below.
Discrete Mathematics
Step 2.
(i).Between q1 and q2, there is a transition. To remove that transition, we find
all the edges starting from q2. The edge is q2 to q2 for input 2.
(ii). Duplicate the transition starting from the state q1, keeping the edge label
the same. q1 is the initial state, so make q2 also an initial state. q2 is the final
state, so make q1 also a final state. The modified transition diagram is given
below.

Step 3
(i). Between q0 and q2, there is a transition. To remove that transition, we find
all the edges starting from q2. The edge is q2 to q2 for input 2.
(ii). Duplicate the transition starting from the state q0, keeping the edge label
the same. q0 is the initial state, so make q2 also an initial state. q2 is the final
state, so make q0 also a final state. The modified transition diagram is given
Discrete Mathematics

This is the equivalent NFA without move obtained from the NFA with
transaction.
Example (3). Convert the following NFA with move to an equivalent NFA
without move.
Theory of Computation
Equivalence of NFA and DFA.
In contrast to the NFA, the DFA has no transitions. Also, for every (q, a) with
q Q and a there is at most one successor state. Therefore, for every string
w * , there is at most one w path in the transition diagram for DFA . If w is in the
language of DFA then this path leads from the initial state to a final state. So, DFA
are preferred for practical purposes. A DFA can simulate the behavior of NFA by
increasing the number of states. A DFA M = (Q, , , q0, F ) can be viewed as an NFA
M’= ( Q, , , q0, F ) by defining ( q, a) = {(q, a)}
Conversion of NFA into DFA.
Theorem. If a language L is accepted by an NFA then there is a DFA that accepts L.
Proof. We shall use a constructive procedure by using subset construction. If there
are two w paths in NFA, the corresponding states from a common state q in DFA will
be

Let R = (Q, , , q0, F ) be an NFA accepting the language L. We construct DFA


Theory of Computation
S = ( Q, , , q0, F ) as follows. S = (Q’, , ’, q0’ , F ) , where Q’ = 2Q (any state in Q is
represented by { q1, q2, q3, .... qi}, where q1, q2, q3, .... qi Q, q’0 = q0, F = set of all
subsets of Q containing an element of F. Let us consider the construction of Q, q0
and F. NFA R is initially at q0, the initial state. By applying an input symbol a, R can
reach any of the states in (q0, a). To describe S, we require all the possible states
that R can reach after the application of a. So, S has to remember all these
possible states at any instance of time. Hence the states of S may be defined as
subset of Q. As q0 is initial state so q0’ is defined as [q0]. If the string w is accepted
by R, then R reaches a final state on processing w. Therefore a final state in DFA S
is any subset of Q having some final state of NFA R. Now we can define transition
function of DFA S as
([q1, q2, q3, .... qk], a) = (q1, a) (q2, a) (q3, a) ... (qk, a)
or ([q1, q2, q3, .... qk ], a) = [P1, P2, P3, . . . Pk] if and only if
( {q1, q2, q3, .... qk}, a) = [P1, P2, P3, . . . Pk]
Now we prove
’(q0’, x) = [q1, q2, q3, .... qk] if and only if (q0, s) = {q1, q2, q3, .... qk } for all s in *.
When |s| = 0, (q0, ) = q0 and by definition of ’ we have ’(q0, ) = q0’ = [ q0’ ]
Assume that there is another string t with t m. Let s be a string of length
7
m + 1. So we can write s as t a, where | t | = m and a S.
Theory of Computation
Let ( q0, t) = [P1, P2, P3, . . . Pk ] and ( q0, t a) = {r1, r2, r3, ... rk } as t m, by induction
hypothesis we can say
’(q0’, t) = [P1, P2, P3, . . . Pk]
and
{r1, r2, r3, ... rk } = ( q0, ta) = ( ( q0, t), a) = ({P1, P2, P3, . . . Pk}, a).
Now by definition of ’, ’([P1, P2, P3, . . . Pk], a) = {r1, r2, r3, ... rk }. Hence
’(q0, ta) = ’(’(q0’, t), a) = ’( [P1, P2, P3, . . . Pk], a) = [r1, r2, r3, ... rk ]. Thus we can say
that s = ta. Now, s T(R) if and only if (q0, s) contains a state of F. (q0, x) contains
a state of F iff ’ (q0’, s) is in F’. Hence s T(S) if and only if s T(R). This proves that
DFA S accepts the language L. (s T(S) represents the acceptability of string s by
S). When transition for NFA R is given in form of transition table, the
construction of DFA S equivalent to NFA R is done by following method.
(qi, a) is given by the row corresponding to qi and column corresponding to
input symbol say a. To construct ([q1, q2, q3, ..., qk ], a), consider the states
present in the rows corresponding to q1, q2, q3, ..., qk and the column
corresponding to a. These states will construct ([q1, q2, q3, ..., qk ], a).
Example(4)
(i)Construct a DFA equivalent to the NFA given by the following transition Table
8
Theory of Computation

(ii) Show that the following NFA and DFA are equivalent

(iii) Convert the following NFA into equivalent DFA:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy