Equivalence of DFAs & NFAs

Lesson 6 proves that nondeterminism buys convenience but not power. It states the equivalence theorem and disposes of its trivial direction, then builds the subset construction component by component, including the empty subset as a dead state and the accepting rule people get wrong, the epsilon-closure in the start subset, and the transition rule. It works conversions from a worklist both with and without free moves, proves correctness by induction on the input length, and gives the pigeonhole lower bound showing that the exponential blowup is unavoidable. It ends with the consequences: complementing an NFA in the right order, and deciding emptiness and infiniteness by graph search.

Subject: Theory of Computation · 110 slides · symbolic lesson

Open the interactive version of this deck · Homework for this lesson

What this lesson covers

The lesson, slide by slide

1. Equivalence of DFAs and NFAs

Title

Theory of Computation · Lesson 6

Every active set becomes a single state. One construction turns any guessing machine into a deterministic one — and shows the guessing bought convenience, not power.

2. What you will be able to do

Objectives

Lesson 5 made machines easy to design by letting them branch. This lesson proves nothing was gained in power, by building the deterministic machine explicitly. By the end you can:

  1. State the equivalence theorem in both directions and say which direction is trivial.
  2. Run the subset construction, with and without ε-arrows, using a worklist.
  1. Prove the construction correct by an induction on input length.
  2. Explain why only the reachable subsets matter, and use that to keep machines small.
  1. Show that the exponential blowup is unavoidable for a specific family of languages.
  2. Use the equivalence to complement a nondeterministic machine and to decide emptiness.

3. What survived from Nondeterministic Finite Automata?

Warm-up

Discussion prompt

Before we open Equivalence of DFAs & NFAs: without looking back, what was the main idea of Nondeterministic Finite Automata, and what could you do by the end of it that you could not do before?

Hint: One sentence for the idea, one for the skill. If the second one is blank, that is the part to revisit.

Answer:

Lesson 5 drops the determinism requirement and lets a machine take several arrows on one symbol, or none at all. It covers the active-set method of running such a machine, acceptance as an existential claim over paths, and the computation tree, then gives the five-tuple with its set-valued transition function, epsilon-arrows and epsilon-closure, and the extended transition function with closures. It closes with guess-and-verify design and the exponential saving in states it can produce, why swapping the accepting set fails to complement an NFA, and what nondeterminism is not.

4. The Claim

Section

Section 1

5. The theorem, and why it is surprising

Concept

The two models look very different. One is forced down a single path; the other explores every path at once. The theorem says they recognize exactly the same languages.

equivalence of the models — A language is recognized by some nondeterministic finite automaton if and only if it is recognized by some deterministic one.

\[ \exists N : L = L(N) \quad \iff \quad \exists D : L = L(D) \]

It is worth pausing on how unusual this is. The analogous statement for the machines of Lesson 20 is one of the great open problems of the subject. Here it is simply true, and the proof is a construction.

6. Break it if you can: The theorem, and why it is surprising

Counterexample

Discussion prompt

The two models look very different. One is forced down a single path; the other explores every path at once. The theorem says they recognize exactly the same languages.

That is stated as though it always holds. Do one of two things: produce a case where it fails, or say precisely what rules such a case out. "It just does" is not on the menu.

Hint: Hunt at the extremes first — zero, one, negative, empty, equal. If every extreme survives, the reason they survive is the proof.

7. One direction is already done

Intuition

An if-and-only-if needs both directions, but one of them was settled in Lesson 5 without any work.

Every deterministic machine already is a nondeterministic one: wrap each transition value in braces and the definition is satisfied. The active set stays a one-element set forever, so behaviour is unchanged.

\[ \delta_N(q,a) = \{\delta_D(q,a)\} \]

So the whole content of the theorem is the other direction: given a machine that branches, produce one that does not. That is what the rest of this lesson builds.

8. By analogy: One direction is already done

Analogy

Discussion prompt

Explain One direction is already done by analogy to something with no Theory of Computation in it at all — a queue, a recipe, a map, a bank balance, whatever fits. Then say where your analogy breaks.

Hint: An analogy that never breaks is not an analogy, it is the same idea wearing a hat. Find the seam — that is the part that is actually new.

Answer:

An if-and-only-if needs both directions, but one of them was settled in Lesson 5 without any work.

9. The key idea in one line

Concept

The construction rests on a single observation, and everything else is bookkeeping.

At any moment during a run, the nondeterministic machine's situation is completely described by the set of states it could be in. Nothing else about the history matters.

That set is a subset of the state set, and the state set is finite, so there are only finitely many possible situations — exactly as many as there are subsets. Finitely many situations is precisely what a deterministic state set needs to be.

\[ \text{situations} = \mathcal{P}(Q_N), \qquad |\mathcal{P}(Q_N)| = 2^{|Q_N|} \]

10. Teach it back: The key idea in one line

Explain it

Discussion prompt

Explain The key idea in one line to a student a year behind you. No notation, no jargon they have not met — and it still has to be true.

Hint: If your explanation needs a symbol they have never seen, you are describing the notation rather than the idea.

Answer:

The construction rests on a single observation, and everything else is bookkeeping.

11. Make each situation a state

Intuition

The move is almost too simple to state: take the thing the machine is uncertain about, and make that the new machine's state.

The uncertainty does not disappear. It gets absorbed into the names of the states. A deterministic machine sitting in the state named 'the set containing the first and third states' is deterministically recording exactly what the original was unsure about.

This trick — determinize by making the uncertainty explicit — reappears throughout the subject. It is the same idea that turns a search into a dynamic program.

\[ \text{uncertainty about } Q_N \;\longmapsto\; \text{certainty about } \mathcal{P}(Q_N) \]

12. What 'the same language' means here

Concept

The theorem is a claim about languages, not about machines. Two machines are called equivalent when they agree on every string, without exception.

equivalent machines — Two machines, of any kind, that accept exactly the same set of strings.

\[ M_1 \equiv M_2 \quad \overset{\text{def}}{\iff} \quad L(M_1) = L(M_2) \]

Nothing about shape, size or determinism enters the definition. A two-state machine and a two-hundred-state machine are equivalent if they agree everywhere, and disagreeing on one string of length forty is enough to make them inequivalent.

13. What has to happen first: Check two machines agree by comparing verdicts

Ranking

Put in order

Put the moves of Check two machines agree by comparing verdicts into the order they have to happen.

  1. Run both on a string that exercises the choice
  2. Run both on a rejected string
  3. Run both on the empty string
  4. Note what testing cannot establish
  5. Verify that a single disagreement would settle it

Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. Take the input 101. The deterministic machine walks a single path; the nondeterministic one tracks an active set.

14. Check two machines agree by comparing verdicts

Worked example

Before constructing anything, practise the notion of equivalence on a pair of small machines that both claim to accept the strings ending in 1.

Run both on a string that exercises the choice

Why: Take the input 101. The deterministic machine walks a single path; the nondeterministic one tracks an active set. Both finish in an accepting situation.

\[ \hat{\delta}_D(q_0,101) \in F, \qquad \hat{\delta}_N(q_0,101) \cap F \neq \varnothing \]

Run both on a rejected string

Why: Take 110. The deterministic machine finishes on a non-accepting state; the nondeterministic active set misses the accepting set. They agree again.

Run both on the empty string

Why: Neither accepts it, since neither start situation is accepting. Boundary cases are where inequivalence usually hides, so this is not a formality.

Note what testing cannot establish

Why: Agreeing on three strings is not agreement on all of them. Testing can refute equivalence outright but can never confirm it, which is precisely why the rest of this lesson proves a theorem instead.

Verify that a single disagreement would settle it

Why: Had either machine differed on any one of the three strings, that string alone would prove them inequivalent — no further work needed. Refutation is cheap; confirmation needs the construction and its proof.

\[ \exists w : w \in L(M_1) \;\triangle\; L(M_2) \;\Rightarrow\; M_1 \not\equiv M_2 \ \checkmark \]

15. Do the construction by hand on a two-state machine

Worked example

Before the general definition, watch it happen on the smallest interesting example: a machine over one symbol whose start state has two a-arrows.

Figure (svg): Automaton with states n0, n1

One symbol, one branch point.

Name the start subset

Why: The run begins with only the start state live, so the deterministic machine's start state is the one-element subset holding it.

\[ s_0 = \{n_0\} \]

Ask where that subset goes on a

Why: Union the a-arrows from every member. The only member has two, so the result is a two-element subset — a new state of the deterministic machine.

\[ \delta_D(\{n_0\}, a) = \{n_0, n_1\} \]

Ask where the new subset goes on a

