Skip to main content

Crate leanfran_build

Crate leanfran_build 

Source
Expand description

Build script support of leanfran.

The main of the build script (build.rs):

leanfran_build::Builder::new().compile().unwrap();

Builder::compile finds the lean! blocks in src/**/*.rs, and for each block copies the cached Rust module from .leanfran/cache/ to OUT_DIR. Blocks without a cache entry are written into the crate’s Lean package (lean/LeanRustGen/Embed/), checked with lake build and generated with leanfran module generate.

It also compares the #[leanfran::model] functions with the lockfile leanfran.lock (without Lean or Charon), reports the stale and unextracted obligations with cargo:warning, and writes the rustdoc of their states.

Environment variables: LEANFRAN_CLI (the leanfran executable, default from PATH), LEANFRAN_OFFLINE=1 (use the cache only), LEANFRAN_EXTRACTING=1 (set by cargo leanfran extract: use the cache only and skip the lockfile), LEANFRAN_REQUIRE=proved (fail unless every obligation is proved, as [package.metadata.leanfran] require = "proved").

Modules§

gen
Lean files generated from Aeneas’s model: the aliases of the loops, the obligations, the functions calling the Rust functions (rs: externs) and the @[csimp] replacements.
lock
The lockfile leanfran.lock: the items each model was extracted from, with the hashes of their tokens, and the state of the proof of each obligation.
model
The syntax of #[leanfran::model], shared by the macro, the build script and cargo leanfran: the attribute keys, the signature of a modelled function, its loops, and the items of a crate with the hashes of their tokens.
syntax
The syntax of lean!, shared by the macro and the build script.
verify
The state of the obligations of a crate, from its source and its lockfile, without Lean or Charon: stale when an item a model was extracted from or a spec changed, unextracted when a modelled function or an obligation is not in the lockfile, the state recorded by cargo leanfran check otherwise.

Structs§

Block
A lean! block found in the crate.
Builder
Configures and runs the build step.
Error
An error of the build script, with a message for the user.
OpaqueModel
The Lean model of a #[leanfran::opaque] function, written in lean/External.lean.

Constants§

AENEAS_MODEL_LEAN
LeanRust/AeneasModel.lean of leanfran’s Lean library: the classes of the laws of Rust’s traits over Aeneas’s models, written to lean/LeanRustGen/Lib/AeneasModel.lean by cargo leanfran extract for the obligations of generic functions.
AENEAS_REV
The rev of Aeneas this leanfran works with: the require aeneas of the crate’s Lean package.
CHARON_VERSION
The version of the Charon bundled with that Aeneas.
GENERATOR_VERSION
Version of the generated code: the leanfran --generator-version this crate works with, and part of every cache key.
INSTANCES_LEAN
LeanRust/Instances.lean of leanfran’s Lean library: the rust_instances command, written to lean/LeanRustGen/Lib/Instances.lean for the lean! blocks that use it.
INSTANCES_MODULE
The module of INSTANCES_LEAN in the crate’s Lean package.
LEAN_TOOLCHAIN
The Lean toolchain of the crate’s Lean package (lean/lean-toolchain).

Functions§

cache_keys
The cache key of every block: SHA-256 over the crate name, the file, the block name, the imports, the source, the keys of the used blocks, extra (the hash of the @[csimp] replacements) and GENERATOR_VERSION.
depends_on_model
true when the block imports the crate’s model (LeanRustGen.Model, .Alias or .Extern, written by cargo leanfran extract), directly or through the blocks it uses.
lean_source
The Lean file of a block, the number of lines before the source and the indentation removed from the source.
module_path_string