skip to main content
research-article

A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions

Published:07 January 2008Publication History
Skip Abstract Section

Abstract

Higher-order abstract syntax (HOAS) is a simple, powerful technique for implementing object languages, since it directly supports common and tricky routines dealing with variables, such as capture-avoiding substitution and renaming. This is achieved by representing binders in the object-language via binders in the meta-language. However, enriching functional programming languages with direct support for HOAS has been a major challenge, because recursion over HOAS encodings requires one to traverse lambda-abstractions and necessitates programming with open objects.

We present a novel type-theoretic foundation based on contextual modal types which allows us to recursively analyze open terms via higher-order pattern matching. By design, variables occurring in open terms can never escape their scope. Using several examples, we demonstrate that our framework provides a name-safe foundation to operations typically found in nominal systems. In contrast to nominal systems however, we also support capture-avoiding substitution operations and even provide first-class substitutions to the programmer. The main contribution of this paper is a syntax-directed bi-directional type system where we distinguish between the data language and the computation language together with the progress and preservation proof for our language.

References

  1. Martin Abadi, Luca Cardelli, Pierre-Louis Curien, and Jean-Jacques Levy. Explicit substitutions. In Conference Record of the Seventeenth Annual ACM Symposium on Principles of Programming Languages, San Francisco, California, pages 31--46. ACM, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Joelle Despeyroux, Frank Pfenning, and Carsten Schürmann. Primitive recursion for higher--order abstract syntax. In R. Hindley, editor, Proceedings of the Third International Conference on Typed Lambda Calculus and Applications (TLCA'97), pages 147--163, Nancy, France, Lecture Notes in Computer Science (LNCS) 1210, Springer-Verlag, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Murdoch Gabbay and Andrew Pitts. A new approach to abstract syntax involving binders. In G. Longo, editor, Proceedings of the 14th Annual Symposium on Logic in Computer Science (LICS'99), pages 214--224, Trento, Italy, IEEE Computer Society Press, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Louis-Julien Guillemette and Stefan Monnier. Statically verified type--preserving code transformations in Haskell. In Programming Languages meets Program Verification (PLPV), Seattle, USA, Electronic Notes in Theoretical Computer Science (ENTCS), Elsevier, 2006.Google ScholarGoogle Scholar
  5. Robert Harper, Furio Honsell, and Gordon Plotkin. A framework for defining logics. Journal of the Association for Computing Machinery, 40(1): 143--184, January 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Masatomo Hashimoto and Atsushi Ohori. A typed context calculus. Theoretical Computer Science, 266(1--2): 249--272, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Ik-Soon Kim, Kwangkeun Yi, and Cristiano Calcagno. A polymorphic modal type system for Lisp-like multi-staged languages. In 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages(POPL '06), pages 257--268, New York, NY, USA, ACM Press, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Ian A. Mason. Computing with contexts. Higher-Order and Symbolic Computation, 12(2): 171--201, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Andrew McCreight and Carsten Schürmann. A meta-linear logical framework. In Carsten Sch"urmann, editor, 4th International Workshop on Logical Frameworks and Meta-Languages (LFM'04), 2004.Google ScholarGoogle Scholar
  10. Dale Miller. Unification of simply typed lambda-terms as logic programming. In Eighth International Logic Programming Conference, pages 255--269, Paris, France, MIT Press, 1991.Google ScholarGoogle Scholar
  11. Dale Miller. An extension to ML to handle bound variables in data structures. In G. Huet and G. Plotkin, editors, Proceedings of the First Workshop on Logical Frameworks, pages 323--335, 1990.Google ScholarGoogle Scholar
  12. Aleksandar Nanevski, Frank Pfenning, and Brigitte Pientka. A contextual modal type theory. ACM Transactions on Computational Logic (accepted, to appear in 2008), page 56 pages, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Shin-Ya Nishizaki. A polymorphic environment calculus and its type--inference algorithm. Higher Order Symbol. Comput., 13 (3): 239--278, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Frank Pfenning and Carsten Schürmann. System description: Twelf -- a meta-logical framework for deductive systems. In H. Ganzinger, editor, Proceedings of the 16th International Conference on Automated Deduction (CADE-16), pages 202--206, Trento, Italy, Lecture Notes in Artificial Intelligence (LNAI) 1632, Springer-Verlag, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Brigitte Pientka. Tabled higher-order logic programming. PhD thesis, Department of Computer Sciences, Carnegie Mellon University, 2003. CMU-CS-03-185. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Brigitte Pientka and Frank Pfennning. Optimizing higher-order pattern unification. In F. Baader, editor, 19th International Conference on Automated Deduction, pages 473--487, Miami, USA, Lecture Notes in Artificial Intelligence (LNAI) 2741, Springer-Verlag, 2003.Google ScholarGoogle Scholar
  17. Adam Poswolsky and Carsten Schürmann. Programming with higher-order encodings and dependent types. Technical Report YALEU/DCS/TR1375, Department of Computer Science,Yale University, July 2007.Google ScholarGoogle Scholar
  18. Francois Pottier. Static name control for FreshML. In Twenty-Second Annual IEEE Symposium on Logic in Computer Science (LICS'07), pages 356--365, Wroclaw, Poland, IEEE Computer Society, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Masahiko Sato, Takafumi Sakurai, and Rod Burstall. Explicit environments. Fundamenta Informaticae, 45 (1--2): 79--115, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Masahiko Sato, Takafumi Sakurai, and Yukiyoshi Kameyama. A simply typed context calculus with first-class environments. Journal of Functional and Logic Programming, 2002 (4), March 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Carsten Schürmann. Automating the meta theory of deductive systems. PhD thesis, Department of Computer Sciences, Carnegie Mellon University, Available as Technical Report CMU-CS-00-146, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Carsten Schürmann and Frank Pfenning. A coverage checking algorithm for LF. In D. Basin and B. Wolff, editors, Proceedings of the 16th International Conference on Theorem Proving in Higher Order Logics (TPHOLs 2003), pages 120--135, Rome, Italy, Lecture Notes in Computer Science(LNCS) 2758, Springer-Verlag, 2003.Google ScholarGoogle Scholar
  23. Carsten Schürmann, Adam Poswolsky, and Jeffrey Sarnat. The nabla-calculus. functional programming with higher-order encodings. In Pawel Urzyczyn, editor, Proceedings of the 7th International Conference on Typed Lambda Calculi and Application (TLCA'05), pages 339--353, Nara, Japan, Lecture Notes in Computer Science (LNCS) 3461, Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Mark R. Shinwell, Andrew M. Pitts, and Murdoch J. Gabbay. FreshML: programming with binders made simple. In Eighth ACM SIGPLAN International Conference on Functional Programming (ICFP'03), pages 263--274, New York, NY, USA, 2003. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Geoff Washburn and Stephanie Weirich. Boxes go bananas: Encoding higher-order abstract syntax with parametric polymorphism. Journal of Functional Programming, 2007 (to appear). Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Kevin Watkins, Iliano Cervesato, Frank Pfenning, and David Walker. A concurrent logical framework I: Judgments and properties. Technical Report CMU-CS-02-101, Department of Computer Science, Carnegie Mellon University, 2002.Google ScholarGoogle Scholar

Index Terms

  1. A type-theoretic foundation for programming with higher-order abstract syntax and first-class substitutions

      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 43, Issue 1
        POPL '08
        January 2008
        420 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/1328897
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '08: Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
          January 2008
          448 pages
          ISBN:9781595936899
          DOI:10.1145/1328438

        Copyright © 2008 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 7 January 2008

        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!