All Projects → plclub → hs-to-coq

plclub / hs-to-coq

Licence: MIT license
Convert Haskell source code to Coq source code.

Programming Languages

Coq
218 projects
haskell
3896 projects
Yacc
648 projects
ruby
36898 projects - #4 most used programming language
Nix
1067 projects
emacs lisp
2029 projects

Labels

Projects that are alternatives of or similar to hs-to-coq

Vellvm
The Vellvm (Verified LLVM) coq development.
Stars: ✭ 243 (+279.69%)
Mutual labels:  coq
toychain
A minimalistic blockchain consensus implemented and verified in Coq
Stars: ✭ 103 (+60.94%)
Mutual labels:  coq
coqeal
The Coq Effective Algebra Library [maintainers=@CohenCyril,@proux01]
Stars: ✭ 62 (-3.12%)
Mutual labels:  coq
goose
Goose converts a small subset of Go to Coq
Stars: ✭ 73 (+14.06%)
Mutual labels:  coq
coq-100-theorems
Statements of famous theorems proven in Coq [maintainer=@jmadiot]
Stars: ✭ 41 (-35.94%)
Mutual labels:  coq
coq-ecosystem
No description or website provided.
Stars: ✭ 39 (-39.06%)
Mutual labels:  coq
Fscq
FSCQ is a certified file system written and proven in Coq
Stars: ✭ 208 (+225%)
Mutual labels:  coq
hydra-battles
Variations on Kirby & Paris' hydra battles and other entertaining math in Coq (collaborative, documented, includes exercises) [maintainer=@Casteran]
Stars: ✭ 38 (-40.62%)
Mutual labels:  coq
coq-elpi
Coq plugin embedding elpi
Stars: ✭ 92 (+43.75%)
Mutual labels:  coq
koika
A core language for rule-based hardware design 🦑
Stars: ✭ 103 (+60.94%)
Mutual labels:  coq
WasmCert-Coq
A mechanisation of Wasm in Coq
Stars: ✭ 68 (+6.25%)
Mutual labels:  coq
coq-to-ocaml-to-js
Proof of concept to generate safe and fast JavaScript
Stars: ✭ 25 (-60.94%)
Mutual labels:  coq
stablesort
Stable sort algorithms and their stability proofs in Coq
Stars: ✭ 19 (-70.31%)
Mutual labels:  coq
corn
Coq Repository at Nijmegen [maintainers=@spitters,@VincentSe]
Stars: ✭ 106 (+65.63%)
Mutual labels:  coq
coq-tal
Formalization of Typed Assembly Language (TAL) in Coq
Stars: ✭ 15 (-76.56%)
Mutual labels:  coq
Foundations
Voevodsky's original development of the univalent foundations of mathematics in Coq
Stars: ✭ 210 (+228.13%)
Mutual labels:  coq
CoqCheatSheet
Reference sheet for the Coq language.
Stars: ✭ 15 (-76.56%)
Mutual labels:  coq
coqdocjs
Collection of scripts to improve the output of coqdoc [maintainers=@chdoc,@palmskog]
Stars: ✭ 28 (-56.25%)
Mutual labels:  coq
Actuary
Formalization of the basic actuarial mathematics using Coq
Stars: ✭ 17 (-73.44%)
Mutual labels:  coq
coqffi
Coq to OCaml FFI made easy [maintainer=@lthms]
Stars: ✭ 27 (-57.81%)
Mutual labels:  coq

hs-to-coq

hs-to-coq

Join our discussion on: Zulip

This repository contains a converter from Haskell code to equivalent Coq code, as part of the CoreSpec component of the DeepSpec project.

CPP'18 paper “Total Haskell is Reasonable Coq” by Antal Spector-Zabusky, Joachim Breitner, Christine Rizkallah, and Stephanie Weirich. This paper describes the following examples:

  • bag Multiset implementation from GHC's implemention
  • compiler Hutton's razor
  • base-src The sources of the base/ directory

ICFP'18 paper "Ready, set, verify! applying hs-to-coq to real-world Haskell code (experience report)" by Joachim Breitner, Antal Spector-Zabusky, Yao Li, Christine Rizkallah, John Wiegley, and Stephanie Weirich. This paper describes the verification of the containers library.

Documentation for the hs-to-coq tool is available!

Installation

hs-to-coq uses Coq 8.10.2 and ssreflect.

Compilation

The recommended way of building hs-to-coq is to use stack. If you have not setup stack before, run:

stack setup

To build hs-to-coq, then run

stack build

(hs-to-coq can be built with GHC 8.4, 8.6, 8.8, and 8.10. However, the repo only contains the translation of Haskell libraries such as base from GHC 8.4. Therefore, it is advised to build hs-to-coq with GHC 8.4 if you plan to use example translations contained in this repo.)

Building the base library

This repository comes with a version of (parts of the) Haskell base library converted to Coq, which you will likely need if you want to verify Haskell code.

You must have Coq 8.10.2 and ssreflect to build the base library. To install these tools:

  1. opam repo add coq-released https://coq.inria.fr/opam/released (for SSReflect and MathComp)
  2. opam update
  3. opam install coq.8.10.2 coq-mathcomp-ssreflect.1.10.0

Once installed, you can build the base library with

cd base && coq_makefile -f _CoqProject -o Makefile && make -j && cd ..

Th directory base-thy/ contains auxillary definitions and lemmas, such as lawful type-class instances. You can build these with

cd base-thy && coq_makefile -f _CoqProject -o Makefile && make -j && cd ..

Using the tool

To use the tool, run it (using stack), passing the Haskell file to be translated and an output directory to write to:

stack exec hs-to-coq -- -o output-directory/ Input/File.hs

Very likely you want to make use of the base/ library. In that case, make sure you pass -e base/edits.

Have a look at the example directories, e.g. examples/successors, for a convenient Makefile based setup.

Edits

The edits file contains directives to hs-to-coq for ignoring or transforming some Haskell constructs into proper Coq.

For example, it is common in Haskell to have the following code:

module Foo where
...
newtype SomeType = SomeType { someFiled :: Integer }

Coq has a single namespace for types and values hence the type name will conflict with constructor name. One can pass -e edit file containing custom directives to ensure correctness of generated code with the following directive:

rename value Foo.SomeType = Foo.MkSomeType

See the manual for documentation for the edits files.

Other directories

  • The examples/ directories contains a number of example translation and verification projects, including

    Some examples use git submodule, so run

    git submodule update --init --recursive
    

    once.

  • structural-isomorphism-plugin: (In progress.) A GHC plugin that connects the re-extracted converted code back into GHC, allowing us to run Haskell programs against verified/verifiable code. Currently does not work.

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