CakeML v36712026-11-07
Corresponding HOL commit: trindemossen-2-v10
Changes since release v3479:
Source language and front‑end
The CakeML source language now supports open and let open (#1482).
The CakeML source language now supports variable-length word shifts (#1500).
Operations for reading or writing a single bit of a byte array have also been added to the source language (#1497).
The monadic translator now targets CakeML's byte arrays for arrays of type word8 (#1494).
The monadic translator also has new support for space-efficient bool arrays represented as byte arrays (#1498).
The compiler now supports unsafe strsub (#1538).
New primitives UnsafeIndexArith and UnsafeIndexTest provide smallnum arithmetic and comparisons without runtime bignum checks (#1551). The smallnumness obligations are met by a witness (index a vector, array, byte array or string) or by proving the numbers are smallnums even on 32-bit architectures.
The S-expression representation of the AST was vastly simplified and is not backwards-compatible. It now follows the AST as close as possible. For example, val (a, b) = (~1, 2) is represented as
``
((Dlet NoLocs
(Pcon NONE ((Pvar a) (Pvar b)))
(Con NONE ((Lit (IntLit ~1)) (Lit (IntLit 2))))))
`
The CakeML source language now supports pointer equality (#1561). Note that this makes the source semantics non-deterministic and many top-level theorems have changed shape.
New primitives Aw8ScanEq, Aw8ScanNeq, StrScanEq and StrScanNeq scan a range of a byte array or string for the first position whose element is equal (or not equal) to a given byte or char (#1559). The compiler implements these scans word-at-a-time. The same PR adds primitives CopyVecVec, CopyVecArr, CopyArrVec and CopyArrArr for copying slices between vectors and arrays.
Basis library
The shift and rotate functions <<, >>, ~>> and ror in the Word8 and Word64 modules now take the shift amount as a word of the same size instead of an int, e.g. Word8.<< : Word8.word -> Word8.word -> Word8.word (#1500). Programs that call these functions with an int amount need to be updated.
The modules Ast and AstSexp have been added. These modules provide the CakeML AST and functions to convert an ast to/from S-expression.
List
List.intersperse, which inserts a given element between every consecutive pair of elements in a list, has been added to basis.
Char
isLower, isUpper, isDigit, isAlpha and isAlphaNum have been added to the Char module.
String
String.Fast.compare has been added. Like the other operations in the String.Fast module, it orders strings by length first and only compares contents when the lengths are equal, which is faster.
String.scanEq and String.scanNeq have been added (#1559):
`
String.scanEq: int -> int -> char -> string -> int
String.scanNeq: int -> int -> char -> string -> int
`
String.scanEq start end c s returns the first index i with start <= i < end such that String.sub s i = c, or end if there is no such index (or if end <= start). String.scanNeq is the same but looks for a char different from c. Both raise Subscript if start or end is outside 0 to String.size s.
Map
Map.diff has been added to basis. Map.diff m1 m2 removes from m1 every key that occurs in m2. The inputs can have different value types.
SocketIO
A new module for socket I/O, SocketIO, has been added to basis. SocketIO currently supports Unix domain sockets and Linux raw sockets. Use of the module is demonstrated by two new examples. CF specs and proofs are still TODO, for now.
TextIO
TextIO.output's behavior is now linear in the size of the string (previously quadratic -- oops!). This should allow users to output large strings (as in: much larger than 2kB) without the program hanging (#1425).
TextIO.outputFile has been added to basis. It writes a string to a file, taking care of opening and closing. It comes with a CF spec.
TextIO.openOut now has CF specs: openOutIOFSspec and openOutSTDIOspec.
TextIO.inputAllFrom has been added to basis. It reads all input from stdin (on None) or from a named file (on Some fname), closing the stream afterwards, and returns None if the file cannot be opened.
Word8Array
There are new primitives for reading and updating a bit of a byte array (#1502):
`
Word8Array.subBit: byte_array -> int -> bool
Word8Array.updateBit: byte_array -> int -> bool -> unit
`
The supplied index i is used as follows: i div 8 is the read/updated byte, and, in that byte, bit i mod 8 is read/updated.
There are new primitives for scanning a range of a byte array (#1559):
`
Word8Array.scanEq: int -> int -> Word8.word -> byte_array -> int
Word8Array.scanNeq: int -> int -> Word8.word -> byte_array -> int
`
These behave like String.scanEq and String.scanNeq, but on byte arrays.
Array
There are new primitives for copying slices of arrays and vectors (#1559):
`
Array.copySlice: 'a Array.array -> int -> int -> 'a Array.array -> int -> unit
Array.copyVecSlice: 'a Vector.vector -> int -> int -> 'a Array.array -> int -> unit
Array.subvector: 'a Array.array -> int -> int -> 'a Vector.vector
`
Array.copySlice src srcoff len dst dstoff copies len elements of src, starting at srcoff, into dst at dstoff. Array.copyVecSlice does the same with a vector as the source. Array.subvector arr off len returns a new vector holding len elements of arr starting at off. All three raise Subscript if a slice is out of bounds.
Vector
Vector.subvector: 'a Vector.vector -> int -> int -> 'a Vector.vector has been added (#1559). Vector.subvector vec off len returns the len elements of vec starting at off.
Compiler backend and runtime
The compiler handles dynamic installation of new code in new way (#1486). Building on this, the Eval/Install mechanism has been updated (#1507) so that it does a memcpy instead of a byte-by-byte write, which enabled support for Eval on Arm. The new basisffi.c now has a function called cmlinstall implementing this; the whole C file has also been cleaned up. This is NOT backwards compatible. On the flip side, the REPL now runs on ARM8 + Mac combinations which have W^X permissions.
Smallnums and nullary constructors have improved runtime representation (#1487). This means, e.g., that smallnums can use 63 bits on 64-bit architectures.
The exported assembly marks the stack as non-executable on ELF platforms, so cake and the programs it compiles no longer get an executable stack from the linker (#1517).
The backend now supports IMul and IDiv instructions and uses them in fast paths for signed small-integer arithmetic (#1533). Some further cleanup of the asm ops might be expected in the future.
The global dead code elimination pass has moved from flatLang to source, specifically, flatelim has been replaced by sourcedce (#1508).
A new constant lifting pass has been added as a source-to-source pass to the compiler backend (#1542).
The compiler backend now attaches a bit of metadata to every function (#1535). This is completely internal to the compiler. Debug names for functions now come from metadata rather than a separate mapping (#1539).
Byte-array copying is now implemented efficiently in datatoword` (#1559): after a bytewise prefix up to word alignment, it copies whole words at a time (shifting them into place if the destination is unaligned), then copies the remaining bytes one at a time. Overlapping copies still use the byte-by-byte loops.
Pancake
Queryable feature tags (#1470).
The initial version of the decompiler-into-itree of Pancake---DecompIt (#1492).
Candle
The Candle parser has been moved out of HOL into user code (#1537). One user-facing change is that CakeML itself in EVAL mode now starts with a larger data buf
CakeML v34792026-08-26
Corresponding HOL commit: trindemossen-2-v6
Changes since release v3400:
Source language and front‑end
No changes in source language or front-end since last release.
Basis library
List
List.intersperse,
which inserts a given element between every consecutive pair of elements in a list,
has been added to basis.
Char
isLower, isUpper, isDigit, isAlpha and isAlphaNum have been added to the Char module.
String
String.concatWith has been reimplemented using concat and intersperse,
avoiding potentially quadratic behavior due to left-associative concatenations (#1425).
TextIO
TextIO.output's behavior is now linear in the size of the string
(previously quadratic -- oops!). This should allow users to output large strings
(as in: much larger than 2kB) without the program hanging (#1425).
FFI oracle
The basisffioracle has been redfined to have an extra parameter
meant to model "additional underspecified FFIs". (#1446)
Compiler backend and runtime
Compilation of pattern matching
The exhaustiveness checker for pattern-match rows has been replaced by a much better one:
the new function implements the exhaustiveness case of Maranget's usefulness algorithm
adapted to sibling annotations in place of a typing environment.
BVI
BVI now supports multi-arg calls/returns (with a separate constructor).
A new pass, bvi_tmc, performs tail recursion modulo cons, turning
self-recursive calls under a constructor into tail calls. The compiler
pass is Ry Wiese's MSc thesis work.
Two new compiler flags/configs --tmc=true/false and --tailrec=true/false,
both default to true. They can be used to turn of bvitmc and bvitailrec.
Thunks
The datatoword invariants now allow thunks to be inlined (#1440).
The intention is that the GC will, in the future, inline evalated thunks.
targetSem
targetSem is now more lax about the FFI/clear-cache havocs (#1458)
Pancake
Function return value shape is now part of the semantics of Pancake. (#1466)
Pancake's returns are now directly compiled to multi-valued returns at crep-loop-word. (#1466)
Crep now has multi-leveled Break/Continue. (#1466)
A parser bug related to field accesses has been fixed (#1438).
Exeception syntax has been improved (#1450)
Variable length shifts are now supported (#1460).
Candle
Parser
The parser now supports multi-line string literals.
Soundness
The top-level soundness theorem is now more precise about the FFI (#1446).
Consistency is proved for the actual Candle context (#1445).
Examples
The CakePB example now has a verified CP encoder frontend (#1436).
The distrup checker has minor fixes (#1441).
Proof engineering and tooling
New function for proving whole program correctness theorems
The basisffiLib.wholeprog_thm, which is used to prove semantics
results, has been deleted and a new basisffiLib.provesem_thm is to
be used instead from now on. The old one used to be slow and clunky to
use; the new one runs within a few seconds at each call site.
simp additions
The following simps have been added:
fsFFIProps
``
Theorem getmodefsupdate[simp]:
getmode (fsupdate fs fd' k pos content) fd = getmode fs fd
`
Finite map translation
The translator can now deal nicely with finite maps (#1442)
Miscellaneous
CONCATWITH (misc) and concatWithCONCAT_WITH (mlstring)
have been removed due to being unused.
inferScript.sml now uses the state-exception monad defined in
ml_monadBase instead of a locally defined version of it.
Some files have been refactored to use monadsyntax.tempenablemonad
instead of manual overloads of constants such as monad_bind.
Some files have been refactored to use stexignore_bind instead of
a locally defined version using stexbind`.
CakeML v34002026-06-19
Corresponding HOL commit: HOL-Theorem-Prover/HOL@d456022724bd61e57303339e998313b6580c592d
Changes since release v3304:
Source language and front‑end
patbindings and patsbindings no longer take an accumulator argument (progress on #662).
A first-order version of CakeML's PEG parser now exists (#1407).
Basis library
TextIO.inputAllFrom has been added to the basis library. The CF theorem for TextIO.inputAll has been corrected (#1375, #1366).
Compiler backend and runtime
perf-record --call-graph support (x64-only)
Passing --perf_callgraph=T to the CakeML compiler (x64-only) generates an unverified binary that can be profiled with perf record --call-graph fp.
The in-logic compiler uses the default config in x64_config.
Thus, to profile binaries such as checkers, the Dafny compiler, the Scheme compiler, etc., it is necessary to set perf_calls:=T in the configuration ultimately used by the compiler.
FlatLang
FlatLang has been simplified slightly (#1380).
DataLang
dataLang now supports multi-arg returns (#1416)
dataLang now avoid storing args in the cutsets unnecessarily (#1403)
WordLang
word_cse has been reworked to match more aggresively (#1410)
word_copy pass now additionally correctly propagates store-reg equality (#1385).
WordLang now supports Loop, Break, Continue (#1389).
Pancake
addwithcarry now available
It is now possible to use addwithcarry(left, right, carry_in)
in user code, which is compiled to wordLang's AddCarry.
Syntax example:
fun {1,1} f() {
var a = 1;
var b = 2;
var c = 0;
var {1,1} r = addwithcarry(a, b, c);
r = addwithcarry(a, b, c);
return r;
}
Permitted positions for addwithcarry are declaration RHS and assignment RHS;
standalone, handler-attached, and tail-return calls are not supported.
LoopLang
LoopLang now supports multi-arg returns (#1391) and arbitrary depth Break/Continue (#1395).
LoopLang now compiles to WordLang Loops instead of tail calls, i.e., the old loop_remove pass is removed (#1391).
Garbage collector always disabled
The Pancake compiler now unconditionally compiles with GC set to none; any --gc=... flag passed alongside --pancake is silently ignored. This removes the unused GC runtime that Zhewen Shen's BSc thesis (p. 35) noted was being linked into every Pancake binary.
Candle
By optimizing the kernel Candle, we were able to achieve a 1.88x speedup on make_complex.ml (previously 56m49.502s, now 30m10.587s) (#1415).
A model of Little Theories (Farmer et al., 1992) has been added to Candle (#1405).
Examples
A new example for distributed SAT proof checking (#1384)
The FloVer example -- a Certificate Checker for Roundoff Error Bounds -- has been repaired and added back into the build-sequence (#1297, #1404).
Build infrastructure
examples/compilation/{ag32,x64} now make use of HOL's LOCALPARALLELISMLIMIT instead of CLINE_OPTIONS = -j1, limiting parallelism only in that directory and not others (#1414).
Proof engineering and tooling
mlstring
- str has been renamed to chrtostr, freeing up str to be used for parameter names, for example. (#1307, #1372)
- Added toString overload for chrtostr (#1307, #1372).
- Fused strlit and implode (#491, #1376).
- Incompatibilities
- implode_def has been removed, so any references to it in tactics and automation need to be removed in user files.
- A few proofs may break. In the cakeml repo the required fixes were relatively straightforward.
- Deprecations
- strlit has been added as an inferior overload for backwards compatibility, but may be removed in the future. It is recommended to use implode instead.
- strlittm, mkstrlit, deststrlit and isstrlit are still available but may be removed in the future. It is recommended to use implodetm, mkimplode, destimplode and isimplode instead.
CakeML v33042026-04-25
Corresponding HOL commit: HOL-Theorem-Prover/HOL@77fad203c275899bfee21faf6d2d3a66e749d7e1
Changes since release v3213:
Source language and front‑end
- flatLang op wrapped in a Src ast$op constructor (#1337, issue #1336).
This unifies how source‑level operations are propagated into flatLang;
flat_elimProof and friends are updated.
- OCaml front‑end (#1345, #1360). Desugaring from OCaml to the CakeML AST
is reworked, and the earlier handling of true/false in the OCaml parser
is reverted.
- Verified string comparisons (#1331). Test gains semantics for string
comparisons, and a new MemOp StringCmp is implemented and verified through
the back‑end.
- MOD fixity follow‑up. HOL changed MOD from Infixl 650 to
Infixl 600 (matching *). Explicit parentheses are added across the tree
so that a b MOD c keeps its old meaning a (b MOD c).
Basis library and runtime
- TextIO.inputLine → TextIO.inputLineWith (#1340). The old name is
reused/renamed to better reflect the configurable line‑terminator behaviour;
callers throughout the tree are updated.
- Runtime.customFFI added. New basis entry point with a matching C
helper, giving user programs a sanctioned way to invoke a custom FFI.
Configuration
- incconfig removed (#1335, issue #1081).** The incremental‑compilation
configuration record is retired in favour of the regular configuration.
Compiler backend
- New Loop construct in stackLang (#1355). While is removed and
replaced by a more general Loop together with Break/Continue that can
jump out of (or continue) any enclosing loop. stackalloc, wordto_stack,
stacktolab, and the cv translator are updated, and the new semantics is
proved correct (including removing all earlier cheats).
- Variable‑length shifts (#1341). Support for variable shift amounts is
added in wordLang and all lower compiler phases.
- 32‑bit memory ops refactor (#1339). memload32/memstore32 are
rewritten on top of the existing wordofbytes/get_byte primitives.
- Store read/write peephole optimisation in wordLang is the change that
shipped with v3213 (#1327) and forms the baseline for this range.
Register allocator
- Four IRC register‑allocator bugs fixed (#1338).
- Pancake entry points now save callee‑saved registers (#1332). Missing
RISC‑V, MIPS and ARMv8 callee‑saved register entries are added to the MEP
assembly stubs.
Pancake
- Callee‑saved register fix above (#1332).
- Pancake proofs migrated to the new suspend/Resume/Finalise style and
simplified by inlining theorem goals and removing ind_thm indirection
(#1356).
Candle / theorem prover
- cvif re‑defined in Candle (#1351).**
- mcandidate printer‑API fix (#1344). tempremoveuser_printer calls
are updated for the new HOL mcandidate API.
- Candle and REPL evaluate proofs are ported to
suspend/Resume/Finalise (#1356).
Examples
- Pseudo‑Boolean (PB) checker example refreshed (#1353).
Build infrastructure
- Unverified sexp bootstrap reinstated in the build (#1358). The
unverified sexp bootstrap target is fixed up and added back to the standard
build sequence; a small error in types.txt is corrected on the way.
Proof engineering and tooling
- suspend/Resume/Finalise rollout (#1356). A large clean‑up replaces
ad‑hoc proof bookkeeping in flattoclosProof, bvltobvi, word_cse,
wordtostack, wordProps, the pancake proofs, and the Candle/REPL
evaluate proofs. Every use of get_goal is removed from the codebase.
- No more parsing in library files (#1357, #1348). Library‑level
Definition/Theorem boilerplate is rewritten to use explicit Syntax
constructors instead of HOL term‑parser quotations, with assorted fix‑ups
(correct theories for type operators, missing imports of astSyntax before
astToSexprLib, regenerated READMEs, type‑variable / constant fixes).
- typevars ordering swap. typevars and typevarsin_term now
return their results in the reversed (HOL‑canonical) order in the local
Lib files; downstream code adjusted accordingly.
- SmartOp2thm sped up (#1361).**
- Two datatowordProof proofs sped up.
- HOLSet addition no longer goes via List.rev.
Miscellaneous
- Typo fixes (#1354) and several stray‑character / mismatched‑quote fixes.
CakeML v32132026-02-10
Corresponding HOL commit: HOL-Theorem-Prover/HOL@b725f6e8834462a5b4bb2fb67b35e36f368cb8b6
CakeML v30002025-10-05
Corresponding HOL commit: HOL-Theorem-Prover/HOL@a406a513a9778e7975ada234be5f6efa80cbad88
CakeML for HOL Trindemossen 22025-08-19
Corresponding HOL is the Trindemossen-2 release, i.e., HOL commit
https://github.com/HOL-Theorem-Prover/HOL/commit/bdc6917eeafd45f1067c08b6061c2243c1b1edb0.
CakeML v28822025-07-02
Corresponding HOL commit: HOL-Theorem-Prover/HOL@718b3aaabc70079271693d5540ba16669c2e7ad2
CakeML v28072025-04-23
Corresponding HOL commit: HOL-Theorem-Prover/HOL@48a676cadda70ad7fc2f6c7b17ecd434f84db113
CakeML v27472024-12-13
Corresponding HOL commit: HOL-Theorem-Prover/HOL@81404220103cb7dac8d837073e53e07f92dca26a