Git Product home page Git Product logo

coq-of-ocaml's Introduction

Logo CoqOfOCaml

Compile OCaml to Coq.

Start with the file main.ml:

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

Run:

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

Get:

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
  end.

Install

With OPAM

Add the Coq repository:

opam repo add coq-released https://coq.inria.fr/opam/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

Manually

This compiler needs a working installation of OCaml 4.02 and Coq 8.4, 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:

./configure.sh
make
make install

The compiler

Go to the root folder and run:

make
make test

Usage

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/.

License

MIT © Guillaume Claret.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.