Reducibility & Advanced Undecidability

computational self-reproduction (quines)

/ quine rhymes with 'mine' /

A quine is a program that, when run, prints its own source code exactly, with no input and without reading its own file. At first this feels like a paradox: to print its code the program would have to contain its code, which contains its code, forever. Yet quines exist in every general-purpose language. They are the playful, concrete face of the recursion theorem: proof that a program really can get hold of, and reproduce, its own description.

The trick that defeats the apparent infinite regress is to split the program into two cooperating parts: a piece of data that is a quoted copy of the program's text, and a piece of code that prints that data twice, once as a string literal and once as live code. The data describes the code; the code, when run, reconstructs the data. Schematically: let part B be the instruction 'print the following string, then print it again but as code', and let part A be a quoted copy of B; running A then B reproduces A then B. No part contains an infinite copy of itself; each half describes the other, and together they close the loop. This 'compute a description of the whole from a part' move is exactly the engine of the recursion theorem's proof.

Self-reproduction is more than a curiosity. It is the formal heart of the recursion theorem (a machine can obtain its own description), and by extension it underlies serious phenomena: self-replicating structures studied by von Neumann, the theoretical underpinnings of computer viruses (a program that copies itself into other programs), and the self-reference at the core of Godel's incompleteness, where a logical sentence effectively says 'I am not provable'. An honest caveat: a quine printing itself is not a contradiction or a violation of any limit; it is perfectly computable. The limits appear only when self-reference is combined with a demand to decide one's own undecidable behavior, as in the recursion-theorem proofs of undecidability.

A quine in two cooperating halves: a data string s holding a quoted copy of the program, and code that (1) prints the code-half using s, then (2) prints s itself, suitably quoted. Running it emits the same two halves, reproducing the whole source. No half ever stores an infinite copy of itself; each describes the other.

Split into data-that-describes-the-code and code-that-prints-the-data; together they print the whole program.

Reading its own source file from disk does NOT count as a quine, and it is not what the recursion theorem provides. A true quine reconstructs its text purely from its own running code, which is the deep point.

Also called
self-reproducing programself-replicating programquine自我複製程式