Automata Theory 简明教程

Non-deterministic Finite Automaton

在 NDFA 中,对于特定的输入符号,机器可以移动到机器中的任何状态组合。换句话说,无法确定机器移动到的确切状态。因此,它称为 Non-deterministic Automaton 。由于它有有限数量的状态,因此机器称为 Non-deterministic Finite MachineNon-deterministic Finite Automaton

In NDFA, for a particular input symbol, the machine can move to any combination of the states in the machine. In other words, the exact state to which the machine moves cannot be determined. Hence, it is called Non-deterministic Automaton. As it has finite number of states, the machine is called Non-deterministic Finite Machine or Non-deterministic Finite Automaton.

Formal Definition of an NDFA

NDFA 可以用 5 元组 (Q, ∑, δ, q0, F) 表示,其中−

An NDFA can be represented by a 5-tuple (Q, ∑, δ, q0, F) where −

  1. Q is a finite set of states.

  2. is a finite set of symbols called the alphabets.

  3. δ is the transition function where δ: Q × ∑ → 2Q (Here the power set of Q (2Q) has been taken because in case of NDFA, from a state, transition can occur to any combination of Q states)

  4. q0 is the initial state from where any input is processed (q0 ∈ Q).

  5. F is a set of final state/states of Q (F ⊆ Q).

Graphical Representation of an NDFA: (same as DFA)

NDFA 由称为状态图的有向图表示。

An NDFA is represented by digraphs called state diagram.

  1. The vertices represent the states.

  2. The arcs labeled with an input alphabet show the transitions.

  3. The initial state is denoted by an empty single incoming arc.

  4. The final state is indicated by double circles.

Example

令非确定性有限自动机为→

Let a non-deterministic finite automaton be →

  1. Q = {a, b, c}

  2. ∑ = {0, 1}

  3. q0 = {a}

  4. F = {c}

过渡函数 δ 如下所示−

The transition function δ as shown below −

Present State

Next State for Input 0

Next State for Input 1

a

a,

b

b

c

a, c

c

b,

c

它的图形表示如下−

Its graphical representation would be as follows −

ndfa graphical representation

DFA vs NDFA

下表列出了 DFA 和 NDFA 之间的差异。

The following table lists the differences between DFA and NDFA.

DFA

NDFA

The transition from a state is to a single particular next state for each input symbol. Hence it is called deterministic.

The transition from a state can be to multiple next states for each input symbol. Hence it is called non-deterministic.

Empty string transitions are not seen in DFA.

NDFA permits empty string transitions.

Backtracking is allowed in DFA

In NDFA, backtracking is not always possible.

Requires more space.

Requires less space.

A string is accepted by a DFA, if it transits to a final state.

A string is accepted by a NDFA, if at least one of all possible transitions ends in a final state.

Acceptors, Classifiers, and Transducers

Acceptor (Recognizer)

计算布尔函数的自动机称为 acceptor 。接受器的所有状态要么接受要么拒绝给定的输入。

An automaton that computes a Boolean function is called an acceptor. All the states of an acceptor is either accepting or rejecting the inputs given to it.

Classifier

一个 classifier 有多于两个最终状态,并且在终止时给出单个输出。

A classifier has more than two final states and it gives a single output when it terminates.

Transducer

基于当前输入和/或先前状态生成输出的自动机称为 transducer 。转换器可以是两种类型:

An automaton that produces outputs based on current input and/or previous state is called a transducer. Transducers can be of two types −

  1. Mealy Machine − The output depends both on the current state and the current input.

  2. Moore Machine − The output depends only on the current state.

Acceptability by DFA and NDFA

当 DFA/NDFA 从初始状态开始在完整读取字符串后结束于接受状态(任何最终状态)时,一个字符串才会被 DFA/NDFA 接受。

A string is accepted by a DFA/NDFA iff the DFA/NDFA starting at the initial state ends in an accepting state (any of the final states) after reading the string wholly.

字符串 S 被 DFA/NDFA (Q, ∑, δ, q0, F) 接受,当且仅当

A string S is accepted by a DFA/NDFA (Q, ∑, δ, q0, F), iff

δ (q0, S) ∈ F*

δ(q0, S) ∈ F*

DFA/NDFA 接受的语言 L

The language L accepted by DFA/NDFA is

{S | S ∈ ∑ 并且 δ*(q0, S) ∈ F}*

{S | S ∈ ∑ and δ*(q0, S) ∈ F}*

如果一个字符串 S′ 不被 DFA/NDFA (Q, ∑, δ, q0, F) 所接受,则

A string S′ is not accepted by a DFA/NDFA (Q, ∑, δ, q0, F), iff

δ (q0, S′) ∉ F*

δ(q0, S′) ∉ F*

DFA/NDFA 所不接受的语言 L′(所接受语言 L 的补集)为

The language L′ not accepted by DFA/NDFA (Complement of accepted language L) is

{S | S ∈ ∑ and δ*(q0, S) ∉ F}*

{S | S ∈ ∑ and δ*(q0, S) ∉ F}*

Example

我们考虑图 1.3 中所示的 DFA。可以从 DFA 推导出可接受的字符串。

Let us consider the DFA shown in Figure 1.3. From the DFA, the acceptable strings can be derived.

acceptability of strings by dfa

上述 DFA 所接受的字符串:{0, 00, 11, 010, 101, …​…​…​..}

Strings accepted by the above DFA: {0, 00, 11, 010, 101, …​…​…​..}

上述 DFA 所不接受的字符串:{1, 011, 111, …​…​..}

Strings not accepted by the above DFA: {1, 011, 111, …​…​..}