-
Notifications
You must be signed in to change notification settings - Fork 64
Improve specs of bitwise operations #1839
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: master
Are you sure you want to change the base?
Conversation
| #[ensures(self >> $type::BITS - result == $zero)] | ||
| #[ensures((result != $type::BITS) == (self >> ($type::BITS - result - 1u32) == $one))] | ||
| #[ensures((result == $type::BITS) == (self == $zero))] |
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.
| #[ensures(self >> $type::BITS - result == $zero)] | |
| #[ensures((result != $type::BITS) == (self >> ($type::BITS - result - 1u32) == $one))] | |
| #[ensures((result == $type::BITS) == (self == $zero))] | |
| #[ensures((result != $type::BITS) == (self >> ($type::BITS - result - 1u32) == $one))] | |
| #[ensures((result == $type::BITS) == (self == $zero))] |
This clause is redundant (though it's unclear whether SMT solvers will be more comfortable with suc or such clause).
| #[ensures(self << $type::BITS - result == $zero)] | ||
| #[ensures((result != $type::BITS) == ((self >> $type::BITS) & $one == $one))] | ||
| #[ensures((result == $type::BITS) == (self == $zero))] |
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.
| #[ensures(self << $type::BITS - result == $zero)] | |
| #[ensures((result != $type::BITS) == ((self >> $type::BITS) & $one == $one))] | |
| #[ensures((result == $type::BITS) == (self == $zero))] | |
| #[ensures((result != $type::BITS) == (self << ($type::BITS - result - 1u32) == $one << ($type::BITS - 1u32))] | |
| #[ensures((result == $type::BITS) == (self == $zero))] |
I see no reason we would have a different spec for both functions.
| #[ensures(!self >> $type::BITS - result == $zero)] | ||
| #[ensures((result != $type::BITS) == (!self >> ($type::BITS - result - 1u32) == $zero))] | ||
| #[ensures((result == $type::BITS) == (self == $type::MAX))] |
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.
| #[ensures(!self >> $type::BITS - result == $zero)] | |
| #[ensures((result != $type::BITS) == (!self >> ($type::BITS - result - 1u32) == $zero))] | |
| #[ensures((result == $type::BITS) == (self == $type::MAX))] | |
| #[ensures((result != $type::BITS) == (!self >> ($type::BITS - result - 1u32) == $zero))] | |
| #[ensures((result == $type::BITS) == (self == $type::MAX))] |
| #[ensures(!self << $type::BITS - result == $zero)] | ||
| #[ensures((result != $type::BITS) == ((!self >> $type::BITS) & $one == $one))] | ||
| #[ensures((result == $type::BITS) == (self == $type::MAX))] |
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.
| #[ensures(!self << $type::BITS - result == $zero)] | |
| #[ensures((result != $type::BITS) == ((!self >> $type::BITS) & $one == $one))] | |
| #[ensures((result == $type::BITS) == (self == $type::MAX))] | |
| #[ensures((result == $type::BITS) == (!self << ($type::BITS - result - 1u32) == $one << ($type::BITS - 1u32)))] | |
| #[ensures((result == $type::BITS) == (self == $type::MAX))] |
|
Suggestion: have logic functions for |
|
@mcoulmance the main todo is to fix the translation of |
No description provided.