skip to main content
10.1145/292540.292547acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article
Free Access

Improvement in a lazy context: an operational theory for call-by-need

Authors Info & Claims
Published:01 January 1999Publication History

ABSTRACT

The standard implementation technique for lazy functional languages is call-by-need, which ensures that an argument to a function in any given call is evaluated at most once. A significant problem with call-by-need is that it is difficult -- even for compiler writers -- to predict the effects of program transformations. The traditional theories for lazy functional languages are based on call-by-name models, and offer no help in determining which transformations do indeed optimize a program.In this article we present an operational theory for call-by-need, based upon an improvement ordering on programs: M is improved by N if in all program-contexts C, when C[M] terminates then C[N] terminates at least as cheaply.We show that this improvement relation satisfies a "context lemma", and supports a rich inequational theory, subsuming the call-by-need lambda calculi of Ariola et al. [AFM+95]. The reduction-based call-by-need calculi are inadequate as a theory of lazy-program transformation since they only permit transformations which speed up programs by at most a constant factor (a claim we substantiate); we go beyond the various reduction-based calculi for call-by-need by providing powerful proof rules for recursion, including syntactic continuity -- the basis of fixed-point-induction style reasoning, and an improvement theorem, suitable for arguing the correctness and safety of recursion-based program transformations.

