Skip to content

Replace the unchecked_mul harnesses with autoharness - #809

Open
bardiharborow wants to merge 1 commit into
model-checking:mainfrom
bardiharborow:fix-vacuous-unchecked-mul
Open

bardiharborow wants to merge 1 commit into
model-checking:mainfrom
bardiharborow:fix-vacuous-unchecked-mul

Conversation

@bardiharborow

Copy link
Copy Markdown

Remove the 36 hand-written unchecked_mul harnesses and verify all 12 integer types with autoharness instead, over all inputs that satisfy the contract.

24 of the removed harnesses were vacuous. Both operands were restricted to an interval in which every product overflows, and the product was then assumed not to overflow, so unchecked_mul was never called. For the 32-bit and wider types and isize/usize, only products of operands in -10..=10 (signed) or 0..=10 (unsigned) were verified.

The ESBMC workflow ran on four of the removed harnesses, so point it at the NonZero::unchecked_mul harnesses for i8, i16, u8 and u16, which call the primitive unchecked_mul.

Resolves #808

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

Remove the 36 hand-written `unchecked_mul` harnesses and verify all 12
integer types with autoharness instead, over all inputs that satisfy the
contract.

24 of the removed harnesses were vacuous. Both operands were restricted
to an interval in which every product overflows, and the product was
then assumed not to overflow, so `unchecked_mul` was never called. For
the 32-bit and wider types and `isize`/`usize`, only products of
operands in `-10..=10` (signed) or `0..=10` (unsigned) were verified.

The ESBMC workflow ran on four of the removed harnesses, so point it at
the `NonZero::unchecked_mul` harnesses for `i8`, `i16`, `u8` and `u16`,
which call the primitive `unchecked_mul`.
@bardiharborow
bardiharborow requested a review from a team as a code owner December 1, 2026 16:21
@feliperodri feliperodri self-assigned this Dec 1, 2026
@feliperodri
feliperodri requested a balanced review from Copilot December 1, 2026 20:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the replacement of manual unchecked_mul harnesses with Kani autoharness coverage.

No open issues 🎉

What changed in this PR

This PR addresses #808 by replacing hand-written unchecked_mul harnesses with Kani autoharness coverage for all 12 integer types, targeting all contract-valid inputs without changing standard-library runtime logic.

Changes:

  • Removes 36 manual harnesses, including 24 with unsatisfiable assumptions.
  • Adds all 12 primitive unchecked_mul methods to the Kani autoharness selection.
  • Retargets ESBMC to existing NonZero::unchecked_mul harnesses that call primitive multiplication.
File Description
scripts/​run-esbmc.sh Updates comments showing example harness filenames and entry points; no behavior change.
library/​core/​src/​num/​mod.rs Removes manual unchecked_mul harnesses and their generation macros.
.github/​workflows/​kani.yml Adds autoharness selection patterns for all 12 integer types.
.github/​workflows/​esbmc.yml Selects NonZero multiplication harnesses instead of the removed primitive harnesses.

Review effort: Balanced

This branch has not been deployed

No deployments
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: 24 of the 36 unchecked_mul harnesses are vacuous

3 participants