Futamura Projections[Y. Futamura, ``Partial Evaluation of Computation Process -- An Approach to a Compiler-Compiler'', Systems, Computers, Controls, 2(5):45-50, 1971. The presentation here follows Jones et al.]
Partial evaluation is a powerful unifying technique that describes many operations in computer science.
We use the notation [![ P ]!] L to denote running a program P in language L. Suppose that int is an interpreter for a language S and source is a program written in S. Then:
output | = | [![ source ]!] s [ input ] |
= | [![ int ]!] [ source, input] | |
= | [![ [![ mix ]!] [ int, source] ]!] [ input] | |
= | [![ target ]!] [ input ] | |
Therefore, target = [![ mix ]!] [ int, source] .
target | = | [![ mix ]!] [ int, source] |
= | [![ [![ mix ]!] [ mix, int ] ]!] [ source] | |
= | [![ compiler ]!] [ source ] | |
Thus, compiler = [![ mix ]!] [ mix, int ]
= [![ cogen ]!] [ int ]