Why: Union again: the first state contributes both, and the second contributes nothing. The result is the same two-element subset, so no new state appears.

\[ \delta_D(\{n_0,n_1\}, a) = \{n_0,n_1\} \cup \varnothing = \{n_0,n_1\} \]

Mark the accepting subsets

Why: A subset is accepting when it contains at least one accepting state of the original. Only the two-element subset qualifies.

\[ F_D = \{\, \{n_0,n_1\} \,\} \]

Verify the finished machine against the original

Why: The deterministic machine has two states and accepts every nonempty run of a's, rejecting only the empty string. The original accepted exactly the same strings, since one a is enough to put an accepting state in the active set. Four subsets exist in principle, but only two were ever reached.

\[ L(D) = a^{+} = L(N) \ \checkmark \]

16. Decode the notation: Do the construction by hand on a two-state machine

Notation

Annotate

From Do the construction by hand on a two-state machine — read this one piece at a time. What is each part doing?

On: \( \delta_D(\{n_0\}, a) = \{n_0, n_1\} \)

  • The run begins with only the start state live, so the deterministic machine's start state is the one-element subset holding it.
  • Union the a-arrows from every member. The only member has two, so the result is a two-element subset — a new state of the deterministic machine.
  • Union again: the first state contributes both, and the second contributes nothing. The result is the same two-element subset, so no new state appears.

17. Rebuild the recipe: The subset construction, as a procedure

Ranking

Put in order

These are the steps of The subset construction, as a procedure, scrambled. Put them back in order before the next slide shows you.

  1. Start with the subset holding just the start state, and put it on the worklist.
  2. Take a subset off the worklist. For each symbol, union the transitions of all its members.
  3. If the resulting subset is new, name it a state and add it to the worklist.
  4. Repeat until the worklist is empty.
  5. Mark as accepting every subset that contains at least one accepting state of the original.

Why: This is the order the recipe itself gives. Recalling the sequence without the slide in front of you is the difference between recognising the method and being able to run it — most of what goes wrong in practice is a step done out of turn.

18. The subset construction, as a procedure

Pattern

Run it as a worklist. Never enumerate all the subsets in advance — most of them are unreachable.

  1. Start with the subset holding just the start state, and put it on the worklist.
  2. Take a subset off the worklist. For each symbol, union the transitions of all its members.
  3. If the resulting subset is new, name it a state and add it to the worklist.
  4. Repeat until the worklist is empty.
  5. Mark as accepting every subset that contains at least one accepting state of the original.

Working from the worklist is what keeps the construction practical. The exponential in the theorem is a worst case, not a typical one.

19. Rule out three: Check yourself: the key idea

Elimination

Eliminate the wrong options

In the subset construction, what does one state of the resulting deterministic machine represent?

3 of these 4 are wrong. Strike them one at a time, and say what rules each one out before you strike the next. The survivor is the answer.

  • A. A set of states the original machine could currently be in
  • B. A single state of the original machine
  • C. One accepting path through the original machine
  • D. One input string the original machine accepts

Survives elimination: A

Why: The uncertainty about which state the original occupies is exactly what the new state records. Making that set the unit of bookkeeping is what removes the branching, since a set has a single well-defined successor on each symbol.

20. Check yourself: the key idea

Check

Think about what the new machine's states are named after.

Check your understanding

In the subset construction, what does one state of the resulting deterministic machine represent?

  • A. A set of states the original machine could currently be in (correct)
  • B. A single state of the original machine
  • C. One accepting path through the original machine
  • D. One input string the original machine accepts

Answer: A

Why: The uncertainty about which state the original occupies is exactly what the new state records. Making that set the unit of bookkeeping is what removes the branching, since a set has a single well-defined successor on each symbol.

Why B tempts people
If states corresponded one to one, the branching would be unresolved: a single state can have two successors on one symbol, which is what determinism forbids.
Why C tempts people
There can be unboundedly many accepting paths, and paths depend on the input. The state set must be finite and fixed before any input is seen.
Why D tempts people
The language may be infinite, so there could be no finite state set at all under that reading.

21. The Construction, Component by Component

Section

Section 2

22. The five components of the new machine

Concept

Given a nondeterministic machine, define a deterministic one over the same alphabet, one component at a time.

ComponentDefinition
statesthe subsets of the original state set
alphabetunchanged
transitionunion the transitions of every member
startthe subset holding the original start state
acceptingthe subsets meeting the original accepting set

\[ Q_D = \mathcal{P}(Q_N), \qquad |Q_D| = 2^{|Q_N|} \]

23. Fill in: Definition for The five components of the new machine

Comparison

Comparison matrix

From The five components of the new machine: refill the Definition column from what you know. The rest of the table is as it appeared.

ComponentDefinition
statesthe subsets of the original state set
alphabetunchanged
transitionunion the transitions of every member
startthe subset holding the original start state
acceptingthe subsets meeting the original accepting set

24. The transition rule

Concept

The transition function of the new machine is the active-set update rule of Lesson 5, promoted to a definition.

\[ \delta_D(S,a) \;=\; \bigcup_{p \in S} \delta(p,a) \quad \text{(no free moves)} \]

This is a genuine function: given a subset and a symbol, the union is one specific subset. Nothing is left to choose, so the new machine is deterministic by construction.

Note that it is total as well. If the union comes out empty, the empty subset is still a perfectly good state of the new machine — it is the state meaning 'every branch has died'.

\[ \delta_D(\varnothing, a) = \varnothing \]

25. The empty subset is a dead state

Concept

The subset with no members deserves a moment, because it is where the two models' differences go to be resolved.

The original machine could get stuck, with no arrow to follow. The new machine never gets stuck: it moves into the empty subset and stays there, since a union over no members is empty.

The empty subset contains no accepting state, so it is not accepting. It loops to itself on every symbol. That is exactly the dead state of Lesson 4, arrived at by construction rather than by hand.

\[ \varnothing \notin F_D \quad\text{and}\quad \delta_D(\varnothing,a) = \varnothing \]

26. Something is wrong here: which subsets count as accepting

Anomaly

Predict first

A student writes this, and it looks reasonable:

In the determinized machine, which subsets belong in the accepting set?

It is wrong. Say what breaks — and say it before you turn the page.

Correct: A subset ought to count as accepting when the subset itself 'is' accepting — so require every member of it to be an accepting state of the original.

In the determinized machine, which subsets belong in the accepting set?

Why: A subset ought to count as accepting when the subset itself 'is' accepting — so require every member of it to be an accepting state of the original.

27. Trap: which subsets count as accepting

Trap

The trap

In the determinized machine, which subsets belong in the accepting set?

Take the subsets made entirely of accepting states

Why: A subset ought to count as accepting when the subset itself 'is' accepting — so require every member of it to be an accepting state of the original.

\[ F_D = \{\, S \;:\; S \subseteq F \,\} \]

Apply it to a mixed subset

Why: A subset holding one accepting and one non-accepting state fails the test, so it is rejected — and every string reaching it is rejected too.

\[ \{q_0, q_2\} \not\subseteq \{q_2\} \;\Rightarrow\; \text{reject} \]

The fix

In the determinized machine, which subsets belong in the accepting set?

Take the subsets that CONTAIN at least one accepting state

Why: The subset records the states the original could be in. The original accepts when SOME branch is accepting, so the subset must be accepting the moment a single member is.

\[ F_D = \{\, S \;:\; S \cap F \neq \varnothing \,\} \]

Apply it to the same mixed subset

Why: The mixed subset meets the accepting set, so it is accepting — which is right, since the branch sitting on the accepting state is a genuine accepting path.

\[ \{q_0, q_2\} \cap \{q_2\} \neq \varnothing \;\Rightarrow\; \text{accept} \ \checkmark \]

28. Decode the notation: Trap: which subsets count as accepting

Notation

Annotate

From Trap: which subsets count as accepting — read this one piece at a time. What is each part doing?

On: \( \{q_0, q_2\} \cap \{q_2\} \neq \varnothing \;\Rightarrow\; \text{accept} \ \checkmark \)

  • A subset ought to count as accepting when the subset itself 'is' accepting — so require every member of it to be an accepting state of the original.
  • A subset holding one accepting and one non-accepting state fails the test, so it is rejected — and every string reaching it is rejected too.
  • The subset records the states the original could be in. The original accepts when SOME branch is accepting, so the subset must be accepting the moment a single member is.

29. Handling epsilon-arrows: close everywhere

Concept

If the original has ε-arrows, two of the five components change, and both changes are the same idea: saturate before you look.

The start subset is the ε-closure of the original start state, not the bare start state.

\[ s_0 = E\big(\{q_0\}\big) \]

