Skip to content

Challenge 12: Verify safety of NonZero#565

Open
Samuelsills wants to merge 1 commit intomodel-checking:mainfrom
Samuelsills:challenge-12-nonzero
Open

Challenge 12: Verify safety of NonZero#565
Samuelsills wants to merge 1 commit intomodel-checking:mainfrom
Samuelsills:challenge-12-nonzero

Conversation

@Samuelsills
Copy link

Summary

Verify all 38 NonZero functions listed in Challenge 12. 432 Kani proof harnesses across all 12 integer types, 0 failures.

Part 1: Harnesses for new (iff + value equality assertions) and from_mut (iff + dereference). Pre-existing contracts and harnesses for new_unchecked and from_mut_unchecked.

Part 2: Harnesses for all 34 listed functions including bitor (3 impls), count_ones, rotate_left/right, swap_bytes, reverse_bits, endianness conversions, checked/saturating mul/pow/add, checked_next_power_of_two, midpoint, isqrt, abs variants (6), and neg variants (4).

Strengthened loop invariant on checked_pow in uint_macros.rs and int_macros.rs from true to a property that preserves the nonzero invariant through loop iterations. This is a verification-only annotation (no-op at runtime).

abs and neg harnesses exclude T::MIN (documented overflow behavior). The MIN case is separately verified by wrapping_abs, overflowing_abs, wrapping_neg, and overflowing_neg which pass for all inputs.

Resolves #71

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

@Samuelsills Samuelsills force-pushed the challenge-12-nonzero branch 3 times, most recently from 938fdd1 to 32bbacc Compare March 24, 2026 17:10
Verify all 38 NonZero functions listed in the challenge specification.
432 Kani proof harnesses across all 12 integer types, 0 failures.

Resolves model-checking#71

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 and MIT licenses.
@Samuelsills Samuelsills force-pushed the challenge-12-nonzero branch from 32bbacc to 71e54d0 Compare March 24, 2026 17:26
@Samuelsills Samuelsills marked this pull request as ready for review March 24, 2026 20:50
@Samuelsills Samuelsills requested a review from a team as a code owner March 24, 2026 20:50
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 12: Safety of NonZero

1 participant