kani icon indicating copy to clipboard operation
kani copied to clipboard

Add support for uninterpreted function stub

Open celinval opened this issue 1 year ago • 2 comments

Requested feature: Stubs that behave like an uninterpreted function. Use case: Generating stubs that return the same arbitrary value for multiple invocations if the inputs are the same. Link to relevant documentation (Rust reference, Nomicon, RFC): http://www.cprover.org/cprover-manual/modeling/nondeterminism/ and https://model-checking.github.io/kani/rfc/rfcs/0002-function-stubbing.html#future-possibilities

Example:

/// This harness has some code that is conditional on the value of a few arguments.
/// Check that it behaves for all combination of arguments, however,
/// an argument should always have the same value.
#[kani::proof]
#[kani::stub_uninterpreted(Arg::is_enabled)]
fn check_uninterpreted() {
    /* logic goes here */
}

Note: We will have to figure out the best mechanism to only return valid values.

celinval avatar Mar 27 '24 18:03 celinval

@nchong-at-aws would that make sense?

celinval avatar Mar 27 '24 18:03 celinval

Yes, exactly right. The behavior I want is a function whose result is non-deterministic but different calls will return the same value if the inputs are the same.

nchong-at-aws avatar Mar 27 '24 18:03 nchong-at-aws