rocq-of-ocaml
Transpiler that translates OCaml programs into Rocq code so their properties can be formally verified.
At a Glance
About rocq-of-ocaml
rocq-of-ocaml is an open-source formal verification tool from Formal Land that translates OCaml programs into similar-looking Rocq code. It was developed for the Tezos crypto-currency protocol, and the project documentation says it was funded by the French Government and the Tezos Foundation. The command-line tool is installed through opam and released under the MIT license.
What It Is
rocq-of-ocaml is a transpiler from OCaml to the Rocq proof language, producing a shallow embedding of OCaml in Rocq. The generated code is meant to be idiomatic, human readable, and of a size similar to the OCaml source. Users then write proofs about the generated definitions in Rocq, for example induction proofs over a recursive function.
Workflow
The tool compiles OCaml files one by one, using Merlin to access each file's typing environment, so a compiled project with a working Merlin configuration (automatic with dune) is required. Running rocq-of-ocaml file.ml produces a Rocq .v file. Teams typically translate the critical .ml files and keep the rest as axioms generated from .mli files. When something is not handled, the tool emits an error message and a dummy Rocq term rather than failing outright.
The generated code may not compile on the first try because of unsupported features or name collisions. The documentation lists remedies: adjust the OCaml input, use attributes or configuration, fork the translator, or post-process the output by script or by hand.
Language Support and Limits
The tool supports the purely functional parts of OCaml, including functors, first-class modules, records, inductive types, and multi-file projects. Side effects can be translated when represented by a monad. Side effects outside a monad, such as references, are translated to axioms or ignored, and object-oriented programming is not supported. GADTs, polymorphic variants, and extensible types have only partial support. OCaml integers are represented as unbounded integers, so overflow must be accounted for in proofs. The docs state there are no proofs that the translation preserves semantics, so manual review is needed.
Background
The project began as part of a PhD at Paris 7 and was later financed by Nomadic Labs and the Tezos Foundation. The README says it was used to verify the Tezos protocol, about 100,000 lines of OCaml, in the coq-tezos-of-ocaml project.
Collections
Popular collections
- Code Knowledge Graphs
Collection by @evtuff
- Obsidian Agentic & AI plugins
Collection by @samofcode
- Codebase Context Generators
Collection by @joemseifi
- Frameworks
Collection by @joemseifi
Add rocq-of-ocaml to one of your collections.
Community Discussions
Be the first to start a conversation about rocq-of-ocaml
Share your experience with rocq-of-ocaml, ask questions, or help others learn from your insights.
Pricing
Open Source
rocq-of-ocaml is released under the MIT license and can be installed and used at no cost via opam.
- MIT License (OSI-approved)
- Install via opam: opam install rocq-of-ocaml
- OCaml to Rocq transpiler for formal verification
- Full source code available on GitHub
Capabilities
Key Features
- Translates OCaml to readable Rocq code
- Shallow embedding of OCaml in Rocq
- Supports functors, first-class modules, and module types
- Supports monadic side-effects
- Multi-file projects via Merlin
- Generates axioms from .mli files
- Attributes and configuration to customize translation
- Emits error messages while still generating output
- Partial GADT support
