Crates.io | hax-frontend-exporter |
lib.rs | hax-frontend-exporter |
version | 0.1.0-alpha.1 |
source | src |
created_at | 2023-10-23 12:23:36.66593 |
updated_at | 2024-10-07 14:05:49.279846 |
description | Provides mirrors of the algebraic data types used in the Rust compilers, removing indirections and inlining various pieces of information. |
homepage | https://github.com/hacspec/hax |
repository | https://github.com/hacspec/hax |
max_upload_size | |
id | 1011273 |
size | 4,482,632 |
🌐 Website | 📖 Book | 📝 Blog | 💬 Zulip | 🛠️ Internal docs | 🛝 Playground
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.
Here are some resources for learning more about hax:
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
, easycrypt
or pro-verif
. cargo hax into --help
gives the full list of supported backends.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.git clone git@github.com:hacspec/hax.git && cd hax
./setup.sh
.cargo-hax --help
This should work on Linux, MacOS and Windows.
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
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
git clone git@github.com:hacspec/hax.git && cd hax
docker build -f .docker/Dockerfile . -t hax
docker run -it --rm -v /some/dir/with/a/crate:/work hax bash
cargo-hax --help
(notice here we use cargo-hax
instead of cargo hax
)Hax intends to support full Rust, with the two following exceptions, promoting a functional style:
unsafe
code (see https://github.com/hacspec/hax/issues/417);&mut T
) on return types or when aliasing (see https://github.com/hacspec/hax/issues/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:
The documentation of the internal crate of hax and its engine can be found here.
Just clone & cd
into the repo, then run nix develop .
.
You can also just use direnv, with editor integration.
rust-frontend/
: Rust library that hooks in the rust compiler and
extract its internal typed abstract syntax tree
THIR as JSON.engine/
: the simplification and elaboration engine that translates
programs from the Rust language to various backends (see engine/backends/
).cli/
: the hax
subcommand for Cargo.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
).Before starting any work please join the Zulip chat, start a discussion on Github, or file an issue to discuss your contribution.
Zulip graciously provides the hacspec & hax community with a "Zulip Cloud Standard" tier.