Abstract

Increasing sharing in programs is desirable to compactify the code, and to avoid duplication of reduction work at run-time, thereby speeding up execution. We show how a maximal degree of sharing can be obtained for programs expressed as terms in the lambda calculus with letrec. We introduce a notion of 'maximal compactness' for λ letrec -terms among all terms with the same infinite unfolding. Instead of defined purely syntactically, this notion is based on a graph semantics. λ letrec -terms are interpreted as first-order term graphs so that unfolding equivalence between terms is preserved and reflected through bisimilarity of the term graph interpretations. Compactness of the term graphs can then be compared via functional bisimulation. We describe practical and efficient methods for the following two problems: transforming a λ letrec -term into a maximally compact form; and deciding whether two λ letrec -terms are unfolding-equivalent. The transformation of a λ letrec -terms L into maximally compact form L 0 proceeds in three steps: (i) translate L into its term graph G = [[L]] ; (ii) compute the maximally shared form of G as its bisimulation collapse G 0 ; (iii) read back a λ letrec -term L 0 from the term graph G 0 with the property [[ L 0 ]] = G 0 . Then L 0 represents a maximally shared term graph, and it has the same unfolding as L . The procedure for deciding whether two given λ letrec -terms L 1 and L 2 are unfolding-equivalent computes their term graph interpretations [[ L 1 ]] and [[ L 2 ]], and checks whether these are bisimilar. For illustration, we also provide a readily usable implementation.

Full Text
Paper version not known

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call