Giter Site home page Giter Site logo

coq-community / bits Goto Github PK

View Code? Open in Web Editor NEW
22.0 10.0 5.0 182 KB

A formalization of bitset operations in Coq and the corresponding axiomatization and extraction to OCaml native integers [maintainer=@anton-trunov]

License: Apache License 2.0

Makefile 0.73% Coq 98.91% OCaml 0.17% Shell 0.18%
coq ssreflect coq-library coq-extraction paper-artifacts bitset mathcomp

bits's Introduction

Bits

Docker CI Contributing Code of Conduct Zulip DOI

A formalization of bitset operations in Coq with a corresponding axiomatization and extraction to OCaml native integers.

Meta

Building and installation instructions

The easiest way to install the latest released version of Bits is via OPAM:

opam repo add coq-released https://coq.inria.fr/opam/released
opam install coq-bits

To instead build and install manually, do:

git clone https://github.com/coq-community/bits.git
cd bits
make   # or make -j <number-of-cores-on-your-machine> 
make install

Origins

This library has been extracted from Andrew Kennedy et al. 'x86proved' fork. This link presently redirects to https://github.com/nbenton/x86proved repository.

The main paper for this project is Coq: The world’s best macro assembler?.

Using the library

To import the main library, do:

From Bits Require Import bits.

An axiomatic interface supporting efficient extraction to OCaml can be loaded with:

From Bits Require Import extraction.axioms8.  (* or 16 or 32 *)

Organization

This library, briefly described in the paper From Sets to Bits in Coq, helps to model operations on bitsets. It's a formalization of logical and arithmetic operations on bit vectors. A bit vector is defined as an SSReflect tuple of bits, i.e. a list of booleans of fixed (word) size.

The key abstractions offered by this library are as follows:

  • BITS n : Type - vector of n bits
  • getBit bs k - test the k-th bit of bs bit vector
  • andB xs ys - bitwise "and"
  • orB xs ys - bitwise "or"
  • xorB xs ys - bitwise "xor"
  • invB xs - bitwise negation
  • shrB xs k - right shift by k bits
  • shlB xs k - left shift by k bits

The library characterizes the interactions between these elementary operations and provides embeddings to and from the additive group ℤ/(2ⁿ)ℤ.

The overall structure of the code is as follows:

For a specific formalization developed in a file A.v, one will find its associated properties in the file A/properties.v. For example, bit-level operations are defined in src/spec/operations.v, therefore their properties can be found in src/spec/operations/properties.v.

Verification axioms

Axioms can be verified for 8-bit and 16-bit (using only extracted code) using the following command:

make verify

For 8bit, the verification process should finish in few seconds. However for 16-bit, depending on your computer speed, it could take more than 6 hours.

bits's People

Contributors

anton-trunov avatar artart78 avatar klntsky avatar palmskog avatar pi8027 avatar proux01 avatar vzaliva avatar zimmi48 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bits's Issues

opam release

  • Rename the repo into bits.
  • Update meta.yml and regenerate
  • Create a 1.0.0 tag and GitHub release notes
  • Publish on Coq's opam registry

make verify hangs

make verify pass 8-bit tests but hangs on 16-bit.
Coq 8.12.2 and OCaml 4.07.1.

src/extraction/verif.sh
patching file axioms8.ml
Hunk #1 succeeded at 159 (offset 5 lines).
Hunk #2 FAILED at 836.
1 out of 2 hunks FAILED -- saving rejects to file axioms8.ml.rej
patching file axioms16.ml
Hunk #1 succeeded at 159 (offset 5 lines).
Hunk #2 FAILED at 836.
1 out of 2 hunks FAILED -- saving rejects to file axioms16.ml.rej
Verifying 8bit
Finished, 8 targets (8 cached) in 00:00:00.
... Ok
Verifying 16bit
Finished, 8 targets (8 cached) in 00:00:00.

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.