Nondeterministic finite automata (NFA)
Nondeterministic finite automata definition
A nondeterministic finite automaton is a 5-tuple \( (Q, \Sigma, \delta, q_0, F) \), where
- \( Q \) is a finite set called the states,
- \( \Sigma \) is a finite set called the alphabet,
- \( \delta : Q \times \Sigma_{\varepsilon} \to 2^Q \) is the transition function,
- \( q_0 \in Q \) is the start sate, and
- \( F \subseteq Q \) is the set of accept states.
String acceptance
Let \( M = (Q, \Sigma, \delta, q_0, F) \) be a NFA, let \( w \) be a string over the alphabet \( \Sigma \), and let \( \Sigma_{\varepsilon} = \Sigma \cup \{\varepsilon\} \) (where \( \varepsilon \) represents the empty string).
Then \( M \) accepts \( w \) iff we can write \( w = y_1y_2...y_m \) where \( y_i \in \Sigma_{\varepsilon} \) and there exists a sequence of states in \( Q \), \( r_0, r_1, ..., r_m \), meeting three conditions:- \( r_0 = q_0 \)
- \( r_{i+1} \in \delta(r_i, y_{i+1}) \text{, for } i = 0, ..., m-1 \)
- \( r_m \in F \)
\( w \) is rejected iff it is not accepted.
Every nondeterministic finite automaton has an equivalent deterministic finite automaton (two machines are equivalent iff they recognize the same language). The proof of this is worth studying.
Viewed from the perspective of a state machine, nondeterministic finite automata depart from deterministic finite automata by:
- allowing multiple transitions out of a state for a single symbol in the alphabet.
- introducing the automatic transitions, denoted with \( \varepsilon \).
- their parallel computation and acceptance.
Proof outline of NFA an DFA equivalence
Let \( N = (Q, \Sigma, \delta, q_0, F) \) be the NFA recognizing some language \( A \). Try to construct a DFA \( M = (Q', \Sigma, \delta', q_0', F') \) that is equivalent to \( N \).
Construction
- States
-
\( Q' = 2^Q \)
If a DFA is to keep track of the computation of an NFA, it must keep track of all possible active states of the NFA. If an NFA has \( k \) states, an equivalent DFA needs to have \( 2^k \) states, one state for every subset of the NFA's states.
Note how the elements of \( Q' \) are sets! This must be understood in order to make sense of the transition function.
- Transitions
-
For \( R \in Q' \) and \( a \in \Sigma \), let \( \delta'(R, a) = \{q \in Q \mid q \in \delta(r, a) \text{ for some } r \in R \} \)
The transition function for M maps a subset of states of N to a subset of states of N.
- Start state
- \( q_0' = {q_0} \). Note that for the DFA, the state is a set.
- Accept states
- \( F' = \{ R \in Q' \mid R \text{ contains an accept state of N} \} \)
A tweak of the transition function described above is needed to account for the \( \varepsilon \) transitions.
Example