Skip to content
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

Fix precondition of conditionalNegate() #6

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

4tXJ7f
Copy link

@4tXJ7f 4tXJ7f commented Mar 24, 2022

conditionalNegate() was asserting that if we negate the input, then
the input cannot correspond to 100...0. However, this is problematic
when the operation is used conditionally. This is for example necessary
in convertFloatToSBV(), where we want to apply the negation if the
result is not the safe overflow value. This commit removes the assertion
and adds a comment to conditionalNegate() that documents why we cannot
have an assertion there.

Additionally, the commit makes convertFloatToSBV() safer by explicitly
handling the safe overflow case. Previously, we negated such a value,
even though it cannot be negated. This worked out in the cvc5 case
(because it blindly computes ~x + 1 without asserting anything), but
could be dangerous.

`conditionalNegate()` was asserting that if we negate the input, then
the input cannot correspond to `100...0`. However, this is problematic
when the operation is used conditionally. This is for example necessary
in `convertFloatToSBV()`, where we want to apply the negation if the
result is not the safe overflow value. This commit removes the assertion
and adds a comment to `conditionalNegate()` that documents why we cannot
have an assertion there.

Additionally, the commit makes `convertFloatToSBV()` safer by explicitly
handling the safe overflow case. Previously, we negated such a value,
even though it cannot be negated. This worked out in the cvc5 case
(because it blindly computes `~x + 1` without asserting anything), but
could be dangerous.
@4tXJ7f 4tXJ7f marked this pull request as draft March 24, 2022 20:33
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.

1 participant