And the transition rule closes after unioning, so no free move is ever missed.

\[ \delta_D(S,a) \;=\; E\!\left(\bigcup_{p \in S} \delta(p,a)\right) \]

Nothing else changes. The accepting rule is untouched, because closure has already put every freely reachable state into the subset before the test is applied.

30. Read the subset names aloud and the machine explains itself

Intuition

A determinized machine can look opaque, because its states are named after sets. Saying the names out loud fixes that immediately.

The state named after a two-element subset means: 'the original could be in either of these two right now'. The state named after the empty subset means: 'every branch has died'. Those readings are the whole semantics.

Once the names are read this way, the finished machine usually turns out to be a machine you could have designed by hand — with the subsets standing for exactly the facts a Lesson 4 design would have tracked.

\[ \{q_0,q_1\} \;\longleftrightarrow\; \text{'could be at the start, or one step in'} \]

31. The start subset is the only asymmetric component

Concept

Four of the five components are defined uniformly over all subsets. The start is the exception, and it is where ε-arrows first bite.

Without free moves the start subset is simply the one-element subset holding the original start state. With them it is that state's closure, which may be much larger.

\[ s_0 = E\big(\{q_0\}\big) \;\supseteq\; \{q_0\} \]

This is also what makes the base case of the correctness proof work. Getting the start subset wrong is the single most common construction error, and it shows up first on the empty string.

32. Answer it before you see the options: Check yourself: handling free moves

Prediction

Predict first

When determinizing a machine that has ε-arrows, where must ε-closure be applied?

Answer it in your own words, now, with nothing to choose from. The options are on the next slide — and picking the right one off a list is an easier skill than producing it.

Correct: To the start subset, and to the union after every symbol

Why: Free moves may be taken at any moment, including before the first symbol and after every later one. Closing in both places is what guarantees the constructed state always equals the original's true active set.

33. Check yourself: handling free moves

Check

Think about where a closure has to be applied.

Check your understanding

When determinizing a machine that has ε-arrows, where must ε-closure be applied?

  • A. To the start subset, and to the union after every symbol (correct)
  • B. To the start subset only
  • C. To the union after every symbol only
  • D. To the accepting subsets, when deciding which are accepting

Answer: A

Why: Free moves may be taken at any moment, including before the first symbol and after every later one. Closing in both places is what guarantees the constructed state always equals the original's true active set.

Why B tempts people
Closing only at the start misses every ε-arrow taken later in the run, so the constructed machine would understate the active set from the second symbol onwards.
Why C tempts people
Closing only after symbols misses the free moves available before any symbol is read, which is exactly what decides the empty string.
Why D tempts people
The accepting rule needs no closure of its own. Because the subsets are already closed when they are built, the plain meets-the-accepting-set test is correct as written.

34. Running the construction with epsilon-arrows

Pattern

The same worklist, with two closures inserted. Say 'close, read, close' at every step.

  1. Compute the ε-closure of the start state; that closed set is the start subset.
  2. For each symbol, union the transitions of every member of the current subset.
  3. Take the ε-closure of that union — this is the step most often skipped.
  4. Add any new subset to the worklist and repeat.
  5. Mark accepting exactly those subsets meeting the original accepting set.

If a machine has no ε-arrows, every closure is the identity, so this procedure is the earlier one. There is no need to remember two constructions.

35. Worked Conversions

Section

Section 3

36. Picture it first: Convert the ends-in-01 machine to a…

Picture it

Figure (svg): Automaton with states q0, q1, q2

Discussion prompt

Read the picture before the words. What is this showing, and what is the one thing it is built to make obvious? Commit to an answer, then read on.

Hint: Name the parts, then say what changes between them — and if nothing changes, say what is being held still.

Answer:

Determinize this three-state machine. There are no ε-arrows, so every closure is trivial.

37. Convert the ends-in-01 machine to a deterministic one

Worked example

Determinize this three-state machine. There are no ε-arrows, so every closure is trivial.

Figure (svg): Automaton with states q0, q1, q2

Write the original's set-valued table first

Why: This is the lookup table every later step consults, so getting it right once saves all the later work.

δ01
-> q0{q0, q1}{q0}
q1{}{q2}
* q2{}{}

Start from the subset holding the start state

Why: Union the rows of its single member for each symbol. Both results are new subsets, so both go on the worklist.

\[ \delta_D(\{q_0\},0) = \{q_0,q_1\}, \qquad \delta_D(\{q_0\},1) = \{q_0\} \]

Process the two-element subset by unioning both members' rows

Why: On 0 the first member gives both states and the second gives nothing. On 1 the first gives the start state and the second gives the accepting state.

\[ \delta_D(\{q_0,q_1\},0) = \{q_0,q_1\}, \qquad \delta_D(\{q_0,q_1\},1) = \{q_0,q_2\} \]

Process the subset containing the accepting state

Why: On 0 the start state gives both and the accepting state gives nothing. On 1 the start state gives itself and the accepting state gives nothing. No new subsets appear, so the worklist empties.

subset01
-> {q0}{q0,q1}{q0}
{q0,q1}{q0,q1}{q0,q2}
* {q0,q2}{q0,q1}{q0}

Mark the accepting subsets and compare with Lesson 4

Why: Only the subset containing the accepting state qualifies. The finished machine has three states, and their meanings match the hand-built DFA exactly: no progress, ends in 0, ends in 01. The construction rediscovered the invariants that had to be invented by hand.

Verify on two strings and count the reachable subsets

Why: The string 101 ends in 01 and its subset run finishes in the accepting subset; 010 does not and finishes outside it. Eight subsets exist in principle but only three were reached, so the worklist never wasted effort on the other five.

\[ 101 \in L(D), \quad 010 \notin L(D), \quad 3 \text{ of } 2^{3} \text{ subsets reachable} \ \checkmark \]

38. Watch it run: Convert the ends-in-01 machine to a deterministic one

Pattern

Step through it

Step through Convert the ends-in-01 machine to a deterministic one one row at a time. What is driving the change, and what would the row after the last one be?

  1. Step 1: δ is -> q0
  2. Step 2: δ is q1
  3. Step 3: δ is * q2

39. Without one step: Naming the subsets so the result stays readable

Constraint

Discussion prompt

Run Naming the subsets so the result stays readable with this step confiscated:

Rename each state after that meaning, not after a number.

Is it still possible? If it is, say what takes its place and what it costs you. If it is not, say exactly what that step was providing that nothing else does.

Hint: A step you can drop for free was never load-bearing. If you cannot drop it, name the thing that goes wrong the moment it is gone.

Answer:

  1. Keep the subset names while you build, so every transition can be checked against the original.
  2. When the worklist empties, read each subset aloud and write down what it means.
  3. Rename each state after that meaning, not after a number.
  4. Keep the subset names in a side column, so the construction stays auditable.
  5. Only then draw the diagram.

40. Naming the subsets so the result stays readable

Pattern

A determinized machine with subset names is correct but unreadable. Renaming it is a small step that pays for itself.

  1. Keep the subset names while you build, so every transition can be checked against the original.
  2. When the worklist empties, read each subset aloud and write down what it means.
  3. Rename each state after that meaning, not after a number.
  4. Keep the subset names in a side column, so the construction stays auditable.
  5. Only then draw the diagram.

This is also the moment when a determinized machine can be compared with a hand-built one. If the meanings match, the two designs are the same machine wearing different labels.

41. Where does it stop working: Naming the subsets so the result stays…

Edge cases

Discussion prompt

Naming the subsets so the result stays readable works on the cases you have just seen. Push it to the edge: what is the most degenerate input it still handles — empty, zero, one item, everything equal — and what is the first case where it stops being true? Name the case, not just "it breaks".

Hint: Try the smallest legal input, then the largest, then the one where two things collide. Methods are specified at their edges; the middle takes care of itself.

Answer:

A determinized machine with subset names is correct but unreadable. Renaming it is a small step that pays for itself.

42. Why the unreachable subsets can be discarded safely

Intuition

The definition builds every subset, and most constructions build almost none of them. It is worth being clear on why that is not cheating.

A state that no input can reach cannot influence any verdict, because verdicts are decided by where inputs end up. Deleting it changes no accepted string and no rejected one.

The reachable collection is also closed under transitions — anything one step from a reachable subset is itself reachable — so the restricted machine is still total and still deterministic. Nothing about the definition is violated.

\[ S \text{ reachable} \;\Rightarrow\; \delta_D(S,a) \text{ reachable} \]

43. Where does each piece belong: Equivalence of DFAs & NFAs

Sorting

Sort into buckets

