Deterministic Finite Automata
Get an introduction to the formal definition of deterministic finite automata and explore examples of different DFAs.
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:
- , a set of states, one of which is the initial (or start) state, and a subset of which are final (or accepting) states.
- , an alphabet of valid input symbols.
- , 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, , represents the transitions/edges in the machine. The subset of 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
To illustrate the application of the formal definition of a DFA, consider the DFA in the figure below, which accepts the language that contains all strings over the alphabet that end with the symbol . We can write this language as .
Get hands-on with 1400+ tech skills courses.