Use MIRAI annotations to assist formal verification
mainThe mirai-annotations crate provides macros that replace standard Rust assert! and debug_assert! macros. These annotations allow the MIRAI formal verification tool to distinguish between path conditions and verification conditions, manage assumptions versus verifications, and perform expensive checks at compile time rather than runtime.
There are four primary families of macros based on their logical role:
- assume: Conditions the verifier should treat as true.
- precondition: Conditions that must be true before a function executes (acts like
assumefor the caller). - postcondition: Conditions that must be true after a function executes (acts like
assumefor the caller). - verify: Conditions that the verifier must prove are true.