4.6.2 · D5Theory of Computation

Question bank — Finite automata — DFA - formal definition (5-tuple), state diagrams

2,039 words9 min readBack to topic

Quick symbol reminder so nothing here is used before it is grounded. A DFA is the 5-tuple , and every symbol on this page comes from it:

  • = the finite, non-empty set of states (the squares of the hopping game). It must be non-empty because the machine has to be somewhere: even the do-nothing machine needs at least a start square to stand on.
  • = the alphabet, the finite set of symbols the machine may read.
  • = the set of all finite strings over , including the empty string (the string of length zero).
  • = one-step transition: given (state, one symbol) it names exactly one next state.
  • = extended transition: given (state, whole string) it names where you land after reading it all.
  • = the single start state, the square you stand on before any symbol is read; always begins its run here.
  • = the accept states (drawn as double circles); accepts iff .
  • = the ==language of ==, meaning the set of all strings it accepts: . So "" means " accepts no string at all."
  • = a dead / trap state: a non-accepting state whose transitions on every symbol loop back to itself. Once a run enters it, it can never leave and never accept — it is the honest home of every "missing arrow."

True or false — justify

A DFA can have zero accept states.
True. is a legal subset of ; the definition only says , with no lower bound. Then no string can satisfy , so — an empty language is valid even though and themselves must be non-empty for the tuple to describe a working machine.
A DFA can have infinitely many states as long as stays finite.
False. The word finite in "finite automaton" is a hard requirement — must be finite because is the machine's entire memory; an infinite would smuggle in unbounded memory and let it recognize non-regular languages, defeating the model's purpose.
Every DFA accepts at least one string.
False. If no path from reaches a state in (or ), then for every , so — which is still a perfectly valid regular language, just an empty one.
Two different DFAs can recognize the exact same language.
True. Given one DFA you can always add unreachable states or split a state into two behaviourally-identical copies without changing which strings reach , so is unchanged. This many-to-one relationship is exactly why minimization exists — to pick the unique smallest representative.
If , the DFA accepts the empty string .
True. The base case of the extended transition gives , so "does accept ?" becomes "is ?" Nothing is read, so only the starting position decides.
A DFA with states can only accept strings of length up to .
False. Self-loops and cycles let a run revisit states, so a length-1000 string can run through the same states over and over; input length is unbounded while the number of distinct remembered situations stays fixed at .
Swapping accept and non-accept states () gives a DFA for the complement language.
True. Because is total, every string has exactly one landing state , which is in either or but never both; flipping the label therefore flips membership for every string, yielding exactly .
An NFA is strictly more powerful than a DFA.
False. NFAs are more convenient to design but recognize the exact same class (the regular languages); subset construction mechanically turns any NFA into an equivalent DFA, proving equal power.
and can be used interchangeably.
False. eats one symbol; eats a whole string by recursion over its length. They only coincide on a single-symbol input (), and only is even defined on and on multi-symbol strings.
If a language is finite, some DFA recognizes it.
True. For a finite language you can build a "spelling tree" whose branches spell out each allowed string, mark the ends as accept states, and route every other transition to ; this is always a valid finite DFA, so every finite language is regular.

Spot the error

(These items quote a claim someone might make about a diagram they are looking at; you supply the fix from the definition alone — no figure is needed to see why each is wrong.)

