Kleene's recursion theorem
Kleene's recursion theorem isresultcomputability theory first proved by Stephen Kleene;allowsconstruct programs, Turing machinesrecursive functions that refer backtheir own description.The theorem can be formulatedany ofequivalent modelscomputation listed incomputability theory article. Here we will use Pascal programs.
If p isstring that describesPascal program which readssingle input stringproducessingle output string, then we will denotecorresponding partial function from input stringsoutput strings by fp. (This ispartial function becausesome input stringsprogram described by p may run into an infinite loopnever produce an output.)
The statement oftheoremas follows: If Q isPascal program which takes two input strings xyproducessingle output string Q(x,y) (which again may be undefined if Q runs into an infinite loop), then there always existsstring p describing some Pascal program such thatall input strings y:
- Q(p,y) = fp(y).
As an application, we can show that there must existPascal program which takessingle input, ignores that inputprints itself as output: Define Q(x,y) = x, thentheorem yieldsPascal program p such thatall y: fp(y) = Q(p,y) = p. Itan amusing exerciseactually write suchprogram p.
