Skip to content

Add loop_invariants for some Int power functions #327

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

thanhnguyen-aws
Copy link

@thanhnguyen-aws thanhnguyen-aws commented Apr 15, 2025

Is PR add loop_invariants for checked_pow, wrapping_pow, overflowing_pow functions in library/core/src/num/uint_macros.rs and library/core/src/num/int_macros.rs.

NOTE: This PR requires the Kani version which supports loop loops.

Side notes:

  • We need the feature that separate panic and other UBs to verify the function strict_pow, because this function calls strict_mul, which will panic when overflow happens.
  • The function pow can overflow and may require contracts, such as
#[kani::requires(self.checked_pow(exp).is_some())]
#[kani::ensures(|x| *x == self.checked_pow(exp).unwrap())]

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

@thanhnguyen-aws thanhnguyen-aws requested a review from a team as a code owner April 15, 2025 20:05
@tautschnig
Copy link
Member

NOTE: This PR requires the Kani version which supports loop loops.

#326 will give us the automation fix to have a PR created that updates this repo to such a version.

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.

2 participants