All Projects → coq-community → coqffi

coq-community / coqffi

Licence: MIT license
Coq to OCaml FFI made easy [maintainer=@lthms]

Programming Languages

ocaml
1615 projects
Coq
218 projects
shell
77523 projects

Projects that are alternatives of or similar to coqffi

Quickchick
Randomized Property-Based Testing Plugin for Coq
Stars: ✭ 188 (+596.3%)
Mutual labels:  coq
WasmCert-Coq
A mechanisation of Wasm in Coq
Stars: ✭ 68 (+151.85%)
Mutual labels:  coq
rust-ffi-examples
FFI examples written in Rust
Stars: ✭ 42 (+55.56%)
Mutual labels:  ffi-bindings
Coqgym
A Learning Environment for Theorem Proving with the Coq proof assistant
Stars: ✭ 201 (+644.44%)
Mutual labels:  coq
corn
Coq Repository at Nijmegen [maintainers=@spitters,@VincentSe]
Stars: ✭ 106 (+292.59%)
Mutual labels:  coq
cuda
Haskell FFI bindings to CUDA
Stars: ✭ 73 (+170.37%)
Mutual labels:  ffi-bindings
Coq Chick Blog
🐣 A blog engine written and proven in Coq
Stars: ✭ 173 (+540.74%)
Mutual labels:  coq
coq-ecosystem
No description or website provided.
Stars: ✭ 39 (+44.44%)
Mutual labels:  coq
goose
Goose converts a small subset of Go to Coq
Stars: ✭ 73 (+170.37%)
Mutual labels:  coq
coq-elpi
Coq plugin embedding elpi
Stars: ✭ 92 (+240.74%)
Mutual labels:  coq
Fscq
FSCQ is a certified file system written and proven in Coq
Stars: ✭ 208 (+670.37%)
Mutual labels:  coq
Vellvm
The Vellvm (Verified LLVM) coq development.
Stars: ✭ 243 (+800%)
Mutual labels:  coq
coq-to-ocaml-to-js
Proof of concept to generate safe and fast JavaScript
Stars: ✭ 25 (-7.41%)
Mutual labels:  coq
Metacoq
Metaprogramming in Coq
Stars: ✭ 192 (+611.11%)
Mutual labels:  coq
toychain
A minimalistic blockchain consensus implemented and verified in Coq
Stars: ✭ 103 (+281.48%)
Mutual labels:  coq
Jscert
A Coq specification of ECMAScript 5 (JavaScript) with verified reference interpreter
Stars: ✭ 186 (+588.89%)
Mutual labels:  coq
iris-simp-lang
We define a simple programming language, simp_lang, then instantiate Iris to verify simple simp_lang programs with concurrent separation logic.
Stars: ✭ 40 (+48.15%)
Mutual labels:  coq
stablesort
Stable sort algorithms and their stability proofs in Coq
Stars: ✭ 19 (-29.63%)
Mutual labels:  coq
CoqCheatSheet
Reference sheet for the Coq language.
Stars: ✭ 15 (-44.44%)
Mutual labels:  coq
coq-100-theorems
Statements of famous theorems proven in Coq [maintainer=@jmadiot]
Stars: ✭ 41 (+51.85%)
Mutual labels:  coq

coqffi

Docker CI Contributing Code of Conduct Zulip

coqffi generates the necessary Coq boilerplate to use OCaml functions in a Coq development, and configures the Coq extraction mechanism accordingly.

Meta

  • Author(s):
    • Thomas Letan
    • Li-yao Xia
    • Yann Régis-Gianas
    • Yannick Zakowski
  • Coq-community maintainer(s):
  • License: MIT License
  • Compatible Coq versions: 8.12 or later
  • Compatible OCaml versions: 4.08 or later
  • Additional dependencies:
  • Coq namespace: CoqFFI
  • Related publication(s): none

Building and installation instructions

Make sure your OPAM installation points to the official Coq repository as documented here, and then, the following should work:

git clone https://github.com/coq-community/coqffi.git
cd coqffi
opam install .

Alternatively, you can install coqffi’s dependencies (as listed in the Meta section of the README), then build it.

git clone https://github.com/coq-community/coqffi.git
cd coqffi
./src-prepare.sh
dune build -p coq-coqffi

Example

Suppose the following OCaml header file (file.mli) is given:

type fd

val std_out : fd
val fd_equal : fd -> fd -> bool [@@pure]

val openfile : string -> fd
val closefile : fd -> unit
val read_all : fd -> string
val write : fd -> string -> unit

coqffi then generates the necessary Coq boilerplate to use these functions in a Coq development:

(* This file has been generated by coqffi. *)

Set Implicit Arguments.
Unset Strict Implicit.
Set Contextual Implicit.
Generalizable All Variables.

From CoqFFI Require Export Extraction.
From SimpleIO Require Import IO_Monad.
From CoqFFI Require Import Interface.

(** * Types *)

Axiom fd : Type.

Extract Constant fd => "Examples.File.fd".

(** * Pure functions *)

Axiom std_out : fd.
Axiom fd_equal : fd -> fd -> bool.

Extract Constant std_out => "Examples.File.std_out".
Extract Constant fd_equal => "Examples.File.fd_equal".

(** * Impure Primitives *)

(** ** Monad Definition *)

Class MonadFile (m : Type -> Type) : Type :=
  { openfile : string -> m fd
  ; closefile : fd -> m unit
  ; read_all : fd -> m string
  ; write : fd -> string -> m unit
  }.

(** ** [IO] Instance *)

Axiom io_openfile : string -> IO fd.
Axiom io_closefile : fd -> IO unit.
Axiom io_read_all : fd -> IO string.
Axiom io_write : fd -> string -> IO unit.

Extract Constant io_openfile
  => "(fun x0 k__ -> k__ (Examples.File.openfile x0))".
Extract Constant io_closefile
  => "(fun x0 k__ -> k__ (Examples.File.closefile x0))".
Extract Constant io_read_all
  => "(fun x0 k__ -> k__ (Examples.File.read_all x0))".
Extract Constant io_write
  => "(fun x0 x1 k__ -> k__ (Examples.File.write x0 x1))".

Instance IO_MonadFile : MonadFile IO :=
  { openfile := io_openfile
  ; closefile := io_closefile
  ; read_all := io_read_all
  ; write := io_write
  }.

(* The generated file ends here. *)

The generated module may introduce additional dependency to your project. For instance, the simple-io feature (enabled by default) generates the necessary boilerplate to use the impure primitives of the input module within the IO monad introduced by the coq-simple-io package.

See the coqffi man pages for more information on how to use it.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].