Deterministic Finite Automaton
Get Deterministic Finite Automaton essential facts below. View Videos or join the Deterministic Finite Automaton discussion. Add Deterministic Finite Automaton to your Like2do.com topic list for future reference or share this resource on social media.
Deterministic Finite Automaton

An example of a deterministic finite automaton that accepts only binary numbers that are multiples of 3. The state S0 is both the start state and an accept state.

In the theory of computation, a branch of theoretical computer science, a deterministic finite automaton (DFA)--also known as deterministic finite acceptor (DFA), deterministic finite state machine (DFSM), or deterministic finite state automaton (DFSA)--is a finite-state machine that accepts or rejects strings of symbols and only produces a unique computation (or run) of the automaton for each input string.[1]Deterministic refers to the uniqueness of the computation. 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.[2][3]

The figure illustrates a deterministic finite automaton using a state diagram. In the automaton, there are three states: S0, S1, and S2 (denoted graphically by circles). 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 (denoted graphically by an arrow coming in from nowhere) where computations begin, and a set of accept states (denoted graphically by a double circle) 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. For example, a DFA can model software that decides whether or not online user input such as email addresses are valid.[4]

DFAs recognize exactly the set of regular languages,[1] which are, among other things, useful for doing lexical analysis and pattern matching. DFAs can be built from nondeterministic finite automata (NFAs) using the powerset construction method.

## Formal definition

A deterministic finite automaton ${\displaystyle M}$ is a 5-tuple, ${\displaystyle (Q,\Sigma ,\delta ,q_{0},F)}$, consisting of

• a finite set of states ${\displaystyle Q}$
• a finite set of input symbols called the alphabet ${\displaystyle \Sigma }$
• a transition function ${\displaystyle \delta :Q\times \Sigma \rightarrow Q}$
• an initial or start state ${\displaystyle q_{0}\in Q}$
• a set of accept states ${\displaystyle F\subseteq Q}$

Let ${\displaystyle w=a_{1}a_{2}...a_{n}}$ be a string over the alphabet ${\displaystyle \Sigma }$. The automaton ${\displaystyle M}$ accepts the string ${\displaystyle w}$ if a sequence of states, ${\displaystyle r_{0},r_{1},...,r_{n}}$, exists in ${\displaystyle Q}$ with the following conditions:

1. ${\displaystyle r_{0}=q_{0}}$
2. ${\displaystyle r_{i+1}=\delta (r_{i},a_{i+1})}$, for ${\displaystyle i=0,...,n-1}$
3. ${\displaystyle r_{n}\in F}$.

In words, the first condition says that the machine starts in the start state ${\displaystyle q_{0}}$. The second condition says that given each character of string ${\displaystyle w}$, the machine will transition from state to state according to the transition function ${\displaystyle \delta }$. The last condition says that the machine accepts ${\displaystyle w}$ if the last input of ${\displaystyle w}$ causes the machine to halt in one of the accepting states. Otherwise, it is said that the automaton rejects the string. The set of strings that ${\displaystyle M}$ accepts is the language recognized by ${\displaystyle M}$ and this language is denoted by ${\displaystyle L(M)}$.

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.

## Complete and incomplete

According to the above definition, deterministic finite automata are always complete: they define a transition for each state and 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.

## Example

The following example is of a DFA ${\displaystyle M}$, with a binary alphabet, which requires that the input contains an even number of 0s.

The state diagram for M

${\displaystyle M=(Q,\Sigma ,\delta ,q_{0},F)}$ where

• ${\displaystyle Q=\{S_{1},S_{2}\}}$
• ${\displaystyle \Sigma =\{0,1\}}$
• ${\displaystyle q_{0}=S_{1}}$
• ${\displaystyle F=\{S_{1}\}}$ and
• ${\displaystyle \delta }$ is defined by the following state transition table:
 0 1 S1 S2 S1 S2 S1 S2

The state ${\displaystyle S_{1}}$ represents that there has been an even number of 0s in the input so far, while ${\displaystyle S_{2}}$ signifies an odd number. A 1 in the input does not change the state of the automaton. When the input ends, the state will show whether the input contained an even number of 0s or not. If the input did contain an even number of 0s, ${\displaystyle M}$ will finish in state ${\displaystyle S_{1}}$, an accepting state, so the input string will be accepted.

The language recognized by ${\displaystyle M}$ is the regular language given by the regular expression ((1*) 0 (1*) 0 (1*))*, where * is the Kleene star, e.g., 1* denotes any number (possibly zero) of consecutive ones.

## 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.

• Union
• Intersection
• Concatenation
• Negation
• Kleene closure
• Reversal
• Init
• Quotient[]
• Substitution[]
• Homomorphism[]

