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.
Supplemental Material
Available for Download
Code accompanying the paper "Operational Semantics Using the Partiality Monad" by Nils Anders Danielsson
- 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 Scholar
- Samson Abramsky. The lazy lambda calculus. In Research Topics in Functional Programming. Addison-Wesley, 1990. Google Scholar
Digital Library
- The Agda Team. The Agda Wiki. Available at http://wiki.portal.chalmers.se/agda/, 2012.Google Scholar
- 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 Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- The Coq Development Team. The Coq Proof Assistant, Reference Manual, Version 8.3pl3, 2011.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Digital Library
- Graham Hutton. Programming in Haskell. Cambridge University Press, 2007. Google Scholar
Digital Library
- Xavier Leroy. Formal verification of a realistic compiler. Communications of the ACM, 52: 107--115, 2009. 10.1145/1538788.1538814. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- Eugenio Moggi. Notions of computation and monads. Information and Computation, 93 (1): 55--92, 1991. 10.1016/0890-5401(91)90052-4. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- Ulf Norell. Towards a practical programming language based on dependent type theory. PhD thesis, Chalmers University of Technology and Göteborg University, 2007.Google Scholar
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- Mads Tofte. Type inference for polymorphic references. Information and Computation, 89 (1): 1--34, 1990. 10.1016/0890-5401(90)90018-D. Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Operational semantics using the partiality monad
Recommendations
Operational semantics using the partiality monad
ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programmingThe 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? ...
Parametric higher-order abstract syntax for mechanized semantics
ICFP '08We present parametric higher-order abstract syntax (PHOAS), a new approach to formalizing the syntax of programming languages in computer proof assistants based on type theory. Like higher-order abstract syntax (HOAS), PHOAS uses the meta language's ...
Total parser combinators
ICFP '10A monadic parser combinator library which guarantees termination of parsing, while still allowing many forms of left recursion, is described. The library's interface is similar to those of many other parser combinator libraries, with two important ...







Comments