-
Notifications
You must be signed in to change notification settings - Fork 55
Add loop invariants and harnesses for DecimalSeq functions #439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add loop invariants and harnesses for DecimalSeq functions #439
Conversation
let mut a: DecimalSeq = kani::any(); | ||
let shift: usize = kani::any_where(|x| *x > 0 && *x <= 60); | ||
let n = number_of_digits_decimal_left_shift(&a, shift); | ||
assert!(n <= 19); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain the magic number "19" (and include a comment doing so)?
@@ -363,6 +381,7 @@ fn number_of_digits_decimal_left_shift(d: &DecimalSeq, mut shift: usize) -> usiz | |||
let pow5_b = (0x7FF & x_b) as usize; | |||
let pow5 = &TABLE_POW5[pow5_a..]; | |||
|
|||
#[kani::loop_invariant(true)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This currently fails with error: custom attribute panicked
- presumably because we need a Kani version that has for
loop support merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I mentioned it in the PR description.
impl kani::Arbitrary for DecimalSeq { | ||
fn any() -> DecimalSeq { | ||
let mut ret = DecimalSeq { | ||
num_digits: kani::any(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use kani::any_where
?
Co-authored-by: Michael Tautschnig <[email protected]>
Co-authored-by: Michael Tautschnig <[email protected]>
This PR adds loop invariants and harnesses for DecimalSeq functions
Require: for-loop support for Kani: model-checking/kani#4143
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.