Prove AbsoluteMin#1
Open
Grover-c13 wants to merge 5 commits into
Open
Conversation
Adds a plain @BmcProof asserting AbsoluteMin.getMinValue's documented contract: the result must be the input element closest to zero. It REFUTES with the two-element witness getMinValue(-3, -2) == -3 (should be -2, since |-2| < |-3|). The bug: the filter keeps abs-<= candidates but then takes the arithmetic Math.min, so the more-negative element wins. CI goes red and the proof-report comment shows the counterexample row.
bmc4j proof results
|
The defect is specifically that, among two negatives, getMinValue keeps the more-negative (larger-magnitude) value instead of the one closest to zero. Constraining both symbolic inputs to be negative makes the refutation witness land in that regime, matching the documented counterexample.
Reverts the negative-only pinning: keep both inputs symbolic over [-3, 3] so the proof asserts the contract across positives and negatives alike. The refutation witness the engine emits is reported faithfully in the PR comment.
a265028 to
9a8d94f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
maths/AbsoluteMin.getMinValue(int...)is documented to return the element with the smallest absolute value (the upstreamAbsoluteMinTestassertsgetMinValue(3, -10, -2) == -2). It doesn't.This PR adds one plain
@BmcProofasserting that contract over symbolic inputs:|result|must equal the minimum absolute value among the inputs. It REFUTES.Counterexample
getMinValue(-3, -2)returns-3, but|-2| < |-3|, so the contract requires-2.Witness:
a = -3, b = -2, r = -3, minAbs = 2.Root cause
After filtering to the abs-≤ candidates, the code updates the running winner with
Math.min(value, number)— the arithmetic minimum — instead of the candidate itself. Between two negatives that keeps the more negative (larger-magnitude) value.CI is therefore red on purpose: the asserted contract genuinely refutes, and the proof-results comment below shows the
❌ REFUTEDrow with the counterexample. That red check + the witness is the shareable artifact. Left open as the showcase; upstream is untouched.