Paths in this guide are relative to langs/Rust/.
LeanRust/ and LeanRust/Cli.lean: Lean IR emitter and compiler CLI. LeanRust/Embed.lean has the Backend of leanfran --lang rust sync, check and status.crates/leanfran-runtime/: runtime and C-symbol externs.crates/leanfran-build/: the build script (the copy of the cache and its keys), and the syntax of lean! and #[leanfran::model], which the macros and cargo-leanfran share.crates/leanfran-macros/: host-language macros. #[exported] gives each public function a type __leanfran_call_<name> whose product with the tuple of the arguments calls it; the tests of #[model] call the specs through it (Call of crates/leanfran/src/check.rs), so a spec of other types is an error of its test.crates/leanfran/: public API.crates/cargo-leanfran/: the commands scan (src/scan.rs, the lean! blocks with the cache keys of the build script, and the functions) and translate (src/translate.rs, Charon and Aeneas) that the compiler runs. src/gen.rs reads the output of Aeneas and writes the obligations. src/callers.rs gives Charon a copy of a crate whose code calls a block that has no code yet. src/AeneasStd.lean has the definitions that stand in place of Aeneas's, and src/llbc.rs (what Charon compiled), src/conditions.rs (the source of the crate) and gen::unfaithful (the names in the model) find the functions whose models would not return what Rust returns.tests/, LeanRustTest/, samples/: host tests, native oracles and examples.generatorVersion in LeanRust/Cli.lean and GENERATOR_VERSION in crates/leanfran-build/src/lib.rs together when the generated code changes. The caches of the samples hold it in their first line.make gen-externs regenerates the extern table.uses. Other changes, also of GENERATOR_VERSION, rewrite the file of the same key in sync.#[leanfran::opaque] is a block <crate>::<function> [opaque] in the output of scan, whose Lean file only imports the model.translate sets LEANFRAN_EXTRACTING=1 for Charon: the build script does not stop at a block without code, and the macros expand to the bare items. Charon compiles the whole crate: when that fails and a block has no code, translate runs Charon on a copy of the crate in .leanfran/rust/translate/<crate>/crate/ (links to the other files of the workspace). There the block is a module of the names that declarations use, and the bodies with errors of rustc panic. translate then names the block in blocked, and runs again with its code.leanfran of the target directory. A cargo build with LEANFRAN_AUTO_SYNC=1 holds the lock of the target directory and may wait for a sync that runs Charon.LEANFRAN_AUTO_SYNC=1 the build script runs sync with LEANFRAN_AUTO_SYNC=0 and LEANFRAN_SYNC_MODELS=0, which ends before translate.AeneasStd.lean, which gen::with_aeneas_std writes in its place, or its users are unextracted. tests/ops compares the models of the operations with Rust on the boundaries of their arguments, and tests/verify/fixtures has a function for each reason to refuse a model.translate runs it again for a target of 64 and a target of 32 bits, and compares what Aeneas writes for them.use declarations, the aliases and the macros that they name.src/inputs.rs of leanfran for the types it knows, and from any for others.#[leanfran::model] has one test, __leanfran_<function>::check (one of each type of instances). leanfran::check takes an input that fails through the steps of proptest, then through Shrink, which tries other steps below an input that requires rejects.Build the shared compiler with lake --dir ../.. build leanfran and run ../../.lake/build/bin/leanfran --lang rust --help. Install it on your PATH with nix profile install 'github:conao3/lean-leanfran#leanfran'.
Inside nix develop ../..#rust (elan, Rust, cargo-nextest):
make check
runs the format check, clippy, the diff tests against Lean's C backend (../../maint/Rust/test-diff.sh), the
public API tests (../../maint/Rust/test-public.sh), the tests of the crates, the lean! tests
(tests/embed/test.sh for the build, and tests/embed/sync.sh for leanfran --lang rust sync), the
tests of tests/verify and the samples, a project of Rust and C (tests/project), the theorems of
the blocks (../../maint/test-theorems.sh), when their code is out of date (../../maint/test-freshness.sh), and builds the runtime for
wasm32-unknown-unknown and runs tests/wasm in node, all without Charon or Mathlib.
make check-verify
translates the functions and checks the proofs again: tests/verify/test.sh (check reproduces the
committed files; stale states, require = "proved", wrong specs and a wrong implementation on
copies in test-out/verify/), tests/embed/late.sh (a crate that calls a block that imports its model)
and make verify of the samples. It needs Mathlib: packages-dir of
the leanfran.toml files shares .lake-aeneas/packages/ (7.9 GB, git-ignored), which the first
sync fills.
See the backend README for supported features and examples.
The Release and Publish workflows release every backend under one version, as CONTRIBUTING.md describes. ../../maint/Rust/bump-version.sh writes the version to the crates, README.md and ../../docs/rust-guide.md, and the Publish job publishes the crates to crates.io with trusted publishing.
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |