950 likes | 1.02k Views
Theory of Computation. Nondeterministic Finite Automaton (NFA). An NFA is a collection of three things 1) Finite states with one initial and some final states 2) Finite set of input letters ( Σ ) from which input strings are formed
E N D
Nondeterministic Finite Automaton (NFA) An NFA is a collection of three things 1) Finite states with one initial and some final states 2) Finite set of input letters (Σ) from which input strings are formed 3) Finite set of transitions, showing where to move if a letter is input at certain state, there may be more than one transition for certain letters and there may not be any transition for certain letters.
Observations The string is supposed to be accepted, if there exists at least one successful path, otherwise rejected. NFA can be considered to be an intermediate structure between FA and TG.
Example The above NFA accepts the language consisting of a and ab. 2+ a a 1- 3 a b 4 5+
Example The above NFA accepts the language of strings, defined over Σ = {a, b}, containing aa. a, b a,b a a 1- 3+ 2
Non-determinism This refers to situations in which the next state of a computation is not uniquely determined by the current state. In these situations we know only a range of possibilities
Converting an FA to an equivalent NFA If a language is accepted by an FA, then there exists a TG accepting that language(Kleene’s theorem). Since, an NFA is also a TG, there exists an NFA accepting the language accepted by the given FA. In this case these FA and NFA are said to be equivalent to each others.
Example Consider the following FA corresponding to (a+b)*b The above FA may be equivalent to the following NFA a b b - + a a, b b - +
Example Consider the following FA The above FA may be equivalent to the following NFA a,b b a a - + 1 b a,b a, b a a - + 1
Note Every FA can be considered to be an NFA, but the converse may not true. Every NFA can be considered to be a TG, but the converse may not true.
An NFA can be considered to be a TG, so a RE corresponding to the given NFA can be determined Again using Kleene’s theorem, an FA can be built corresponding to that RE. NFA to FA
Example 2 b a 1- 4+ b a 3 a 1- 2 b 4+ a b a a, b 3 b a, b
Alphabet = Two choices
Alphabet = Two choices No transition No transition
First Choice All input is consumed “accept”
Second Choice No transition: the automaton hangs
Second Choice Input cannot be consumed “reject”
An NFA accepts a string: if there is a computation of the NFA that accepts the string i.e., all the input is consumed and the automaton is in an accepting state
Example is accepted by the NFA: “accept” “reject” because this computation accepts
First Choice “reject”
Second Choice “reject”
Example is rejected by the NFA: “reject” “reject” All possible computations lead to rejection
First Choice No transition: the automaton hangs
First Choice Input cannot be consumed “reject”
Second Choice No transition: the automaton hangs
Second Choice Input cannot be consumed “reject”
is rejected by the NFA: “reject” “reject” All possible computations lead to rejection
all input is consumed “accept” String is accepted