ABSTRACT
In programming languages, a function closure is a function whose body includes possibly free variables and that is accompanied by association with their values. The association of variables with their values is called an environment. If a programming language uses lexical scope and treats functions as first-class objects, then function closures are mandatory. Function closures are provided in Common Lisp, Emacs Lisp, Scheme and other dialects of LISP, as well as in modern scripting languages such as Python, JavaScript and Ruby, and procedural languages such as C++.
In our previous paper, we proposed a mechanism that enables us to extract an environment part from a function closure. However, it brings a situation that environments must be handled as a first-class object, which is a huge extension of the traditional theory to be avoid if possible, since several desirable properties will be lost.
This paper presents a method for replacing the environment of a function closure in the lambda calculus with the environment of another function closure.
By taking this approach rather than extracting the environment from the function closure and using it, it ise to avoid treating the environment directly as a first-class object.
We introduce a new computational system called lambda calculus with environment transplantation to explore the theoretical aspects of this process. Our system is defined by its syntax and reduction rules, and we provide a semantics for it through a transformation to the lambda calculus with records. The soundness of the reduction is demonstrated within this transformation semantics. Additionally, we give a simple type system to our calculus and show its subject reduction system.
- M. Abadi, L. Cardelli, P-.L. Curien, and J.-J. Lévy. 1991. Explicit Substitutions. Journal of Functional Programming 1, 4 (October 1991), 375–416.Google ScholarCross Ref
- Andrej Bauer and Matijab Pretnar. 2015. Programming with algebraic effects and handlers. Journal of Logical and Algebraic Methods in Programming 84, 1 (January 2015), 108–123.Google ScholarCross Ref
- Stroustrup Bjarne. 2013. C++ Programming Languagee, Fourth Edition. Addison-Wesley Professional.Google Scholar
- Pierre-Louis Curien, Thérèse Hardin, and Jean-Jacques Lévy. 1996. Confluence properties of weak and strong calculi of explicit substitutions. Journal of the ACM 43, 2 (March 1996), 362–397.Google ScholarDigital Library
- N. G. de Bruijn. 1972. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae 75, 5 (1972), 381–392.Google ScholarCross Ref
- James Gosling, Bill Joy an Guy L. Steele, Gilad Bracha, and Alex Buckley. 2014. The Java Language Specification, Java SE 8 Edition. Addison-Wesley Professional.Google Scholar
- Hiroki Joko and Shin ya Nishizaki. 2017. First-class Environments in Categorical Combinators. In Thoery and Practice of Computation. 28–43. https://doi.org/10.1142/9789813234079_0003Google ScholarCross Ref
- Gilles Kahn. 1987. Natural Semantics. In STACS 87(Lecture Notes in Computer Science, Vol. 247). Springer-Verlag, Berlin, Heidelberg, 22–39.Google Scholar
- Ryotaro Kasuga and Shin-ya Nishizaki. 2022. Formalizing dynamic-wind in the lambda calculs. In ICSCA 2022: 2022 11th International Conference on Software and Computer Applications. ACM, New York, NY, United States, 90–96. https://doi.org/10.1145/3524304.3524318Google ScholarDigital Library
- Bil Lewis, Dan LaLiberte, and Richard Stallman. 2021. GNU Emacs Lisp Reference Manual For Emacs Version 27.2. https://www.gnu.org/software/emacs/manual/elisp.html.Google Scholar
- Shin-ya Nishizaki. 1995. Simply Typed Lambda Calculus with First-class Environments. Publications of Research Institute for Mathematical Sciences Kyoto University 30, 6 (1995), 1055–1121. https://doi.org/10.2977/prims/1195164948Google ScholarCross Ref
- Shin-ya Nishizaki. 2000. A Polymorphic Environment Calculus and its Type Inference Algorithm. Higher-Order and Symbolic Computation 13 (2000), 239–278.Google ScholarDigital Library
- Shin-ya Nishizaki. 2013. Evaluation Strategy and Translation of Environment Calculus. In Information Computing and Applications. Springer Berlin Heidelberg, 232–242. https://doi.org/10.1007/978-3-642-53932-9_23Google ScholarCross Ref
- Shin-ya Nishizaki and Mizuki Fujii. 2012. Strong reduction for typed lambda calculus with first-class environments. In Lecture Notes in Computer Science, Vol. 7473. Springer-Verlag Berlin Heidelberg, 632–639. https://doi.org/10.1007/978-3-642-34062-8_82Google ScholarDigital Library
- Shin-ya Nishizaki and Ryotaro Kasuga. 2021. Untyped lambda calculus with functionally referable environments. In ICSCA 2021: 2021 10th International Conference on Software and Computer Applications. ACM, New York, NY, United States, 100–104. https://doi.org/10.1145/3457784.3457798Google ScholarDigital Library
- Shin-ya Nishizaki and Yuta Takayanagi. 2022. Extracting Environments from Function Closure. In ICSCA 2022: 2022 11th International Conference on Software and Computer Applications. ACM, New York, NY, United States, 61–68. https://doi.org/10.1145/3524304.3524313Google ScholarDigital Library
- Gordon D. Plotkin. 1981. A Structural Approach to Operational Semantics. Technical Report DAIMI FN-19. Computer Science Department, Aarhus University.Google Scholar
- Gordon D. Plotkin. 2004. The origins of structural operational semantics. The Journal of Logic and Algebraic Programming 60–61 (2004), 3–15.Google Scholar
Index Terms
- Transplanting of Environments between Closures in the lambda calculus
Recommendations
Untyped lambda calculus with functionally referable environments
ICSCA '21: Proceedings of the 2021 10th International Conference on Software and Computer ApplicationsThe environment is the relationship between variables and their bound values during program execution and is a notion in program semantics. A first-class environment is a mechanism that allows the environment to be treated like data, such as integer ...
Extracting Environments from Function Closures
ICSCA '22: Proceedings of the 2022 11th International Conference on Software and Computer ApplicationsIn this paper, we study the mechanism for extracting the environment from a function closure in the framework of the lambda calculus. We propose the lambda calculus with environment extraction, which extends environment calculus. We define the untyped ...
Linear lambda calculus with non-linear first-class continuations
ICSCA '17: Proceedings of the 6th International Conference on Software and Computer ApplicationsThe Curry-Howard isomorphism is the correspondence between propositions and types, proofs and lambda-terms, and proof normalization and evaluation. In Curry-Howard isomorphism, we find a duality between values and continuations in pure functional ...
Comments