DevelopmentTutorial - rocq-prover/rocq GitHub Wiki
The information below are valid for developing in Rocq 9.1 (2025)
Developing Rocq: A tutorial
Getting Rocq sources
Rocq sources are hosted on GitHub. The recommended way is to get them is:
git clone https://github.com/rocq-prover/rocq
Compiling Rocq sources
Follow the instructions from the file INSTALL of the Rocq archive
Basic developer setup
Before running dune build commands to build .vo files you need to run make dunestrap.
Alternatively you can stick to the make check and make world
targets which will handle dunestrap automatically and never call dune directly yourself.
Directory structure
The Rocq archive contains the following subdirectories:
-
devmiscellaneous tools and information for developers (notably including CI scripts) -
docthe Rocq documentation and User's reference manual sources -
manRocq man pages -
toolssources ofrocq doc,rocq dep,rocq tex,rocq makefile, etc. -
theoriesthe Rocq Corelib library and Ltac2 library -
pluginssources of plugins (extraction, firstorder, ...) -
test-suitethe Rocq test suite
The sources of Rocq reside in the following directories
-
configOCaml files created by the configure script -
clibgeneral purpose data structures -
libutilities, general-purpose data structures, ... -
perfperformance counter code (for CPU instruction counting) -
bootpath bootstrapping (eg finding the corelib), cf system configuration in the refman -
kernelthe Rocq kernel, which implements the type-checker of the Calculus of Inductive Constructions -
libraryglobal names, infrastructure for backtracking, reading/writing vo files, ... -
pretypingunification, compilation of pattern-matching, type inference, coercions -
enginelow-level part of the proof engine -
proofshigh-level part of the proof engine -
tacticsspecific tactics and the tactic language -
interpsyntax interpretation layer: notations, implicit arguments, globalization of names, ... -
gramlibparsing engine (fork of camlp5) -
parsingparsers -
printingprinters -
stmthe state transition machine for asynchronous evaluation -
vernacvernacular commands -
sysinitinitialization (setting up custom GC params, handling command line args, ...) -
toplevelinteractive loop, treatment of options, ... -
topbinmain executables -
idesource of the RocqIDE graphical interface (and coqide-server ie the XML protocol) -
checkersource ofrocqchk -
coqppsource ofrocq preprocess-mlg
.mlg files
The Rocq source contains the usual OCaml .ml and .mli files but it
also contains .mlg files that need to be preprocessed by rocq preprocess-mlg.
See dev/doc/parsing.md for more info.
Main developer targets
A complete compilation is done by make world. It takes about 10 minutes with option -j4 on a 4 core processor.
When developing, you may use partial targets such as:
-
statesbuilds the initial state, this is required to run Rocq. Since the stdlib moved to a separate repo this is not much smaller thanworld, so you may as well buildworldinstead. -
rocqidebuilds RocqIDE. -
check(equivalent todune build @check) typechecks OCaml files. -
refman-htmlandrefman-pdfbuild the refman (both need sphinx, PDF version needs latex, seedev/ci/dockerfor packages installed in CI).
Simple debugging with Drop
After make world, run dune exec -- rocq top-with-drop and type
Drop.. This will drop to the OCaml toplevel. Then type:
#use "include";;
#trace String.uppercase;; (* or any name of a function you'd like to trace *)
go();;
The last go() restarts the Coq parser. You can type any Coq command and observe when it calls the function asked to be traced.