Coder Social home page Coder Social logo

jasondavies / hax Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hacspec/hax

0.0 1.0 0.0 5.61 MB

A Rust verification tool

Home Page: https://hacspec.org/blog

Shell 0.19% JavaScript 2.90% OCaml 76.48% Rust 14.78% Standard ML 0.01% CSS 0.01% Nix 0.46% Makefile 0.61% HTML 0.18% Dockerfile 0.02% F* 4.37%

hax's Introduction

Hax

hax is a tool for high assurance translations that translates a large subset of Rust into formal languages such as F* or Coq. This extends the scope of the hacspec project, which was previously a DSL embedded in Rust, to a usable tool for verifying Rust programs.

So what is hacspec now?

hacspec is the functional subset of Rust that can be used, together with a hacspec standard library, to write succinct, executable, and verifiable specifications in Rust. These specifications can be translated into formal languages with hax.

Usage

Hax is a cargo subcommand. The command cargo hax accepts the following subcommands:

  • into (cargo hax into BACKEND): translate a Rust crate to the backend BACKEND (e.g. fstar, coq).
  • json (cargo hax json): extract the typed AST of your crate as a JSON file.

Note:

  • BACKEND can be fstar, coq or easycrypt. cargo hax into --help gives the full list of supported backends.
  • The subcommands cargo hax, cargo hax into and cargo hax into <BACKEND> takes options. For instance, you can cargo hax into fstar --z3rlimit 100. Use --help on those subcommands to list all options.

Installation

Manual installation
  1. Make sure to have the following installed on your system:
  1. Clone this repo: git clone [email protected]:hacspec/hax.git && cd hax
  2. Run the setup.sh script: ./setup.sh.
  3. Run cargo-hax --help
Nix

This should work on Linux, MacOS and Windows.

Prerequisites: Nix package manager (with flakes enabled)
  • Either using the Determinate Nix Installer, with the following bash one-liner:
    curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
  • or following those steps.
  • Run hax on a crate directly to get F*/Coq/... (assuming you are in the crate's folder):

    • nix run github:hacspec/hax -- into fstar extracts F*.
  • Install hax: nix profile install github:hacspec/hax, then run cargo hax --help anywhere

  • Note: in any of the Nix commands above, replace github:hacspec/hax by ./dir to compile a local checkout of hax that lives in ./some-dir

  • Setup binary cache: using Cachix, just cachix use hax

Using Docker
  1. Clone this repo: git clone [email protected]:hacspec/hax.git && cd hax
  2. Build the docker image: docker build -f .docker/Dockerfile . -t hax
  3. Get a shell: docker run -it --rm -v /some/dir/with/a/crate:/work hax bash
  4. You can now run cargo-hax --help (notice here we use cargo-hax instead of cargo hax)

Supported Subset of the Rust Language

Hax indenteds to support full Rust, with the two following exceptions, promoting a functional style:

  1. no unsafe code (see hacspec#417);
  2. mutable references (aka &mut T) on return types or when aliasing (see hacspec#420).

Each unsupported Rust feature is documented as an issue labeled unsupported-rust. When the issue is labeled wontfix-v1, that means we don't plan on supporting that feature soon.

Quicklinks:

Examples

There's a set of examples that show what hax can do for you. Please check out the examples directory.

Hacking on Hax

Edit the sources (Nix)

Just clone & cd into the repo, then run nix develop .. You can also just use direnv, with editor integration.

Structure of this repository

  • rust-frontend/: Rust library that hooks in the rust compiler and extract its internal typed abstract syntax tree THIR as JSON.
  • engine/: the simplication and elaboration engine that translate programs from the Rust language to various backends (see engine/backends/).
  • cli/: the hax subcommand for Cargo.

Recompiling

You can use the .utils/rebuild.sh script (which is available automatically as the command rebuild when using the Nix devshell):

  • rebuild: rebuild the Rust then the OCaml part;
  • rebuild TARGET: rebuild the TARGET part (TARGET is either rust or ocaml).

Publications & Other material

Secondary literature, using hacspec:

Contributing

Before starting any work please join the Zulip chat, start a discussion on Github, or file an issue to discuss your contribution.

Acknowledgements

Zulip graciously provides the hacspec & hax community with a "Zulip Cloud Standard" tier.

hax's People

Contributors

bors[bot] avatar cmester0 avatar dieracdelta avatar franziskuskiefer avatar jschneider-bensch avatar karthikbhargavan avatar mzacho avatar pnmadelaine avatar sonmarcho avatar strub avatar w95psp avatar xvzcf avatar

Watchers

 avatar

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.