Compile OCaml to Coq.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
OCaml Remove Ruby dependency Aug 18, 2017
interfaces All tests are valid Aug 3, 2015
smartPrint Spaces cleaning Aug 5, 2015
src Fix the import path of the interfaces Aug 31, 2017
tests No specific extraction for the exceptions anymore Aug 3, 2015
.gitignore Remove Ruby dependency Aug 18, 2017
.travis.yml Add Travis CI Aug 18, 2017
LICENSE Updated license to MIT Nov 18, 2014
Makefile Spaces cleaning Aug 5, 2015
test.rb Fail the tests if some are invalid Aug 18, 2017

Logo CoqOfOCaml

Compile OCaml to Coq.

travis status

Start with the file

let head l =
  match l with
  | [] -> failwith "empty list"
  | x :: _ -> x


ocamlc -bin-annot
coqOfOCaml.native -mode v main.cmt


Require Import OCaml.OCaml.

Local Open Scope Z_scope.
Local Open Scope type_scope.
Import ListNotations.

Definition head {A : Type} (l : list A) : M [ OCaml.Failure ] A :=
  match l with
  | [] => OCaml.Pervasives.failwith "empty list" % string
  | cons x _ => ret x



Add the Coq repository:

opam repo add coq-released

and run:

opam install coq-of-ocaml

With Docker

Run the Dockerfile with:

docker build --tag=coq-of-ocaml .

It will install the dependencies (can take time) and compile CoqOfOCaml. You can run the Docker image:

docker run -ti coq-of-ocaml

and make the tests:

eval `opam config env` # initialize the OPAM environment
make test


This compiler needs a working installation of OCaml and Coq, plus the following packages (can be installed using OPAM):

You have two parts to compile in order:

The Coq library

Go to CoqOfOCaml/ and run:

make install

The compiler

Go to the root folder and run:

make test


CoqOfOCaml compiles the .cmt files (generated by the OCaml compiler using the option -bin-annot) to Coq definitions and print it on the standard output:

coqOfOCaml.native -mode v file.cmt

You can start to experiment with the test files in tests/.


MIT © Guillaume Claret.