skip to main content
research-article
Open Access

Sealing pointer-based optimizations behind pure functions

Published:03 August 2020Publication History
Skip Abstract Section

Abstract

Functional programming languages are particularly well-suited for building automated reasoning systems, since (among other reasons) a logical term is well modeled by an inductive type, traversing a term can be implemented generically as a higher-order combinator, and backtracking search is dramatically simplified by persistent datastructures. However, existing pure functional programming languages all suffer a major limitation in these domains: traversing a term requires time proportional to the tree size of the term as opposed to its graph size. This limitation would be particularly devastating when building automation for interactive theorem provers such as Lean and Coq, for which the exponential blowup of term-tree sizes has proved to be both common and difficult to prevent. All that is needed to recover the optimal scaling is the ability to perform simple operations on the memory addresses of terms, and yet allowing these operations to be used freely would clearly violate the basic premise of referential transparency. We show how to use dependent types to seal the necessary pointer-address manipulations behind pure functional interfaces while requiring only a negligible amount of additional trust. We have implemented our approach for the upcoming version (v4) of Lean, and our approach could be adopted by other languages based on dependent type theory as well.

Skip Supplemental Material Section

Supplemental Material

References

  1. Thorsten Altenkirch and Ambrus Kaposi. 2016. Type theory in type theory using quotient inductive types. ACM SIGPLAN Notices 51, 1 ( 2016 ), 18-29.Google ScholarGoogle Scholar
  2. Phil Bagwell. 2001. Ideal hash trees. Technical Report.Google ScholarGoogle Scholar
  3. Maksym Bortin and Christoph Lüth. 2010. Structured Formal Development with Quotient Types in Isabelle/HOL. In Intelligent Computer Mathematics, Serge Autexier, Jacques Calmet, David Delahaye, Patrick D. F. Ion, Laurence Rideau, Renaud Rioboo, and Alan P. Sexton (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 34-48.Google ScholarGoogle Scholar
  4. Ana Bove, Peter Dybjer, and Ulf Norell. 2009. A brief overview of Agda-a functional language with dependent types. In International Conference on Theorem Proving in Higher Order Logics. Springer, 73-78.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Robert S Boyer and Warren A Hunt Jr. 2006. Function memoization and unique object representation for ACL2 functions. In Proceedings of the sixth international workshop on the ACL2 theorem prover and its applications. 81-89.Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Edwin Brady. 2013. Idris, a general-purpose dependently typed programming language: Design and implementation. Journal of functional programming 23, 5 ( 2013 ), 552-593.Google ScholarGoogle ScholarCross RefCross Ref
  7. Thomas Braibant, Jacques-Henri Jourdan, and David Monniaux. 2014. Implementing and reasoning about hash-consed data structures in Coq. Journal of automated reasoning 53, 3 ( 2014 ), 271-304.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Cyril Cohen. 2013. Pragmatic Quotient Types in Coq. In Interactive Theorem Proving-4th International Conference, ITP 2013, Rennes, France, July 22-26, 2013. Proceedings. Springer, 213-228. https://doi.org/10.1007/978-3-642-39634-2_17 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Leonardo de Moura, Soonho Kong, Jeremy Avigad, Floris Van Doorn, and Jakob von Raumer. 2015. The Lean theorem prover (system description). In International Conference on Automated Deduction. Springer, 378-388.Google ScholarGoogle ScholarCross RefCross Ref
  10. Margaret A Ellis and Bjarne Stroustrup. 1990. The annotated C++ reference manual. Addison-Wesley.Google ScholarGoogle Scholar
  11. Phil Freeman. 2015. PureScript.Google ScholarGoogle Scholar
  12. François Garillot. 2011. Generic Proof Tools and Finite Group Theory. Ph.D. Dissertation.Google ScholarGoogle Scholar
  13. Jean Goubault. 1994. Implementing functional languages with fast equality, sets and maps: an exercise in hash consing. Journées Francophones des Langages Applicatifs (JFLA'93) ( 1994 ), 222-238.Google ScholarGoogle Scholar
  14. Rich Hickey. 2008. The Clojure programming language. In Proceedings of the 2008 symposium on Dynamic languages. 1-1.Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Martin Hofmann. 1995. Extensional concepts in intensional type theory. ( 1995 ).Google ScholarGoogle Scholar
  16. Gérard Huet. 1992. The Gallina specification language: A case study. In International Conference on Foundations of Software Technology and Theoretical Computer Science. Springer, 229-240.Google ScholarGoogle ScholarCross RefCross Ref
  17. Simon Peyton Jones. 2003. Haskell 98 language and libraries: the revised report. Cambridge University Press.Google ScholarGoogle Scholar
  18. Simon Peyton Jones, Simon Marlow, and Conal Elliott. 1999. Stretching the storage manager: weak pointers and stable names in Haskell. In Symposium on Implementation and Application of Functional Languages. Springer, 37-58.Google ScholarGoogle Scholar
  19. Matt Kaufmann and J. Strother Moore. 1997. An industrial strength theorem prover for a logic based on Common Lisp. IEEE Transactions on Software Engineering 23, 4 ( 1997 ), 203-213.Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Xavier Leroy, Damien Doligez, Alain Frisch, Jacques Garrigue, Didier Rémy, and Jérôme Vouillon. 2018. The OCaml system release 4.07: Documentation and user's manual. ( 2018 ).Google ScholarGoogle Scholar
  21. The mathlib Community. 2020. The lean mathematical library. In Proceedings of the 9th ACM SIGPLAN International Conference on Certified Programs and Proofs, CPP 2020, New Orleans, LA, USA, January 20-21, 2020, Jasmin Blanchette and Catalin Hritcu (Eds.). ACM, 367-381. https://doi.org/10.1145/3372885.3373824 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. David CJ Matthews. 1985. Poly manual. ACM SIGPLAN Notices 20, 9 ( 1985 ), 52-76.Google ScholarGoogle Scholar
  23. James McGraw, Stephen Skedzielewski, Stephen Allan, D Grit, R Oldehoeft, J Glauert, I Dobes, and P Hohensee. 1983. SISAL: streams and iteration in a single-assignment language. Language reference manual, Version 1. Technical Report. Lawrence Livermore National Lab., CA (USA).Google ScholarGoogle Scholar
  24. Tobias Nipkow, Lawrence C Paulson, and Markus Wenzel. 2002. Isabelle/HOL: a proof assistant for higher-order logic. Vol. 2283. Springer Science & Business Media.Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Aleksey Nogin. 2002. Quotient Types: A Modular Approach. In Proceedings of the 15th International Conference on Theorem Proving in Higher Order Logics, Victor Carreño, César Muñoz, and Sofiène Tashar (Eds.). Springer-Verlag, 263-280. Available at http://nogin.org/papers/quotients.html.Google ScholarGoogle ScholarCross RefCross Ref
  26. Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Sebastian Maneth, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. 2004. An overview of the Scala programming language. Technical Report.Google ScholarGoogle Scholar
  27. Sam Owre, John M Rushby, and Natarajan Shankar. 1992. PVS: A prototype verification system. In International Conference on Automated Deduction. Springer, 748-752.Google ScholarGoogle ScholarCross RefCross Ref
  28. Sven-Bodo Scholz. 1994. Single Assignment C-Functional Programming Using Imperative Style. In In John Glauert (Ed.) : Proceedings of the 6th International Workshop on the Implementation of Functional Languages. University of East Anglia.Google ScholarGoogle Scholar
  29. Daniel Selsam, Sebastian Ullrich, and Leonardo de Moura. 2020. Tabled Typeclass Resolution. arXiv preprint arXiv: 2001. 04301 ( 2020 ).Google ScholarGoogle Scholar
  30. Matthieu Sozeau and Nicolas Oury. 2008. First-class type classes. In International Conference on Theorem Proving in Higher Order Logics. Springer, 278-293.Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Guy Steele. 1990. Common LISP: the language. Elsevier.Google ScholarGoogle Scholar
  32. David Turner. 1986. An overview of Miranda. ACM Sigplan Notices 21, 12 ( 1986 ), 158-166.Google ScholarGoogle Scholar
  33. Sebastian Ullrich and Leonardo de Moura. 2019. Counting Immutable Beans: Reference Counting Optimized for Purely Functional Programming. arXiv preprint arXiv: 1908. 05647 ( 2019 ).Google ScholarGoogle Scholar
  34. The Univalent Foundations Program. 2013. Homotopy Type Theory: Univalent Foundations of Mathematics. https: //homotopytypetheory.org/book, Institute for Advanced Study.Google ScholarGoogle Scholar
  35. Philip Wadler. 1990. Comprehending monads. In Proceedings of the 1990 ACM conference on LISP and functional programming. 61-78.Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Philip Wadler and Stephen Blott. 1989. How to make ad-hoc polymorphism less ad hoc. In Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages. ACM, 60-76.Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Sealing pointer-based optimizations behind pure functions

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image Proceedings of the ACM on Programming Languages
      Proceedings of the ACM on Programming Languages  Volume 4, Issue ICFP
      August 2020
      1070 pages
      EISSN:2475-1421
      DOI:10.1145/3415018
      Issue’s Table of Contents

      Copyright © 2020 Owner/Author

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 3 August 2020
      Published in pacmpl Volume 4, Issue ICFP

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article
    • Article Metrics

      • Downloads (Last 12 months)103
      • Downloads (Last 6 weeks)6

      Other Metrics

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!