奎因莫克拉斯基方法_超越源代码奎因和自我复制

奎因莫克拉斯基方法

The “Beyond the Source Code” series of posts will explore source code beyond its use as a set of instructions that direct a process or set of processes. We will dive in topics such as readability, metaprogramming, quines, and many other topics that look at source code in a different light. The motivation for this series comes from the idea of making source code work for developers, rather than the developers having to work against the source code.

“超越源代码”系列文章将探讨源代码,而不是将其用作指导一个过程或一组过程的指令集。 我们将探讨诸如可读性,元编程,quines之类的主题,以及许多其他以不同的眼光看待源代码的主题。 本系列的动机来自使开发人员可以使用源代码的想法,而不是开发人员必须对源代码进行工作。

In the previous article we dove into readability and understanding of source code, with a focus on self-documenting code, comments, and documentation automation.

在上一篇文章中,我们着重于对源代码的可读性和理解,重点是自文档代码,注释和文档自动化。

In this post, we will be exploring quines and self-replication. Quines are curious little programs that perform a single function — taking no input and only outputting a copy of themselves. They are an interesting topic of computer science as they have both philosophical and biological underpinnings. To understand quines, let’s take a step back and look at the concept of self-replicating programs and machines.

在这篇文章中,我们将探索奎因和自我复制。 Quines是执行单个功能的好奇小程序-不输入任何内容,仅输出其自身的副本。 它们是计算机科学的一个有趣主题,因为它们具有哲学和生物学基础。 要了解奎恩,让我们退后一步,看看自我复制程序和机器的概念。

我恐惧的世界 (A World I Fear)

A world I fear is one in which the following two statements hold true:

我担心的世界是以下两个说法正确的世界:

  1. The artificial intelligence (AI) singularity has happened, or the point when artificial intelligence matches that of humans.

    人工智能(AI)的奇异性已经发生,也就是人工智能与人类相匹配的时刻。
  2. 3D printers who are capable of the above intelligence, and have the capability of producing other 3D printers.

    具有上述能力并具有生产其他3D打印机的能力的3D打印机。

If these two statements were to be true, we would have self-aware machines capable of producing other self-aware machines, similar to human reproduction. Even worse, human reproduction requires the interaction between two individuals, while a self-replicating and self-aware 3D printer could be completely autonomous and independent. A self-replicating machine would create a far-greater rate of exponential population growth than the rate at which humans reproduce since a single machine could recreate infinite number of copies. Couple this with machine-to-machine communication networks capable of high-speed throughput, massive amounts of data available on the internet, and our reliance on machines and you have a recipe for disaster.

如果这两个陈述是正确的,我们将拥有能够产生其他类似于人类繁殖的自我意识机器的自我意识机器。 更糟糕的是,人类复制需要两个人之间的互动,而具有自我复制和自我意识的3D打印机可能是完全自主和独立的。 由于一台机器可以复制无限数量的副本,因此自动复制机将创造比人类繁殖更高的指数种群增长速度。 将此与具有高速吞吐能力的机器对机器通信网络,互联网上可用的大量数据以及我们对机器的依赖相结合,您会遭受灾难。

Luckily, machines don’t hold a candle to human intelligence (yet) and 3D printers are still relatively simplistic in their capabilities.

幸运的是,机器还没有吸引到人类的智慧,而且3D打印机的功能仍然相对简单。

自我复制 (Self-Reproduction)

Self-reproducing machines and programs have been theorized since the beginning of computer science and programming. John Von Neumann in the 1940s, without the use of a computer, designed the first known example of self-reproducing automata. Automata are programs or machines that act independently based on a set of internal rules and external stimuli. The word “automata” comes from the Greek word αὐτόματα, meaning “self-making.”

自计算机科学和程序设计开始以来,自我复制的机器和程序已得到理论化。 1940年代,约翰·冯·诺依曼(John Von Neumann)在没有使用计算机的情况下,设计了第一个已知的自我复制自动机示例 自动机是根据一组内部规则和外部刺激独立运行的程序或机器。 “自动机”一词来自希腊文αὐτόματα,意为“自我创造”。

This first example is known as Von Neumann’s “Universal Constructor.”

第一个示例称为冯·诺依曼(Von Neumann)的“通用构造函数”。

Image for post
Original automaton: Renato Nobili and Umberto Pesavento
原始自动机:Renato Nobili和Umberto Pesavento

The Universal Constructor utilized the concept of cellular automata, which are grid-like maps of independent automata, or cells, that have a finite number of states and interact with each other. Capable of reproducing itself ad infinitum, the Universal Constructor had three components that lends to its reproductive behavior:

通用构造函数利用了细胞自动机的概念,它是独立自动机或单元格的网格状图,具有有限数量的状态并且彼此交互。 通用构造函数能够无限制地进行自我复制,它具有三个有助于其生殖行为的成分:

  • A description for the machine, that defines a program capable of self-replication.

    对机器的描述,它定义了能够自我复制的程序。
  • The “Universal Constructor” itself that can read any description and construct the program it defines.

    “通用构造函数”本身可以读取任何描述并构造其定义的程序。
  • A “Universal Copy” machine that is able to copy any description that it reads

    一台“通用复制”机器,能够复制其读取的任何描述

Given these components, it can be seen how the recursive self-reproducing behavior is created. A program is created with all of the above components, it’s description is copied using the Universal Copier, and the Universal Constructor reads the description copy and builds another one. Rinse and repeat, and you end up with an army of self-reproducing cellular automata capable of producing their own armies of cellular automata. Scary to think, these self-reproducing programs were designed in the 1940s, 44 years before the release of the first Terminator and the idea of Skynet. Even more so, a few years before the first digital computer, the ENIAC.

给定这些组件,可以看出如何创建递归自重生成行为。 将使用上述所有组件创建一个程序,使用通用复印机复制其描述,然后通用构造函数读取该描述副本并构建另一个。 冲洗并重复,您最终会得到一群能够自我复制的自动机,能够产生自己的自动机大军。 令人难以置信的是,这些自我复制程序是在1940年代设计的,即第一个终结者和天网的发布之前的44年。 更是如此,比第一台数字计算机ENIAC早了几年。

Interested to read more about the Universal Constructor? Here is a paper on it.

有兴趣阅读有关通用构造函数的更多信息吗? 是一张纸。

奎因 (Quines)

Quines operate in the same context of self-reproducing automata, but are quite simpler. Similar to the three components that a Universal Constructor is comprised of, a Quine is made up of a program capable of outputting data (a Constructor and Copier of sorts), and a representation of the source code as data (the Description). Quines have a strict rule of not reading a copy of its own source code or requiring any input, and any quine that does so is known as a “cheating quine.” An example of a quine in Python (3.X) can be seen below:

奎因在自我复制自动机的相同上下文中运行,但非常简单。 与通用构造器所组成的三个组件相似,Quine由能够输出数据的程序(某种构造器和复印机)以及将源代码表示为数据(说明)组成。 Quines有严格的规则,不得读取其自身源代码的副本或需要任何输入,任何这样做的quine被称为“作弊quine”。 以下是Python(3.X)中的Quine的示例:

_='_=%r;print (_%%_)';print%_)

Notice the information density and size of this program — not a single smidgen of syntax goes to waste. Yet, this program does something philosophically remarkable. It is able to self-replicate and indirectly reference itself.

注意该程序的信息密度和大小-不会浪费任何语法。 但是,该程序在哲学上做得很出色。 它能够自我复制并间接引用自身。

Quines are a wonderful study into the world of metaprogramming, and what source code is capable of beyond being an instruction set for a process. Given the challenge of optimizing information density, programmers will often compete in a style of programming known as “code golf” to create the shortest possible quines with the least amount of code. These compact lilliputian programs carry much more weight from a theoretical perspective than they do in purpose and looks.

Quines是对元编程世界的一次精彩研究,而源代码除了可以作为过程的指令集之外,还能提供哪些源代码。 面对优化信息密度的挑战,程序员通常会以一种称为“代码高尔夫”的编程方式竞争以用最少的代码创建尽可能短的quines。 从理论上讲,这些紧凑的小人国节目具有比目标和外观更大的影响力。

The idea of being able to recreate self-replicating behavior in the smallest form possible is analogous to concepts in biology and “meaning of life” philosophical studies. Biologists have studied microscopic organisms capable of reproduction to understand life at the smallest scales, and philosophers continuously research the far corners of logic and understanding to understand the purpose of life. In fact, the concept of Quines was not discovered by a computer scientist, but derived from the work of a philosopher.

能够以最小的形式重现自我复制行为的想法类似于生物学和“生命的意义”哲学研究中的概念。 生物学家研究了能够繁殖的微观有机体,以最小的尺度了解生命,而哲学家不断研究逻辑和理解的各个角落,以理解生命的目的。 实际上,Quines的概念并不是由计算机科学家发现的,而是源于哲学家的工作。

威拉德·范·奥曼·奎因 (Willard Van Orman Quine)