For each operation, an optimal construction with respect to the number of states has been determined in the state complexity research. Since DFAs are equivalent to nondeterministic finite automata (NFA), 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 ${\displaystyle a\in \Sigma }$, one may construct a transition function ${\displaystyle \delta _{a}:Q\rightarrow Q}$ by defining ${\displaystyle \delta _{a}(q)=\delta (q,a)}$ for all ${\displaystyle q\in Q}$. (This trick is called currying.) From this perspective, ${\displaystyle \delta _{a}}$ "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 ${\displaystyle \delta _{a}}$, ${\displaystyle \delta _{b}}$, and so on. Given a pair of letters ${\displaystyle a,b\in \Sigma }$, one may define a new function ${\displaystyle {\widehat {\delta }}_{ab}=\delta _{a}\circ \delta _{b}}$, where ${\displaystyle \circ }$ denotes function composition.

Clearly, this process may be recursively continued, giving the following recursive definition of ${\displaystyle {\widehat {\delta }}:Q\times \Sigma ^{\star }\rightarrow Q}$:

${\displaystyle {\widehat {\delta }}(q,\epsilon )=q}$, where ${\displaystyle \epsilon }$ is the empty string and
${\displaystyle {\widehat {\delta }}(q,wa)=\delta _{a}({\widehat {\delta }}(q,w))}$, where ${\displaystyle w\in \Sigma ^{*},a\in \Sigma }$ and ${\displaystyle q\in Q}$.

${\displaystyle {\widehat {\delta }}}$ is defined for all words ${\displaystyle w\in \Sigma ^{*}}$. A run of the DFA is a sequence of compositions of ${\displaystyle {\widehat {\delta }}}$ 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 ${\displaystyle {\widehat {\delta }}}$, one can reconstruct a ${\displaystyle \delta }$, and so the two descriptions are equivalent.

## Local automata

A local automaton is a DFA 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.[5][6]

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.[5] The class of languages accepted by Myhill graphs is the class of local languages.[7]

## Random

When the start state and accept states are ignored, a DFA of ${\displaystyle n}$ states and an alphabet of size ${\displaystyle k}$ can be seen as a digraph of ${\displaystyle n}$ vertices in which all vertices have ${\displaystyle k}$ out-arcs labeled ${\displaystyle 1,\ldots ,k}$ (a ${\displaystyle k}$-out digraph). It is known that when ${\displaystyle k\geq 2}$ is a fixed integer, with high probability, the largest strongly connected component (SCC) in such a ${\displaystyle k}$-out digraph chosen uniformly at random is of linear size and it can be reached by all vertices.[8] It has also been proven that if ${\displaystyle k}$ is allowed to increase as ${\displaystyle n}$ increases, then the whole digraph has a phase transition for strong connectivity similar to Erd?s-Rényi model for connectivity.[9]

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.[8][10] This is also true for the largest induced sub-digraph of minimum in-degree one, which can be seen as a directed version of ${\displaystyle 1}$-core.[9]

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.

Because DFAs can be reduced to a canonical form (minimal DFAs), there are also efficient algorithms to determine:

• whether a DFA accepts any strings (Emptiness Problem)
• whether a DFA accepts all strings (Universality Problem)
• whether two DFAs recognize the same language (Equality Problem)
• whether the language recognized by a DFA is included in the language recognized by a second DFA (Inclusion Problem)
• the DFA with a minimum number of states for a particular regular language (Minimization Problem)

DFAs are equivalent in computing power to nondeterministic finite automata (NFAs). This is because, firstly any DFA is also an NFA, so an NFA can do what a DFA can do. Also, given an NFA, using the powerset construction one can build a DFA that recognizes the same language as the NFA, although the DFA could have exponentially larger number of states than the NFA.[11][12] However, even though NFAs are computationally equivalent to DFAs, the above mentioned problems are not necessarily solved efficiently also for NFAs. The non-universality problem for NFAs is PSPACE complete since there are small NFAs with shortest rejecting word in exponential size. A DFA is universal if and only if all states are final states, but this does not hold for NFAs. The Equality, Inclusion and Minimization Problems are also PSPACE complete since they require forming the complement of an NFA which results in an exponential blow up of size.[13]

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 a's, followed by an equal number of b's.[14]

## Notes

1. ^ a b
2. ^
3. ^
4. ^ Gouda, Prabhakar, Application of Finite automata
5. ^ a b Lawson (2004) p.129
6. ^ Sakarovitch (2009) p.228
7. ^ Lawson (2004) p.128
8. ^ a b Grusho, A. A. (1973). "Limit distributions of certain characteristics of random automaton graphs". Mathematical Notes of the Academy of Sciences of the USSR. 4: 633-637. doi:10.1007/BF01095785.
9. ^ a b Cai, X.S.; Devroye, L. "The graph structure of a deterministic automaton chosen at random: full version". arXiv:.
10. ^ Carayol, Arnaud; Nicaud,, Cyril (2012). "Distribution of the number of accessible states in a random deterministic automaton".
11. ^ Sakarovitch (2009) p.105
12. ^ Lawson (2004) p.63
13. ^ https://www7.in.tum.de/um/courses/auto/ws1718/slides1718/04-Implementations_sets.pdf
14. ^ Lawson (2004) p.46