Verified Software Toolchain (VST) refers to a modular ecosystem for developing certified software programs.
First, install CompCert.
Then, install VST in a sibling directory. Instructions are found here.
The programs have been tested with Coq 8.11.1, CompCert 3.7, and VST 2.6.
- At the base level is CompCert C, the program language, which is a subset of C in which programs can be written. CompCert is the certified compiler that correctly compiles down CompCert C code into assembly with respect to the source language's operational semantics. The compiler transforms the CompCert C code into a series of intermediate representations, first by removing side effects from expressions (C light) and then allocating variables to the stack (C minor), etc.
- Core Verifiable C is a separation logic whose soundness has been proved with respect to CompCert C's operational semantics.
- Verifiable C is a separation logic derived from Core Verifiable C that supports proof automation.
- Floyd is a proof automation system/library that is used to reason with the properties of Verifiable C programs.
This reference manual outlines the steps to produce a correctness proof of a C program using VST. In summary, the steps are:
- Translate the C program into abstract syntax trees (ASTs) of the Clight intermediate language using
clightgen
. - Use Floyd to declare the functional model and API specifications for each function in the program.
- Use Floyd to prove that each function body satisfies $$its specification declared in the previous step.
Clightgen
is CompCert's front-end tool that produces a C-light abstract syntax data structure (a .v
file), given a C program (a .c
file). This consists of two steps: a parser from source to CompCert C (unverified); and a translator from CompCert C to abstract syntax trees of C light (verified).
Example:
<PATH_TO_COMPCERT>/clightgen -normalize /path/to/file.c
The functional model is a purely mathematical model consisting of definitions and lemmas. It should be independent of the C program.
The API specification is a series of funspec
s where each one corresponds to a function in the C program.
The proof proceeds by forward execution.
To verify the C programs in this directory, do the following.
- Copy the file
_CoqProject-export
from the root of yourVST
installation to this directory and rename it to_CoqProject
. - Use
clightgen
from the root of yourCompCert
installation to generate the.v
file which contains the AST. - Compile the
.v
file into a.vo
file usingcoqc
. When doing so, pass the-R
and-Q
arguments contained in_CoqProject
. (e.g.,coqc $(cat _CoqProject) swap.v
) - The files prefixed with
verif_
are the verification scripts. Open it with Proof General. It should recognized the compiled AST from step 3 as a module when youRequire Import
it.