Willard Van Orman Quine was an American philosopher in the 20th century best known for his work in logic and set theory. His work on the idea of “indirect self-reference” is essentially recursion from a philosophical point of view, or an object referring to itself indirectly. Quine demonstrated indirect self-reference with the following paradox:

威拉德·范·奥曼·奎因( Willard Van Orman Quine)是20世纪的美国哲学家,以其逻辑和集合论的研究而闻名。 他关于“间接自我指称”的工作本质上是从哲学角度出发的递归,或者是一个间接指称自己的客体。 Quine表现出间接的自我参照,存在以下悖论:

“yields falsehood when preceded by its quotation” yields falsehood when preceded by its quotation.

“在引用之前产生虚假”在引用之前产生虚假。

This became known as Quine’s paradox, and is the reason for the curious little programs’ name and origin.

这被称为Quine的悖论,并且是奇怪的小程序的名称和起源的原因。

An easier to understand example of indirect self-reference can be seen in the following sentence from this Wikipedia page.

Wikipedia页面的以下句子中,可以看到一个更容易理解的间接自引用示例。

"Is a sentence fragment" is a sentence fragment.

“是一个句子片段”是一个句子片段。

  • The quoted sentence itself is a sentence fragment.

    引用的句子本身是一个句子片段。
  • The self-reference identifies the preceding quotation as a sentence fragment.

    自引用将前面的引号标识为句子片段。
  • The full sentence itself is grammatically and syntactically correct in the English language.

    完整句子本身在英语上在语法和语法上都是正确的。

Isn’t it interesting how source code can go beyond the concepts of computer science and programming, and be used as reflections on philosophy and logic?

源代码如何超越计算机科学和编程的概念,并用作对哲学和逻辑的反思,这不是很有趣吗?

Taking the idea of self-replicating or self-referencing behavior, how can this be seen in computer programs today?

以自我复制或自我引用行为的想法,如何在当今的计算机程序中看到这一点?

蠕虫 (Worms)

We started off this article with a musing about a scary topic (end of the world caused by machines), so lets end with another one. A worm is a type of malware that seeks to infect as many computers as possible through self-replication. Often targeting a weak host on a network, a worm will then use its first host to spread to others in the same network. Due to the exponential growth that programs are capable of achieving when undergoing self-replication, worms are extremely dangerous and will usually damage entire networks rather than a single machine.

我们从对一个可怕的话题(由机器引起的世界末日)的沉思开始了这篇文章,因此让我们结束另一个话题。 蠕虫是一种恶意软件,它试图通过自我复制来感染尽可能多的计算机。 蠕虫通常针对网络上的弱主机,然后会使用其第一台主机传播到同一网络中的其他主机。 由于程序在进行自我复制时能够实现指数级增长,因此蠕虫非常危险,通常会损坏整个网络,而不是单个计算机。

An interesting example of a self-replicating worm is the Stuxnet worm of 2010. Designed to target industrial control systems (SCADA, supervisory control and data acquisition systems), Stuxnet is the likely culprit for causing a lot of damage to Iran’s nuclear program. As a worm, Stuxnet was capable of infinite replication to targeted host systems, and was therefore extremely difficult to stop and quarantine. Starting from an engineer’s computer, the worm quickly spread through centrifuges and industrial equipment, continuously replicating and causing damage along the way.

自复制蠕虫的一个有趣例子是2010年的Stuxnet蠕虫。Stuxnet旨在针对工业控制系统(SCADA,监督控制和数据采集系统),可能是对伊朗核计划造成重大损害的罪魁祸首。 作为蠕虫,Stuxnet能够无限复制到目标主机系统,因此极难停止和隔离。 该蠕虫从工程师的计算机开始,Swift在离心机和工业设备中传播,不断复制并造成破坏。

The concepts first visited in this article of machine takeovers and program replication start to become very real when worms are specifically designed to target industrial equipment and factory controls. This is where the line between the virtual and physical worlds really start to become blurred, when self-replicating non-tangible programs start to wreak havoc on physical world systems.

当蠕虫专门针对工业设备和工厂控制而设计时,在本文中机器访问和程序复制中首次访问的概念就变得非常现实。 当自我复制的非有形程序开始对物理世界系统造成严重破坏时,虚拟世界和物理世界之间的界限实际上开始变得模糊。

Let’s hope that self-replicating programs and behavior stay confined to the seemingly benign world of quines and universal constructors for years to come.

让我们希望,在以后的几年中,自我复制程序和行为将始终局限于看似良性的奎因和通用构造函数的世界。

翻译自: https://medium.com/@riptidedata/beyond-the-source-code-quines-and-self-replication-fab3e000696c

奎因莫克拉斯基方法

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值