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 andcargo 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:
stalewhen an item a model was extracted from or a spec changed,unextractedwhen a modelled function or an obligation is not in the lockfile, the state recorded bycargo leanfran checkotherwise.
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.
- Opaque
Model - The Lean model of a
#[leanfran::opaque]function, written inlean/External.lean.
Constants§
- AENEAS_
MODEL_ LEAN LeanRust/AeneasModel.leanof leanfran’s Lean library: the classes of the laws of Rust’s traits over Aeneas’s models, written tolean/LeanRustGen/Lib/AeneasModel.leanbycargo leanfran extractfor the obligations of generic functions.- AENEAS_
REV - The rev of Aeneas this leanfran works with: the
require aeneasof 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-versionthis crate works with, and part of every cache key. - INSTANCES_
LEAN LeanRust/Instances.leanof leanfran’s Lean library: therust_instancescommand, written tolean/LeanRustGen/Lib/Instances.leanfor thelean!blocks that use it.- INSTANCES_
MODULE - The module of
INSTANCES_LEANin 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) andGENERATOR_VERSION. - depends_
on_ model truewhen the block imports the crate’s model (LeanRustGen.Model,.Aliasor.Extern, written bycargo 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