These are the pieces of Equivalence of DFAs & NFAs, out of order. Put each one back under the part of the lesson it belongs to.

The Claim
The theorem, and why it is surprising; One direction is already done; The key idea in one line
The Construction, Component by Component
The five components of the new machine; The transition rule; The empty subset is a dead state
Worked Conversions
Convert the ends-in-01 machine to a deterministic one; Naming the subsets so the result stays readable; Why the unreachable subsets can be discarded safely
s1
The Claim is where Equivalence of DFAs & NFAs puts The theorem, and why it is surprising, One direction is already done, The key idea in one line. Knowing which part of the lesson a problem belongs to is most of knowing which method to reach for.
s2
The Construction, Component by Component is where Equivalence of DFAs & NFAs puts The five components of the new machine, The transition rule, The empty subset is a dead state. Knowing which part of the lesson a problem belongs to is most of knowing which method to reach for.
s3
Worked Conversions is where Equivalence of DFAs & NFAs puts Convert the ends-in-01 machine to a deterministic one, Naming the subsets so the result stays readable, Why the unreachable subsets can be discarded safely. Knowing which part of the lesson a problem belongs to is most of knowing which method to reach for.

44. Only the reachable subsets matter

Concept

The definition takes the state set to be all subsets, which is convenient for the proof and wasteful in practice.

A state no path ever reaches cannot affect which strings are accepted. So we may safely restrict the state set to the subsets reachable from the start subset.

The restricted machine is still deterministic — the reachable collection is closed under transitions by construction — and it recognizes the same language.

