COMS W3261
Computer Science Theory
Lecture 4: September 21, 2009
Nondeterministic Finite Automata
1. Outline
- Review
- Nondeterministic finite automata
- The subset construction
- DFAs and NFAs are equivalent
2. Review
- Deterministic finite automata
- If L = L(A) for some DFA A, then
L is a regular language.
3. Nondeterministic Finite Automata
- A nondeterministic finite automaton (NFA) consists of
A finite set of states Q.
- An input alphabet consisting of a finite set of symbols Σ.
- A transition function δ that maps Q × &Sigma to
P(Q), the set of subsets of Q.
Like a DFA, this transition function can be represented by a transition diagram
in which the nodes are labeled by states and arcs by symbols.
Unlike a DFA, an NFA may have transitions to zero or more states from
a given state on a given input symbol.
- A start state that is one of the states in Q.
- A set of final (or accepting) states F.
F is a subset of Q.
- An NFA accepts an input string x if there is a path of transitions
from the initial state to a final state that spells out x.
Note that, unlike for a DFA, in an NFA there may be more than one path from
the initial state to a final state that spells out x.
- Note the definition of an extended transition function
for an NFA. See Sect 2.3.3 of HMU.
- L(A), the language defined by an NFA A is the set of
strings accepted by A.
4. Equivalence of DFAs and NFAs: the Subset Construction
- From an NFA N =
(QN, Σ, δN, q0, FN),
we can construct a DFA D =
(QD, Σ, δD, {q0}, FD)
that simulates all possible moves of N on any given input.
QD is the set of all subsets of QN.
- The input alphabet of D is the same as that of N.
- For each state S in QN and each input symbol a in Σ,
- δD(S,a) is the union of all states in
δN(p,a) for all p in S.
- The start state of D is the state {q0}.
- FD, the final states of D, are those states of QD that
contain a state in FN.
- We can prove by induction on the length of an input string w that D can reach
deterministic state S in QD on w iff N can reach each
nondeterministic state p in S on w. See Sect. 2.3.5 of HMU.
5. Bad Case for the Subset Construction
- Let L be the language (a+b)*a(a+b)n-1, that is,
all strings of a's and b's in which the nth
character from the end is an "a". The smallest DFA that accepts L must
have at least 2n states.
6. Practice Problems
- Construct an NFA that accepts all strings of a's and b's ending in abb.
- Show all sequences that your NFA can make on the input string ababb.
- Use the subset construction to convert your NFA into an equivalent DFA.
- Construct an NFA that accepts (a+b)*a(a+b)(a+b).
- Use the subset construction to convert your NFA into an equivalent DFA.
7. Reading Assignment
aho@cs.columbia.edu