Deterministic Finite Automata

Formal definition

The automata we have discussed so far are all deterministic in that there is no ambiguity about which edge to follow from each state. Deterministic finite automata are also easy to program; we simply need have a case for each state, and inside each case, we choose the target state corresponding to the current input symbol. In the next section, we’ll see how nondeterministic finite automata can also be useful.

A deterministic finite automaton (DFA) is a finite state machine consisting of the following:

  • QQ, a set of states, one of which is the initial (or start) state, and a subset of which are final (or accepting) states.
  • Σ\Sigma, an alphabet of valid input symbols.
  • δ:Q×ΣQ\delta:Q \times \Sigma \rightarrow Q, a transition function which, given a state and input symbol, determines the next state of the machine.

The definition above is merely a mathematical reformulation of what we already understood a DFA to be. The transition function, δ\delta, represents the transitions/edges in the machine. The subset of QQ comprising the final states can be empty in the case of machines that produce an output string instead of a yes-or-no result. There must be exactly one transition out of every state for each symbol in the alphabet of the DFA.

Remember: There can only be one transition out of every state for each symbol in the alphabet of the DFA.

DFA accepting strings ending with bb

To illustrate the application of the formal definition of a DFA, consider the DFA in the figure below, which accepts the language LL that contains all strings over the alphabet Σ={a,b}\Sigma=\{a,b\} that end with the symbol bb. We can write this language as L={All strings that end with b}L = \{\textrm{All strings that end with }b\}.

Get hands-on with 1400+ tech skills courses.