Deterministic Finite Automata (DFA)

a deterministic finite automaton

A deterministic finite automaton, or DFA, is the simplest real machine in the theory of computation, and it is your first genuine automaton. Think again of a turnstile or a vending machine: it reads its input one symbol at a time, holds only a single state as its whole memory, and for any state-and-symbol pair there is exactly one thing it does next. That word deterministic is the promise that there is never any choice or ambiguity: given where you are and what you just read, the next state is completely determined.

A DFA runs like this. It starts in a designated start state, reads the input string from left to right, and on each symbol it follows the unique arrow for the current state and that symbol to a new state. When the input is exhausted, it looks at the state it ended in. If that final state is one of the marked accept states, the DFA accepts the string; otherwise it rejects. So a DFA is fundamentally a yes/no decider: every string over its alphabet gets exactly one verdict.

DFAs matter far beyond toys. They are the engine behind the lexical phase of compilers (recognising keywords and numbers), behind search-and-replace and many regular-expression matchers, and behind protocol and hardware controllers. They are also the cleanest model for asking what finite memory can and cannot do, which is why a whole theory — regular languages, the pumping lemma, minimization — is built on them.

A DFA over the alphabet {0,1} that accepts exactly the strings ending in 1: two states, A (last symbol was not 1, or empty) and B (last symbol was 1). Start in A. On 1 go to B; on 0 go to A. B is the only accept state. Run on 1101: A->B->B->A->B, end in B, accept. Run on 110: A->B->B->A, end in A, reject.

Two states are enough to remember the one fact 'did the last symbol equal 1?'.

A DFA is exactly as powerful as a nondeterministic finite automaton — they recognise the very same languages. Determinism is about uniqueness of the next move, not about what can be recognised.

Also called
DFAdeterministic finite-state machine決定性有限自動機DFA