今天这段依然出自艾伦·图灵(Alan Turing)1936年发表的经典论文《论可计算数及其在判定问题上的应用》(Alan Turing, On Computable Numbers, with an Application to the Entscheidungsproblem, 1936),具体是文章的第六章。
原文
6. The universal computing machine.
It is possible to invent a single machine which can be used to compute any computable sequence. If this machine $\mathcal{U}$ is supplied with a tape on the beginning of which is written the S.D of some computing machine $\mathcal{M}$, then $\mathcal{U}$ will compute the same sequence as $\mathcal{M}$. In this section I explain in outline the behaviour of the machine. The next section is devoted to giving the complete table for $\mathcal{U}$.
Let us first suppose that we have a machine $\mathcal{M}'$ which will write down on the $F$-squares the successive complete configurations of $\mathcal{M}$. These might be expressed in the same form as on p. 235, using the second description, (C), with all symbols on one line. Or, better, we could transform this description (as in §5) by replacing each $m$-configuration by "$D$" followed by "$A$" repeated the appropriate number of times, and by replacing each symbol by "$D$" followed by "$C$" repeated the appropriate number of times. The numbers of letters "$A$" and "$C$" are to agree with the numbers chosen in §5, so that, in particular, "0" is replaced by "$DC$", "1" by "$DCC$", and the blanks by "$D$". These substitutions are to be made after the complete configurations have been put together, as in (C). Difficulties arise if we do not do the substitution first. In each complete configuration the blanks would all have to be replaced by "$D$", so that the complete configuration would not be expressed as a finite sequence of symbols.
If in the description of the machine II of §3 we replace "$\mathfrak{o}$" by "$DAA$", "$\mathfrak{q}$" by "$DCCC$", "$\mathfrak{p}$" by "$DAAA$", then the sequence (C) becomes:
$DA : DCCCDCCCDAADCDDC : DCCCDCCCDAAADCDDC : \ldots$ ($C_1$)
(This is the sequence of symbols on $F$-squares.)
It is not difficult to see that if $\mathcal{M}$ can be constructed, then so can $\mathcal{M}'$. The manner of operation of $\mathcal{M}'$ could be made to depend on having the rules of operation (i.e., the S.D) of $\mathcal{M}$ written somewhere within itself (i.e. within $\mathcal{M}'$); each step could be carried out by referring to these rules. We have only to regard the rules as being capable of being taken out and exchanged for others and we have something very akin to the universal machine.
One thing is lacking: at present the machine $\mathcal{M}'$ prints no figures. We may correct this by printing between each successive pair of complete configurations the figures which appear in the new configuration but not in the old. Then ($C_1$) becomes
$DDA : 0 : 0 : DCCCDCCCDAADCDDC : DCCC : \ldots$ ($C_2$)
It is not altogether obvious that the $E$-squares leave enough room for the necessary "rough work", but this is, in fact, the case.
The sequences of letters between the colons in expressions such as ($C_1$) may be used as standard descriptions of the complete configurations. When the letters are replaced by figures, as in §5, we shall have a numerical description of the complete configuration, which may be called its description number.
翻译
6. 通用计算机器
我们可以发明一种单一的机器,它可以用来计算任何可计算序列。如果已经有一条纸带的开头是某个机器$\mathcal{M}$ 的标准描述(S.D),然后将这条纸带提供给另外一台机器 $\mathcal{U}$ ,那么 $\mathcal{U}$ 将计算出与 $\mathcal{M}$ 相同的序列。本节将简要解释这台机器$\mathcal{U}$ 的行为。下一节将专门给出 $\mathcal{U}$ 的完整表格。
首先,假设我们有一台机器 $\mathcal{M}'$,它会在 $F$-方格上写下 $\mathcal{M}$ 的连续完整构型。这些构型可以用第 235 页第三章所述的形式表达,即采用第二种描述方式 (C),将所有符号写在同一行上。或者,更好的做法是,我们可以(如 §5 所示)对这种描述进行转换:用“$D$”后跟适当数量的“$A$”来替换每个 $m$-构型(状态),用“$D$”后跟适当数量的“$C$”来替换每个符号。字母“$A$”和“$C$”的重复次数应与 §5 中的规定一致,即“0”替换为“$DC$”,“1”替换为“$DCC$”,空白替换为“$D$”。注意,这些替换操作必须在完整构型拼接完成后进行,如 (C) 所示。如果我们在拼接之前先进行替换,拼接就会遇到困难:因为在每个完整构型中,所有的空白都需要被替换为“$D$”,这样一来,完整构型就无法用有限的符号序列来表示了。
如果在 §3 中机器 II 的描述里,我们用“$DAA$”替换“$\mathfrak{o}$”,用“$DCCC$”替换“$\mathfrak{q}$”,用“$DAAA$”替换“$\mathfrak{p}$”,那么序列 (C) 将变为:
$DA : DCCCDCCCDAADCDDC : DCCCDCCCDAAADCDDC : \ldots$ ($C_1$)
(这是 $F$-方格上的符号序列。)
不难看出,既然机器 $\mathcal{M}$ 是可以被构造出来的,那么模拟它的机器 $\mathcal{M}'$ 自然也是可以构造的。我们可以这样设计 $\mathcal{M}'$ 的运作机制:将 $\mathcal{M}$ 的操作规则(即标准描述 S.D)记录在 $\mathcal{M}'$ 内部;$\mathcal{M}'$ 每执行一步,都通过查阅这些规则来决定如何行动。此时,如果我们把这些规则看作是可以随时取出并替换成其他规则的,那么我们就得到了一种非常接近于通用机器的东西。
目前还有一个缺憾:机器 $\mathcal{M}'$ 只记录状态,并不打印数字(即计算结果)。我们可以做个修正:在每两个连续的完整构型之间,顺便打印出新构型中新增的数字。这样序列 ($C_1$) 就变成了:
$DDA : 0 : 0 : DCCCDCCCDAADCDDC : DCCC : \ldots$ ($C_2$)
$E$-方格上是否留有足够的空间来进行必要的“草稿工作”,这一点并非显而易见,但事实上确实是足够的。
在像 ($C_1$) 这样的表达式中,冒号之间的字母序列可用作完整构型的标准描述。当这些字母被数字替换时(如 §5 所示),我们将得到完整构型的数值描述,这可以称为它的描述数(Description Number)。
逐段解析
1. 通用图灵机(The Universal Turing Machine, U)的概念
“我们有可能发明一种单一的机器,它可以用来计算任何可计算序列。”
- 历史性时刻:这是计算机科学史上最重要的时刻之一。在此之前,机器都是专用的(比如织布机只能织布,加法机只能做加法)。
- 通用性:图灵提出了一种机器 $\mathcal{U}$,它本身不执行特定的计算任务,而是模拟另一台机器 $\mathcal{M}$ 的行为。
- 软件的诞生:$\mathcal{U}$ 能够工作的关键在于,它读取了 $\mathcal{M}$ 的标准描述 (S.D)。这个 S.D 就是我们今天所说的软件(Software)或程序。通用图灵机 $\mathcal{U}$ 本质上就是现代的可编程计算机(CPU)。
2. 模拟机制
“让我们假设我们有一台机器 $\mathcal{M}'$,它会在 $F$-方格上写下 $\mathcal{M}$ 的连续完整构型。”
- 状态快照的演变:$\mathcal{U}$ 的工作方式不是直接算出结果,而是一步步地打印出被模拟机器 $\mathcal{M}$ 的状态变化过程。
- 快照序列:
- 时刻 0:$DA$ (初始状态)
- 时刻 1:$DCCCDCCCDAADCDDC$ (经过一步后的状态)
- ...
- 解释器 (Interpreter):$\mathcal{U}$ 实际上是一个解释器。它读取 $\mathcal{M}$ 的源代码(规则表),查看 $\mathcal{M}$ 当前的状态和纸带符号,然后在规则表中查找“下一步该做什么”,并更新 $\mathcal{M}$ 的状态快照。
3. 输出的处理
“目前机器 $\mathcal{M}'$ 不打印数字... 我们可以通过... 打印... 数字来修正这一点。”
- 分离元数据与数据:$\mathcal{M}'$ 主要在忙着记录 $\mathcal{M}$ 的内部状态变化(这些是元数据)。但 $\mathcal{U}$ 作为一台计算机器,也需要输出最终结果(数字 0 或 1)。
- 嵌入输出:图灵建议在状态快照之间,顺便把 $\mathcal{M}$ 刚刚打印出的数字(如果有的话)也打印出来。这样 $\mathcal{U}$ 的纸带上就混合了:
- $\mathcal{M}$ 的代码(S.D)
- $\mathcal{M}$ 的当前状态快照
- $\mathcal{M}$ 产生的真实输出数据
总结
这一章提出了存储程序计算机(Stored-program computer)的理论原型。 1. 硬件与软件的分离:$\mathcal{U}$ 是硬件,$\mathcal{M}$ 的 S.D 是软件。 2. 模拟:计算不仅仅是算数,还可以是“模拟另一种计算过程”。 3. 图灵完备性:如果一个系统能够模拟通用图灵机,那么它就能计算任何可计算序列。这一概念源于此。
CycleUser