Higher-Order and Symbolic Computation

, Volume 20, Issue 3, pp 271–293

Improving the lazy Krivine machine

  • Daniel P. Friedman
  • Abdulaziz Ghuloum
  • Jeremy G. Siek
  • Onnie Lynn Winebarger
Article

DOI: 10.1007/s10990-007-9014-0

Cite this article as:
Friedman, D.P., Ghuloum, A., Siek, J.G. et al. Higher-Order Symb Comput (2007) 20: 271. doi:10.1007/s10990-007-9014-0

Abstract

Krivine presents the \(\mathcal {K}\)  machine, which produces weak head normal form results. Sestoft introduces several call-by-need variants of the \({\mathcal {K}}\)  machine that implement result sharing via pushing update markers on the stack in a way similar to the TIM and the STG machine. When a sequence of consecutive markers appears on the stack, all but the first cause redundant updates. Improvements related to these sequences have dealt with either the consumption of the markers or the removal of the markers once they appear. Here we present an improvement that eliminates the production of marker sequences of length greater than one. This improvement results in the \({\mathcal {C}}\)  machine, a more space and time efficient variant of \({\mathcal {K}}\) .

We then apply the classic optimization of short-circuiting operand variable dereferences to create the call-by-need \({\mathcal {S}}\)  machine. Finally, we combine the two improvements in the \({\mathcal {CS}}\)  machine. On our benchmarks this machine uses half the stack space, performs one quarter as many updates, and executes between 27% faster and 17% slower than our ℒ variant of Sestoft’s lazy Krivine machine. More interesting is that on one benchmark ℒ, \({\mathcal {S}}\) , and \({\mathcal {C}}\) consume unbounded space, but \({\mathcal {CS}}\) consumes constant space. Our comparisons to Sestoft’s Mark 2 machine are not exact, however, since we restrict ourselves to unpreprocessed closed lambda terms. Our variant of his machine does no environment trimming, conversion to deBruijn-style variable access, and does not provide basic constants, data type constructors, or the recursive let. (The Y combinator is used instead.)

Keywords

Lambda calculusAbstract machineCall by needLazy evaluation

Copyright information

© Springer Science+Business Media, LLC 2007

Authors and Affiliations

  • Daniel P. Friedman
    • 1
  • Abdulaziz Ghuloum
    • 1
  • Jeremy G. Siek
    • 2
  • Onnie Lynn Winebarger
    • 1
  1. 1.Indiana UniversityBloomingtonUSA
  2. 2.University of Colorado at BoulderBoulderUSA