Equivalence of
NFA and DFA
-Sampath Kumar S,
AP/CSE, SECE
Equivalence of NFA and DFA
 The NFA with ε can be converted to NFA
without ε and this NFA without ε can be
converted to DFA.
11/21/2017
Sampath Kumar S, AP/CSE, SECE
2
ε-NFA
NFA
DFA
Conversion of NFA to DFA:
The conversion of NFA to DFA involves following steps:
1. QD = 2Q
N. If NFA has n states. DFA at most have 2n
states.
2. Σn=ΣD
3. [q0]=[q0]
4. FD = A set of all the states of QD that contains at
least one of the final states of FN .
5. δD((q1,q2,q3),a)=
δn(q1,a) u δn(q2,a) u δn(q3,a) ={p1,p2,p3}
Add state [P1,P2,P3] to QD if it is not there
11/21/20173
Sampath Kumar S, AP/CSE, SECE
Problem to discuss:
38. Convert the following NFA to DFA
11/21/20174
Sampath Kumar S, AP/CSE, SECE
Problem to discuss:
39. Construct DFA equivalent to NFA
M = ( {p,q,r,s}, {0,1}, δ, P, {q,s} )
where δ is defined in the following table.
11/21/20175
Sampath Kumar S, AP/CSE, SECE
δ 0 1
->p {q, s} {q}
q* {r} {q,r}
r {s} {p}
s* - {p}
Problem to discuss:
40. Convert the given NFA to its equivalent DFA
11/21/20176
Sampath Kumar S, AP/CSE, SECE
Conversion of ε-NFA to NFA:
The conversion of ε-NFA to NFA involves following
steps:
1. Find out all the ε-transition from each state from Q.
That will be called as ε-closure {qi} where qi ∈ Q.
2. Then δ’ transition can be obtained. The δ’ transition
means and ε-closure on δ moves.
3. Step 2 is repeated for each input symbol and for
each state of given NFA.
4. Using the resultant states the transition table for
equivalent NFA without ε can be built
11/21/20177
Sampath Kumar S, AP/CSE, SECE
Rule for conversion:
δ’(q,a) = ε-closure (δ (δ (q, ε ), a)
Where
δ (q, ε ) = ε-closure (q)
11/21/20178
Sampath Kumar S, AP/CSE, SECE
Problem to discuss:
41. Convert the following ε-NFA to NFA
11/21/20179
Sampath Kumar S, AP/CSE, SECE
Solution:
Step 1: Find ε-closure for all states:
ε-closure (q)={q, r, s}
ε-closure (r)={ r, s}
ε-closure (s)={s}
11/21/201710
Sampath Kumar S, AP/CSE, SECE
Solution:
δ’(q,a) = ε-closure (δ (q,r,s), a)
= ε-closure (δ(q,a) U δ(r,a) U δ(s,a) )
= ε-closure (q U Φ U Φ)
= ε-closure (q) = {q, r, s}
δ’(q,b) = ε-closure (δ (δ (q, ε ), b)
= ε-closure (δ (q,r,s), b)
= ε-closure (δ(q,b) U δ(r,b) U δ(s,b) )
= ε-closure (Φ U r U Φ)
= ε-closure (r) = {r, s}
11/21/201711
Sampath Kumar S, AP/CSE, SECE
Solution:
δ’(q,c) = ε-closure (δ (δ (q, ε ), c)
= ε-closure (δ (q,r,s), c)
= ε-closure (δ(q,c) U δ(r,c) U δ(s,c) )
= ε-closure (Φ U Φ U s)
= ε-closure (s) = {s}
11/21/201712
Sampath Kumar S, AP/CSE, SECE
Final Solution:
δ’(q,a) = {q, r, s}
δ’(q,b) = {r, s}
δ’(q,c) = {s}
δ’(r,a) = {Φ}
δ’(r,b) = {r, s}
δ’(r,c) = {s}
δ’(s,a) = {Φ}
δ’(s,b) = {Φ}
δ’(s,c) = {s}
11/21/201713
Sampath Kumar S, AP/CSE, SECE
Problem to discuss:
42. Convert the following ε-NFA to NFA
11/21/201714
Sampath Kumar S, AP/CSE, SECE
Conversion of ε-NFA to DFA:
The conversion of NFA to DFA involves following steps:
1. Compute ε* for the current state, resulting in a set
of the states S.
2. δ(S, a) is computed for all a Σ by
1. Let S ={p1,p2, ….. pK}
2. Compute R = δ(S, a) as
R = pi S δ(pi, a) ={r1,r2, ….. rm}
This set is achieved by the following input a, not by
following any ε transitions.
3. Add the ε transitions in by computing ε-closure(R)
3. Make a state, an accepting state if it includes any
final states in the NFA
11/21/201715
Sampath Kumar S, AP/CSE, SECE
Problem to discuss:
43. Convert the following ε-NFA to DFA
11/21/201717
Sampath Kumar S, AP/CSE, SECE
Problem to discuss:
44. Convert the given ε-NFA to its equivalent DFA
11/21/201718
Sampath Kumar S, AP/CSE, SECE
11/21/2017
Sampath Kumar S, AP/CSE, SECE
19
நன்றி
11/21/2017
Sampath Kumar S, AP/CSE, SECE
20

1.7. eqivalence of nfa and dfa

  • 1.
    Equivalence of NFA andDFA -Sampath Kumar S, AP/CSE, SECE
  • 2.
    Equivalence of NFAand DFA  The NFA with ε can be converted to NFA without ε and this NFA without ε can be converted to DFA. 11/21/2017 Sampath Kumar S, AP/CSE, SECE 2 ε-NFA NFA DFA
  • 3.
    Conversion of NFAto DFA: The conversion of NFA to DFA involves following steps: 1. QD = 2Q N. If NFA has n states. DFA at most have 2n states. 2. Σn=ΣD 3. [q0]=[q0] 4. FD = A set of all the states of QD that contains at least one of the final states of FN . 5. δD((q1,q2,q3),a)= δn(q1,a) u δn(q2,a) u δn(q3,a) ={p1,p2,p3} Add state [P1,P2,P3] to QD if it is not there 11/21/20173 Sampath Kumar S, AP/CSE, SECE
  • 4.
    Problem to discuss: 38.Convert the following NFA to DFA 11/21/20174 Sampath Kumar S, AP/CSE, SECE
  • 5.
    Problem to discuss: 39.Construct DFA equivalent to NFA M = ( {p,q,r,s}, {0,1}, δ, P, {q,s} ) where δ is defined in the following table. 11/21/20175 Sampath Kumar S, AP/CSE, SECE δ 0 1 ->p {q, s} {q} q* {r} {q,r} r {s} {p} s* - {p}
  • 6.
    Problem to discuss: 40.Convert the given NFA to its equivalent DFA 11/21/20176 Sampath Kumar S, AP/CSE, SECE
  • 7.
    Conversion of ε-NFAto NFA: The conversion of ε-NFA to NFA involves following steps: 1. Find out all the ε-transition from each state from Q. That will be called as ε-closure {qi} where qi ∈ Q. 2. Then δ’ transition can be obtained. The δ’ transition means and ε-closure on δ moves. 3. Step 2 is repeated for each input symbol and for each state of given NFA. 4. Using the resultant states the transition table for equivalent NFA without ε can be built 11/21/20177 Sampath Kumar S, AP/CSE, SECE
  • 8.
    Rule for conversion: δ’(q,a)= ε-closure (δ (δ (q, ε ), a) Where δ (q, ε ) = ε-closure (q) 11/21/20178 Sampath Kumar S, AP/CSE, SECE
  • 9.
    Problem to discuss: 41.Convert the following ε-NFA to NFA 11/21/20179 Sampath Kumar S, AP/CSE, SECE
  • 10.
    Solution: Step 1: Findε-closure for all states: ε-closure (q)={q, r, s} ε-closure (r)={ r, s} ε-closure (s)={s} 11/21/201710 Sampath Kumar S, AP/CSE, SECE
  • 11.
    Solution: δ’(q,a) = ε-closure(δ (q,r,s), a) = ε-closure (δ(q,a) U δ(r,a) U δ(s,a) ) = ε-closure (q U Φ U Φ) = ε-closure (q) = {q, r, s} δ’(q,b) = ε-closure (δ (δ (q, ε ), b) = ε-closure (δ (q,r,s), b) = ε-closure (δ(q,b) U δ(r,b) U δ(s,b) ) = ε-closure (Φ U r U Φ) = ε-closure (r) = {r, s} 11/21/201711 Sampath Kumar S, AP/CSE, SECE
  • 12.
    Solution: δ’(q,c) = ε-closure(δ (δ (q, ε ), c) = ε-closure (δ (q,r,s), c) = ε-closure (δ(q,c) U δ(r,c) U δ(s,c) ) = ε-closure (Φ U Φ U s) = ε-closure (s) = {s} 11/21/201712 Sampath Kumar S, AP/CSE, SECE
  • 13.
    Final Solution: δ’(q,a) ={q, r, s} δ’(q,b) = {r, s} δ’(q,c) = {s} δ’(r,a) = {Φ} δ’(r,b) = {r, s} δ’(r,c) = {s} δ’(s,a) = {Φ} δ’(s,b) = {Φ} δ’(s,c) = {s} 11/21/201713 Sampath Kumar S, AP/CSE, SECE
  • 14.
    Problem to discuss: 42.Convert the following ε-NFA to NFA 11/21/201714 Sampath Kumar S, AP/CSE, SECE
  • 15.
    Conversion of ε-NFAto DFA: The conversion of NFA to DFA involves following steps: 1. Compute ε* for the current state, resulting in a set of the states S. 2. δ(S, a) is computed for all a Σ by 1. Let S ={p1,p2, ….. pK} 2. Compute R = δ(S, a) as R = pi S δ(pi, a) ={r1,r2, ….. rm} This set is achieved by the following input a, not by following any ε transitions. 3. Add the ε transitions in by computing ε-closure(R) 3. Make a state, an accepting state if it includes any final states in the NFA 11/21/201715 Sampath Kumar S, AP/CSE, SECE
  • 16.
    Problem to discuss: 43.Convert the following ε-NFA to DFA 11/21/201717 Sampath Kumar S, AP/CSE, SECE
  • 17.
    Problem to discuss: 44.Convert the given ε-NFA to its equivalent DFA 11/21/201718 Sampath Kumar S, AP/CSE, SECE
  • 18.
  • 19.

Editor's Notes

  • #2 School of EECS, WSU