CakeML: A Verified Implementation of ML


CakeML is a functional programming language with a proven-correct compiler and runtime system.

CakeML is based on a substantial subset of Standard ML. Its semantics is specified in higher-order logic. The compiler algorithm, also specified in higher-order logic, has been proven to transform CakeML programs to semantically equivalent machine code. The compiler implementation is a CakeML program that has been verified by a bootstrap method that executes the compiler specification on the compiler implementation to create a proven-correct compiler binary. The correctness proofs use validated ISA models for machine code. A verified binary of the CakeML read-eval-print loop is available for x86-64; binaries for ARM, MIPS, and RISC-V are anticipated.

A long-term goal is to make proof assistants into trustworthy and practical program development and implementation platforms. The CakeML compiler verification is an example of proof-assistant-based development; specifically, of proven-correct synthesis of machine code from higher-order logic specifications. The verified compiler is both a standalone tool and a component in the logic-to-binary synthesis toolchain.

CakeML is free software. So far it is the result of about ten person years of work by an international team of six core developers spread across three continents. The beta version of CakeML is undergoing evaluation by a US-based industrial collaborator. More project participants and evaluators are sought.

This website provides further details of the CakeML project, links to papers, courseware, auxiliary tools and suggestions for masters and doctoral level projects.


  • Ramana Kumar received the John C. Reynolds Doctoral Dissertation Award 2017 for his PhD thesis on Self-compilation and Self-verification.

  • There will be CakeML tutorials at PLDI'17 (full-day tutorial) and ICFP'17 (half-day tutorial). These tutorials will let participants try out the tools of the CakeML ecosystem and use them to produce end-to-end verified binaries. The tutorials are a good way to get involved in CakeML.
    CakeML ecosystem

  • We have released some previews of CakeML version 2.

  • There are two open PhD positions related to CakeML at Chalmers University of Technology, Sweden. Application deadline: 25 April 2017

  • ESOP'17 has accepted our paper (preprint) on verified characteristic formulae (CF) for CakeML.

  • CPP'17 has accepted our paper (preprint) on the target-specific aspects of compiling and assembling CakeML to real machine code.

  • Our IFL'15 paper (preprint) about CakeML's type system and inference algorithm has been awarded the Peter Landin prize for best paper.

  • ICFP'16 has accepted our paper (preprint) on the new CakeML compiler, A New Verified Compiler Backend for CakeML. A diagram of the new compiler can be seen on the right.

  • Our ESOP'16 paper (preprint) describes and advocates the use of functional big-step semantics for both reasoning about programming languages and compiler verification.

  • CakeML together with our formalisation of HOL in HOL is being used in research supported by the Future of Life Institute on AI safety, in particular on improving our understanding of reflective reasoning. Our ITP'15 paper on reflection precedes and supports the work on this project.

  • A new representation for pattern matching in HOL, as described in this ITP'15 paper on pattern matching, has been incorporated into the HOL-to-CakeML translator.

  • We gave a guest lecture in the Advanced Topics in Software Verification course at UNSW, about bootstrapping the verified CakeML compiler. (See the slides for Week 10, 2016, or Week 12, 2015.)

  • The beta (see item below) now also supports character literals.

  • A beta version of the verified CakeML implementation (version 1) is available here. To build and run the code: unzip, then make, and ./cake.

    Note that this is a beta version with a few known issues: (1) stack overflow is checked by the OS, leads to a segfault; (2) compiling on Mac OS produces some compiler warnings. If you stumble upon other issues, let us know on

    This is verified software. Why might it have issues? The short answer is that we might not have checked our assumptions thoroughly enough. Is our model of the x86-64 machine accurate enough? Are we interacting with the unverified C code correctly? The assumptions have been tested, but one can never be 100% sure that testing caught all possible issues.

  • A preliminary version of the CakeML Compiler Explorer is available. This web service lets you run the verified compiler and see the results of various stages of compilation.

  • Our ITP'14 paper describes work on formalising the semantics and soundness of higher-order logic, including support for its principles of definition, and producing a verified implementation of the kernel of a theorem prover in CakeML. The paper describes a method for supporting definitions via translation into Stateless HOL.

    We have since developed a direct semantics for all of HOL (supporting both definitions and non-definitional context extensions including new axioms). This version was presented in our ITP'14 talk. It is described in more detail in our subsequent JAR paper.

  • We gave an MPhil course at Cambridge on specifying, implementing, and verifying functional programming languages.

  • Our POPL'14 paper describes CakeML and a verified x86-64 implementation of a read-eval-print loop for CakeML, using the bootstrapped compiler below, a verified translation from bytecode to x86-64, and a mostly-synthesised verified runtime.

  • We have written, verified, and bootstrapped a compiler (including lexing, parsing, type inference, and code generation) from CakeML to CakeML Bytecode. The correctness theorem covers both terminating and diverging programs, and says that the generated code behaves according to the semantics in either case. The compiler is written in HOL; we use the translator, mentioned below, to generate a verified CakeML implementation, and then evaluate the compiler on this implementation (bootstrap) to generate verified bytecode.

  • One of our initial target case studies is to construct a verified CakeML version of the HOL Light theorem prover. For this case study, we extended the translation tool, mentioned below, to be able to translate into stateful CakeML code. Initial results are described in our ITP'13 short paper.

  • We have developed a tool which translates functions from higher-order logic into CakeML. This tool is proof producing: for each translation it proves a theorem which states that the generated CakeML code correctly implements the original HOL function, according to the operational semantics of CakeML. See our ICFP'12 paper, and subsequent JFP paper, for more details.


Current developers:
  • Oskar Abrahamsson,
  • Rob Arthan,
  • Connor Cashman,
  • Gregorio Curello,
  • Mike Gordon,
  • Armaël Guéneau,
  • John Harrison,
  • Rikard Hjort,
  • Jakob Holmgren,
  • Felix Kam,
  • Stephen Kell,
  • Andreas Lööw,
  • Dominic Mulligan,
  • Christian Persson,
  • Christopher Pulte,
  • Adam Sandberg Eriksson,
  • Konrad Slind,
  • Partha Susarla,
  • Trần Tiến Dũng (logo design),
  • Freek Wiedijk,
  • James Wood.


  • This work is partly supported by REMS: Rigorous Engineering of Mainstream Systems, EPSRC Programme Grant EP/K008528/1.
  • This work is partly supported by EPSRC grant EP/N028759/1 on Trustworthy Refactoring.
  • This work is partly supported by the Swedish Foundation for Strategic Research.
  • This work is partly supported by the Swedish Research Council.


The code for this project is hosted on GitHub. We also host pre-built downloads.

Mailing list

For help and announcements, join CakeML Users.


Join the #cakeml IRC channel on freenode (webchat).


We maintain a list of project ideas for students, interns, and other contributors.

Latest compiler

The latest verified CakeML compiler passes through 12 intermediate languages and targets machine code for 5 architectures. The verified CakeML compiler, version 2