skip to main content
research-article

Typed self-interpretation by pattern matching

Published:19 September 2011Publication History
Skip Abstract Section

Abstract

Self-interpreters can be roughly divided into two sorts: self-recognisers that recover the input program from a canonical representation, and self-enactors that execute the input program. Major progress for statically-typed languages was achieved in 2009 by Rendel, Ostermann, and Hofer who presented the first typed self-recogniser that allows representations of different terms to have different types. A key feature of their type system is a type:type rule that renders the kind system of their language inconsistent.

In this paper we present the first statically-typed language that not only allows representations of different terms to have different types, and supports a self-recogniser, but also supports a self-enactor. Our language is a factorisation calculus in the style of Jay and Given-Wilson, a combinatory calculus with a factorisation operator that is powerful enough to support the pattern-matching functions necessary for a self-interpreter. This allows us to avoid a type:type rule. Indeed, the types of System F are sufficient. We have implemented our approach and our experiments support the theory.

Skip Supplemental Material Section

Supplemental Material

_talk10.mp4

References

  1. Harold Abelson, Gerald Jay Sussman, and Julie Sussman. Structure and Interpretation of Computer Programs. MIT Press, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Henk Barendregt. Self-interpretations in lambda calculus. J. Funct. Program, 1(2):229--233, 1991.Google ScholarGoogle ScholarCross RefCross Ref
  3. HP Barendregt. Handbook of Logic in Computer Science (vol. 2): Background: Computational Structures: Abramski,S (ed), chapter Lambda Calculi with Types. Oxford University Press, Inc., New York, NY, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Michel Bel. A recursion theoretic self interpreter for the lambda-calculus. http://www.belxs.com/michel/#selfint.Google ScholarGoogle Scholar
  5. Alessandro Berarducci and Corrado Böhm. A self-interpreter of lambda calculus having a normal form. In CSL, pages 85--99, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Mathieu Boespflug. From self-interpreters to normalization by evaluation. In Olivier Danvy, editor, Proceedings of Workshop on Normalization by Evaluation, 2009.Google ScholarGoogle Scholar
  7. bondi programming language. www-staff.it.uts.edu.au/~cbj/bondi.Google ScholarGoogle Scholar
  8. Reg Braithwaite. The significance of the meta-circular interpreter. http://weblog.raganwald.com/2006/11/significance-of-meta-circular_22.html, November 2006.Google ScholarGoogle Scholar
  9. Jacques Carette, Oleg Kiselyov, and Chung chieh Shan. Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages. Journal of Functional Programming, 19(5):509--543, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Olivier Danvy and Pablo E. Martínez López. Tagging, encoding, and Jones optimality. In Proceedings of ESOP'03, European Symposium on Programming, pages 335--347. Springer-Verlag (LNCS), 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Sir Arthur Conan Doyle. The Sign of the Four. Lippincott's Monthly Magazine, February 1890.Google ScholarGoogle Scholar
  12. Brendan Eich. Narcissus. http://mxr.mozilla.org/mozilla/source/js/narcissus/jsexec.js, 2010.Google ScholarGoogle Scholar
  13. J-Y. Girard, Y. Lafont, and P. Taylor. Proofs and Types. Tracts in Theoretical Computer Science. Cambridge University Press, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Masami Hagiya. Meta-circular interpreter for a strongly typed language. Journal of Symbolic Computation, 8(6):651--680, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. R. Hindley and J. P. Seldin. Introduction to Combinators and Lambda-calculus. Cambridge University Press, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Barry Jay. Pattern Calculus: Computing with Functions and Structures. Springer, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Barry Jay and Thomas Given-Wilson. A combinatory account of internal structure. Journal of Symbolic Logic, 2011. To appear. http://www-staff.it.uts.edu.au/~cbj/Publications/factorisation.pdf.Google ScholarGoogle ScholarCross RefCross Ref
  18. Barry Jay and Delia Kesner. First-class patterns. Journal of Functional Programming, 19(2):191--225, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. C. B. Jay. The pattern calculus. ACM Transactions on Programming Languages and Systems (TOPLAS), 26(6):911--937, November 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S.C. Kleene. Introduction to Methamathematics. van Nostrand, 1952.Google ScholarGoogle Scholar
  21. Stephen C. Kleene. λ-definability and recursiveness. Duke Math. J., pages 340--353, 1936.Google ScholarGoogle ScholarCross RefCross Ref
  22. Konstantin Läufer and Martin Odersky. Self-interpretation and reflection in a statically typed language. In Proceedings of OOPSLA Workshop on Reflection and Metalevel Architectures. ACM, October 1993.Google ScholarGoogle Scholar
  23. Oleg Mazonka and Daniel B. Cristofani. A very short self-interpreter. http://arxiv.org/html/cs/0311032v1, November 2003.Google ScholarGoogle Scholar
  24. J. C. Mitchell. Polymorphic type inference and containment. Information and Computation, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Torben Æ. Mogensen. Efficient self-interpretations in lambda calculus. Journal of Functional Programming, 2(3):345--363, 1992. See also DIKU Report D-128, Sep 2, 1994.Google ScholarGoogle ScholarCross RefCross Ref
  26. Torben Æ. Mogensen. Linear-time self-interpretation of the pure lambda calculus. Higher-Order and Symbolic Computation, 13(3):217--237, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Greg Morrisett, David Walker, Karl Crary, and Neal Glew. From System F to typed assembly language. In Proceedings of POPL'98, 25th Annual SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 85--97, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Matthew Naylor. Evaluating Haskell in Haskell. The Monad.Reader, 10:25--33, 2008.Google ScholarGoogle Scholar
  29. Frank Pfenning and Peter Lee. Metacircularity in the polymorphic λ-calculus. Theoretical Computer Science, 89(1):137--159, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Didier Rémy. Simple, partial type-inference for System F based on type-containment. In Proceedings of the tenth ACM SIGPLAN international conference on Functional programming, ICFP '05, pages 130--143, New York, NY, USA, 2005. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Tillmann Rendel, Klaus Ostermann, and Christian Hofer. Typed self-representation. In Proceedings of PLDI'09, ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 293--303, June 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. John C. Reynolds. Definitional interpreters for higher-order programming languages. In Proceedings of 25th ACM National Conference, pages 717--740. ACM Press, 1972. The paper later appeared in Higher-Order and Symbolic Computation, 11, 363--397 (1998). Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Armin Rigo and Samuele Pedroni. Pypy's approach to virtual machine construction. In OOPSLA Companion, pages 044--953, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Andreas Rossberg. HaMLet. http://www.mpi-sws.org/rossberg/hamlet, 2010.Google ScholarGoogle Scholar
  35. Fangmin Song, Yongsen Xu, and Yuechen Qian. The self-reduction in lambda calculus. Theoretical Computer Science, 235(1):171--181, March 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Walid Taha, Henning Makholm, and John Hughes. Tag elimination and Jones-optimality. In Proceedings of PADO'01, Programs as Data Objects, Second Symposium, pages 257--275, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Terese. Term Rewriting Systems, volume 53 of Tracts in Theoretical Computer Science. Cambridge University Press, 2003.Google ScholarGoogle Scholar
  38. John Tromp. Binary lambda calculus and combinatory logic. In Kolmogorov Complexity and Applications, 2006. A Revised Version is available at http://homepages.cwi.nl/tromp/cl/LC.pdf.Google ScholarGoogle Scholar
  39. J. B. Wells. Typability and type checking in the second-order λ-calculus are equivalent and undecidable. In Proceedings of LICS'94, Ninth Annual IEEE Symposium on Logic in Computer Science, 1994.Google ScholarGoogle ScholarCross RefCross Ref
  40. Wikipedia. Pypy. http://en.wikipedia.org/wiki/PyPy, 2010.Google ScholarGoogle Scholar
  41. Wikipedia. Rubinius. http://en.wikipedia.org/wiki/Rubinius, 2010.Google ScholarGoogle Scholar
  42. Tetsuo Yokoyama and Robert Glück. A reversible programming language and its invertible self-interpreter. In Proceedings of PEPM'07, ACM Symposium on Partial Evaluation and Semantics-Based Program Manipulation, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Typed self-interpretation by pattern matching

              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

              Full Access

              • Published in

                cover image ACM SIGPLAN Notices
                ACM SIGPLAN Notices  Volume 46, Issue 9
                ICFP '11
                September 2011
                456 pages
                ISSN:0362-1340
                EISSN:1558-1160
                DOI:10.1145/2034574
                Issue’s Table of Contents
                • cover image ACM Conferences
                  ICFP '11: Proceedings of the 16th ACM SIGPLAN international conference on Functional programming
                  September 2011
                  470 pages
                  ISBN:9781450308656
                  DOI:10.1145/2034773

                Copyright © 2011 ACM

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 19 September 2011

                Check for updates

                Qualifiers

                • research-article

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader
              About Cookies On This Site

              We use cookies to ensure that we give you the best experience on our website.

              Learn more

              Got it!