Nondeterministic Finite Automata (NFA)

acceptance by an NFA

How does a machine that can branch in many directions decide whether to say yes? The rule is generous: an NFA accepts a string if there EXISTS at least one path — one sequence of legal moves consistent with the input — that reads the whole string and lands on an accept state. Picture all the branching paths as a tree of possibilities; the answer is yes precisely when at least one leaf of that tree is an accepting state.

Work it out by tracking the SET of states the machine could possibly be in. Start in the start state (plus everything reachable by epsilon-moves). For each input symbol, replace your current set by the union of all states reachable from any state in it on that symbol (then add epsilon-reachable states). After the last symbol, the string is accepted if the final set contains ANY accept state. A path that gets "stuck" — reaches a state with no outgoing move on the next symbol — simply dies; it does not cause rejection on its own, because other paths may still survive.

This existential rule is the heart of nondeterminism. Rejection is the all-paths-fail case: the string is rejected only when EVERY possible path either dies or ends in a non-accepting state. So one surviving accepting path outvotes any number of dead-end or rejecting paths. This asymmetry — accept if some path works, reject only if all fail — is exactly what makes nondeterminism such a convenient design lens.

Run the "ends in ab" NFA on input ab. Reachable sets: start {q0}; read a -> {q0, q1}; read b -> {q0, q2}. The final set {q0, q2} contains the accept state q2, so ab is accepted — even though the parallel path that stayed in q0 the whole time did not accept.

Accept if the final set of possible states contains at least one accept state.

A path getting stuck (no legal move) is not the same as rejection; it just removes that one path. Rejection requires ALL paths to fail.

Also called
NFA acceptance conditionNFA 接受條件