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

[smt] negative BitVectorLit value #9

Closed
ekiwi opened this issue Nov 8, 2019 · 4 comments
Closed

[smt] negative BitVectorLit value #9

ekiwi opened this issue Nov 8, 2019 · 4 comments

Comments

@ekiwi
Copy link
Contributor

ekiwi commented Nov 8, 2019

I was just going through the uclid.smt patches that I have lying around and I found one that might be interesting to the broader community.
It deals with a negative value in the BitVectorLit class [src].
The way the current serialization code is written is not compatible with value < 0:

override def toString = "(_ bv" + value.toString + " " + width.toString +")"

If value is negative this yields an invalid SMTLib expression.

My quick way of fixing this was to add an assert:

  Utils.assert(value >= 0, s"Value $value is negative. Negative BitVector literals are not supported.")

Another way of dealing with this would be to take the bits of the two complements integer and turn those into a string which would also yield a valid SMTLib expression.

As an example: BitVectorLit(-2, 3).toString could yield #b110 or alternatively (_ bv6 3).

@pramodsu
Copy link
Contributor

pramodsu commented Nov 8, 2019

Thanks for pointing this out, Kevin.

Could you make a pull request on the private repo? I'll merge and push the change over here.

@ekiwi
Copy link
Contributor Author

ekiwi commented Nov 8, 2019

Could you make a pull request on the private repo? I'll merge and push the change over here.

I can make a pull request for the quick-fix, i.e., using the assertion. If you are interested in allowing negative values and then converting them to bits using two's complement, I could also try to implement that, it will just take a bit more time.
Let me know what you prefer.

Just FYI: I think some of my prior uclid.smt patches might be missing from your private fork.

@pramodsu
Copy link
Contributor

pramodsu commented Nov 9, 2019

Please do make the PR for the quick-fix. If you have time to make the full fix, that would be great as well.

Unfortunately, the public and private repos don't share history so it is possible we lost patches submitted only to the public repo. Can you point me to the patches and I will redo them in the private repo?

Thanks!

@ekiwi
Copy link
Contributor Author

ekiwi commented Nov 12, 2019

Fixed in the private repo.

@ekiwi ekiwi closed this as completed Nov 12, 2019
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

No branches or pull requests

2 participants