Deterministic finite automaton
In the theory of computation, a branch of theoretical computer science, a deterministic finite automaton —also known as deterministic finite acceptor, deterministic finite-state machine, or deterministic finite-state automaton —is a finite-state machine that accepts or rejects a given string of symbols, by running through a state sequence uniquely determined by the string. Deterministic refers to the uniqueness of the computation run. In search of the simplest models to capture finite-state machines, Warren McCulloch and Walter Pitts were among the first researchers to introduce a concept similar to finite automata in 1943.
The figure illustrates a deterministic finite automaton using a state diagram. In this example automaton, there are three states: S0, S1, and S2. The automaton takes a finite sequence of 0s and 1s as input. For each state, there is a transition arrow leading out to a next state for both 0 and 1. Upon reading a symbol, a DFA jumps deterministically from one state to another by following the transition arrow. For example, if the automaton is currently in state S0 and the current input symbol is 1, then it deterministically jumps to state S1. A DFA has a start state where computations begin, and a set of accept states which help define when a computation is successful.
A DFA is defined as an abstract mathematical concept, but is often implemented in hardware and software for solving various specific problems such as lexical analysis and pattern matching. For example, a DFA can model software that decides whether or not online user input such as email addresses are syntactically valid.
DFAs have been generalized to nondeterministic finite automata which may have several arrows of the same label starting from a state. Using the powerset construction method, every NFA can be translated to a DFA that recognizes the same language. DFAs, and NFAs as well, recognize exactly the set of regular languages.
Formal definition
A deterministic finite automaton is a 5-tuple,, consisting of- a finite set of states
- a finite set of input symbols called the alphabet
- a transition function
- an initial state
- a set of accepting states
- , for
- .
A deterministic finite automaton without accept states and without a starting state is known as a transition system or semiautomaton.
For more comprehensive introduction of the formal definition see automata theory.
Example
The following example is of a DFA, with a binary alphabet, which requires that the input contains an even number of 0s.where
- and
- is defined by the following state transition table:
The language recognized by is the regular language given by the regular expression
0 )*, where * is the Kleene star, e.g., 1* denotes any number of consecutive ones.Variations
Complete and incomplete
According to the above definition, deterministic finite automata are always complete: they define from each state a transition for each input symbol.While this is the most common definition, some authors use the term deterministic finite automaton for a slightly different notion: an automaton that defines at most one transition for each state and each input symbol; the transition function is allowed to be partial. When no transition is defined, such an automaton halts.
Local automata
A local automaton is a DFA, not necessarily complete, for which all edges with the same label lead to a single vertex. Local automata accept the class of local languages, those for which membership of a word in the language is determined by a "sliding window" of length two on the word.A Myhill graph over an alphabet A is a directed graph with vertex set A and subsets of vertices labelled "start" and "finish". The language accepted by a Myhill graph is the set of directed paths from a start vertex to a finish vertex: the graph thus acts as an automaton. The class of languages accepted by Myhill graphs is the class of local languages.
Randomness
When the start state and accept states are ignored, a DFA of states and an alphabet of size can be seen as a digraph of vertices in which all vertices have out-arcs labeled . It is known that when is a fixed integer, with high probability, the largest strongly connected component in such a -out digraph chosen uniformly at random is of linear size and it can be reached by all vertices. It has also been proven that if is allowed to increase as increases, then the whole digraph has a phase transition for strong connectivity similar to Erdős–Rényi model for connectivity.In a random DFA, the maximum number of vertices reachable from one vertex is very close to the number of vertices in the largest SCC with high probability. This is also true for the largest induced sub-digraph of minimum in-degree one, which can be seen as a directed version of -core.
Closure properties
If DFAs recognize the languages that are obtained by applying an operation on the DFA recognizable languages then DFAs are said to be closed under the operation. The DFAs are closed under the following operations.For each operation, an optimal construction with respect to the number of states has been determined in state complexity research.
Since DFAs are equivalent to nondeterministic finite automata, these closures may also be proved using closure properties of NFA.
As a transition monoid
A run of a given DFA can be seen as a sequence of compositions of a very general formulation of the transition function with itself. Here we construct that function.For a given input symbol, one may construct a transition function by defining for all. From this perspective, "acts" on a state in Q to yield another state. One may then consider the result of function composition repeatedly applied to the various functions,, and so on. Given a pair of letters, one may define a new function, where denotes function composition.
Clearly, this process may be recursively continued, giving the following recursive definition of :
is defined for all words. A run of the DFA is a sequence of compositions of with itself.
Repeated function composition forms a monoid. For the transition functions, this monoid is known as the transition monoid, or sometimes the transformation semigroup. The construction can also be reversed: given a, one can reconstruct a, and so the two descriptions are equivalent.
Advantages and disadvantages
DFAs are one of the most practical models of computation, since there is a trivial linear time, constant-space, online algorithm to simulate a DFA on a stream of input. Also, there are efficient algorithms to find a DFA recognizing:- the complement of the language recognized by a given DFA.
- the union/intersection of the languages recognized by two given DFAs.
- whether a DFA accepts any strings
- whether a DFA accepts all strings
- whether two DFAs recognize the same language
- whether the language recognized by a DFA is included in the language recognized by a second DFA
- the DFA with a minimum number of states for a particular regular language
On the other hand, finite-state automata are of strictly limited power in the languages they can recognize; many simple languages, including any problem that requires more than constant space to solve, cannot be recognized by a DFA. The classic example of a simply described language that no DFA can recognize is bracket or Dyck language, i.e., the language that consists of properly paired brackets such as word ")". Intuitively, no DFA can recognize the Dyck language because DFAs are not capable of counting: a DFA-like automaton needs to have a state to represent any possible number of "currently open" parentheses, meaning it would need an unbounded number of states. Another simpler example is the language consisting of strings of the form anbn for some finite but arbitrary number of as, followed by an equal number of bs.