Skip to content
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

Contracts and Harnesses for unchecked_neg #102

Conversation

Yenyun035
Copy link

@Yenyun035 Yenyun035 commented Oct 4, 2024

Resolves #59

Changes

  • Added contracts for unchecked_neg (located in library/core/src/num/int_macros.rs)
  • Added a harness for unchecked_neg of each signed integer type
    • i8, i16, i32, i64, i128, isize --- 6 harnesses in total.
  • Fixed comments.

Revalidation

  1. Per the discussion in Challenge 11: Safety of Methods for Numeric Primitive Types #59, we have to build and run Kani from feature/verify-rust-std branch.
  2. To revalidate the verification results, run the following command. <harness_to_run> can be either num::verify to run all harnesses or num::verify::<harness_name> (e.g. check_unchecked_neg_i8) to run a specific harness.
kani verify-std  "path/to/library" \
    --harness <harness_to_run> \
    -Z unstable-options \
    -Z function-contracts \
    -Z mem-predicates

All default harnesses should pass.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

yew005 and others added 28 commits September 10, 2024 17:11
* Added harnesses for unchecked multiplication (`unchecked_mul`) and shift right (`unchecked_shr`)
* Added a macro and input limits for multiplication proofs
* Reduced duplicity in code by using macros to generate proof harnesses
library/core/src/num/int_macros.rs Outdated Show resolved Hide resolved
library/core/src/num/mod.rs Show resolved Hide resolved
@Yenyun035
Copy link
Author

@zhassan-aws Thank you for your reviews! I have fixed the precondition for unchecked_neg and fixed some comments.

@Yenyun035
Copy link
Author

@feliperodri @celinval @carolynzech May I request the second approval to merge this PR? Thank you very much :)

Copy link

@celinval celinval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Yenyun035
Copy link
Author

@celinval @zhassan-aws Thank you! This PR can get merged now :)

@zhassan-aws zhassan-aws merged commit 32e0cf9 into model-checking:main Oct 8, 2024
7 of 8 checks passed
@Yenyun035 Yenyun035 deleted the c-0011-core-nums-yenyunw-unchecked-neg branch November 27, 2024 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Challenge 11: Safety of Methods for Numeric Primitive Types
4 participants