Home

Awesome

Coq Program Verification Template

Docker CI

Template project for program verification in Coq. Uses the Verified Software Toolchain and a classic binary search program in C as an example.

Meta

Building instructions

Installing dependencies

The recommended way to install Coq and other dependencies is via the Coq Platform. To install dependencies manually via opam:

opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq.8.19.2 coq-compcert.3.13.1 coq-vst.2.14

Obtaining the project

git clone https://github.com/coq-community/coq-program-verification-template.git
cd coq-program-verification-template

Option 1: building the project using coq_makefile

With make and the coq_makefile tool bundled with Coq:

make   # or make -j <number-of-cores-on-your-machine> 

Option 2: building the project using Dune

With the Dune build system, version 3.5 or later:

dune build

Compiling the program using CompCert (optional)

ccomp -o bsearch src/binary_search.c

File and directory structure

Core files

General configuration

Make configuration

Dune configuration

Caveats

coq_makefile vs. Dune

coq_makefile and Dune builds are independent. However, for local development, it is recommended to use coq_makefile, since Coq editors may not be able find files compiled by Dune. Due to its build hygiene requirements, Dune will refuse to build when binary (.vo) files are present in theories; run make clean to remove them.

Generating Clight for Coq

The Coq representation of the C program (binary_search.v) is kept in version control due to licensing concerns for CompCert's clightgen tool. If you have a license to use clightgen, you can delete the generated file and have the build system regenerate it. To regenerate the file manually, you need to run:

clightgen -o theories/binary_search.v -normalize src/binary_search.c