Statement Annotations
Statement annotations express conditions at a particular point in a function body.
Syntax
ContractStatement :=
Assertion
| Assumption
Semantics
An assertion states a condition to establish at its location. An assumption supplies a condition for reasoning from that location. Both may refer to variables in scope and describe the state at the annotation.
Example
use trust2_contract::prelude::*;
pub fn check(x: u8) {
contract_assume!(x < 16);
contract_assert!(x <= 15);
}
The assertion follows from the preceding assumption. This does not prove that x < 16 holds for every call to check.
Implementation boundaries
- Frontend
rust-llbc: supports assertions and assumptions, retaining their conditions, kinds, and positions. - Backend
llbc-why3: translates them to WhyMLassertandassume, respectively.
See Assertions and Assumptions for specific uses and limitations.