Proof-Producing Synthesis of CakeML with I/O and Local State from Monadic HOL Functions

  • Son Ho
  • Oskar Abrahamsson
  • Ramana Kumar
  • Magnus O. Myreen
  • Yong Kiam Tan
  • Michael Norrish
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 10900)


We introduce an automatic method for producing stateful ML programs together with proofs of correctness from monadic functions in HOL. Our mechanism supports references, exceptions, and I/O operations, and can generate functions manipulating local state, which can then be encapsulated for use in a pure context. We apply this approach to several non-trivial examples, including the type inferencer and register allocator of the otherwise pure CakeML compiler, which now benefits from better runtime performance. This development has been carried out in the HOL4 theorem prover.



The second and fourth authors were partly supported by the Swedish Foundation for Strategic Research. The fifth author was supported by an A*STAR National Science Scholarship (PhD), Singapore.


  1. 1.
    Anand, A., Appel, A., Morrisett, G., Paraskevopoulou, Z., Pollack, R., Belanger, O.S., Sozeau, M., Weaver, M.: CertiCoq: a verified compiler for Coq. In: CoqPL (2017)Google Scholar
  2. 2.
    Anand, A., Boulier, S., Tabareau, N., Sozeau, M.: Typed template Coq - certified meta-programming in Coq. In: CoqPL (2018)Google Scholar
  3. 3.
    Blazy, S., Robillard, B., Appel, A.W.: Formal verification of coalescing graph-coloring register allocation. In: Gordon, A.D. (ed.) ESOP 2010. LNCS, vol. 6012, pp. 145–164. Springer, Heidelberg (2010). Scholar
  4. 4.
    Bulwahn, L., Krauss, A., Haftmann, F., Erkök, L., Matthews, J.: Imperative functional programming with Isabelle/HOL. In: Mohamed, O.A., Muñoz, C., Tahar, S. (eds.) TPHOLs 2008. LNCS, vol. 5170, pp. 134–149. Springer, Heidelberg (2008). Scholar
  5. 5.
    Guéneau, A., Myreen, M.O., Kumar, R., Norrish, M.: Verified characteristic formulae for CakeML. In: Yang, H. (ed.) ESOP 2017. LNCS, vol. 10201, pp. 584–610. Springer, Heidelberg (2017). Scholar
  6. 6.
    Hupel, L., Nipkow, T.: A verified compiler from Isabelle/HOL to CakeML. In: Ahmed, A. (ed.) ESOP 2018. LNCS, vol. 10801, pp. 999–1026. Springer, Cham (2018). Scholar
  7. 7.
    Hurd, J.: The OpenTheory standard theory library. In: Bobaru, M., Havelund, K., Holzmann, G.J., Joshi, R. (eds.) NFM 2011. LNCS, vol. 6617, pp. 177–191. Springer, Heidelberg (2011). Scholar
  8. 8.
    Kumar, R., Arthan, R., Myreen, M.O., Owens, S.: Self-formalisation of higher-order logic - semantics, soundness, and a verified implementation. J. Autom. Reason. 56(3), 221–259 (2016)MathSciNetCrossRefGoogle Scholar
  9. 9.
    Kumar, R., Myreen, M.O., Norrish, M., Owens, S.: CakeML: a verified implementation of ML. In: Jagannathan, S., Sewell, P. (eds.) POPL, pp. 179–192 (2014)Google Scholar
  10. 10.
    Lammich, P.: Refinement to imperative/HOL. In: Urban, C., Zhang, X. (eds.) ITP 2015. LNCS, vol. 9236, pp. 253–269. Springer, Cham (2015). Scholar
  11. 11.
    Launchbury, J., Jones, S.L.P.: Lazy functional state threads. In: Sarkar, V., Ryder, B.G., Soffa, M.L. (eds.) PLDI, pp. 24–35 (1994)Google Scholar
  12. 12.
    Mullen, E., Pernsteiner, S., Wilcox, J.R., Tatlock, Z., Grossman, D.: Œuf: minimizing the Coq extraction TCB. In: CPP (2018)Google Scholar
  13. 13.
    Myreen, M.O., Owens, S.: Proof-producing translation of higher-order logic into pure and stateful ML. J. Funct. Program. 24(2–3), 284–315 (2014)MathSciNetCrossRefGoogle Scholar
  14. 14.
    Owens, S., Myreen, M.O., Kumar, R., Tan, Y.K.: Functional big-step semantics. In: Thiemann, P. (ed.) ESOP 2016. LNCS, vol. 9632, pp. 589–615. Springer, Heidelberg (2016). Scholar
  15. 15.
    Reynolds, J.C.: Separation logic: a logic for shared mutable data structures. In: LICS, pp. 55–74 (2002)Google Scholar

Copyright information

© Springer International Publishing AG, part of Springer Nature 2018

Authors and Affiliations

  • Son Ho
    • 1
  • Oskar Abrahamsson
    • 2
  • Ramana Kumar
    • 3
  • Magnus O. Myreen
    • 2
  • Yong Kiam Tan
    • 4
  • Michael Norrish
    • 5
  1. 1.MINES ParisTechPSL Research UniversityParisFrance
  2. 2.Chalmers University of TechnologyGothenburgSweden
  3. 3.Data61, CSIROUNSWSydneyAustralia
  4. 4.Carnegie Mellon UniversityPittsburghUSA
  5. 5.Data61, CSIROANUCanberraAustralia

Personalised recommendations