From checking to inference via driving and dag grammars
Abramov and Gluck have recently introduced a technique called URA for inverting first order functional programs. Given some desired output value, URA computes a potentially infinite suquence of substitutions/restrictions corresponding to the relevant input values. In some cases this process does not terminate. In the present paper, we propose a new program analysis for inverting programs. The technique works by computing a finite grammar describing the set of all input that relate to a given output. During the production of the grammar, the original program is implicitly transformed using so-called driving steps. Whereas URA is sound and complete, but sometimes fails to terminate, our technique always terminates and is complete, but not sound. As an example, we demonstrate how to derive type inference from type checking. The idea of approximating functional programs by grammars is not new. For instance, the second author has developed a technique using tree grammars to approximate termination behaviour of deforestation. However, for the present purposes it has been necessary to invent a new type of grammar that extends tree grammars by permitting a notion of sharing in the productions. These dag grammars seem to be of independent interest.
inference program inversion supercompilation