This artifact contains an implementation of the Trocq parametricity framework as a plugin for the Coq proof assistant. As such, we offer several possibilities for the reader, according to their level of familiarity with the ecosystem and interest in our work for their own use. All methods were tested on Linux and macOS, we therefore recommend that the reader use one of these operating systems.
Open codespaces and click "Create codespace".
In this set-up, the reader considers this code mainly as the artifact for our paper, and thus wants to check it is working properly. To that end, we propose to interact in an easy way with a Docker container containing our code. The main requirement for the reader is to have Docker and VSCode installed on their machine. The VSCode current user must have permission to run Docker. You also need to ensure you have more than 6GB of disk space available.
The container with all the dependencies is accessible on Dockerhub as cohencyril/trocq-deps
and the corresponding Dockerfile
is in .devcontainer/Dockerfile in this repo. You could run it manually using docker run -it cohencyril/trocq-deps
but you would not be able to run VSCode in the docker terminal, hence the setup described below.
Here are the instructions:
- Make sure your VSCode has the Dev
Containers
extension by running
code --install-extension ms-vscode-remote.remote-containers
or from the menus. - Clone or download the repository of the Trocq
plugin, e.g.
curl -L -O https://github.com/coq-community/trocq/archive/master.zip && unzip master.zip
- Run VSCode in it (e.g.
code trocq-master
, orcode trocq-ESOP2024
if you are browsing the companion artifact to the paper) and immediately after opening it will suggest to "Reopen in Container", click this (otherwise type F1 and "Reopen in Container"). - Wait for VSCode to download a 1.28 GB archive that extracts to about 6 GB, on our system this takes about 2 min.
- Wait for VSCode to compile the code of the plugin, this takes about 30s.
The last line of the terminal output should be
before you can actually skip to the next section.
make[1]: Leaving directory '/workspaces/trocq'
- First install nix https://nixos.org/download
- Add the cachix repository
coq-community
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use coq-community
- Clone the current repository and type
nix-shell
git clone https://github.com/coq-community/trocq.git
nix-shell
- You may also use
nix-build
to build it and reuse it as a nix package.
- Install opam and configure the coq opam repository
- Install the custom version of
coq-elpi
opam pin add coq-elpi https://github.com/ecranceMERCE/coq-elpi/archive/refs/heads/strat.tar.gz
- Build Trocq
git clone https://github.com/coq-community/trocq.git
cd trocq
opam install . --deps-only # to install dependencies
make # or make -j <number-of-cores-on-your-machine>
- You can also run
make install
to install Trocq on your system.
After completing the Getting the right setup phase above, the examples
folder can be unfolded and the files can be inspected by clicking on them.
When a file is clicked, it is displayed and a Goals
tab opens. It shows the
state of step-by-step execution of the file by Coq. The main actions related to
the Trocq plugin are the Trocq Use
commands feeding the database of the
plugin, and the trocq
tactic actually performing the expected proof transfer
step.
One can check that this tactic is working as expected by clicking right before
it in the Coq file, waiting for Coq to execute the file until the pointer and
update the proof state in the Goals
panel, then clicking right after the dot
after trocq
and waiting for the proof state to be updated with the associated
goal generated by Trocq to replace the initial one. The process should be almost
instantaneous on all the examples. Please note that on the first time a line is
clicked in a file, the proof state can take a few seconds to update.
If you have unexpected errors press "Ctrl-Shift-P" to get the command palette
and type Coq LSP: Restart the Coq Language Server
and enter to reload the
Coq
In file artifact_paper_example.v
, this amounts to putting the pointer on line
38 column 7 (counter visible on the bottom right-hand side of the editor), then
on line 38 column 14 and checking the updated goal is the expected one (in this
particular case, featuring nat
in the associated goal instead of N
in the
initial goal).