Hostname: page-component-77c89778f8-rkxrd Total loading time: 0 Render date: 2024-07-19T20:51:44.506Z Has data issue: false hasContentIssue false

A call-by-need lambda calculus with locally bottom-avoiding choice: context lemma and correctness of transformations

Published online by Cambridge University Press:  01 June 2008

DAVID SABEL
Affiliation:
Institut für Informatik, Fachbereich Informatik und Mathematik, Johann Wolfgang Goethe-Universität, Postfach 11 19 32, D-60054 Frankfurt, Germany Email: sabel@ki.informatik.uni-frankfurt.de, schauss@ki.informatik.uni-frankfurt.de
MANFRED SCHMIDT-SCHAUSS
Affiliation:
Institut für Informatik, Fachbereich Informatik und Mathematik, Johann Wolfgang Goethe-Universität, Postfach 11 19 32, D-60054 Frankfurt, Germany Email: sabel@ki.informatik.uni-frankfurt.de, schauss@ki.informatik.uni-frankfurt.de

Abstract

We present a higher-order call-by-need lambda calculus enriched with constructors, case expressions, recursive letrec expressions, a seq operator for sequential evaluation and a non-deterministic operator amb that is locally bottom-avoiding. We use a small-step operational semantics in the form of a single-step rewriting system that defines a (non-deterministic) normal-order reduction. This strategy can be made fair by adding resources for book-keeping. As equational theory, we use contextual equivalence (that is, terms are equal if, when plugged into any program context, their termination behaviour is the same), in which we use a combination of may- and must-convergence, which is appropriate for non-deterministic computations. We show that we can drop the fairness condition for equational reasoning, since the valid equations with respect to normal-order reduction are the same as for fair normal-order reduction. We develop a number of proof tools for proving correctness of program transformations. In particular, we prove a context lemma for both may- and must- convergence that restricts the number of contexts that need to be examined for proving contextual equivalence. Combining this with so-called complete sets of commuting and forking diagrams, we show that all the deterministic reduction rules and some additional transformations preserve contextual equivalence. We also prove a standardisation theorem for fair normal-order reduction. The structure of the ordering ≤c is also analysed, and we show that Ω is not a least element and ≤c already implies contextual equivalence with respect to may-convergence.

Type
Paper
Copyright
Copyright © Cambridge University Press 2008

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

References

