Turing machine

1. 图灵机(普通图灵机)

A is a 7-tuple, , where are all finite sets and

  1. is the set of states,
  2. is the input alphabet not containing the ,
  3. is the tape alphabet, where and ,
  4. is the transition function,
  5. is the start state,
  6. is the accept state, and
  7. is the reject state, where .

input string belongs to

A Turing machine accepts input if a sequence of configurations exists, where

  1. is the start configuration of on input ,
  2. each yields , and
  3. is an accepting configuration.

The collection of strings that accepts is the language of , or the language recognized by , denoted .

If a Turing machine can always enter the accepting state or the rejecting state after a finite number of state transitions for all inputs, then the Turing machine is called decider.

A decider that recognizes some language also is said to decide that language. Call a language Turing-decidable or simply decidable if some Turing machine decides it.

flowchart TD
    subgraph Turing-recognizable
        subgraph decidable
            subgraph context-free
                subgraph regular
                end
            end
        end
    end

    style Turing-recognizable fill:none,stroke:#333
    style decidable fill:none,stroke:#333
    style context-free fill:none,stroke:#333
    style regular fill:none,stroke:#333

2. 图灵机的(等价)变体:逗留(stay)图灵机

A is a 7-tuple, , where are all finite sets and

  1. is the set of states,
  2. is the input alphabet not containing the ,
  3. is the tape alphabet, where and ,
  4. is the transition function,
  5. is the start state,
  6. is the accept state, and
  7. is the reject state, where .

任意逗留图灵机都可由一个普通图灵机模拟。

构造等价的普通图灵机:

表示投影映射,表示取第一个分量

例如,若,则

表示的指标集

对于任意状态 和符号 ,定义新状态 。转移函数如下:

  • 对任意 ,令
  • ,则
  • ,则
  • ,则

非确定性图灵机

3. 形式定义

非确定性图灵机(nondeterministic Turing machine,NTM) 是一个 7-元组

其中:

  1. 是有限状态集;
  2. 是不包含空白符 的输入字母表;
  3. 是纸带字母表,满足
  4. 是转移函数;
  5. 是起始状态;
  6. 是接受状态;
  7. 是拒绝状态,且

4. 非确定性转移函数

确定性图灵机的每个“状态—纸带符号”对恰好确定一个后继动作;非确定性图灵机则允许有限个可能的后继动作。其转移函数定义为

其中 表示集合 的幂集。因为 都是有限集,所以 也是有限集。

若机器当前处于状态 ,读写头扫描到符号 ,则每个

都表示一种合法的后继动作:进入状态 ,将当前位置改写为 ,并令读写头向方向 移动一格。一次具体计算只选择其中一个动作;不同选择形成不同的计算分支。

5. 配置与计算树

  • 配置(configuration):与确定性图灵机相同,一个配置由当前状态、纸带内容和读写头位置组成。

  • 一步产生关系(yield):若应用 中的某个合法动作可使配置 一步变为 ,则记作

  • 计算分支(computation branch):从初始配置开始,连续选择合法后继配置所得到的配置序列。

  • 计算树(computation tree):给定输入 ,以初始配置为根、以所有合法后继配置为子节点形成的树。它同时描述 上的所有可能计算分支。

6. 接受、拒绝与判定

对于输入

  • 若计算树中至少存在一条有限分支到达 ,则称 接受
  • 若所有计算分支都在有限步内停机且没有任何分支接受(通常均到达 ),则称 拒绝
  • 若所有计算分支都会在有限步内停机,则称 为非确定性判定器。

所识别的语言定义为

因此,非确定性的接受语义是“存在一个接受分支”,而不是要求所有分支都接受。