Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/2628136.2628148acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Maximal sharing in the Lambda calculus with letrec

Published: 19 August 2014 Publication History

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 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. Then L0 represents a maximally shared term graph, and it has the same unfolding as L.
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 are bisimilar.
For illustration, we also provide a readily usable implementation.

Supplementary Material

ZIP File (icfp38.zip)
"Maximal Sharing in the Lambda Calculus with letrec" for ICFP 2014 by Clemens Grabmayer and Jan Rochel.

References

[1]
A. Asperti and S. Guerrini. The Optimal Implementation of Functional Programming Languages. Cambridge University Press, 1998.
[2]
T. Balabonski. A unified approach to fully lazy sharing. In Proceedings of POPL '12, pages 469--480, New York, NY, USA, 2012. ACM.
[3]
R. S. Bird and R. Patterson. de Bruijn notation as a nested datatype. Journal of Functional Programming, 9(1):77--91, 1999.
[4]
S. Blom. Term Graph Rewriting - Syntax and Semantics. PhD thesis, Vrije Universiteit Amsterdam, 2001.
[5]
M. v. d. Brand and P. Klint. ATERMs for manipulation and exchange of structured data: It's all about sharing. Information and Software Technology, 49(1):55--64, 2007.
[6]
O. Chitil. Common Subexpressions Are Uncommon in Lazy Functional Languages. In Selected Papers from the 9th International Workshop IFL (IFL '97), pages 53--71, London, UK, UK, 1998. Springer-Verlag.
[7]
O. Danvy and U. P. Schultz. Lambda-lifting in quadratic time. Journal of Functional and Logic Programming, 2004, 2004.
[8]
N. G. de Bruijn. Lambda Calculus Notation with Nameless Dummies, a Tool for Automatic Formula Manipulation, with Applic. to the Church-Rosser Theorem. Indagationes Mathematicae, 34:381--392, 1972.
[9]
A. L. de Medeiros Santos. Compilation by Transformation in Non-Strict Functional Languages. PhD thesis, University of Glasgow, 1995.
[10]
B. Goldberg and P. Hudak. Detecting Sharing of Partial Applications in Functional Programs. Technical Report YALEU/DCS/RR-526, Department of Computer Science, Yale University, March 1987.
[11]
C. Grabmayer and J. Rochel. Expressibility in the Lambda Calculus with Letrec. Technical report, arXiv, August 2012. arXiv:1208.2383.
[12]
C. Grabmayer and J. Rochel. Term Graph Representations for Cyclic Lambda Terms. In Proceedings of TERMGRAPH 2013, number 110 in EPTCS, 2013. For an extended report see: arXiv:1308.1034.
[13]
C. Grabmayer and J. Rochel. Expressibility in the Lambda Calculus withμ. In Proceedings of RTA 2013, 2013. Report: arXiv:1304.6284.
[14]
C. Grabmayer and J. Rochel. Confluent Let-Floating. In Proceedings of IWC 2013 (2nd International Workshop on Confluence), 2013.
[15]
C. Grabmayer and J. Rochel. Maximal Sharing in the Lambda Calculus with letrec. Technical report, 2014. arXiv:1401.1460.
[16]
C. Grabmayer and V. van Oostrom. Nested Term Graphs. Technical report, arXiv, May 2014. arXiv:1405.6380.
[17]
D. Hendriks and V. van Oostrom. λ. In F. Baader, editor, Proceedings CADE-19, volume 2741 of LNAI, pages 136--150. Springer, 2003.
[18]
J. Hopcroft. An nlog n Algorithm for Minimizing States in a Finite Automata. Technical report, Stanford University, CA, USA, 1971.
[19]
J. Hopcroft and R. Karp. A Linear Algorithm for Testing Equivalence of Finite Automata. Technical report, Cornell University, 1971.
[20]
R. Hughes. Supercombinators: A new implementation method for applicative languages. In LFP '82: Proceedings of the 1982 ACM symposium on LISP and functional programming, pages 1--10, 1982.
[21]
T. Johnsson. Lambda lifting: Transforming programs to recursive equations. In FPCA, pages 190--203, 1985.
[22]
J. Ketema and J. G. Simonsen. Infinitary Combinatory Reduction Systems. Information and Computation, 209(6):893--926, 2011.
[23]
R. Milner. Communicating and mobile systems: the π-calculus. Cambridge University Press, 1999.
[24]
M. T. Morazán and U. P. Schultz. Optimal lambda lifting in quadratic time. In Workshop IAFL 2007, number 5083 in LNCS. Springer, 2008.
[25]
D. A. Norton. Algorithms for Testing Equivalence of Finite Automata. Master's thesis, Dept. of Computer Science, Rochester Institute of Technology, 2009. https://ritdml.rit.edu/handle/1850/8712.
[26]
V. v. Oostrom, K.-J. van de Looij, and M. Zwitserlood. Lambdascope. Extended Abstract, Workshop ALPS, Kyoto, April 10th 2004, 2004.
[27]
J. Palsberg and M. Schwartzbach. Binding-time analysis: abstract interpretation versus type inference. In Int. Conf. on Computer Languages, 1994, pages 289--298, 1994.
[28]
S. L. Peyton Jones. The Implementation of Functional Programming Languages. Prentice-Hall, Inc., 1987.
[29]
D. Plump. Evaluation of Functional Expressions by Hypergraph Rewriting. PhD thesis, Universität Bremen, 1993.
[30]
Terese. Term Rewriting Systems, volume 55 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 2003.
[31]
C. P. Wadsworth. Semantics and Pragmatics of the Lambda-Calculus. PhD thesis, University of Oxford, 1971.

Cited By

View all
  • (2024)From Compactifying Lambda-Letrec Terms to Recognizing Regular-Expression ProcessesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.408.2408(21-41)Online publication date: 1-Oct-2024
  • (2024)Hashing Modulo Context-Sensitive 𝛼-EquivalenceProceedings of the ACM on Programming Languages10.1145/36564598:PLDI(2027-2050)Online publication date: 20-Jun-2024
  • (2019)Modeling Terms by Graphs with Structure Constraints (Two Illustrations)Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.288.1288(1-13)Online publication date: 6-Feb-2019
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
ICFP '14: Proceedings of the 19th ACM SIGPLAN international conference on Functional programming
August 2014
390 pages
ISBN:9781450328739
DOI:10.1145/2628136
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 19 August 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. higher-order term graphs
  2. lambda calculus with letrec
  3. maximal sharing
  4. subterm sharing
  5. unfolding semantics

Qualifiers

  • Research-article

Funding Sources

Conference

ICFP'14
Sponsor:

Acceptance Rates

ICFP '14 Paper Acceptance Rate 28 of 85 submissions, 33%;
Overall Acceptance Rate 333 of 1,064 submissions, 31%

Upcoming Conference

ICFP '25
ACM SIGPLAN International Conference on Functional Programming
October 12 - 18, 2025
Singapore , Singapore

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)7
  • Downloads (Last 6 weeks)0
Reflects downloads up to 30 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)From Compactifying Lambda-Letrec Terms to Recognizing Regular-Expression ProcessesElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.408.2408(21-41)Online publication date: 1-Oct-2024
  • (2024)Hashing Modulo Context-Sensitive 𝛼-EquivalenceProceedings of the ACM on Programming Languages10.1145/36564598:PLDI(2027-2050)Online publication date: 20-Jun-2024
  • (2019)Modeling Terms by Graphs with Structure Constraints (Two Illustrations)Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.288.1288(1-13)Online publication date: 6-Feb-2019
  • (2019)Sharing Equality is LinearProceedings of the 21st International Symposium on Principles and Practice of Declarative Programming10.1145/3354166.3354174(1-14)Online publication date: 7-Oct-2019
  • (2015)Nested Term Graphs (Work In Progress)Electronic Proceedings in Theoretical Computer Science10.4204/EPTCS.183.4183(48-65)Online publication date: 26-May-2015
  • (2015)On the Relative Usefulness of FireballsProceedings of the 2015 30th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS.2015.23(141-155)Online publication date: 6-Jul-2015
  • (2014)Maximal sharing in the Lambda calculus with letrecACM SIGPLAN Notices10.1145/2692915.262814849:9(67-80)Online publication date: 19-Aug-2014
  • (2021)Structure-Constrained Process Graphs for the Process Semantics of Regular ExpressionsElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.334.3334(29-45)Online publication date: 8-Feb-2021
  • (2020)A Complete Proof System for 1-Free Regular Expressions Modulo BisimilarityProceedings of the 35th Annual ACM/IEEE Symposium on Logic in Computer Science10.1145/3373718.3394744(465-478)Online publication date: 8-Jul-2020
  • (2015)On the Relative Usefulness of FireballsProceedings of the 2015 30th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS)10.1109/LICS.2015.23(141-155)Online publication date: 6-Jul-2015

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media