skip to main content
research-article

Operational semantics using the partiality monad

Published:09 September 2012Publication History
Skip Abstract Section

Abstract

The operational semantics of a partial, functional language is often given as a relation rather than as a function. The latter approach is arguably more natural: if the language is functional, why not take advantage of this when defining the semantics? One can immediately see that a functional semantics is deterministic and, in a constructive setting, computable.

This paper shows how one can use the coinductive partiality monad to define big-step or small-step operational semantics for lambda-calculi and virtual machines as total, computable functions (total definitional interpreters). To demonstrate that the resulting semantics are useful type soundness and compiler correctness results are also proved. The results have been implemented and checked using Agda, a dependently typed programming language and proof assistant.

Skip Supplemental Material Section

Supplemental Material

References

  1. Andreas Abel. MiniAgda: Integrating sized and dependent types. In Proceedings Workshop on Partiality and Recursion in Interactive Theorem Provers (PAR 2010), volume 43 of EPTCS, 2010. 10.4204/EPTCS.43.2.Google ScholarGoogle Scholar
  2. Samson Abramsky. The lazy lambda calculus. In Research Topics in Functional Programming. Addison-Wesley, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. The Agda Team. The Agda Wiki. Available at http://wiki.portal.chalmers.se/agda/, 2012.Google ScholarGoogle Scholar
  4. Thorsten Altenkirch and Nils Anders Danielsson. Termination checking in the presence of nested inductive and coinductive types. Short note supporting a talk given at the Workshop on Partiality and Recursion in Interactive Theorem Provers (PAR 2010), 2010.Google ScholarGoogle Scholar
  5. Brian E. Aydemir, Aaron Bohannon, Matthew Fairbairn, J. Nathan Foster, Benjamin C. Pierce, Peter Sewell, Dimitrios Vytiniotis, Geoffrey Washburn, Stephanie Weirich, and Steve Zdancewic. Mechanized metatheory for the masses: The PoplMark challenge. In Theorem Proving in Higher Order Logics, 18th International Conference, TPHOLs 2005, volume 3603 of LNCS, pages 50--65, 2005. 10.1007/11541868_4. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Nick Benton and Chung-Kil Hur. Biorthogonality, step-indexing and compiler correctness. In ICFP'09, Proceedings of the 2009 ACM SIGPLAN International Conference on Functional Programming, pages 97--107, 2009. 10.1145/1596550.1596567. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Nick Benton, Andrew Kennedy, and Carsten Varming. Some domain theory and denotational semantics in Coq. In Theorem Proving in Higher Order Logics, 22nd International Conference, TPHOLs 2009, volume 5674 of LNCS, pages 115--130, 2009. 10.1007/978-3-642-03359-9_10. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Venanzio Capretta. General recursion via coinductive types. Logical Methods in Computer Science, 1 (2): 1--28, 2005. 10.2168/LMCS-1(2:1)2005.Google ScholarGoogle ScholarCross RefCross Ref
  9. The Coq Development Team. The Coq Proof Assistant, Reference Manual, Version 8.3pl3, 2011.Google ScholarGoogle Scholar
  10. Thierry Coquand. Infinite objects in type theory. In Types for Proofs and Programs, International Workshop TYPES '93, volume 806 of LNCS, pages 62--78, 1994. 10.1007/3-540-58085-9_72. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Patrick Cousot and Radhia Cousot. Inductive definitions, semantics and abstract interpretations. In POPL '92, Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 83--94, 1992. 10.1145/143165.143184. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Patrick Cousot and Radhia Cousot. Bi-inductive structural semantics. Information and Computation, 207 (2): 258--283, 2009. 10.1016/j.ic.2008.03.025. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Nils Anders Danielsson. Beating the productivity checker using embedded languages. In Proceedings Workshop on Partiality and Recursion in Interactive Theorem Provers (PAR 2010), volume 43 of EPTCS, pages 29--48, 2010. 10.4204/EPTCS.43.3.Google ScholarGoogle ScholarCross RefCross Ref
  14. Nils Anders Danielsson and Thorsten Altenkirch. Subtyping, declaratively: An exercise in mixed induction and coinduction. In Mathematics of Program Construction, 10th International Conference, MPC 2010, volume 6120 of LNCS, pages 100--118, 2010. 10.1007/978-3-642-13321-3_8. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Neil Ghani and Tarmo Uustalu. Monad combinators, non-determinism and probabilistic choice. Extended abstract distributed at the workshop on Categorical Methods in Concurrency, Interaction and Mobility (CMCIM 2004), 2004.Google ScholarGoogle Scholar
  16. Sergey Goncharov and Lutz Schröder. A coinductive calculus for asynchronous side-effecting processes. In Fundamentals of Computation Theory, 18th International Symposium, FCT 2011, volume 6914 of LNCS, pages 276--287, 2011. 10.1007/978-3-642-22953-4_24. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Graham Hutton. Programming in Haskell. Cambridge University Press, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Xavier Leroy. Formal verification of a realistic compiler. Communications of the ACM, 52: 107--115, 2009. 10.1145/1538788.1538814. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Xavier Leroy and Hervé Grall. Coinductive big-step operational semantics. Information and Computation, 207 (2): 284--304, 2009. 10.1016/j.ic.2007.12.004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Robin Milner and Mads Tofte. Co-induction in relational semantics. Theoretical Computer Science, 87 (1): 209--220, 1991. 10.1016/0304-3975(91)90033-X. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Eugenio Moggi. An abstract view of programming languages. Technical Report ECS-LFCS-90-113, Lab. for Found. of Comp. Sci., University of Edinburgh, 1990.Google ScholarGoogle Scholar
  22. Eugenio Moggi. Notions of computation and monads. Information and Computation, 93 (1): 55--92, 1991. 10.1016/0890-5401(91)90052-4. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Keiko Nakata and Tarmo Uustalu. Trace-based coinductive operational semantics for While: Big-step and small-step, relational and functional styles. In Theorem Proving in Higher Order Logics, 22nd International Conference, TPHOLs 2009, volume 5674 of LNCS, pages 375--390, 2009. 10.1007/978-3-642-03359-9_26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Keiko Nakata and Tarmo Uustalu. Resumptions, weak bisimilarity and big-step semantics for While with interactive I/O: An exercise in mixed induction-coinduction. In Proceedings Seventh Workshop on Structural Operational Semantics (SOS 2010), volume 32 of EPTCS, pages 57--75, 2010. 10.4204/EPTCS.32.5.Google ScholarGoogle ScholarCross RefCross Ref
  25. Ulf Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology and Göteborg University, 2007.Google ScholarGoogle Scholar
  26. Christine Paulin-Mohring. A constructive denotational semantics for Kahn networks in Coq. In From Semantics to Computer Science: Essays in Honour of Gilles Kahn, pages 383--413. Cambridge University Press, 2009.Google ScholarGoogle ScholarCross RefCross Ref
  27. John C. Reynolds. Definitional interpreters for higher-order programming languages. In ACM '72, Proceedings of the ACM annual conference, volume 2, pages 717--740, 1972. 10.1145/800194.805852. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. J. J. M. M. Rutten. A note on coinduction and weak bisimilarity for while programs. Theoretical Informatics and Applications, 33: 393--400, 1999. 10.1051/ita:1999125.Google ScholarGoogle ScholarCross RefCross Ref
  29. Davide Sangiorgi and Robin Milner. The problem of "weak bisimulation up to". In CONCUR '92, Third International Conference on Concurrency Theory, volume 630 of LNCS, pages 32--46, 1992. 10.1007/BFb0084781. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Mads Tofte. Type inference for polymorphic references. Information and Computation, 89 (1): 1--34, 1990. 10.1016/0890-5401(90)90018-D. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Philip Wadler. The essence of functional programming. In POPL '92, Proceedings of the 19th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 1--14, 1992. 10.1145/143165.143169. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Operational semantics using the partiality monad

                  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 47, Issue 9
                    ICFP '12
                    September 2012
                    368 pages
                    ISSN:0362-1340
                    EISSN:1558-1160
                    DOI:10.1145/2398856
                    Issue’s Table of Contents
                    • cover image ACM Conferences
                      ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programming
                      September 2012
                      392 pages
                      ISBN:9781450310543
                      DOI:10.1145/2364527

                    Copyright © 2012 ACM

                    Publisher

                    Association for Computing Machinery

                    New York, NY, United States

                    Publication History

                    • Published: 9 September 2012

                    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!