Verify safety of NonZero operations (Challenge 12) #544
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #71 (Challenge 12: Safety of NonZero)
Adds 376 new Kani verification harnesses for all remaining NonZero functions specified in the challenge, covering:
count_ones,swap_bytes,reverse_bits,rotate_left,rotate_right(12 types each)from_be,from_le,to_be,to_le(12 types each)NonZero|NonZero,NonZero|T,T|NonZero(12 types each)checked_mul,saturating_mul,checked_add,saturating_add(unsigned-only for add)checked_pow,saturating_pow(12 types each)checked_next_power_of_two,midpoint,isqrtneg,abs,checked_abs,overflowing_abs,saturating_abs,wrapping_abs,unsigned_abs,checked_neg,overflowing_neg,wrapping_negfrom_mutChanges
library/core/src/num/nonzero.rs: 376 new verification harnesses inmod verifylibrary/core/src/num/uint_macros.rs: Remove trivial#[safety::loop_invariant(true)]fromchecked_powthat caused CBMC assigns check interference withNonZero::new_uncheckedverificationlibrary/core/src/num/int_macros.rs: Same loop_invariant removal for signed typesVerification
All 385 harnesses pass (376 new + 9 existing):
Run with: