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 -term L into maximally compact form L0 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 G0 ; (iii) read back a λ letrec -term L0 from the term graph G0 with the property L0 = G0. This guarantees that L0 and L have the same unfolding, and that L0 exhibits maximal sharing.The procedure for deciding whether two given λ letrec -terms L1 and L2 are unfolding-equivalent computes their term graph interpretations L1 and L2 , and checks whether these term graphs are bisimilar.For illustration, we also provide a readily usable implementation.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.
customersupport@researchsolutions.com
10624 S. Eastern Ave., Ste. A-614
Henderson, NV 89052, USA
Copyright © 2024 scite LLC. All rights reserved.
Made with 💙 for researchers
Part of the Research Solutions Family.