"My diagram is a DFA: state has two outgoing arrows both labelled ."
Error: not deterministic. A DFA needs exactly one target per (state, symbol); two -arrows out of means isn't single-valued — that is an NFA, not a DFA.
"It's a valid DFA; state just has no arrow drawn for symbol ."
Error: must be total. A genuinely missing -transition is illegal; the honest reading is that goes on to a dead state that loops on itself and never accepts.
", given (symbol, state)."
Order error: the standard signature is — state first, symbol second. The mapping's values are the same, but matching the convention avoids reading transition tables backwards.
"The start state must not be an accept state."
Error: there is no such rule. Nothing in the tuple forbids ; that overlap is exactly the case where is accepted. Start-ness and accept-ness are independent properties.
" is the set of states the machine can reach."
Error: is a set of strings, not states — precisely . Reachable states are a property of ; the language lives in .
"A DFA can have two start states to cover both cases."
Error: a DFA has exactly one start state . Multiple starts is a nondeterministic feature; determinism means the run is completely fixed the moment you place your token on .
"Double-circling every state makes the DFA accept faster."
Error: double circles only mark membership in , not speed. There is no notion of speed here; the machine always reads the entire string, then performs one membership check at the end.

Why questions

Why must be total (defined for every state–symbol pair)?
So the machine never "gets stuck" mid-string; totality guarantees every input string produces a complete, unique run ending in one well-defined state, which is what makes acceptance an unambiguous yes/no.
Why is the state itself called the machine's "entire memory"?
Because a DFA has no counter, stack, or writable tape — the only thing carried from one symbol to the next is which state you're in, so every fact the machine "remembers" must be encoded as a distinct state.
Why do we define recursively instead of just "run repeatedly"?
To pin down acceptance precisely and for : the base case handles the empty string that alone cannot, and the recursive step gives a rigorous definition you can prove things about by induction on string length.
Why does "count the 0's" reduce to just two states for an even-parity language?
Because the accept/reject fact depends only on even vs odd, not the true count — the minimal memory distinguishing the two answers is a single bit, so two states (even-so-far, odd-so-far) capture everything relevant.
Why can a DFA recognize "ends in 1" but not "has equal 0's and 1's"?
"Ends in 1" needs only the last symbol, a bounded fact fitting in finite states; "equal 0's and 1's" needs an unbounded counter, which finitely many states cannot hold — this impossibility is exactly what the Pumping Lemma proves.
Why are DFAs the right model for a tokenizer?
Token patterns are described by regular expressions, and every regex compiles to a DFA that scans left-to-right in one pass with fixed memory — fast and exactly powerful enough for the job.
Why does flipping work for complement but the same trick fails for an NFA?
In a DFA, totality gives one run per string, so flipping accept-status cleanly inverts membership; in an NFA a string may have both accepting and non-accepting runs at once, so flipping does not reliably invert acceptance.

Edge cases

Must the set of states be non-empty?
Yes. A DFA needs a start state , and must begin its run somewhere; with there is no and the tuple is ill-formed, so a non-empty is an implicit requirement of the definition.
What language does a DFA with (every state accepting) recognize?
All of — every run ends in an accept state, so , accepting every string including .
Is a machine with an empty alphabet meaningful?
Only marginally: the sole readable string is , so is either (if ) or . It is technically valid but degenerate — nothing to read means nothing to decide beyond the start state.
Does the empty string have an even or odd number of 0's?
Even — and is even, so an even-parity DFA correctly accepts when its start state is the "even" accept state.
Once a run enters a dead/trap state , can it ever reach an accept state?
No — loops to itself on every symbol and is non-accepting, so any prefix landing there dooms the whole string to rejection regardless of what follows.
If a state is unreachable from , does removing it change ?
No. Unreachable states never appear in any run , so deleting them leaves acceptance of every string unchanged — this is one clean-up step in minimization.
Can two distinct strings both land in the same state?
Yes, and they usually do — a state records only "which situation," so many strings collapse to one. With finitely many states but infinitely many strings, the pigeonhole principle forces infinitely many such collisions.
If every transition is a self-loop, what languages are possible?
Only or — you never leave , so for all and acceptance depends solely on whether , giving all strings or none.

Recall One-line self-test

If you can answer "why must be total, and what hides behind a missing arrow?" in one breath, you own the core trap of this topic. Answer ::: Totality guarantees every string has one complete run; a missing arrow is shorthand for a transition into the hidden non-accepting dead state .