Functional Big-Step Semantics
When doing an interactive proof about a piece of software, it is important that the underlying programming language’s semantics does not make the proof unnecessarily difficult or unwieldy. Both small-step and big-step semantics are commonly used, and the latter is typically given by an inductively defined relation. In this paper, we consider an alternative: using a recursive function akin to an interpreter for the language. The advantages include a better induction theorem, less duplication, accessibility to ordinary functional programmers, and the ease of doing symbolic simulation in proofs via rewriting. We believe that this style of semantics is well suited for compiler verification, including proofs of divergence preservation. We do not claim the invention of this style of semantics: our contribution here is to clarify its value, and to explain how it supports several language features that might appear to require a relational or small-step approach. We illustrate the technique on a simple imperative language with C-like for-loops and a break statement, and compare it to a variety of other approaches. We also provide ML and lambda-calculus based examples to illustrate its generality.
KeywordsRelational Semantic Recursive Call Label Transition System Interactive Proof Type Soundness
We thank Arthur Charguéraud for advice on Coq and pretty-big-step. The first author was supported by the EPSRC [EP/K040561/1]. The second author was partially supported by the Swedish Research Council. NICTA is funded by the Australian Government through the Department of Communications and the Australian Research Council through the ICT Centre of Excellence Program.
- 4.Poulsen, C.B., Mosses, P.D.: Divergence as state in coinductive big-step semantics (extended abstract). In: 26th Nordic Workshop on Programming Theory, NWPT 2014 (2014). http://www.plancomps.org/nwpt2014/
- 8.Boyer, R., Moore, J.S.: Mechanized formal reasoning about programs and computing machines. In: Automated Reasoning and Its Applications: Essays in Honor of Larry Wos. MIT Press (1996)Google Scholar
- 9.Chambart, P.: High level OCaml optimisations (2013). https://ocaml.org/meetings/ocaml/2013/slides/chambart.pdf
- 11.Danielsson, N.A.: Operational semantics using the partiality monad. In: ACM SIGPLAN International Conference on Functional Programming, ICFP 2012, pp. 127–138 (2012). doi: 10.1145/2364527.2364546
- 13.Ellison, C., Rosu, G.: An executable formal semantics of C with applications. In: Proceedings of the 39th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POpPL 2012, pp. 533–544 (2012). doi: 10.1145/2103656.2103719
- 14.Klein, C., Clements, J., Dimoulas, C., Eastlund, C., Felleisen, M., Flatt, M., McCarthy, J.A., Rafkind, J., Tobin-Hochstadt, S., Findler, R.B.: Run your research: on the effectiveness of lightweight mechanization. In: Proceedings of the 39th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POpPL 2012, pp. 285–296 (2012). doi: 10.1145/2103656.2103691
- 15.Kumar, R., Myreen, M.O., Norrish, M., Owens, S.: CakeML: a verified implementation of ML. In: Proceedings of the 41st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2014, pp. 179–191. ACM Press (2014). doi: 10.1145/2535838.2535841
- 16.Leroy, X.: Formal certification of a compiler back-end or: programming a compiler with a proof assistant. In: Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POpPL 2006, pp. 42–54 (2006). doi: 10.1145/1111037.1111042
- 24.Rompf, T., Amin, N.: From F to DOT: type soundness proofs with definitional interpreters (2015). CoRR abs/1510.05216
- 25.Siek, J.: Big-step, diverging or stuck? (2012). http://siek.blogspot.com/2012/07/big-step-diverging-or-stuck.html
- 26.Siek, J.: Type safety in three easy lemmas (2013). http://siek.blogspot.com/2013/05/type-safety-in-three-easy-lemmas.html