A finite automaton, FA, provides the simplest model of a computing device. It has a central processor of finite capacity and it is based on the concept of state. It can also be given a formal mathematical definition. Finite automata are used for pattern matching in text editors, for compiler lexical analysis.
It is also possible to prove that given a language
L
there exists a unique (up to isomorphism) minimum finite state automaton that accepts it, i.e. an automaton with a minimum set of states.S is a non-empty finite set of states, is the alphabet (defining what set of input strings the automaton operates on), is the transition function,:S
S
q0 is the starting state, andS
F is a set of final (or accepting states).S
DFAs represent regular languages, and can be used to test whether any string in
aa*b
):The vertex 0 is the initial state q0 , and the vertex 2 is the only state in F . Note that for every vertex there is an edge leading away from it with a label for each symbol in 
. This is a requirement of DFAs, which guarantees that operation is well-defined for any finite string.
If given the string
, the operation of the DFA halts. Since it has halted in the accepting state 2, the string
Now let us trace operation on the string
Remarks.
If given the string
aaab
as input, operation of the DFA above is as follows. The first a
is removed from the input string, so the edge from 0 to 1 is followed. The resulting input string is aab
. For each of the next two a
s, the edge is followed from 1 to itself. Finally, b
is read from the input string and the edge from 1 to 2 is followed. Since the input string is now aaab
is accepted as a sentence in the regular language implemented by this DFA.Now let us trace operation on the string
aaaba
. Execution is as above, until state 2 is reached with a
remaining in the input string. The edge from 2 to 3 is then followed and the operation of the DFA halts. Since 3 is not an accepting state for this DFA, aaaba
is not accepted.Remarks.
- A DFA can be modified to include
-transitionsEpsilonTransitions. But the resulting DFA can be simulated by another DFA (without any epsilon transitions). - Although the operation of a DFA is much easier to compute than that of a non-deterministic automaton, it is non-trivial to directly generate a DFA from a regular grammar. It is much easier to generate a non-deterministic finite automaton from the regular grammar, and then transform the non-deterministic finite automaton into a DFA.