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.
We study various representations for cyclic lambda-terms as higher-order or as first-order term graphs. We focus on the relation between 'lambda-higher-order term graphs' (lambda-ho-term-graphs), which are first-order term graphs endowed with a well-behaved scope function, and their representations as 'lambda-term-graphs', which are plain first-order term graphs with scope-delimiter vertices that meet certain scoping requirements. Specifically we tackle the question: Which class of first-order term graphs admits a faithful embedding of lambda-ho-term-graphs in the sense that (i) the homomorphism-based sharing-order on lambda-ho-term-graphs is preserved and reflected, and (ii) the image of the embedding corresponds closely to a natural class (of lambda-term-graphs) that is closed under homomorphism? We systematically examine whether a number of classes of lambda-term-graphs have this property, and we find a particular class of lambda-term-graphs that satisfies this criterion. Term graphs of this class are built from application, abstraction, variable, and scope-delimiter vertices, and have the characteristic feature that the latter two kinds of vertices have back-links to the corresponding abstraction. This result puts a handle on the concept of subterm sharing for higher-order term graphs, both theoretically and algorithmically: We obtain an easily implementable method for obtaining the maximally shared form of lambda-ho-term-graphs. Furthermore, we open up the possibility to pull back properties from first-order term graphs to lambda-ho-term-graphs, properties such as the complete lattice structure of bisimulation equivalence classes with respect to the sharing order
We address a problem connected to the unfolding semantics of functional programming languages: give a useful characterization of those infinite λ-terms that are λ letrec -expressible in the sense that they arise as infinite unfoldings of terms in λ letrec , the λ-calculus with letrec. We provide two characterizations, using concepts we introduce for infinite λ-terms: regularity, strong regularity, and binding-capturing chains. It turns out that λ letrec -expressible infinite λ-terms form a proper subclass of the regular infinite λ-terms. In this paper we establish these characterizations only for expressibility in λ µ , the λ-calculus with explicit µ-recursion. We show that for all infinite λ-terms T the following are equivalent: (i): T is λ µ -expressible; (ii): T is strongly regular; (iii): T is regular, and it only has finite binding-capturing chains.We define regularity and strong regularity for infinite λ-terms as two different generalizations of regularity for infinite first-order terms: as the existence of only finitely many subterms that are defined as the reducts of two rewrite systems for decomposing λ-terms. These rewrite systems act on infinite λ-terms furnished with a bracketed prefix of abstractions for collecting decomposed λ-abstractions and keeping the terms closed under decomposition. They differ in which vacuous abstractions in the prefix are removed.This report accompanies the article [9], and mainly differs from that by providing the proof of the characterization of λ µ -expressibility with binding-capturing chains.
For the λ -calculus with letrec we develop an optimisation, which is based on the contraction of a certain class of 'future' (also: virtual) redexes.In the implementation of functional programming languages it is common practice to perform β -reductions at compile time whenever possible in order to produce code that requires fewer reductions at run-time. This is, however, in principle limited to redexes and created redexes that are 'visible' (in the sense that they can be contracted without the need for unsharing), and cannot generally be extended to redexes that are concealed by sharing constructs such as letrec. In the case of recursion, concealed redexes become visible only after unwindings during evaluation, and then have to be contracted time and again.We observe that in some cases such redexes exhibit a certain form of repetitive behaviour at run time. We describe an analysis for identifying binders that give rise to such repetitive reduction patterns, and eliminate them by a sort of predictive contraction. Thereby these binders are lifted out of recursive positions or eliminated altogether, as a result alleviating the amount of β -reductions required for each recursive iteration.Both our analysis and simplification are suitable to be integrated into existing compilers for functional programming languages as an additional optimisation phase. With this work we hope to contribute to increasing the efficiency of executing programs written in such languages.In this extended abstract we report on work in progress carried out within the framework of the NWO project Realising Optimal Sharing. Instead of discussing optimal reduction in the λ -calculus, however, here we are concerned with a static analysis of λ letrec -terms which aims at removing β -redexes that are concealed by recursion constructs and cause cyclic migration of arguments during evaluation. We have to stress that our research on this particular topic is still in an early phase.
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
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
Copyright © 2025 scite LLC. All rights reserved.
Made with 💙 for researchers
Part of the Research Solutions Family.