\(\lambda \) to SKI, Semantically

Declarative Pearl
  • Oleg KiselyovEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10818)


We present a technique for compiling lambda-calculus expressions into SKI combinators. Unlike the well-known bracket abstraction based on (syntactic) term re-writing, our algorithm relies on a specially chosen, compositional semantic model of generally open lambda terms. The meaning of a closed lambda term is the corresponding SKI combination. For simply-typed as well as unityped terms, the meaning derivation mirrors the typing derivation. One may also view the algorithm as an algebra, or a non-standard evaluator for lambda-terms (i.e., denotational semantics).

The algorithm is implemented as a tagless-final compiler for (uni)typed lambda-calculus embedded as a DSL into OCaml. Its type preservation is clear even to OCaml. The correctness of both the algorithm and of its implementation becomes clear.

Our algorithm is easily amenable to optimizations. In particular, its output and the running time can both be made linear in the size (i.e., the number of all constructors) of the input De Bruijn-indexed term.



I thank Yukiyoshi Kameyama for his challenge to write the SK conversion in the tagless-final style, and helpful discussions. I am very grateful to Doaitse Swierstra, Fritz Henglein and Noam Zeilberger for many helpful comments and discussions. Numerous suggestions by anonymous reviewers have greatly helped improve the presentation.


  1. 1.
    Carette, J., Kiselyov, O., Shan, C.C.: Finally tagless, partially evaluated: tagless staged interpreters for simpler typed languages. J. Funct. Program. 19(5), 509–543 (2009)MathSciNetCrossRefGoogle Scholar
  2. 2.
    Curry, H.B., Feys, R.: Combinatory Logic. North-Holland, Amsterdam (1958)zbMATHGoogle Scholar
  3. 3.
    Hughes, R.J.M.: Super combinators: a new implementation method for applicative languages. In: Symposium on LISP and Functional Programming, pp. 1–10. ACM, August 1982Google Scholar
  4. 4.
    Joy, M.S., Rayward-Smith, V.J., Burton, F.W.: Efficient combinator code. Comput. Lang. 10(3/4), 211–224 (1985)CrossRefGoogle Scholar
  5. 5.
    Kiselyov, O.: Typed Tagless Final Interpreters. In: Gibbons, J. (ed.) Generic and Indexed Programming. LNCS, vol. 7470, pp. 130–174. Springer, Heidelberg (2012). Scholar
  6. 6.
    Noshita, K.: Translation of Turner combinators in O(n log n) space. Inf. Process. Lett. 20(2), 71–74 (1985)MathSciNetCrossRefGoogle Scholar
  7. 7.
    Peyton Jones, S.: The Implementation of Functional Programming Languages. Prentice Hall, Upper Saddle River, January 1987.
  8. 8.
    Schönfinkel, M.: Über die Bausteine der mathematischen Logik. Math. Ann. 92(3), 305–316 (1924)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Sinot, F.R.: Director strings revisited: a generic approach to the efficient representation of free variables in higher-order rewriting. J. Log. Comput. 15(2), 201–218 (2005)MathSciNetCrossRefGoogle Scholar
  10. 10.
    Sørensen, M.H., Urzyczyn, P.: Lectures on the Curry-Howard isomorphism. Technical report 98/14 (TOPPS note D-368), DIKU, Copenhagen (1998)Google Scholar
  11. 11.
    Stoye, W.R.: The implementation of functional languages using custom hardware. Ph.D. thesis, Computer Laboratory, University of Cambridge, December 1985.
  12. 12.
    Turner, D.A.: Another algorithm for bracket abstraction. J. Symb. Log. 44(2), 267–270 (1979)MathSciNetCrossRefGoogle Scholar
  13. 13.
    Turner, D.A.: A new implementation technique for applicative languages. Softw.-Pract. Exp. 9, 31–49 (1979)CrossRefGoogle Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  1. 1.Tohoku UniversitySendaiJapan

Personalised recommendations