UNIHIVE

Study Hub UNIPORT CSC 396

CSC 396 · Automata theory, Computability and Formal Languages

Nondeterministic automata and the subset construction

NFAs and ε-moves, why they accept the same languages as DFAs, converting an NFA to a DFA, and minimising a DFA.

Our notes

2 min read

Nondeterminism

An NFA may have zero, one or several transitions for a state and symbol, and ε-transitions that move without reading input. It accepts a string if at least one path of choices ends in an accepting state.
Formally the transition function is δ: Q × (Σ ∪ {ε}) → sets of states.

Why NFAs

They are often much easier to design. Strings over {0, 1} whose second-last symbol is 1: an NFA "guesses" when it has reached the second-last symbol:

  • q0: on 0 or 1 stay in q0; on 1 also go to q1.
  • q1: on 0 or 1 go to q2.
  • q2: accepting, no transitions.

Equivalence (Rabin and Scott, 1959)

Every NFA has a DFA that accepts exactly the same language. So NFAs are no more powerful, only more convenient.

The subset construction

Each DFA state is a set of NFA states (all the places the NFA could be).
For the second-last-is-1 NFA:

DFA state01
→ {q0}{q0}{q0, q1}
{q0, q1}{q0, q2}{q0, q1, q2}
*{q0, q2}{q0}{q0, q1}
*{q0, q1, q2}{q0, q2}{q0, q1, q2}

Accepting DFA states are those containing q2. Trace 0110: {q0} → {q0} → {q0, q1} → {q0, q1, q2} → {q0, q2}: accepted (second-last symbol is 1) ✓.
In the worst case an NFA with n states needs 2ⁿ DFA states.

ε-closure

With ε-moves, first take the ε-closure of a set (all states reachable by ε-moves alone) at the start and after every symbol.

Minimising a DFA

Two states are equivalent if every string leads both to accept or both to reject. Merge equivalent states:

  1. Split states into accepting and non-accepting.
  2. Repeatedly split any group whose states go to different groups on some symbol.
  3. When no group splits, each group is one state of the minimal DFA.

The minimal DFA for a language is unique (up to renaming states).

Exams usually ask

  • Define an NFA and explain how it accepts.
  • Convert an NFA (with or without ε-moves) to a DFA by the subset construction.
  • Minimise a given DFA.

Common mistake

Making only the DFA state that equals the NFA's final state accepting. Every subset that contains an NFA accepting state is accepting.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

No reading links here yet

Our team adds free books, videos and practice for each topic, and opens every link before it goes up.

All CSC 396 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.