Abstract
Bahr and Hutton recently developed a new approach to calculating correct compilers directly from specifications of their correctness. However, the methodology only considers converging behaviour of the source language, which means that the compiler could potentially produce arbitrary, erroneous code for source programs that diverge. In this article, we show how the methodology can naturally be extended to support the calculation of compilers that address both convergent and divergent behaviour simultaneously, without the need for separate reasoning for each aspect. Our approach is based on the use of the partiality monad to make divergence explicit, together with the use of strong bisimilarity to support equational-style calculations, but also generalises to other forms of effect by changing the underlying monad.
- Mads Sig Ager, Dariusz Biernacki, Olivier Danvy, and Jan Midtgaard. 2003. From Interpreter to Compiler and Virtual Machine: A Functional Derivation.. Department of Computer Science, University of Aarhus.
Google Scholar
- Roland Backhouse. 2003. Program Construction: Calculating Implementations from Specifications. John Wiley and Sons.
Google Scholar
Digital Library
- Patrick Bahr. 2015. Calculating Certified Compilers for Non-Deterministic Languages. In Proceedings of the Symposium on Mathematics of Program Construction. https://doi.org/10.1007/978-3-319-19797-5_8
Google Scholar
Cross Ref
- Patrick Bahr and Graham Hutton. 2015. Calculating Correct Compilers. Journal of Functional Programming, 25 (2015), https://doi.org/10.1017/S0956796815000180
Google Scholar
Cross Ref
- Patrick Bahr and Graham Hutton. 2020. Calculating Correct Compilers II: Return of the Register Machines. Journal of Functional Programming, 30 (2020), https://doi.org/10.1017/S0956796820000209
Google Scholar
Cross Ref
- Patrick Bahr and Graham Hutton. 2022. Supplementary Material for “Monadic Compiler Calculation”. https://doi.org/10.5281/zenodo.6794696
Google Scholar
Digital Library
- Lennart Beringer, Gordon Stewart, Robert Dockins, and Andrew W. Appel. 2014. Verified Compilation for Shared-Memory C. In Programming Languages and Systems. https://doi.org/10.1007/978-3-642-54833-8_7
Google Scholar
Digital Library
- Edwin Brady. 2013. Idris, a General-Purpose Dependently Typed Programming Language: Design and Implementation. Journal of Functional Programming, 23, 05 (2013), https://doi.org/10.1017/S095679681300018X
Google Scholar
Cross Ref
- Venanzio Capretta. 2005. General Recursion via Coinductive Types. Logical Methods in Computer Science, 1, 2 (2005), https://doi.org/10.2168/LMCS-1(2:1)2005
Google Scholar
Cross Ref
- Nils Anders Danielsson. 2012. Operational Semantics Using the Partiality Monad. In Proceedings of the International Conference on Functional Programming. https://doi.org/10.1145/2364527.2364546
Google Scholar
Digital Library
- Maulik A. Dave. 2003. Compiler Verification: A Bibliography. Software Engineering Notes, 28, 6 (2003), https://doi.org/10.1145/966221.966235
Google Scholar
Digital Library
- Jeremy Gibbons and Ralf Hinze. 2011. Just Do It: Simple Monadic Equational Reasoning. In Proceedings of the International Conference on Functional Programming. https://doi.org/10.1145/2034773.2034777
Google Scholar
Digital Library
- Benjamin Grégoire and Xavier Leroy. 2002. A Compiled Implementation of Strong Reduction. In Proceedings of the International Conference on Functional Programming. https://doi.org/10.1145/581478.581501
Google Scholar
Digital Library
- John Hughes, Lars Pareto, and Amr Sabry. 1996. Proving the Correctness of Reactive Systems Using Sized Types. In Proceedings of the Symposium on Principles of Programming Languages. https://doi.org/10.1145/237721.240882
Google Scholar
Digital Library
- Chung-kil Hur, Paul He, Yannick Zakowski, and Steve Zdancewic. 2020. An Equational Theory for Weak Bisimulation via Generalized Parameterized Coinduction. In Proceedings of the International Conference on Certified Programs and Proofs. https://doi.org/10.1145/3372885.3373813
Google Scholar
Digital Library
- Graham Hutton and Joel Wright. 2007. What is the Meaning of These Constant Interruptions? Journal of Functional Programming, 17, 6 (2007), https://doi.org/10.1017/S0956796807006363
Google Scholar
Digital Library
- Jeehoon Kang, Yoonseung Kim, Chung-Kil Hur, Derek Dreyer, and Viktor Vafeiadis. 2016. Lightweight Verification of Separate Compilation. In Proceedings of the Symposium Principles of Programming Languages. https://doi.org/10.1145/2837614.2837642
Google Scholar
Digital Library
- Xavier Leroy. 2006. Coinductive Big-Step Operational Semantics. In Proceedings of the European Symposium on Programming Languages and Systems. https://doi.org/10.1007/11693024_5
Google Scholar
Digital Library
- Xavier Leroy. 2006. Formal Certification of a Compiler Back-End or: Programming a Compiler with a Proof Assistant. In Proceedings of the Symposium on Principles of Programming Languages. https://doi.org/10.1145/1111037.1111042
Google Scholar
Digital Library
- Erik Meijer. 1992. Calculating Compilers. Katholieke Universiteit Nijmegen.
Google Scholar
- Rasmus Ejlers Møgelberg and Niccolò Veltri. 2019. Bisimulation As Path Type for Guarded Recursive Types. Proceedings of the ACM on Programming Languages, 3, POPL (2019), https://doi.org/10.1145/3290317
Google Scholar
Digital Library
- Georg Neis, Chung-Kil Hur, Jan-Oliver Kaiser, Craig McLaughlin, Derek Dreyer, and Viktor Vafeiadis. 2015. Pilsner: A Compositionally Verified Compiler for a Higher-Order Imperative Language. In Proceedings of the International Conference on Functional Programming. https://doi.org/10.1145/2784731.2784764
Google Scholar
Digital Library
- David Park. 1981. Concurrency and Automata on Infinite Sequences. In Theoretical Computer Science. https://doi.org/10.1007/BFb0017309
Google Scholar
Cross Ref
- Daniel Patterson and Amal Ahmed. 2019. The Next 700 Compiler Correctness Theorems (Functional Pearl). Proceedings of the ACM on Programming Languages, 3, ICFP (2019), https://doi.org/10.1145/3341689
Google Scholar
Digital Library
- James T. Perconti and Amal Ahmed. 2014. Verifying an Open Compiler Using Multi-Language Semantics. In Proceedings of the European Symposium on Programming Languages and Systems. https://doi.org/10.1007/978-3-642-54833-8_8
Google Scholar
Digital Library
- Mitchell Pickard and Graham Hutton. 2021. Calculating Dependently-Typed Compilers. Proceedings of the ACM on Programming Languages, 5, ICFP (2021), https://doi.org/10.1145/3473587
Google Scholar
Digital Library
- John C Reynolds. 1972. Definitional Interpreters for Higher-Order Programming Languages. In Proceedings of the ACM Annual Conference. ACM. https://doi.org/10.1145/800194.805852
Google Scholar
Digital Library
- Peter Sestoft. 1997. Deriving a Lazy Abstract Machine. Journal of Functional Programming, 7, 03 (1997), https://doi.org/10.1017/S0956796897002712
Google Scholar
Digital Library
- Mike Spivey. 1990. A Functional Theory of Exceptions. Science of Computer Programming, 14, 1 (1990), https://doi.org/10.1016/0167-6423(90)90056-J
Google Scholar
Digital Library
- Gordon Stewart, Lennart Beringer, Santiago Cuellar, and Andrew W. Appel. 2015. Compositional CompCert. In Proceedings of the Symposium on Principles of Programming Languages. https://doi.org/10.1145/2676726.2676985
Google Scholar
Digital Library
- Mitchell Wand. 1982. Deriving Target Code as a Representation of Continuation Semantics. Transactions on Programming Languages and Systems, 4, 3 (1982), https://doi.org/10.1145/357172.357179
Google Scholar
Digital Library
- Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, and Steve Zdancewic. 2019. Interaction Trees: Representing Recursive and Impure Programs in Coq. Proceedings of the ACM on Programming Languages, 4, POPL (2019), https://doi.org/10.1145/3371119
Google Scholar
Digital Library
- Angel Zúñiga and Gemma Bel-Enguix. 2020. Coinductive Natural Semantics for Compiler Verification in Coq. Mathematics, 8, 9 (2020), https://doi.org/10.3390/math8091573
Google Scholar
Cross Ref
Index Terms
Monadic compiler calculation (functional pearl)
Recommendations
Calculating dependently-typed compilers (functional pearl)
Compilers are difficult to write, and difficult to get right. Bahr and Hutton recently developed a new technique for calculating compilers directly from specifications of their correctness, which ensures that the resulting compilers are correct-by-...
Lax extensions of coalgebra functors and their logic
We discuss the use of relation lifting in the theory of set-based coalgebra and coalgebraic logic. On the one hand we prove that the neighborhood functor does not extend to a relation lifting of which the associated notion of bisimilarity coincides with ...
Monadic bounded hoops
The main goal of this paper is to investigate monadic bounded hoops and prove the completeness of the monadic hoop logic. In the paper, we introduce monadic bounded hoops: A variety of bounded hoops equipped with universal and existential quantifiers. ...






Comments