References

  1. AB97.Z.M. Ariola and S. Blom, Cyclic lambda calculi, Proc. TACS'97, LNCS, vol. 1281, Springer-Verlag, February 1997, pp. 77-106. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. AB98.Z.M. Ariola and S. Blom, Lambda calculi plus letrec, Tech. report, Dept. of Computer Science, University of Oregon, 1998, Extended version of {AB97}; submitted for publication.Google ScholarGoogle Scholar
  3. AF97.Z.M. Ariola and M. Felleisen, The call-byneed lambda calculus, Journal of Functional Programming 7 (1997), no. 3, 265-301. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. AFM+95.Z. Ariola, M. Felleisen, J. Maraist, M. Odersky, and P. Wadler, A call.by.need lambda calculus, Proc. POPL'95, the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, January 1995, pp. 233-246. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. AK97.Z.M. Ariola and J. W. Klop, Lambda calculus with explicit recursion, Information and Computation 139 (1997), no. 2, 154-233. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. AO93.S. Abramsky and C.-H. L. Ong, Full abstraction in the lazy lambda calculus, Information and Computation 105 (1993), 159-267. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. BLR96.Z.-E.-A. Benaissa, P. Lescanne, and K. H. Rose, Modeling sharing and recursion for weak reduction strategies using explicit substitution, Proc. PLILP'96, the 8th International Symposium on Programming Languages, Implementations, Logics, and Programs, LNCS~ vol. 1140, Springer-Verlag, 1996, pp. 393-407. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Cur91.P.-L. Curien, An abstract framework for environment machines, Theoretical Computer Science 82 (1991), no. 2, 389-402. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Fie90.J. Field, On laziness and optimality in lambda interpreters: Tools for specification and analysis, Proc. POPL'90, the 17th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, January 1990, pp. 1-15. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. GP98.A.D. Gordon and A. M. eitts (eds.), Higher Order Operational Techniques in Semantics, Publications of the Newton institute, Cambridge University Press, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Gus98.J. Gustavsson, A type based sharing analysis for update avoidance and optimisation, Proc. ICFP'98, the 3~a ACM SIGPLAN International Conference on Functional Programming, September 1998, pp. 39-50. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. HM95.J. Hughes and A. K. Moran, Making choices lazily, Proc. FPCA'95, ACM Conference on Functional Programming Languages and Computer Architecture, ACM Press, June 1995, pp. 108-119. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Jef93.A. Jeffrey, A fully abstract semantics for concurrent graph reduction, Tech. Report 93:12, School of Cognitive and Computing Sciences, University of Sussex, 1993.Google ScholarGoogle Scholar
  14. Jef94.A. Jeffrey, A fully abstract semantics for concurrent graph reduction, Proc. LICS'94, the 9th IEEE Symposium on Logic in Computer Science, IEEE Computer Society Press, July 1994, pp. 82-91.Google ScholarGoogle ScholarCross RefCross Ref
  15. Jos89.M.B. Josephs, The semantics of lazy functional languages, Theoretical Computer Science 68 (1989), no. 1, 105-111. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Las98.S.B. Lassen, Relational reasoning about func. tions and nondeterminism, Ph.D. thesis, Department of Computer Science, University of Aarhus, May 1998.Google ScholarGoogle Scholar
  17. Lau93.J. Launchbury, A natural semantics for lazy evaluation, Proc. POPL'93, the 20th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, January 1993, pp. 144-154. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Mar91.L. Maranget, Optimal derivations in weak lambda-calculi and in orthogonal term rewriting systems, Proc. POPL'91, the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, January 1991, pp. 255-269. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. MFP91.E. Meijer, M. Fokkinga, and R. Paterson, Functional programming with bananas, lenses, envelopes and barbed wire, Proc. FPCA'91, ACM Conference on Functional Programming Languages and Computer Architecture (J. Hughes, ed.), LNCS, vol. 523, Springer-Verlag, August 1991, pp. 124-144. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Mil77.R. Milner, Fully abstract models of the typed A-calculus, Theoretical Computer Science 4 (1977), 1-22.Google ScholarGoogle ScholarCross RefCross Ref
  21. MOW98.J. Maraist, M. Odersky, and P. Wadler, The call by need lambda calculus, Journal of Functional Programming 8 (1998), no. 3, 275-317. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. MST96.I.A. Mason, S. F. Smith, and C. L. Talcott, From operational semantics to domain theory, Information and Computation 128 (1996), no. 1, 26-47. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Nie96.J. Niehren, Functional computation as concurrent computation, Proc. POPL'96, the 23~ ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, January 1996, pp. 333-343. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Pit97a.A. M. Pitts, Operational semantics for program equivalence, March 1997, Invited talk at MFPS XIII, the 13th Conference on Mathematical Foundations of Programming Semantics, slides available at http://www.cl.cam.ac.uk/users/ap/talks/ mfpsg7.ps.gz.Google ScholarGoogle Scholar
  25. Pit97b.A.M. Pitts, Operationally-based theories of program equivalence, Semantics and Logics of Computation (P. Dybjer and A. M. Pitts, eds.), Publications of the Newton Institute, Cambridge University Press, 1997, pp. 241- 298.Google ScholarGoogle Scholar
  26. PJPS96.S. Peyton Jones, W. Partain, and A. Santos, Let-floating: moving bindings to give .faster programs, Proc. ICFP'96, the 1~L ACM SIGPLAN International Conference on Functional Programming, ACM Press, May 1996, pp. 1-12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. PJS98.S. Peyton Jones and A. Santos, A transformation-based optimiser for Haskell, Science of Computer Programming 32 (1998), no. 1-3, 3-47. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Ros96.K.H. Rose, Operational reduction models for functional programming languages, Ph.D. thesis, DIKU, University of Copenhagen, Denmark, February 1996, available as DIKU report 96/1.Google ScholarGoogle Scholar
  29. San91.D. Sands, Operational theories of improvement in functional languages (extended abstract), Proc. 1991 Glasgow Functional Programming Workshop, Workshops in Computing Series, Springer-Verlag, August 1991, pp. 298-311. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. San95.D. Sands, A halve time analysis and its theory of cost equivalence, Journal of Logic and Computation 5 (1995), no. 4, 495-541.Google ScholarGoogle ScholarCross RefCross Ref
  31. San96.D. Sands, Total correctness by local improvement in the transformation o/functional program, ACM Transactions on Programming Languages and Systems (TOPLAS) 18 (1996), no. 2, 175-234. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. San97.D. Sands, From SOS rules to proof principles: An operational metatheory for .functional languages, Proc. POPL'97, the 24~h ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, ACM Press, January 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. San98.D. Sands, Improvement theory and its applications, In Gordon and Pitts {GP98}, pp. 275- 306. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Ses97.P. Sestoft, Deriving a lazy abstract machine, Journal of Functional Programming 7 (1997), no. 3, 231-264. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Smi91.S.F. Smith, From operational to denorational semantics, Proc. MFPS VII, the 7~u Conference on Mathematical Foundations of Programming Semantics (S. Brookes, M. Main, A. Melton, M. Mislove, and D. Schmidt, eds.), LNCS, vol. 598, Springer- Verlag, March 1991, pp. 54-76. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. SPI96.J. Seaman and S. Purushothaman Iyer, An operational semantics of sharing in lazy eval' nation, Science of Computer Programming 27 (1996), no. 3, 289-322. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. SPJ97.P. Sansom and S. Peyton Jones, Formallybased profiling }or higher-order functional languages, ACM Transactions on Programming Languages and Systems (TOPLAS) 19 (1997), no. 1, 334-385. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. TH98.M. Tullsen and P. Hudak, An intermediate meta-language /or program transformation, YALEU/DCS/RR 1154, Yale University, June 1998.Google ScholarGoogle Scholar
  39. TWM95.D. N. Turner, P. Wadler, and C. Mossin, Once upon a type, Proc. FPCA'95, ACM Conference on Functional Programming Languages and Computer Architecture, ACM Press, June 1995, pp. 1-11. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. Wad88.P. Wadler, The concatenate vanishes, Tech. report, University of Glasgow (UK), 1988, appeared as a note on an FP electronic mailing list, December 1987.Google ScholarGoogle Scholar
  41. Wad90.P. Wadler, Deforestation: Transforming programs to eliminate trees, Theoretical Computer Science 73 (1990), 231-248. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Yos93.N. Yoshida, Optimal reduction in weaklambda-calculus with shared environments, Proc. FPCA'93, ACM Conference on Functional Programming Languages and Computer Architecture, ACM Press, June 1993, pp. 243-254. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Improvement in a lazy context: an operational theory for call-by-need

        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
        • Published in

          cover image ACM Conferences
          POPL '99: Proceedings of the 26th ACM SIGPLAN-SIGACT symposium on Principles of programming languages
          January 1999
          324 pages
          ISBN:1581130953
          DOI:10.1145/292540

          Copyright © 1999 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 1 January 1999

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • Article

          Acceptance Rates

          POPL '99 Paper Acceptance Rate24of136submissions,18%Overall Acceptance Rate824of4,130submissions,20%

          Upcoming Conference

          POPL '25

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader