You are on page 1of 10

Nondeterministic Finite Automata (NFA)

Afsana Afrin
Lecturer
Dept of Computer Science and Engineering
Bangladesh Army University of Science & Technology

05-Jul-20 Nondeterministic Finite Automata 1


NFA

 NFA stands for non-deterministic finite automata.


 For the NFA, δ is a function that takes a state and input symbol
as arguments, but returns a set of zero, one , or more states.
 Every NFA is not DFA, but each NFA can be translated into
DFA.
 NFA is defined in the same way as DFA but with the following
two exceptions, it contains multiple next states, and it contains ε
transition.

05-Jul-20 Nondeterministic Finite Automata 2


Formal definition of a NFA

An NFA can be represented by a 5-tuple (Q, ∑, δ, q0, F) where

 Q is a finite set of states.


 ∑ is a finite set of symbols called the alphabets.
 δ is the transition function where δ: Q × ∑ → 2Q (Here the
power set of Q (2Q) has been taken because in case of NFA,
from a state, transition can occur to any combination of Q
states)
 q0 is the initial state from where any input is processed (q0 ∈
Q).
 F is a set of final state/states of Q (F ⊆ Q).

05-Jul-20 Nondeterministic Finite Automata 3


Example

Let a nondeterministic finite automaton be →


Q = {q0, q1, q2},
∑ = {0, 1},
q0 = {q0},
F = {q2}, and Transition function δ as shown by the following
table −

Present state Next State for Next State for


Input 0 Input 1
→q0 {q0, q1} {q1}
q1 {q2} {q0}
*q2 {q2} {q1, q2}

05-Jul-20 Nondeterministic Finite Automata 4


Example

Present state Next State for Next State for


Input 0 Input 1
→q0 {q0, q1} {q1}
q1 {q2} {q0}
*q2 {q2} {q1, q2}

05-Jul-20 Nondeterministic Finite Automata 5


Transition function

δ represents the transition with the assistance of inputs from one


state to another.
δ(q0,0)={q0, q1}
δ(q0,1)={q1}
δ(q1,0)={q2}
δ(q1,1)={q0}
δ(q2,0)={q2}
δ(q2,1)={q1,q2}

05-Jul-20 Nondeterministic Finite Automata 6


Input String acceptance

An input string will be accepted only when it will start to transit


from starting state and final input makes a transition to final
state.
Suppose that a input sting 10101010, now we have to check
either it is accepted or rejected for the following NFA.

05-Jul-20 Nondeterministic Finite Automata 7


Input String acceptance
Input String=10101010

Checking:
Input-1 and Transition δ(a,1)=b where a is starting state
Input=0 and Transition δ(b,0)=c
Input=1 and Transition δ(c,1)=c
Input=0 and Transition δ(c,0)=b
Input=1 and Transition δ(b,1)=a
Input=0 and Transition δ(a,0)=a
Input=1 and Transition δ(a,1)=b
Input=0 and Transition δ(b,0)=c where c is a final state.
State Sequence-> a-b-c-c-b-a-a-b-c
So the input string 10101010 is accepted.

05-Jul-20 Nondeterministic Finite Automata 8


Exercise

Check the following string patterns whether accepted or rejected

i. 101011010
ii. 111000110

05-Jul-20 Nondeterministic Finite Automata 9


Thank You

05-Jul-20 Nondeterministic Finite Automata 10

You might also like