Abstract
We formalize the call-by-need evaluation of \(\lambda \)-calculus (with no recursive bindings) and prove its correspondence with call-by-name, using the Coq proof assistant.
It has been long argued that there is a gap between the high-level abstraction of non-strict languages—namely, call-by-name evaluation—and their actual call-by-need implementations. Although a number of proofs have been given to bridge this gap, they are not necessarily suitable for stringent, mechanized verification because of the use of a global heap, “graph-based” techniques, or “marked reduction”. Our technical contributions are twofold: (1) we give a simpler proof based on two forms of standardization, adopting de Bruijn indices for representation of (non-recursive) variable bindings along with Ariola and Felleisen’s small-step semantics, and (2) we devise a technique to significantly simplify the formalization by eliminating the notion of evaluation contexts—which have been considered essential for the call-by-need calculus—from the definitions.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
We believe that our approach can be adopted in other proof assistants as well.
- 2.
Strictly speaking, the reduction rules shown here are called standard reduction rules in their paper, as opposed to non-deterministic reduction. Note that the let-binding \(\mathbf {let}~x=M~\mathbf {in}~N\) is non-recursive.
- 3.
Although this argument seems to be a proof by contradiction, our actual Coq proof is constructive, using an induction on the finite reduction sequence of \({\xrightarrow {\mathrm {name}}}\circ {\xrightarrow {\beta }_*}\) from \(M^\pitchfork \) as we shall see in Sect. 5.
- 4.
Another drawback is that evaluation contexts may introduce an arbitrary number of bindings and therefore need to be indexed by that number to coexist with de Bruijn indices, requiring heavy natural number calculations—like the Omega [9] library for Presburger arithmetic—in the mechanized proofs. Our approach will also obviate the need for such calculations.
- 5.
Indeed, we also formalized the original semantics and proved its correspondence to call-by-name. See: https://github.com/fetburner/call-by-need.
- 6.
This definition is adopted from the accessibility predicate Acc in Coq.
References
Abramsky, S.: The lazy lambda calculus. In: Turner, D.A. (ed.) Research Topics in Functional Programming, pp. 65–116. Addison-Wesley Publishing Co., Boston (1990)
Accattoli, B., Barenbaum, P., Mazza, D.: Distilling abstract machines. In: Jeuring, J., Chakravarty, M.M.T. (eds.) Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming, Gothenburg, Sweden, 1–3 September 2014, pp. 363–376. ACM (2014)
Ariola, Z.M., Blom, S.: Cyclic lambda calculi. In: Abadi, M., Ito, T. (eds.) TACS 1997. LNCS, vol. 1281, pp. 77–106. Springer, Heidelberg (1997). https://doi.org/10.1007/BFb0014548
Ariola, Z.M., Felleisen, M.: The call-by-need lambda calculus. J. Funct. Program. 7(3), 265–301 (1997)
Barendregt, H.P.: The Lambda Calculus: Its Syntax and Semantics. Studies in Logic and the Foundations of Mathematics, vol. 103, Revised edn. North-Holland, New York (1984)
Breitner, J.: The adequacy of Launchbury’s natural semantics for lazy evaluation. J. Funct. Program. 28, e1 (2018)
Chang, S., Felleisen, M.: The call-by-need lambda calculus, revisited. In: Seidl, H. (ed.) ESOP 2012. LNCS, vol. 7211, pp. 128–147. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-28869-2_7
Chlipala, A.: Parametric higher-order abstract syntax for mechanized semantics. In: Hook, J., Thiemann, P. (eds.) Proceeding of the 13th ACM SIGPLAN International Conference on Functional Programming, ICFP 2008, Victoria, BC, Canada, 20–28 September 2008, pp. 143–156. ACM (2008)
Crégut, P.: Omega: a solver of quantifier-free problems in Presburger arithmetic. In: The Coq Proof Assistant Reference Manual, Version 8.7.0 (2017)
de Bruijn, N.G.: Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagation. Math. (Proc.) 75(5), 381–392 (1972)
Fairbairn, J., Wray, S.: Tim: a simple, lazy abstract machine to execute supercombinators. In: Kahn, G. (ed.) FPCA 1987. LNCS, vol. 274, pp. 34–45. Springer, Heidelberg (1987). https://doi.org/10.1007/3-540-18317-5_3
Goldfarb, W.D.: The undecidability of the second-order unification problem. Theor. Comput. Sci. 13, 225–230 (1981)
Gordon, A.D.: A mechanisation of name-carrying syntax up to alpha-conversion. In: Joyce, J.J., Seger, C.-J.H. (eds.) HUG 1993. LNCS, vol. 780, pp. 413–425. Springer, Heidelberg (1994). https://doi.org/10.1007/3-540-57826-9_152
Johnsson, T.: Efficient compilation of lazy evaluation. In: Deusen, M.S.V., Graham, S.L. (eds.) Proceedings of the 1984 SIGPLAN Symposium on Compiler Construction, Montreal, Canada, 17–22 June 1984, pp. 58–69. ACM (1984)
Kesner, D.: Reasoning about call-by-need by means of types. In: Jacobs, B., Löding, C. (eds.) FoSSaCS 2016. LNCS, vol. 9634, pp. 424–441. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-662-49630-5_25
Launchbury, J.: A natural semantics for lazy evaluation. In: Deusen, M.S.V., Lang, B. (eds.) Conference Record of the Twentieth Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Charleston, South Carolina, USA, January 1993, pp. 144–154. ACM Press (1993)
Maraist, J., Odersky, M., Wadler, P.: The call-by-need lambda calculus. J. Funct. Program. 8(3), 275–317 (1998)
McBride, C., McKinna, J.: Functional pearl: I am not a number-I am a free variable. In: Nilsson, H. (ed.) Proceedings of the ACM SIGPLAN Workshop on Haskell, Haskell 2004, Snowbird, UT, USA, 22–22 September 2004, pp. 1–9. ACM (2004)
McKinna, J., Pollack, R.: Some lambda calculus and type theory formalized. J. Autom. Reason. 23(3–4), 373–409 (1999)
Ong, C.L.: Fully abstract models of the lazy lambda calculus. In: 29th Annual Symposium on Foundations of Computer Science, White Plains, New York, USA, 24–26 October 1988, pp. 368–376. IEEE Computer Society (1988)
Peyton Jones, S.L.: Implementing lazy functional languages on stock hardware: the spineless tagless G-machine. J. Funct. Program. 2(2), 127–202 (1992)
Pfenning, F., Elliott, C.: Higher-order abstract syntax. In: Wexelblat, R.L. (ed.) Proceedings of the ACM SIGPLAN 1988 Conference on Programming Language Design and Implementation (PLDI), Atlanta, Georgia, USA, 22–24 June 1988, pp. 199–208. ACM (1988)
Schäfer, S., Tebbi, T., Smolka, G.: Autosubst: reasoning with de Bruijn terms and parallel substitutions. In: Urban, C., Zhang, X. (eds.) ITP 2015. LNCS, vol. 9236, pp. 359–374. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-22102-1_24
Sestoft, P.: Deriving a lazy abstract machine. J. Funct. Program. 7(3), 231–264 (1997)
Urban, C.: Nominal techniques in Isabelle/HOL. J. Autom. Reason. 40(4), 327–356 (2008)
Vassena, M., Breitner, J., Russo, A.: Securing concurrent lazy programs against information leakage. In: 30th IEEE Computer Security Foundations Symposium, CSF 2017, Santa Barbara, CA, USA, 21–25 August 2017, pp. 37–52 (2017)
Wadsworth, C.P.: Semantics and pragmatics of the lambda calculus. Ph.D. thesis, Oxford University (1971)
Acknowledgments
We thank the anonymous reviewers for valuable comments and suggestions. This work was partially supported by JSPS KAKENHI Grant Number 15H02681 and 16K12409.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer International Publishing AG, part of Springer Nature
About this paper
Cite this paper
Mizuno, M., Sumii, E. (2018). Formal Verification of the Correspondence Between Call-by-Need and Call-by-Name. In: Gallagher, J., Sulzmann, M. (eds) Functional and Logic Programming. FLOPS 2018. Lecture Notes in Computer Science(), vol 10818. Springer, Cham. https://doi.org/10.1007/978-3-319-90686-7_1
Download citation
DOI: https://doi.org/10.1007/978-3-319-90686-7_1
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-90685-0
Online ISBN: 978-3-319-90686-7
eBook Packages: Computer ScienceComputer Science (R0)