Toc L#05
Toc L#05
NON-DETERMINISTIC FINITE
AUTOMATON (NFA)
TREE REPRESENTATION
010110 1 0, ε 1
a1 a2 a3 a4
Symbol read
a1
0 ----------------------------------------------------------------------------------
a1
1 -----------------------------------------------------------------------
a1 a2
0 ----------------------------------------------------------------
a1 a3
1 ----------------------------------------------------------
a1 a2 a3 a4
1 ------------------------------------------------
a1 a2 a3 a4 a4
0 ------------------------------------------
a1 a3 a4 a4
CSC3113: Theory of Computation 8
FORMAL DEFINITION OF NFA
NFA is a 5-tuple (Q, Σ, , q0, F)
Q is a finite set of states.
Σ is a finite alphabet.
: Q Σ P(Q).
The transition function takes a state and an input
symbol or the empty string (Σ=Σ ) and produces the
set of possible next states (P(Q) is the power set of Q).
q0Q is the start state.
F Q is the set of accepted states.
FORMAL DEFINITION
Let, the above NFA N1 = (Q1, Σ, 1, a1, F1). 1 in form : Q Σ P(Q)
Q1 = {a1, a2, a3, a4}.
Σ = {0, 1}. 1(a1, 0) = {a1} 1(a3, 0) =
1 | 0 1 1(a1, 1) = {a1, a2} 1(a3, 1) = {a4}
1(a1, ) = 1(a3, ) =
a1 | {a1} {a1, 1(a2, 0) = {a3} 1(a4, 0) = {a4}
a 2} 1(a2, 1) = 1(a4, 1) = {a4}
a2 | {a3} 1(a2, ) = {a3} 1(a4, ) =
{a3}
Q Σa =3 {(a1, |0), (a1, 1), (a1, ), (a2, 0), (a2, 1),
{a4(a} 2, ), (a3, 0), (a3, 1), (a3, ), (a4, 0), (a4, 1), (a4, )}
P(Q) = {, {a1}, {a2}, {a3}, {a4}, {a1,a2}, {a1,a3}, {a1,a4}, {a2,a3}, {a2,a4}, {a3,a4},
a4 | {a4} {a2,a
{a1,a 4} 3}, {a1,a2,a4}, {a1,a3,a4}, {a2,a3,a4}, {a1,a2,a3, a4}}
CSC3113: Theory of Computation
10
NONDETERMINISTI
C FINITE AUTOMATA
(NFA)
EXAMPLE
1. Draw the state diagram of the NFA for the following Languages
over the alphabet is {0, 1}.
a) L={w | w begins/starts with a 0},
b) L={w | w begins/starts with a 1},
2. Draw the state diagram of the NFA for the following Languages
over the alphabet is {a, b}.
a) L={w | w ends with a},
b) L={w | w ends with b},
c) L={w | w contains with b}
d) L={w | w contains with ab}
B1 q1 q2
1
1
1 0 1
0
B2 q1 q2 q3
1 0, 1
B4 q1 q2
0, 1
1 0
B5 q1 q2 q3
0 0 0, 1
1 1
B6 q1 q2 q3
0 0 0
1 1
B7 q1 q2 q3
16
B8 ={w| w has substring 101}.
B9 ={w| w has substring 011}.
∑ = {0,1} 0,1
1 0 1
B8 qs q1 q10 q101 0, 1
0, 1 0
0 1 1
B9 qs q0 q01 q011 0, 1
0
What happens for the language, A2 ={w| w does not have substring 011}?
17
B10 ={w| w starts with a 1 and has even length or
w starts with a 0 and has odd length}.
∑ = {0,1}
0, 1
0, 1
1 q2 q3
B10 q1 0, 1
0 0, 1
q4 q5
18
REFERENCES
NONDETERMINISTIC FINITE AUTOMATA
Introduction to Theory of Computation, Sipser, (3rd ed), NFA.