\[ Q_D' = \{\, \hat{\delta}_D(s_0, w) : w \in \Sigma^{*} \,\} \subseteq \mathcal{P}(Q_N) \]

The worklist procedure computes exactly this restricted set and nothing more, which is why it is the version worth learning.

45. Plan first: Convert a machine with epsilon-arrows

Step zero

Discussion prompt

Convert a machine with epsilon-arrows — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.

Hint: It starts with: Compute the start subset by closing

Answer:

  1. Compute the start subset by closing
  2. Take the a-transition from the start subset
  3. Take the b-transition from the start subset
  4. Finish the worklist
  5. Verify by checking the empty string on both machines

46. Convert a machine with epsilon-arrows

Worked example

Now with free moves in play. Take a machine whose start state has an ε-arrow to a second state, where the second state loops on a and reads b into an accepting state.

Compute the start subset by closing

Why: The start state's closure includes the state at the end of the ε-arrow. The deterministic machine therefore starts in a two-element subset, not a one-element one.

\[ s_0 = E\big(\{p_0\}\big) = \{p_0, p_1\} \]

Take the a-transition from the start subset

Why: Only the second member has an a-arrow. Union gives a one-element subset, and closing it adds nothing new.

\[ \delta_D(s_0, a) = E\big(\{p_1\}\big) = \{p_1\} \]

Take the b-transition from the start subset

Why: Only the second member has a b-arrow, reaching the accepting state. Closing changes nothing, and this subset is accepting.

\[ \delta_D(s_0, b) = \{p_2\}, \qquad \{p_2\} \cap F \neq \varnothing \]

Finish the worklist

Why: The two new subsets are processed the same way. Any transition with no arrows produces the empty subset, which becomes the dead state.

Verify by checking the empty string on both machines

Why: The original accepts the empty string only if the closure of its start state meets the accepting set — it does not, here. The deterministic machine's start subset is that same closed set, and it is not accepting. The two agree on the case the closure was introduced for.

\[ s_0 \cap F = \varnothing \;\Rightarrow\; \varepsilon \notin L(D) = L(N) \ \checkmark \]

47. Convert a machine with epsilon-arrows — line by line

Picture it

Animation

Shows: Each line of the worked example "Convert a machine with epsilon-arrows", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: The original accepts the empty string only if the closure of its start state meets the accepting set — it does not, here. The deterministic machine's start subset is that same closed set, and it is not accepting. The two agree on the case the closure was introduced for.

48. Guess the shape of the answer: Determinize a machine with a genuine branch…

Estimation

Predict first

A machine over the alphabet of a and b that accepts exactly the two strings ab and ba, built with two independent branches from the start.

Commit before you compute: what does Determinize a machine with a genuine branch point come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.

Correct: Verify on both members and two non-members

Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. The strings ab and ba each reach an accepting subset.

49. Determinize a machine with a genuine branch point

Worked example

A machine over the alphabet of a and b that accepts exactly the two strings ab and ba, built with two independent branches from the start.

Write down the original

Why: From the start state, an a-arrow leads into the first branch and a b-arrow into the second. Each branch reads one more symbol into its own accepting state.

\[ L(N) = \{ab, ba\} \]

Start the worklist

Why: The start subset holds only the start state. On a it reaches the first branch's middle state; on b, the second's.

Process both middle subsets

Why: Each has exactly one continuation and one dead direction. The dead direction produces the empty subset, which enters the machine as the dead state.

\[ \delta_D(\{r_1\}, b) = \{r_2\}, \qquad \delta_D(\{r_1\}, a) = \varnothing \]

Count what came out

Why: Five reachable subsets: the start, the two middles, the merged accepting one, and the empty subset. The original had five states, so no blowup occurred at all here.

Verify on both members and two non-members

Why: The strings ab and ba each reach an accepting subset. The strings aa and bb each fall into the empty subset after two symbols, and are rejected. Since the language holds exactly two strings, checking both members and two near-misses settles it.

\[ ab,\ ba \in L(D) \qquad aa,\ bb \notin L(D) \ \checkmark \]

50. Determinize a machine with a genuine branch point — line by line

Picture it

Animation

Shows: Each line of the worked example "Determinize a machine with a genuine branch point", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: The strings ab and ba each reach an accepting subset. The strings aa and bb each fall into the empty subset after two symbols, and are rejected. Since the language holds exactly two strings, checking both members and two near-misses settles it.

51. Check yourself: the construction

Check

Think about what happens when a subset has no continuation.

Check your understanding

During the subset construction, the union for some subset and symbol comes out empty. What should be done?

  • A. Add the empty subset as a state; it is the dead state and loops to itself (correct)
  • B. Leave that transition undefined in the deterministic machine
  • C. Make the empty subset accepting, since nothing rejected it
  • D. Discard the subset that produced it

Answer: A

Why: A deterministic machine needs a total transition function, so the empty subset must be a genuine state. It contains no accepting state, so it is non-accepting, and every union over its zero members is empty, so it loops to itself forever.

Why B tempts people
An undefined transition would make the result not a DFA at all. Totality is exactly what the construction has to deliver.
Why C tempts people
Accepting requires the subset to meet the original accepting set. The empty subset meets nothing at all.
Why D tempts people
The subset that produced it is perfectly reachable and may well lead to accepting subsets on other symbols. Nothing is discarded.

52. Why It Works

Section

Section 4

53. The invariant to prove

Concept

The construction looks obviously right, which is exactly when a proof is worth writing. The claim is a single equation.

After reading any string, the state the deterministic machine occupies is the set of states the original could occupy.

\[ \hat{\delta}_D(s_0, w) \;=\; \hat{\delta}_N(q_0, w) \quad \text{for every } w \]

Note what is being asserted: the left side is a single state of the new machine, and the right side is a subset of the old one. They are equal because the new states are subsets. That identification is the whole proof strategy.

54. Plan first: Prove the invariant by induction on input length

Step zero

Discussion prompt

Prove the invariant by induction on input length — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.

Hint: It starts with: Check the base case

Answer:

  1. Check the base case
  2. Set up the inductive step
  3. Evaluate the deterministic side
  4. Evaluate the nondeterministic side
  5. Verify the two expressions are literally identical, and finish

55. Prove the invariant by induction on input length

Worked example

Induct on the length of the string, exactly as in Lesson 4's correctness proofs.

Check the base case

Why: On the empty string the deterministic machine sits in its start state, which was defined to be the ε-closure of the original start state — and that closure is precisely the original's active set after reading nothing.

\[ \hat{\delta}_D(s_0,\varepsilon) = s_0 = E(\{q_0\}) = \hat{\delta}_N(q_0,\varepsilon) \]

Set up the inductive step

Why: Assume the two sides agree after some string, call that common set S, and read one more symbol.

\[ \hat{\delta}_D(s_0,w) = \hat{\delta}_N(q_0,w) = S \]

Evaluate the deterministic side

Why: By the definition of the extended function it takes one ordinary step from S, and the transition rule says that step is the closed union over the members of S.

\[ \hat{\delta}_D(s_0, wa) = \delta_D(S,a) = E\!\left(\bigcup_{p \in S}\delta(p,a)\right) \]

Evaluate the nondeterministic side

Why: The active-set rule of Lesson 5 gives the closed union over the members of its current set, which by hypothesis is the same S.

\[ \hat{\delta}_N(q_0, wa) = E\!\left(\bigcup_{p \in S}\delta(p,a)\right) \]

Verify the two expressions are literally identical, and finish

Why: Both sides reduced to the same closed union over the same set, so they are equal and the induction closes. Acceptance then follows immediately: the deterministic machine accepts exactly when its state meets the accepting set, which by the invariant is exactly when the original had an accepting branch.

\[ w \in L(D) \iff S \cap F \neq \varnothing \iff w \in L(N) \ \checkmark \]

56. Prove the invariant by induction on input length — line by line

Picture it

Animation

Shows: Each line of the worked example "Prove the invariant by induction on input length", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: On the empty string the deterministic machine sits in its start state, which was defined to be the ε-closure of the original start state — and that closure is precisely the original's active set after reading nothing.

57. Why induction on length is the right induction

Concept

The proof inducted on the length of the input rather than on the structure of the machine. That choice was forced, and seeing why is useful.

The claim being proved mentions an arbitrary string, and strings are built one symbol at a time. So the induction has to follow the way strings are built — which is exactly the recursive definition of the extended transition function from Lesson 4.

A machine, by contrast, has no inductive structure to recurse on: a diagram with cycles has no base case. That asymmetry recurs in Lesson 9, where converting a machine back into an expression cannot be done by recursion either.

\[ \text{strings: inductive} \qquad \text{graphs: not} \]

58. Something is wrong here: closing once instead of at every step

Anomaly

Predict first

A student writes this, and it looks reasonable:

Determinize a machine whose start state reads a into a state r, and r has an ε-arrow onward to an accepting state.

It is wrong. Say what breaks — and say it before you turn the page.

Correct: The start state has no ε-arrow out of it, so its closure is itself.

Determinize a machine whose start state reads a into a state r, and r has an ε-arrow onward to an accepting state.

Why: The start state has no ε-arrow out of it, so its closure is itself. With that done, treat the remaining steps as an ordinary construction and just union the transitions.

59. Trap: closing once instead of at every step

Trap

The trap

Determinize a machine whose start state reads a into a state r, and r has an ε-arrow onward to an accepting state.

Close the start subset and then stop closing

Why: The start state has no ε-arrow out of it, so its closure is itself. With that done, treat the remaining steps as an ordinary construction and just union the transitions.

\[ s_0 = \{p_0\}, \qquad \delta_D(s_0,a) = \{r\} \]

Read off the verdict for the input a

Why: The subset holding r is not accepting, since r itself is not an accepting state. So the machine rejects a.

\[ \{r\} \cap F = \varnothing \;\Rightarrow\; \text{reject} \]

The fix

Determinize a machine whose start state reads a into a state r, and r has an ε-arrow onward to an accepting state.

Close after every union, not only at the start

Why: The transition rule closes the union each time. After reading a, the branch at r may immediately drift down the free arrow, so the subset must include the accepting state as well.

\[ \delta_D(s_0,a) = E\big(\{r\}\big) = \{r, f\} \]

Read off the verdict again

Why: The subset now meets the accepting set, so a is accepted — which is right, since the original machine has a genuine accepting path spelling a.

\[ \{r,f\} \cap F \neq \varnothing \;\Rightarrow\; \text{accept} \ \checkmark \]

60. Which of these survive contact with Equivalence of DFAs & NFAs?

Two truths and a lie

Sort into buckets

Some of these hold up and some are the exact mistakes this lesson is built to prevent. Sort them.

Holds up
The two models look very different. One is forced down a single path; the other explores every path at once. The theorem says they recognize exactly the same languages.; An if-and-only-if needs both directions, but one of them was settled in Lesson 5 without any work.; The construction rests on a single observation, and everything else is bookkeeping.
Breaks
In the determinized machine, which subsets belong in the accepting set?; Determinize a machine whose start state reads a into a state r, and r has an ε-arrow onward to an accepting state.
sound
These are stated as this lesson states them — each one survives the edge cases Equivalence of DFAs & NFAs puts it through.
flawed
Each of these is lifted from a trap in this deck: reasonable-sounding, and wrong in a way that only shows up once you rely on it.

61. Where each hypothesis was used

Intuition

A short proof is worth re-reading for what it quietly relied on.

Change any one of those and the proof breaks at an identifiable line — which is a good sign that the construction has no slack in it.

62. State the rule before it runs: Watch the invariant hold on a concrete…

Hypothesis

Predict first

Watch the invariant hold on a concrete string is about to be worked. State your hypothesis first: which rule or definition decides this one, and what is the first move it forces? Then watch whether the example agrees with you.

Correct: Compare after reading nothing

Why: The original's active set is its start state alone; the deterministic machine sits in the subset of the same name.

A hypothesis you wrote down is falsifiable; a vague sense of how it will go is not. If the example opens somewhere else, that gap is the thing worth chasing.

63. Watch the invariant hold on a concrete string

Worked example

Trace both machines side by side on the input 001, using the ends-in-01 pair from Section 3.

Compare after reading nothing

Why: The original's active set is its start state alone; the deterministic machine sits in the subset of the same name.

\[ \{q_0\} = \{q_0\} \]

Compare after the first 0

Why: The original branches to two states. The deterministic machine takes its single arrow into the subset holding exactly those two.

\[ \{q_0,q_1\} = \{q_0,q_1\} \]

Compare after the second 0

Why: One branch dies and the other splits again, leaving the same pair. The deterministic machine's self-loop agrees.

\[ \{q_0,q_1\} = \{q_0,q_1\} \]

Compare after the 1

Why: The original reaches the start state and the accepting state. The deterministic machine moves to the subset holding both, which is marked accepting.

\[ \{q_0,q_2\} = \{q_0,q_2\} \]

Verify that the agreement held at every prefix, not just at the end

Why: All four pairs matched, which is what an induction on length actually asserts. Both machines accept 001, and they did so for the same reason at every intermediate step.

\[ \varepsilon,\ 0,\ 00,\ 001: \quad \hat{\delta}_D = \hat{\delta}_N \ \checkmark \]

64. Watch the invariant hold on a concrete string — line by line

Picture it

Animation

Shows: Each line of the worked example "Watch the invariant hold on a concrete string", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: All four pairs matched, which is what an induction on length actually asserts. Both machines accept 001, and they did so for the same reason at every intermediate step.

65. How sure are you: Check yourself: the invariant

Commit first

Predict first

In the correctness proof, the deterministic machine's current state is claimed to equal what?

Commit to an answer, then rate it — certain, fairly sure, or guessing — and write the rating down before you turn the page.

Correct: The set of states the original machine could currently occupy

Why: Each state of the constructed machine is literally a subset of the original's states, and the invariant says that subset is exactly the original's active set after the same input. Acceptance then transfers immediately.

The rating matters as much as the answer: confident-and-wrong is the combination that survives revision, because nothing about it feels like it needs revisiting.

66. Check yourself: the invariant

Check

Recall what the two sides of the invariant are.

Check your understanding

In the correctness proof, the deterministic machine's current state is claimed to equal what?

  • A. The set of states the original machine could currently occupy (correct)
  • B. The single state the original machine does occupy
  • C. The set of accepting states reachable from the original's start
  • D. The number of live branches in the original

Answer: A

Why: Each state of the constructed machine is literally a subset of the original's states, and the invariant says that subset is exactly the original's active set after the same input. Acceptance then transfers immediately.

Why B tempts people
There is no single state the original occupies — resolving that ambiguity is the entire purpose of the construction.
Why C tempts people
That set does not change as the input is read, so it could not track anything about the current situation.
Why D tempts people
A count would lose which states are live, and two different active sets of the same size behave completely differently.

67. The Cost: An Unavoidable Blowup

Section

Section 5

68. The bound, and the question it raises

Concept

The construction produces at most as many states as the original has subsets. In the worst case that is exponential.

\[ |Q_D| \;\le\; 2^{|Q_N|} \]

The natural hope is that this is merely a crude analysis and a cleverer construction would do better. It is not. For some languages every deterministic machine really does need exponentially many states.

Proving that requires a lower-bound argument about all machines at once, which is a different kind of reasoning from anything so far — and a preview of Lessons 10 and 11.

69. A language family where the blowup is real

Concept

Return to the family from Lesson 5: for a fixed positive k, the strings whose k-th symbol from the end is a 1.

A nondeterministic machine needs only one state more than k: wait, guess, then count off the remaining symbols. But every deterministic machine for it needs at least as many states as there are binary strings of length k.

\[ \text{NFA: } k+1 \qquad \text{DFA: } \ge 2^{k} \]

The proof is a counting argument, and it is short enough to do in full.

70. What has to happen first: Prove the exponential lower bound

Ranking

Put in order

Put the moves of Prove the exponential lower bound into the order they have to happen.

  1. Suppose a machine exists with too few states
  2. Feed it every string of length k and apply the pigeonhole principle
  3. Find a position where they differ
  4. Append exactly the right number of symbols
  5. Verify the contradiction, and conclude

Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. Assume a deterministic machine recognizes the language using strictly fewer states than there are binary strings of length k.

71. Prove the exponential lower bound

Worked example

Show that no deterministic machine with fewer than the stated number of states can recognize the language.

Suppose a machine exists with too few states

Why: Assume a deterministic machine recognizes the language using strictly fewer states than there are binary strings of length k.

Feed it every string of length k and apply the pigeonhole principle

Why: There are more such strings than states, so two different ones must drive the machine into the same state. Call them u and v.

\[ u \neq v, \quad |u| = |v| = k, \quad \hat{\delta}(q_0,u) = \hat{\delta}(q_0,v) \]

Find a position where they differ

Why: Since the two strings differ, they disagree at some position. Say u has a 1 there and v has a 0, and say that position is the i-th from the end of each.

Append exactly the right number of symbols

Why: Append i minus one zeros to both. Now the symbol that was i-th from the end sits k-th from the end in each extended string, so one extension is in the language and the other is not.

\[ uz \in L, \qquad vz \notin L, \qquad z = 0^{\,i-1} \]

Verify the contradiction, and conclude

Why: Both extensions drive the machine from the same state along the same symbols, so they finish in the same state and receive the same verdict. But one belongs to the language and the other does not — a contradiction. Hence no such machine exists, and the exponential is genuine.

\[ \hat{\delta}(q_0,uz) = \hat{\delta}(q_0,vz) \quad\text{but}\quad uz \in L, \; vz \notin L \ \checkmark \]

72. Prove the exponential lower bound — line by line

Picture it

Animation

Shows: Each line of the worked example "Prove the exponential lower bound", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: Both extensions drive the machine from the same state along the same symbols, so they finish in the same state and receive the same verdict. But one belongs to the language and the other does not — a contradiction. Hence no such machine exists, and the exponential is genuine.

73. What the lower bound is really saying

Intuition

The argument is worth restating without symbols, because the shape of it recurs constantly from here on.

A deterministic machine's state is everything it remembers. To decide this language it must be able to distinguish any two length-k blocks, because for any two distinct blocks there is a future that separates them.

Distinguishing that many things needs that many states. The nondeterministic machine escapes the requirement entirely by not remembering the block at all — it guesses which position matters and checks only that one.

\[ \text{remember the block} \;\text{versus}\; \text{guess the position} \]

74. Plan first: Trace the blowup on the smallest case

Step zero

Discussion prompt

Trace the blowup on the smallest case — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.

Hint: It starts with: Write the nondeterministic machine

Answer:

  1. Write the nondeterministic machine
  2. Run the worklist
  3. List the reachable subsets
  4. See why the subsets encode the last two symbols
  5. Verify the count against the general bound

75. Trace the blowup on the smallest case

Worked example

Take k equal to two: the strings whose second symbol from the end is a 1. Determinize the three-state machine and count.

Write the nondeterministic machine

Why: A waiting state looping on both symbols, a 1-arrow guessing the anchor, then one arrow on either symbol into the accepting state.

\[ |Q_N| = 3 \]

Run the worklist

Why: Starting from the waiting state alone, each symbol either adds the guess branch or does not, and the branches age by one position per symbol.

List the reachable subsets

Why: Four subsets are reachable, and they correspond exactly to the four possible values of the last two symbols read.

subsetmeans the last two symbols were
{w}fewer than two symbols so far, or ending 00 or 01 patterns not yet matched
{w, g}the last symbol was a 1
{w, f}the second-from-last was a 1
{w, g, f}both of the above

See why the subsets encode the last two symbols

Why: Membership of the guess state records that the previous symbol was a 1; membership of the final state records that the one before it was. Together they store exactly the two-symbol window the lower bound said had to be stored.

Verify the count against the general bound

Why: Four reachable subsets, and the lower bound for this k predicts at least four states. The two agree exactly, so for this language the construction is not merely correct but optimal.

\[ 4 = 2^{2} \text{ reachable subsets, and } \ge 2^{2} \text{ required} \ \checkmark \]

76. Trace the blowup on the smallest case — line by line

Picture it

Animation

Shows: Each line of the worked example "Trace the blowup on the smallest case", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: Four reachable subsets, and the lower bound for this k predicts at least four states. The two agree exactly, so for this language the construction is not merely correct but optimal.

77. Distinguishable prefixes are what force states

Concept

The lower-bound argument used one idea twice, and it is worth naming, because it is the engine of every such proof.

distinguishable prefixes — Two strings u and v are distinguishable when some string z sends exactly one of the two extensions into the language.

\[ \exists z : \big(uz \in L\big) \;\text{ and }\; \big(vz \notin L\big) \]

Distinguishable prefixes can never share a state, because from a shared state the machine would give the two extensions the same verdict. So the number of pairwise distinguishable prefixes is a lower bound on the state count.

78. Term to definition: Equivalence of DFAs & NFAs

Matching

Match the pairs

Match each term to the definition this lesson gave it — not the one you would guess from the word.

  • t1. equivalence of the models
  • t2. equivalent machines
  • t3. distinguishable prefixes
  • d1. A language is recognized by some nondeterministic finite automaton if and only if it is recognized by some deterministic one.
  • d2. Two machines, of any kind, that accept exactly the same set of strings.
  • d3. Two strings u and v are distinguishable when some string z sends exactly one of the two extensions into the language.

Why: These are the working definitions of equivalence of the models, equivalent machines, distinguishable prefixes as Equivalence of DFAs & NFAs uses them. Pairing them correctly is the test of whether you could state each one with the slide switched off.

79. This technique returns, and gets a name

Intuition

Counting pairwise distinguishable prefixes proves lower bounds on machine size. Pushed one step further, it proves that no machine exists at all.

If a language has infinitely many pairwise distinguishable prefixes, then no finite state set can separate them, and the language is not regular. That is the Myhill-Nerode view, and it is the cleanest route to the non-regularity results of Lesson 11.

\[ \text{infinitely many distinguishable prefixes} \;\Rightarrow\; \text{not regular} \]

Lesson 10 reaches the same conclusions by a different road — the pumping lemma — which is easier to apply mechanically but proves slightly less. Both roads start from the observation on this slide.

80. Teach it back: This technique returns, and gets a name

Explain it

Discussion prompt

Explain This technique returns, and gets a name to a student a year behind you. No notation, no jargon they have not met — and it still has to be true.

Hint: If your explanation needs a symbol they have never seen, you are describing the notation rather than the idea.

Answer:

Counting pairwise distinguishable prefixes proves lower bounds on machine size. Pushed one step further, it proves that no machine exists at all.

81. Answer it before you see the options: Check yourself: the blowup

Prediction

Predict first

Why does every DFA for 'the k-th symbol from the end is a 1' need at least two-to-the-k states?

Answer it in your own words, now, with nothing to choose from. The options are on the next slide — and picking the right one off a list is an easier skill than producing it.

Correct: Any two distinct length-k blocks are distinguishable, so no two may share a state

Why: For any two different blocks of length k there is a suffix sending exactly one of them into the language, so a machine giving them the same state would give both extensions the same verdict. Counting the blocks therefore bounds the states from below.

82. Check yourself: the blowup

Check

Recall which machine had to remember the window and which one guessed.

Check your understanding

Why does every DFA for 'the k-th symbol from the end is a 1' need at least two-to-the-k states?

  • A. Any two distinct length-k blocks are distinguishable, so no two may share a state (correct)
  • B. The subset construction produces that many, and it is optimal by definition
  • C. The NFA has k plus one states, and determinizing always squares the count
  • D. The language is infinite, so the machine needs unboundedly many states

Answer: A

Why: For any two different blocks of length k there is a suffix sending exactly one of them into the language, so a machine giving them the same state would give both extensions the same verdict. Counting the blocks therefore bounds the states from below.

Why B tempts people
The construction producing a number never shows the number is necessary — a cleverer construction might do better. That is exactly the gap the pigeonhole argument closes.
Why C tempts people
Determinizing does not square anything; the bound is exponential, not quadratic. And the size of one particular NFA says nothing about every DFA.
Why D tempts people
Plenty of infinite languages have tiny machines — the strings ending in 1 is infinite and needs two states. Infiniteness of the language is irrelevant.

83. Blowup is the worst case, not the usual case

Concept

It would be a mistake to leave this section pessimistic. The exponential is a ceiling that most machines never approach.

MachineOriginal statesReachable subsets
ends in 01threethree
exactly ab or bafivefive
k-th from the end is 1k plus onetwo to the k

The first two rows are typical and the third is engineered to be extreme. The worklist procedure charges you only for the subsets you actually reach, which is why determinization is a routine step in real tools.

84. What each one costs: Blowup is the worst case, not the usual case

Trade off

Comparison matrix

From Blowup is the worst case, not the usual case: every row here is a choice with a cost. Fill the Reachable subsets column, then say which row you would actually pick and what you give up for it.

MachineOriginal statesReachable subsets
ends in 01threethree
exactly ab or bafivefive
k-th from the end is 1k plus onetwo to the k

85. Consequences

Section

Section 6

86. What the equivalence licenses

Concept

With the two models proved interchangeable, every later argument may use whichever is convenient without further comment.

\[ \text{DFA} \;\equiv\; \text{NFA} \;\equiv\; \varepsilon\text{-NFA} \]

87. Guess the shape of the answer: Complement a nondeterministic machine end to…

Estimation

Predict first

The operation that failed in Lesson 5 now works, provided the steps are taken in the right order.

Commit before you compute: what does Complement a nondeterministic machine end to end come out to? A rough magnitude and the right form is enough — the point is to have something concrete to be wrong about.

Correct: Verify on one string from each side

Why: A prediction you can defend turns the computation into a check rather than a leap of faith — and an answer that contradicts it is caught on the spot. A string the original accepts drives the deterministic machine into an accepting subset, which is non-accepting after the swap.

88. Complement a nondeterministic machine end to end

Worked example

The operation that failed in Lesson 5 now works, provided the steps are taken in the right order.

Determinize first

Why: Run the subset construction, keeping only the reachable subsets. The result is a deterministic machine for the same language.

\[ N \;\longrightarrow\; D, \qquad L(D) = L(N) \]

Make sure the transition function is total

Why: The construction guarantees this automatically, because the empty subset is present as a genuine dead state. Skipping it here is the classic error, since a missing transition breaks the next step.

Swap the accepting set

Why: Replace the accepting subsets with all the others. Nothing else changes, exactly as in Lesson 4.

\[ D' = (Q_D, \Sigma, \delta_D, s_0, Q_D \setminus F_D) \]

Note why the order cannot be reversed

Why: Swapping before determinizing fails because several branches can be live at once, so a set can meet both the accepting set and its complement. Determinizing first collapses each input to exactly one state, and negation becomes meaningful again.

Verify on one string from each side

Why: A string the original accepts drives the deterministic machine into an accepting subset, which is non-accepting after the swap. A string it rejects does the reverse. Every string switches sides, which is what complementing means.

\[ w \in L(N) \iff w \notin L(D') \ \checkmark \]

89. Complement a nondeterministic machine end to end — line by line

Picture it

Animation

Shows: Each line of the worked example "Complement a nondeterministic machine end to end", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: A string the original accepts drives the deterministic machine into an accepting subset, which is non-accepting after the swap. A string it rejects does the reverse. Every string switches sides, which is what complementing means.

90. Decision problems become easy

Concept

Once a machine is deterministic and finite, several questions about its language become simple graph questions.

QuestionHow to answer
is the language empty?is any accepting state reachable from the start?
is the language infinite?is there a cycle on a path from start to an accepting state?
does it contain the empty string?is the start state accepting?
do two machines agree?determinize both, then test the symmetric difference for emptiness

Every one of these is decided by ordinary reachability on a finite graph, so all of them terminate. Lesson 24 returns to this list and asks the same questions of far stronger machines, where the answers are very different.

91. By analogy: Decision problems become easy

Analogy

Discussion prompt

Explain Decision problems become easy by analogy to something with no Theory of Computation in it at all — a queue, a recipe, a map, a bank balance, whatever fits. Then say where your analogy breaks.

Hint: An analogy that never breaks is not an analogy, it is the same idea wearing a hat. Find the seam — that is the part that is actually new.

Answer:

Once a machine is deterministic and finite, several questions about its language become simple graph questions.

92. Plan first: Decide emptiness and infiniteness of a converted machine

Step zero

Discussion prompt

Decide emptiness and infiniteness of a converted machine — before any calculation: what is the plan? Name the moves in order, in plain English, without doing the arithmetic.

Hint: It starts with: Determinize and keep only the reachable part

Answer:

  1. Determinize and keep only the reachable part
  2. Decide emptiness by reachability
  3. Decide infiniteness by looking for a cycle
  4. Note why the restriction to the reachable part was needed
  5. Verify both answers against the diagram directly

93. Decide emptiness and infiniteness of a converted machine

Worked example

Take a nondeterministic machine, determinize it, and answer both questions about its language.

Determinize and keep only the reachable part

Why: The worklist already produces exactly the reachable subsets, so this step is free.

Decide emptiness by reachability

Why: Search the graph from the start subset. If no accepting subset is ever visited, no string can be accepted and the language is empty.

\[ L = \varnothing \iff \text{no reachable accepting state} \]

Decide infiniteness by looking for a cycle

Why: The language is infinite exactly when some cycle lies on a path from the start to an accepting state, since going round it repeatedly produces unboundedly many accepted strings.

\[ L \text{ infinite} \iff \exists \text{ a cycle between start and an accepting state} \]

Note why the restriction to the reachable part was needed

Why: A cycle among unreachable subsets proves nothing, since no input ever gets there. Both tests are only meaningful on the reachable subgraph.

Verify both answers against the diagram directly

Why: For emptiness, confirm by eye that the accepting subset really is reachable along a concrete path. For infiniteness, name the cycle found and give a string that goes round it twice, then confirm the machine accepts it. Both checks agree with the graph algorithms.

\[ L \neq \varnothing \text{ and } L \text{ infinite} \ \checkmark \]

94. Decide emptiness and infiniteness of a converted… — line by line

Picture it

Animation

Shows: Each line of the worked example "Decide emptiness and infiniteness of a converted machine", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: For emptiness, confirm by eye that the accepting subset really is reachable along a concrete path. For infiniteness, name the cycle found and give a string that goes round it twice, then confirm the machine accepts it. Both checks agree with the graph algorithms.

95. What has to happen first: Decide whether two machines are equivalent

Ranking

Put in order

Put the moves of Decide whether two machines are equivalent into the order they have to happen.

  1. Determinize both machines
  2. Build a machine for the symmetric difference
  3. Test that product machine for emptiness
  4. Read off the answer
  5. Verify the method on an obvious pair

Why: These are the moves of the worked example in the order it makes them, and each one is set up by the one before it. Whatever form the two arrived in, convert each to a deterministic machine over the shared alphabet.

96. Decide whether two machines are equivalent

Worked example

Equivalence testing is the decision problem that makes the rest usable, and it reduces to emptiness.

Determinize both machines

Why: Whatever form the two arrived in, convert each to a deterministic machine over the shared alphabet. Now each input has exactly one run in each.

Build a machine for the symmetric difference

Why: Take the product of the two, and mark a pair accepting when exactly one component is accepting. That machine accepts precisely the strings the two originals disagree on.

\[ L(P) = \big(L_1 \setminus L_2\big) \cup \big(L_2 \setminus L_1\big) \]

Test that product machine for emptiness

Why: Search from its start state. If no accepting state is reachable, there is no string of disagreement.

Read off the answer

Why: An empty symmetric difference means the two languages are equal, so the machines are equivalent. A reachable accepting state gives a concrete string on which they differ.

\[ L(P) = \varnothing \iff L_1 = L_2 \]

Verify the method on an obvious pair

Why: Run it on a machine and a copy of itself. Every product pair has both components accepting or neither, so no pair is accepting, the product language is empty, and the method reports equivalent — which is correct, and confirms the accepting rule was set up the right way round.

\[ L_1 = L_2 \;\Rightarrow\; L(P) = \varnothing \ \checkmark \]

97. Decide whether two machines are equivalent — line by line

Picture it

Animation

Shows: Each line of the worked example "Decide whether two machines are equivalent", appearing one at a time.

The same working the example does, in the order a tutor would write it.

Takeaway: Run it on a machine and a copy of itself. Every product pair has both components accepting or neither, so no pair is accepting, the product language is empty, and the method reports equivalent — which is correct, and confirms the accepting rule was set up the right way round.

98. Minimization is a different question

Concept

The construction produces a deterministic machine, not the smallest one. Those are separate problems, and it is worth keeping them apart.

QuestionAnswered by
is there a DFA at all?the subset construction — this lesson
how small can a DFA be?distinguishable prefixes — the lower bound
what is the smallest DFA?a minimization algorithm, not covered here

The useful fact to carry forward: every regular language has a unique smallest deterministic machine, up to renaming states, and its states correspond exactly to the classes of indistinguishable prefixes. So the lower-bound technique and the minimal machine are two views of one thing.

99. Fill in: Answered by for Minimization is a different question

Comparison

Comparison matrix

From Minimization is a different question: refill the Answered by column from what you know. The rest of the table is as it appeared.

QuestionAnswered by
is there a DFA at all?the subset construction — this lesson
how small can a DFA be?distinguishable prefixes — the lower bound
what is the smallest DFA?a minimization algorithm, not covered here

100. Three definitions of regular, soon four

Intuition

The word regular now has several definitions that this lesson has proved interchangeable.

  1. Recognized by a deterministic finite automaton — the original definition, Lesson 4.
  2. Recognized by a nondeterministic one — proved equal here.
  3. Recognized by one with ε-arrows — also proved equal here.
  4. Denoted by a regular expression — proved equal in Lessons 8 and 9.

Having several equivalent definitions is what makes the class useful. Each proof in the rest of the course picks whichever definition makes it shortest, and this theorem is the licence to do so.

101. Break it if you can: Three definitions of regular, soon four

Counterexample

Discussion prompt

The word regular now has several definitions that this lesson has proved interchangeable.

That is stated as though it always holds. Do one of two things: produce a case where it fails, or say precisely what rules such a case out. "It just does" is not on the menu.

Hint: Hunt at the extremes first — zero, one, negative, empty, equal. If every extreme survives, the reason they survive is the proof.

Answer:

Having several equivalent definitions is what makes the class useful. Each proof in the rest of the course picks whichever definition makes it shortest, and this theorem is the licence to do so.

102. Why this theorem does not generalize

Intuition

It is tempting to conclude that nondeterminism never adds power. That conclusion is false, and knowing why sharpens what was actually proved.

The proof worked because the set of possible situations was finite, so it could be made a state set. A machine with unbounded memory has infinitely many possible situations, and the same move is unavailable.

For the machines of Lesson 16 the determinization genuinely fails: nondeterministic pushdown automata recognize strictly more languages than deterministic ones. For the machines of Lesson 20 the models are equivalent again, but the analogous question about time is the open problem of Lesson 31.

ModelDoes nondeterminism add power?
finite automatano — this lesson
pushdown automatayes — Lesson 16
Turing machinesno — Lesson 22
polynomial-time machinesunknown — Lesson 31

103. Fill in: Does nondeterminism add power? for Why this theorem does not generalize

Comparison

Comparison matrix

From Why this theorem does not generalize: refill the Does nondeterminism add power? column from what you know. The rest of the table is as it appeared.

ModelDoes nondeterminism add power?
finite automatano — this lesson
pushdown automatayes — Lesson 16
Turing machinesno — Lesson 22
polynomial-time machinesunknown — Lesson 31

104. Rule out three: Check yourself: consequences

Elimination

Eliminate the wrong options

You are given an NFA and asked for a machine recognizing the complement of its language. What is the correct order of operations?

3 of these 4 are wrong. Strike them one at a time, and say what rules each one out before you strike the next. The survivor is the answer.

  • A. Determinize by the subset construction, then swap the accepting states
  • B. Swap the accepting states, then determinize
  • C. Swap the accepting states; determinizing is unnecessary
  • D. Reverse every arrow, then swap the accepting states

Survives elimination: A

Why: Swapping only negates the verdict when each input reaches exactly one final state. Determinizing first guarantees that, after which the Lesson 4 argument applies unchanged.

105. Check yourself: consequences

Check

Think about which step makes negation meaningful.

Check your understanding

You are given an NFA and asked for a machine recognizing the complement of its language. What is the correct order of operations?

  • A. Determinize by the subset construction, then swap the accepting states (correct)
  • B. Swap the accepting states, then determinize
  • C. Swap the accepting states; determinizing is unnecessary
  • D. Reverse every arrow, then swap the accepting states

Answer: A

Why: Swapping only negates the verdict when each input reaches exactly one final state. Determinizing first guarantees that, after which the Lesson 4 argument applies unchanged.

Why B tempts people
Determinizing afterwards is too late: the swap has already been applied to a machine where several states can be live at once, so it changed the language in an uncontrolled way.
Why C tempts people
Lesson 5 showed a two-state counterexample where swapping accepts a string the original also accepted, so the result is not the complement.
Why D tempts people
Reversing the arrows produces a machine for the reversed language, which is a different operation entirely.

106. Rebuild the recipe: The determinization workflow

Ranking

Put in order

These are the steps of The determinization workflow, scrambled. Put them back in order before the next slide shows you.

  1. Write the original's set-valued table, with braces in every cell.
  2. Compute the ε-closure of the start state, and use it as the start subset.
  3. Work the worklist: union, close, name any new subset, repeat.
  4. Mark accepting every subset that meets the original accepting set.
  5. Stop when the worklist is empty; unreached subsets are never built.

Why: This is the order the recipe itself gives. Recalling the sequence without the slide in front of you is the difference between recognising the method and being able to run it — most of what goes wrong in practice is a step done out of turn.

107. The determinization workflow

Pattern

Put together, this is the routine every later lesson assumes you can run.

  1. Write the original's set-valued table, with braces in every cell.
  2. Compute the ε-closure of the start state, and use it as the start subset.
  3. Work the worklist: union, close, name any new subset, repeat.
  4. Mark accepting every subset that meets the original accepting set.
  5. Stop when the worklist is empty; unreached subsets are never built.

If the goal was complement, swap the accepting set now. If the goal was a smaller machine, minimization is a separate procedure that this course does not need.

108. Where this shows up: Equivalence of DFAs & NFAs

Real world

Discussion prompt

Outside this lesson: where does Equivalence of DFAs & NFAs actually turn up? Name one concrete situation — a job, a piece of software someone ships, a decision somebody has to make — and say which part of The determinization workflow is doing the work in it.

Hint: Vague is the failure mode here. "Engineering" is not a situation; "deciding whether this build is fast enough to ship" is.

Answer:

Lesson 6 proves that nondeterminism buys convenience but not power. It states the equivalence theorem and disposes of its trivial direction, then builds the subset construction component by component, including the empty subset as a dead state and the accepting rule people get wrong, the epsilon-closure in the start subset, and the transition rule. It works conversions from a worklist both with and without free moves, proves correctness by induction on the input length, and gives the pigeonhole lower bound showing that the exponential blowup is unavoidable. It ends with the consequences: complementing an NFA in the right order, and deciding emptiness and infiniteness by graph search.

109. Connect it up: Equivalence of DFAs & NFAs

Connect it up

Draw it

One page, no notation unless you need it: draw how these connect — The Claim · The Construction, Component by Component · Worked Conversions · Why It Works · The Cost: An Unavoidable Blowup · Consequences. Put an arrow wherever one of them is what makes another possible, and label the arrow with why.

110. What you can do now

Recap

You can move freely between the two machine models, and you know exactly what that freedom costs.

SituationMove
a branching machine to run fastsubset construction, worklist only
free moves in the diagramclose, read, close
the opposite languagedeterminize, then swap
is the language empty?reachability on the reachable subgraph
how big will the result be?count reachable subsets, not all subsets

Lesson 7 uses this freedom to prove the closure properties, building whichever machine is easier and appealing to this theorem to finish.

Sources

  1. Sipser, Introduction to the Theory of Computation, 3rd ed., Ch. 1.2, Theorem 1.39 (Equivalence of NFAs and DFAs) — Cengage, 2013.
  2. Hopcroft, Motwani & Ullman, Introduction to Automata Theory, Languages, and Computation, 3rd ed., Ch. 2.3.5, 2.5.5 (Subset construction) — Pearson, 2007.
  3. Rabin & Scott, 'Finite Automata and Their Decision Problems', IBM Journal of Research and Development 3(2) — IBM, 1959.
  4. Meyer & Fischer, 'Economy of description by automata, grammars, and formal systems', SWAT 1971 (state-complexity lower bounds) — IEEE, 1971.
  5. Every subset table, reachability count and lower-bound argument in this deck was checked by hand against a traced example. — Verified 2026-08-03.

Want this taught 1-on-1? Alexander tutors Theory of Computation — $55/session, free consultation.

Book on Wyzant · Text (657) 465-8108