Commit ad096af
Add loop_invariants for some Int power functions (model-checking#327)
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`.
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.
Co-authored-by: Michael Tautschnig <[email protected]>1 parent dd017ac commit ad096af
2 files changed
+7
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1589 | 1589 | | |
1590 | 1590 | | |
1591 | 1591 | | |
| 1592 | + | |
1592 | 1593 | | |
1593 | 1594 | | |
1594 | 1595 | | |
| |||
2299 | 2300 | | |
2300 | 2301 | | |
2301 | 2302 | | |
| 2303 | + | |
2302 | 2304 | | |
2303 | 2305 | | |
2304 | 2306 | | |
| |||
2316 | 2318 | | |
2317 | 2319 | | |
2318 | 2320 | | |
| 2321 | + | |
2319 | 2322 | | |
2320 | 2323 | | |
2321 | 2324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1780 | 1780 | | |
1781 | 1781 | | |
1782 | 1782 | | |
| 1783 | + | |
1783 | 1784 | | |
1784 | 1785 | | |
1785 | 1786 | | |
| |||
2349 | 2350 | | |
2350 | 2351 | | |
2351 | 2352 | | |
| 2353 | + | |
2352 | 2354 | | |
2353 | 2355 | | |
2354 | 2356 | | |
| |||
2366 | 2368 | | |
2367 | 2369 | | |
2368 | 2370 | | |
| 2371 | + | |
2369 | 2372 | | |
2370 | 2373 | | |
2371 | 2374 | | |
| |||
3044 | 3047 | | |
3045 | 3048 | | |
3046 | 3049 | | |
| 3050 | + | |
3047 | 3051 | | |
3048 | 3052 | | |
3049 | 3053 | | |
| |||
0 commit comments