0% found this document useful (0 votes)
41 views23 pages

Chapter 3

The document describes the process of converting a nondeterministic finite automaton (NFA) to a deterministic finite automaton (DFA). It discusses removing epsilon transitions and multiple transitions between states, constructing the transition function for the DFA, and shows an example of the full conversion process.

Uploaded by

Elias Khoury
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views23 pages

Chapter 3

The document describes the process of converting a nondeterministic finite automaton (NFA) to a deterministic finite automaton (DFA). It discusses removing epsilon transitions and multiple transitions between states, constructing the transition function for the DFA, and shows an example of the full conversion process.

Uploaded by

Elias Khoury
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Chapter 3 :

Convert nfa to dfa


1
Step 1:
• Every edge labeled with a string of length n  2
should be replaced with a series of n edges, an
edge is labeled with one symbol.

aabc

a a b c

2
After we precede by two steps

i. Removing empty transitions

ii. Convert a nfa to dfa. Removing several


edges with the same label originate from
one vertex.

3
Iterated transition function

• Let M = (Q,,,q0,F) be an dfa:


• We can generalize  to *: Qx* |--- Q with:
– *(q, ) = q
– *(q, aw) = *((q,a),w)
• Then for every string w:
– wL(M)  *(q0, w)F
• We call * the iterated transition function
of 
4
Extension nondeterministic
• Let M = (Q,, *,q0,F) be nfa without
-transition and without transition labeled
with a string (only letters), since the
transition relation * can be defined by a
function :
Qx |---(Q)

5
Example
• Let an automaton nfa defined by the relation:
 a b
q0 q0,q3 q0, q1
q1 - q2
q2 q2 q2
q3 q4 -
q4 q4 q4

6
Example
• We consider * as a function  from Qx in
(Q) :
* a b
q0 {q0,q3} {q0, q1}
q1  {q2}
q2 {q2} {q2}
q3 {q4} 
q4 {q4} {q4}

7
Iterated transition function
• We assume, also, that *:
– *(q,) = {q}
– *(q,wa) = {p; r*(q,w) with p  (r,a)}
• Notice:
– wL(M)  *(q0,w)F  
• We extend the function * on (Q) instead of Q: the
image of X(Q) by * is the direct image of the set X
by *.

8
example
• In this example:
* a b
q0 {q0,q3} {q0, q1}
q1  {q2}
q2 {q2} {q2}
q3 {q4} 
q4 {q4} {q4}
• *({q0,q1}, b) = *(q0,b)*(q1,b) =
{q0,q1,q2}
9
nfa with -transitions
• We consider the transition as a function :
 : Qx({}) |--- (Q)

10
Example of nfa with  transitions
a
c
b
 
q0 q1 q2

The transition function  is defined by:


 a b c 
q0 q0 - - q1
q1 - q1 - q2
q2 - - q2 -

11
-closure
• Let consider a state q, the -closure, E(q)
is defined by:
E(q) = set of states that are reached from the
state q with a succession of -transitions.

• We extend  as follows:
• *(q, ) = E(q)
• For every w*, a then *(q, wa) = E(P)
with P = {p; r *(q, w) with p(r, a)}

12
example
• With the previous nfa:
– E(q0) = {q0,q1,q2}; E(q1) = {q1,q2}; E(q2) = {q2}
– *(q0,) = {q0,q1,q2}
– *(q0, aabc):
• by a, we get : {q0,q1,q2}
• by aa : {q0,q1,q2}
• by aab : {q1,q2}
• by aabc : {q2}

13
Elimination of -transitions
• Let M = (Q, , , q0, F) be nfa with -transitions.
• Let M’ = (Q, , ’, q0, F’) where:

if E(q0) enclose a final state of F


F’ = F{q0}
Else F’=F
– ’(q, a) = *(q, a) for every a
• Since M’ has no -transitions

14
example
• With previous example
* a b c
q0 {q0,q1,q2} {q1,q2} {q2}
q1  {q1,q2} {q2}
q2   {q2}

• Then q0 is a final state, E(q0) enclose a final


state (q2) and q2 is a final state in M’, because q2
was a final state in M
15
Result of removing -transitions
c
a b

b
b
q1 q2
q0
a c

16
Determination – Last step
• Now we assume that there is nor -transitions neither
transitions with strings of length greater than 1 , we can
convert a nfa into dfa such as:

17
Conclusion
• Let M = (Q, , q0, F, ) be a nfa automaton where  is relation
Qx(Q) instead of being a function QxQ.
• Let M’ = (Q’, , q’0, F’, ’) with:
– Q’ =(Q)
– q’0 = E(q0)
– F’ = {PQ’; PF}
– ’(P,a) = *(P,a) for every PQ’ and every a
Then:
1. M’ is deterministic ( ’: Q’x  Q’)
2. L(M) = L(M’) (The same associated language of M & M’)

18
Formalization
Let M = (Q, , , q0, F) a nfa automaton.
The dfa automaton M’ = (Q’, , ’, q’0, F’)

E(q) ={pQ | (q,w) |---* (p,w) }

– Q’ =(Q)
– q’0 = E(q0)
– F’ = {PQ’; PF}
– ’(P,a) = { E(q) | pP with (p,a,q)   }

19
construct a dfa equivalent to nfa
c
a b

b
b
q1 q2
q0
a c

20
Defining ’
’ a b c
{q0} {q0, q1, q2} {q1, q2} {q2}
{q0, q1, q2} {q0, q1, q2} {q1, q2} {q2}
{q1, q2}  {q1, q2} {q2}
{q2}   {q2}

21
Direct answer from nfa with
-transitions
• E(q0)={q0, q1, q2}
a b c
{q0,q1,q2} {q0,q1,q2}{q1,q2} {q2}
{q1,q2}  {q1,q2} {q2}
{q2}   {q2}

22
a
b

b
{q0, q1, q2}} {q1, q2}

c c

{q2}

23
c

You might also like