thumb|upright=1.1|An example of a deterministic finite automaton that accepts only binary numbers that are multiples of 3. The state S<sub>0</sub> is both the start state and an accept state. For example, the string "1001" leads to the state sequence S<sub>0</sub>, S<sub>1</sub>, S<sub>2</sub>, S<sub>1</sub>, S<sub>0</sub>, and is hence accepted.

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 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: S<sub>0</sub>, S<sub>1</sub>, and S<sub>2</sub> (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 S<sub>0</sub> and the current input symbol is 1, then it deterministically jumps to state S<sub>1</sub>. 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 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 (NFA) 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 (or start) state <math>q_0 \in Q</math>
  • a set of accepting (or final) states <math>F \subseteq Q</math>

Let be a string over the alphabet . The automaton accepts the string if a sequence of states, , exists in with the following conditions:

  1. , for
  2. <math>r_n \in F</math>.

In words, the first condition says that the machine starts in the start state . The second condition says that given each character of string , the machine will transition from state to state according to the transition function . The last condition says that the machine accepts if the last input of 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 accepts is the language recognized by and this language is denoted by .

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.

right|thumb|upright=1.1|The [[state diagram for M]]

where

  • and
  • is defined by the following state transition table:

:{| border="1" cellpadding="1" cellspacing="0"

| || ||

|-

|S<sub>1</sub> || S<sub>2</sub> || S<sub>1</sub>

|-

|S<sub>2</sub> || S<sub>1</sub> || S<sub>2</sub>

|}

The state represents that there has been an even number of 0s in the input so far, while 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, will finish in state , an accepting state, so the input string will be accepted.

The language recognized by is the regular language given by the regular expression <code>(1*) (0 (1*) 0 (1*))*</code>, where <code>*</code> is the Kleene star, e.g., <code>1*</code> denotes any number (possibly zero) 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 (a -out digraph). It is known that when is a fixed integer, with high probability, the largest strongly connected component (SCC) 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.

  • Substitution
  • Homomorphism

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 a<sup>n</sup>b<sup>n</sup> for some finite but arbitrary number of as, followed by an equal number of bs.

DFA identification from labeled words

Given a set of positive words <math>S^+ \subset \Sigma^*</math> and a set of negative words <math>S^- \subset \Sigma^*</math> one can construct a DFA that accepts all words from <math>S^+</math> and rejects all words from <math>S^-</math>: this problem is called DFA identification (synthesis, learning).

While some DFA can be constructed in linear time, the problem of identifying a DFA with the minimal number of states is NP-complete.

The first algorithm for minimal DFA identification has been proposed by Trakhtenbrot and Barzdin and is called the TB-algorithm.

However, the TB-algorithm assumes that all words from <math>\Sigma</math> up to a given length are contained in either <math>S^+ \cup S^-</math>.

Later, K. Lang proposed an extension of the TB-algorithm that does not use any assumptions about <math>S^+</math> and <math>S^-</math>, the Traxbar algorithm.

However, Traxbar does not guarantee the minimality of the constructed DFA.

In his work the Blue-Fringe evidence-driven state-merging algorithm,

and Windowed-EDSM.

Another research direction is the application of evolutionary algorithms: the smart state labeling evolutionary algorithm allowed to solve a modified DFA identification problem in which the training data (sets <math>S^+</math> and <math>S^-</math>) is noisy in the sense that some words are attributed to wrong classes.

Yet another step forward is due to application of SAT solvers by Marjin J. H. Heule and S. Verwer: the minimal DFA identification problem is reduced to deciding the satisfiability of a Boolean formula. The main idea is to build an augmented prefix-tree acceptor (a trie containing all input words with corresponding labels) based on the input sets and reduce the problem of finding a DFA with <math>C</math> states to coloring the tree vertices with <math>C</math> states in such a way that when vertices with one color are merged to one state, the generated automaton is deterministic and complies with <math>S^+</math> and <math>S^-</math>.

Though this approach allows finding the minimal DFA, it suffers from exponential blow-up of execution time when the size of input data increases.

Therefore, Heule and Verwer's initial algorithm has later been augmented with making several steps of the EDSM algorithm prior to SAT solver execution: the DFASAT algorithm.

This allows reducing the search space of the problem, but leads to loss of the minimality guarantee.

Another way of reducing the search space has been proposed by Ulyantsev et al. by means of new symmetry breaking predicates based on the breadth-first search algorithm:

the sought DFA's states are constrained to be numbered according to the BFS algorithm launched from the initial state. This approach reduces the search space by <math>C!</math> by eliminating isomorphic automata.

Equivalent models

Read-only right-moving Turing machines

Read-only right-moving Turing machines are a particular type of Turing machine that only moves right; these

are almost exactly equivalent to DFAs.

The definition based on a singly infinite tape is a 7-tuple

: <math>M = \langle Q, \Gamma, b, \Sigma, \delta, q_0, F \rangle,</math>

where

: <math>Q</math> is a finite set of states;

: <math>\Gamma</math> is a finite set of the tape alphabet/symbols;

: <math>b \in \Gamma</math> is the blank symbol (the only symbol allowed to occur on the tape infinitely often at any step during the computation);

: <math>\Sigma</math>, a subset of <math>\Gamma</math> not including b, is the set of input symbols;

: <math>\delta: Q \times \Gamma \to Q \times \Gamma \times \{R\}</math> is a function called the transition function, R is a right movement (a right shift);

: <math>q_0 \in Q</math> is the initial state;

: <math>F \subseteq Q</math> is the set of final or accepting states.

The machine always accepts a regular language. There must exist at least one element of the set (a HALT state) for the language to be nonempty.

Example of a 3-state, 2-symbol read-only Turing machine

{|class="wikitable"

|-

|

| colspan="3" | Current state A

| colspan="3" | Current state B

| colspan="3" | Current state C

|-

! tape symbol

! Write symbol

! Move tape

! Next state

! Write symbol

! Move tape

! Next state

! Write symbol

! Move tape

! Next state

|-

! 0

| 1

| R

|style="font-weight:bold" | B

| 1

| R

|style="font-weight:bold" | A

| 1

| R

|style="font-weight:bold" | B

|-

! 1

| 1

| R

|style="font-weight:bold" | C

| 1

| R

|style="font-weight:bold" | B

| 1

| N

| HALT

|}

: <math>Q = \{ A, B, C, \text{HALT} \};</math>

: <math>\Gamma = \{ 0, 1 \};</math>

: <math>b = 0</math>, "blank";

: <math>\Sigma = \varnothing</math>, empty set;

: <math>\delta = </math> see state-table above;

: <math>q_0 = A</math>, initial state;

: <math>F = </math> the one element set of final states: <math>\{\text{HALT}\}</math>.

See also

Notes

References

Further reading

  • — 1.1: "Finite Automata" pp.&nbsp;31&ndash;47. 4.1: "Decidable Languages - Decidable Problems Concerning Regular Languages" pp.&nbsp;152&ndash;155. 4.4: DFA can accept only regular language