Jump to content

Deterministic finite automaton

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Jaredwf (talk | contribs) at 06:17, 14 May 2004 (separated from finite state machine). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

A deterministic finite automaton is a finite state machine where for each state there is at most one transition for each possible input.

Formal definition

A deterministic finite automaton (DFA) is a 5-tuple: (S, Σ, T, s, A)

  • a finite set called the alphabet (Σ)
  • a finite set of states (S)
  • a transition function (T : S × Σ → S).
  • a start state (sS)
  • a set of accept states (AS)

Let M be a DFA such that M = (S, Σ, T, s, A), and X = x1x2 ... xn be a string over the alphabet Σ. M accepts the string X if a sequence of states, r0,r1, ..., rn, exists in S with the following conditions:

  1. r0 = s
  2. ri+1 = T(ri, xi+1), for i = 0, ..., n-1
  3. rnA.

As shown in the first condition, the machine starts in the start state s. The second condition says that given each character of string X, the machine will transition from state to state as ruled by the transition function T. The last condition says that the machine accepts if the last input of X causes the machine to be in one of the accepting states. Otherwise, it is said to reject the string. The set of strings it accepts form a language, which is the language the DFA recognises.


Example

The following example is of a DFA M, with a binary alphabet, which determines if the input contains an even number of 0s.

M = (S, Σ, T, s, A) where

0
1
S1 S2 S1
S2 S1 S2

The state diagram for M is:

File:DFAexample.png

Simply put, the state S1 represents that there has been an even number of 0s in the input so far, while S2 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.

The language of M can be described by the regular expression: