non-deterministic finite automaton

A non-deterministic finite automaton (or NDFA) can be formally defined as a 5-tuple (S,Σ,δ,q0,F), where

  1. 1.

    S is a non-empty finite setMathworldPlanetmath of states,

  2. 2.

    Σ is the alphabet (defining what set of input strings the automaton operates on),

  3. 3.

    δ:S×Σ𝒫(S) is a function called the transition function,

  4. 4.

    q0Q is the starting state, and

  5. 5.

    FS is a set of final (or accepting) states.

Some authors also relax the fourth condition by permitting multiple starting states (see remark below).

Note how this definition differs from that of a deterministic finite automaton (DFA) only by the definition of the transition function δ. OperationMathworldPlanetmath of the NDFA begins at q0, and movement from state to state is governed by the transition function δ.

The transition function takes the first symbol of the (remaining) input string and the current state as its input, and after the transition this first symbol is removed only if the transition is defined for a symbol in Σ instead of λ. Conceptually, all possible transitions from a current state are followed simultaneously (hence the non-determinism). Once every possible transition has been executed, the NDFA is halted. If any of the states reached upon halting are in F for some input string, and the entire input string is consumed to reach that state, then the NDFA accepts that string.

An NDFA can be represented visually as a directed graphMathworldPlanetmath called the state diagramMathworldPlanetmathPlanetmath. Circular vertices denote states, and the set of directed edges, labelled by symbols in Σλ, denotes T. The starting state q0 is usually denoted by an arrow pointing to it that points from no other vertex. States in F are usually denoted by double circles.

NDFAs accept regular languages, and can be used to test whether any string in Σ* is in the languagePlanetmathPlanetmath it represents. Given an NDFA M, the language accepted by M is denoted by L(M).

Consider the following regular language over the alphabet Σ:={𝚊,𝚋} (represented by the regular expressionMathworldPlanetmath aa*b):

<S> ::= aA
<A> ::= λB|𝚊A
<B> ::= b

This language can be represented by the NDFA with state diagram: