skip to main content
research-article
Open Access
Artifacts Available
Artifacts Evaluated & Reusable

The weak call-by-value λ-calculus is reasonable for both time and space

Published:20 December 2019Publication History
Skip Abstract Section

Abstract

We study the weak call-by-value λ-calculus as a model for computational complexity theory and establish the natural measures for time and space — the number of beta-reduction steps and the size of the largest term in a computation — as reasonable measures with respect to the invariance thesis of Slot and van Emde Boas from 1984. More precisely, we show that, using those measures, Turing machines and the weak call-by-value λ-calculus can simulate each other within a polynomial overhead in time and a constant factor overhead in space for all computations terminating in (encodings of) ”true” or ”false”. The simulation yields that standard complexity classes like P, NP, PSPACE, or EXP can be defined solely in terms of the λ-calculus, but does not cover sublinear time or space.

Note that our measures still have the well-known size explosion property, where the space measure of a computation can be exponentially bigger than its time measure. However, our result implies that this exponential gap disappears once complexity classes are considered instead of concrete computations.

We consider this result a first step towards a solution for the long-standing open problem of whether the natural measures for time and space of the λ-calculus are reasonable. Our proof for the weak call-by-value λ-calculus is the first proof of reasonability (including both time and space) for a functional language based on natural measures and enables the formal verification of complexity-theoretic proofs concerning complexity classes, both on paper and in proof assistants.

The proof idea relies on a hybrid of two simulation strategies of reductions in the weak call-by-value λ-calculus by Turing machines, both of which are insufficient if taken alone. The first strategy is the most naive one in the sense that a reduction sequence is simulated precisely as given by the reduction rules; in particular, all substitutions are executed immediately. This simulation runs within a constant overhead in space, but the overhead in time might be exponential. The second strategy is heap-based and relies on structure sharing, similar to existing compilers of eager functional languages. This strategy only has a polynomial overhead in time, but the space consumption might require an additional factor of logn, which is essentially due to the size of the pointers required for this strategy. Our main contribution is the construction and verification of a space-aware interleaving of the two strategies, which is shown to yield both a constant overhead in space and a polynomial overhead in time.

Skip Supplemental Material Section

Supplemental Material

a27-forster.webm

References

  1. Beniamino Accattoli. 2016. The Complexity of Abstract Machines. In Proceedings Third International Workshop on Rewriting Techniques for Program Transformations and Evaluation, [email protected] 2016, Porto, Portugal, 23rd June 2016. 1–15. Google ScholarGoogle Scholar
  2. Beniamino Accattoli. 2018. (In)Efficiency and Reasonable Cost Models. Electr. Notes Theor. Comput. Sci. 338 (2018), 23–43. Google ScholarGoogle Scholar
  3. Beniamino Accattoli and Claudio Sacerdoti Coen. 2015. On the Relative Usefulness of Fireballs. In 30th Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2015, Kyoto, Japan, July 6-10, 2015. 141–155. Google ScholarGoogle Scholar
  4. Beniamino Accattoli and Ugo Dal Lago. 2012. On the Invariance of the Unitary Cost Model for Head Reduction. In 23rd International Conference on Rewriting Techniques and Applications (RTA’12) , RTA 2012, May 28 - June 2, 2012, Nagoya, Japan. 22–37. Google ScholarGoogle Scholar
  5. Beniamino Accattoli and Ugo Dal Lago. 2016. (Leftmost-Outermost) Beta Reduction is Invariant, Indeed. Logical Methods in Computer Science 12, 1 (2016). Google ScholarGoogle Scholar
  6. Beniamino Accattoli and Giulio Guerrieri. 2017. Implementing Open Call-by-Value. In Fundamentals of Software Engineering - 7th International Conference, FSEN 2017, Tehran, Iran, April 26-28, 2017, Revised Selected Papers. 1–19. Google ScholarGoogle Scholar
  7. Andrea Asperti and Wilmer Ricciotti. 2015. A formalization of multi-tape Turing machines. Theoretical Computer Science 603 (Oct. 2015), 23–42. Google ScholarGoogle Scholar
  8. Andrea Asperti and Luca Roversi. 2002. Intuitionistic Light Affine Logic. ACM Trans. Comput. Log. 3, 1 (2002), 137–175. Google ScholarGoogle Scholar
  9. Guy E. Blelloch and John Greiner. 1995. Parallelism in Sequential Functional Languages. In Proceedings of the seventh international conference on Functional programming languages and computer architecture, FPCA 1995, La Jolla, California, USA, June 25-28, 1995. 226–237. Google ScholarGoogle Scholar
  10. Nicolaas Govert De Bruijn. 1972. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. In Indagationes Mathematicae (Proceedings), Vol. 75. Elsevier, 381–392. Issue 5.Google ScholarGoogle Scholar
  11. Ugo Dal Lago and Beniamino Accattoli. 2017. Encoding Turing Machines into the Deterministic Lambda-Calculus. CoRR abs/1711.10078 (2017). arXiv: 1711.10078 http://arxiv.org/abs/1711.10078Google ScholarGoogle Scholar
  12. Ugo Dal Lago and Simone Martini. 2008. The weak lambda calculus as a reasonable machine. Theor. Comput. Sci. 398, 1-3 (2008), 32–50. Google ScholarGoogle Scholar
  13. Ugo Dal Lago and Ulrich Schöpp. 2010. Functional Programming in Sublinear Space. In Programming Languages and Systems, 19th European Symposium on Programming, ESOP 2010, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2010, Paphos, Cyprus, March 20-28, 2010. Proceedings. 205–225. Google ScholarGoogle Scholar
  14. Nachum Dershowitz and Evgenia Falkovich-Derzhavetz. 2015. The Invariance Thesis. Logical Methods in Computer Science (to appear) (2015). http://www.cs.tau.ac.il/~nachumd/papers/InvarianceThesis.pdfGoogle ScholarGoogle Scholar
  15. Yannick Forster, Fabian Kunze, and Marc Roth. 2017. The strong invariance thesis for a 𝜆-calculus. Workshop on Syntax and Semantics of Low-Level Languages (LOLA) (2017).Google ScholarGoogle Scholar
  16. Yannick Forster, Fabian Kunze, and Maximilian Wuttke. 2019. Verified Programming of Turing Machines in Coq. (2019). https://github.com/uds- psl/tm- verification- framework/Google ScholarGoogle Scholar
  17. Yannick Forster and Gert Smolka. 2017. Weak Call-by-Value Lambda Calculus as a Model of Computation in Coq. In Interactive Theorem Proving - 8th International Conference, ITP 2017, Brasília, Brazil, September 26-29, 2017, Proceedings. 189–206. Google ScholarGoogle Scholar
  18. Marco Gaboardi, Jean-Yves Marion, and Simona Ronchi Della Rocca. 2008. A logical account of PSPACE. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2008, San Francisco, California, USA, January 7-12, 2008. 121–131. Google ScholarGoogle Scholar
  19. Fabian Kunze, Gert Smolka, and Yannick Forster. 2018. Formal Small-Step Verification of a Call-by-Value Lambda Calculus Machine. In Programming Languages and Systems - 16th Asian Symposium, APLAS 2018, Wellington, New Zealand, December 2-6, 2018, Proceedings. 264–283. Google ScholarGoogle Scholar
  20. Julia L. Lawall and Harry G. Mairson. 1996. Optimality and Inefficiency: What Isn’t a Cost Model of the Lambda Calculus?. In Proceedings of the 1996 ACM SIGPLAN International Conference on Functional Programming, ICFP 1996, Philadelphia, Pennsylvania, USA, May 24-26, 1996. 92–101. Google ScholarGoogle Scholar
  21. Michael Norrish. 2011. Mechanised Computability Theory. In Interactive Theorem Proving - Second International Conference, ITP 2011, Berg en Dal, The Netherlands, August 22-25, 2011. Proceedings. 297–311. Google ScholarGoogle Scholar
  22. Gordon D. Plotkin. 1975. Call-by-Name, Call-by-Value and the lambda-Calculus. Theor. Comput. Sci. 1, 2 (1975), 125–159. Google ScholarGoogle Scholar
  23. Patrick M. Sansom and Simon L. Peyton Jones. 1995. Time and Space Profiling for Non-Strict Higher-Order Functional Languages. In Conference Record of POPL’95: 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, San Francisco, California, USA, January 23-25, 1995. 355–366. Google ScholarGoogle Scholar
  24. Ulrich Schöpp. 2006. Space-Efficient Computation by Interaction. In Computer Science Logic, 20th International Workshop, CSL 2006, 15th Annual Conference of the EACSL, Szeged, Hungary, September 25-29, 2006, Proceedings. 606–621. Google ScholarGoogle Scholar
  25. Cees F. Slot and Peter van Emde Boas. 1984. On Tape Versus Core; An Application of Space Efficient Perfect Hash Functions to the Invariance of Space. In Proceedings of the 16th Annual ACM Symposium on Theory of Computing, April 30 - May 2, 1984, Washington, DC, USA. 391–400. Google ScholarGoogle Scholar
  26. Daniel Spoonhower, Guy E. Blelloch, Robert Harper, and Phillip B. Gibbons. 2008. Space profiling for parallel functional programs. J. Funct. Program. 20, 5-6 (2008), 417–461. Google ScholarGoogle Scholar
  27. The Coq Proof Assistant. 2019. http://coq.inria.fr .Google ScholarGoogle Scholar

Index Terms

  1. The weak call-by-value λ-calculus is reasonable for both time and space

      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

      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!