1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//! Inline Lean 4 in Rust.
//!
//! [`lean!`] takes Lean code written in a Rust source file, has Lean check it, proofs
//! included, and expands to Rust translated from what Lean's compiler produced for the
//! functions marked `@[export name]`. Nothing of Lean is linked into the program.
//!
//! ```ignore
//! inlean::lean! {
//! @[export midpoint]
//! def midpoint (lo hi : UInt32) : UInt32 := lo + (hi - lo) / 2
//!
//! theorem midpoint_ge (lo hi : UInt32) (h : lo <= hi) : lo <= midpoint lo hi := by
//! grind [midpoint]
//!
//! theorem midpoint_le (lo hi : UInt32) (h : lo <= hi) : midpoint lo hi <= hi := by
//! grind [midpoint]
//! }
//!
//! assert_eq!(midpoint(4_000_000_000, 4_000_000_002), 4_000_000_001);
//! ```
//!
//! With `(lo + hi) / 2` in place of the body, the sum can wrap around, the first theorem is
//! false, and the crate does not compile.
//!
//! A Rust type of the crate takes part at one of three levels, each named in a table of the
//! crate's `Cargo.toml`: converted to a Lean type at each crossing (a [`Primitive`], under
//! `[package.metadata.inlean.types]`), carried unconverted for a type the block declares
//! `opaque` (`[package.metadata.inlean.opaque]`), or carried for a structure or inductive type
//! of the block whose Lean definition is its model (`[package.metadata.inlean.foreign]`). An
//! `@[extern]` declaration of a block runs a Rust function that the crate names under
//! `[package.metadata.inlean.trusted]`, and is trusted, not checked, to compute what the
//! declaration says. The [guide] describes each, and [Choosing a level][levels] says which
//! to use.
//!
//! A block that writes `import Inlean` can also use Rust's own `Vec`, `VecDeque`, `HashMap`
//! and `HashSet`: the collection crosses unconverted, its operations run the standard
//! library's code, and proofs use its model in Lean. Nothing is named in `Cargo.toml`; see
//! [Collections][collections] in the guide.
//!
//! [guide]: https://github.com/shergin/inlean/blob/main/docs/guide/README.md
//! [levels]: https://github.com/shergin/inlean/blob/main/docs/guide/choosing-a-level.md
//! [collections]: https://github.com/shergin/inlean/blob/main/docs/guide/collections.md
pub use ;
pub use ;
/// The runtime that generated code calls. Not a public API.
pub use inlean_runtime as __rt;