Ariola, Z., Felleisen, M., Maraist, J., Odersky, M. and Wadler, P. (1995) A call-by-need lambda calculus. In: Proc. POPL '95, 22'nd Annual Symposium on Principles of Programming Languages, San Francisco, California, ACM Press.CrossRefGoogle Scholar
Barendregt, H. (1984) The Lambda Calculus. Its Syntax and Semantics, North-Holland.Google Scholar
Bois, A. R. D., Pointon, R. F., Loidl, H.-W. and Trinder, P. W. (2002) Implementing declarative parallel bottom-avoiding choice. In: SBAC-PAD, IEEE Computer Society 82–92.Google Scholar
Carayol, A., Hirschkoff, D. and Sangiorgi, D. (2005) On the representation of McCarthy's amb in the pi-calculus. Theor. Comput. Sci. 330 (3)439473.CrossRefGoogle Scholar
Fernández, M. and Khalil, L. (2003) Interaction nets with McCarthy's amb: Properties and applications. Nordic J. Comput. 10 (2)134162.Google Scholar
Hallgren, T. and Carlsson, M. (1995) Programming with fudgets. In: Jeuring, J. and Meijer, E. (eds.) Advanced Functional Programming. Springer-Verlag Lecture Notes in Computer Science 925 137–182.CrossRefGoogle Scholar
Henderson, P. (1980) Functional Programming – Application and Implementation, Series in Computer Science, Prentice Hall International.Google Scholar
Henderson, P. (1982) Purely Functional Operating Systems. In: Darlington, J., Henderson, P. and Turner, D. A. (eds.) Functional Programming and its Applications, Cambridge University Press 177192.Google Scholar
Hughes, J. and Moran, A. (1995) Making choices lazily. In: FPCA '95: Proceedings of the seventh international conference on Functional programming languages and computer architecture, ACM Press 108–119.CrossRefGoogle Scholar
Jones, M. P. and Hudak, P. (1993) Implicit and explicit parallel programming in Haskell. Technical Report CT 06520-2158, Department of Computer Science, Yale University.Google Scholar
Kutzner, A. (2000) Ein nichtdeterministischer call-by-need Lambda-Kalkül mit erratic choice: Operationale Semantik, Programmtransformationen und Anwendungen, Dissertation, J. W. Goethe-Universität Frankfurt (in German).Google Scholar
Kutzner, A. and Schmidt-Schauss, M. (1998) A nondeterministic call-by-need lambda calculus. In: International Conference on Functional Programming 1998, ACM Press 324–335.CrossRefGoogle Scholar
Lassen, S. B. (1998) Relational Reasoning about Functions and Nondeterminism, Ph.D. thesis, Department of Computer Science, University of Aarhus. (BRICS Dissertation Series DS-98-2.)Google Scholar
Lassen, S. B. (2006) Normal Form Simulation for McCarthy's Amb. In: Proceedings of the 21st Annual Conference on Mathematical Foundations of Programming Semantics (MFPS XXI). Electronic Notes in Theoretical Computer Science 155 445465.CrossRefGoogle Scholar
Lassen, S. B., Levy, P. B. and Panangaden, P. (2005) Divergence-least semantics of amb is Hoare. Short presentation at the APPSEM II workshop, Frauenchiemsee, Germany. (Available at http://www.cs.bham.ac.uk/~pbl/papers/.)Google Scholar
Lassen, S. B. and Moran, A. (1999) Unique fixed point induction for McCarthy's amb. In: Kutylowski, M., Pacholski, L. and Wierzbicki, T. (eds.) MFCS. Springer-Verlag Lecture Notes in Computer Science 1672 198208.Google Scholar
Machkasova, E. and Turbak, F. A. (2000) A calculus for link-time compilation. In: Smolka, G. (ed.) ESOP. Springer-Verlag Lecture Notes in Computer Science 1782 260274.Google Scholar
Mann, M. (2005a) A Non-Deterministic Call-by-Need Lambda Calculus: Proving Similarity a Precongruence by an Extension of Howe's Method to Sharing, Dissertation, J. W. Goethe-Universität, Frankfurt.Google Scholar
Mann, M. (2005b) Congruence of bisimulation in a non-deterministic call-by-need lambda calculus. Electronic Notes in Theoretical Computer Science 128 (1)81101.CrossRefGoogle Scholar
Mann, M. and Schmidt-Schauss, M. (2006) How to prove similarity a precongruence in non-deterministic call-by-need lambda calculi. Frank Report 22, Institut für Informatik. J. W. Goethe-Universität Frankfurt.Google Scholar
McCarthy, J. (1963) A Basis for a Mathematical Theory of Computation. In: Braffort, P. and Hirschberg, D. (eds.) Computer Programming and Formal Systems, North-Holland3370.CrossRefGoogle Scholar
Moran, A. and Sands, D. (1999) Improvement in a lazy context: an operational theory for call-by-need. In: POPL '99: Proceedings of the 26th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, ACM Press 43–56.CrossRefGoogle Scholar
Moran, A. K. (1998) Call-by-name, Call-by-need, and McCarthy's Amb, Ph.D. thesis, Department of Computing Science, Chalmers University of Technology and University of Gothenburg, Gothenburg, Sweden.Google Scholar
Natarajan, V. and Cleaveland, R. (1995) Divergence and fair testing. In: Fülöp, Z. and Gécseg, F. (eds.) ICALP. Springer-Verlag Lecture Notes in Computer Science 944 648659.Google Scholar
Peyton Jones, S. (ed.) (2003) Haskell 98 language and libraries: the Revised Report, Cambridge University Press. (Website: www.haskell.org.)Google Scholar
Peyton Jones, S. and Marlow, S. (2002) Secrets of the Glasgow Haskell Compiler inliner. J. Funct. Programming 12 (4+5)393434.CrossRefGoogle Scholar
Sabel, D. (2003a) A guide through HasFuse. (Available at http://www.ki.informatik.uni-frankfurt.de/research/diamond/hasfuse/.)Google Scholar
Sabel, D. (2003b) Realising nondeterministic I/O in the Glasgow Haskell Compiler. Frank Report 17, Institut für Informatik, J. W. Goethe-Universität Frankfurt am Main.Google Scholar
Sabel, D. and Schmidt-Schauss, M. (2006) A call-by-need lambda-calculus with locally bottom-avoiding choice: Context lemma and correctness of transformations. Frank Report 24, Institut für Informatik, J. W. Goethe-Universität Frankfurt.Google Scholar
Santos, A. (1995) Compilation by Transformation in Non-Strict Functional Languages, Ph.D. thesis, Glasgow University, Department of Computing Science.Google Scholar
Schmidt-Schauss, M. (2003) FUNDIO: A Lambda-Calculus with a letrec, case, Constructors, and an IO-Interface: Approaching a Theory of unsafePerformIO. Frank Report 16, Institut für Informatik, J. W. Goethe-Universität Frankfurt.Google Scholar
Schmidt-Schauss, M., Schütz, M. and Sabel, D. (2004) On the safety of Nöcker's strictness analysis. Frank Report 19, Institut für Informatik, J. W. Goethe-Universität Frankfurt.Google Scholar
Schmidt-Schauss, M., Schütz, M. and Sabel, D. (2005) A complete proof of the safety of Nöcker's strictness analysis. Frank Report 20, Institut für Informatik. J. W. Goethe-Universität Frankfurt.Google Scholar
Søndergaard, H. and Sestoft, P. (1992) Non-determinism in functional languages. Comput. J. 35 (5)514523.CrossRefGoogle Scholar
Trinder, P. W., Hammond, K., Loidl, H.-W. and Peyton Jones, S. L. (1998) Algorithm + Strategy = Parallelism. J. Funct. Programming 8 (1)2360.CrossRefGoogle Scholar
Wells, J. B., Plump, D. and Kamareddine, F. (2003) Diagrams for meaning preservation. In Nieuwenhuis, R. (ed.) RTA. Springer-Verlag Lecture Notes in Computer Science 270688106.Google Scholar