-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
[SMTChecker] Fix CHCSmtLib2Interface #11289
Conversation
a36d55f
to
8a444ba
Compare
8a444ba
to
981bca9
Compare
libsmtutil/SolverInterface.h
Outdated
Expression(s256 const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {} | ||
Expression(bigint const& _number): Expression(_number.str(), {}, SortProvider::sintSort) {} | ||
Expression(s256 const& _number): Expression(_number.sign() >= 0 ? _number.str() : "-", _number.sign() >= 0 ? std::vector<Expression>{} : std::vector<Expression>{Expression(size_t(0)), u256(-_number)}, SortProvider::sintSort) {} | ||
Expression(bigint const& _number): Expression(_number.sign() >= 0 ? _number.str() : "-", _number.sign() >= 0 ? std::vector<Expression>{} : std::vector<Expression>{Expression(size_t(0)), u256(-_number)}, SortProvider::sintSort) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the lines above. The fix is correct but looks kinda ugly. Open to suggestions.
@@ -118,7 +118,7 @@ SortPointer smtSort(frontend::Type const& _type) | |||
else | |||
tupleName = arrayType->baseType()->toString(true); | |||
|
|||
tupleName += "[]"; | |||
tupleName += "_array"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed because smtlib2 doesn't like identifiers with []
@@ -300,7 +300,7 @@ class Expression | |||
friend Expression operator/(Expression _a, Expression _b) | |||
{ | |||
auto intSort = _a.sort; | |||
return Expression("/", {std::move(_a), std::move(_b)}, intSort); | |||
return Expression("div", {std::move(_a), std::move(_b)}, intSort); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't the changes in the commit redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why redundant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we end up converting "div" to /
in both z3interface and cvc4interface. Why do we call it div
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because smtlib2 uses the name of the operator when creating the queries. Since we want it to use div
, it makes sense for all solvers to read div
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hrkrshnn only this discussion left to finish I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we currently use pure smt2 queries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an option, via SmtLib2Interface or CHCSmtLib2Inteface
dc919ba
to
c570b63
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some minor comments.
c570b63
to
f7b045b
Compare
@hrkrshnn updated & rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last commit may be squashed, but okay otherwise too.
Yea the last commit has parts that would have to into different commits, so I would merge as is since it's not too much. |
Previously CHCSmtLib2Interface was using z3's the
rule
language sugar to describe Horn clauses. This PR changes it to the proper smtlib2 Horn logic which other solvers can also understand. That is the main fix and is coded in the first commit.The other commits add other small fixes that I felt were small enough to be just single commits in this same PR:
implies
is not smtlib2,=>
is the right operator-10
in smtlib2. It needs to be either(- 10)
or(0 - 10)
. Here I went with the latter to avoid overloading the minus operator./
is actually Real division, whereas we want Integer division which isdiv
gasleft()
should begasleft
bvnat
firstWith these changes, the queries given by CHCSmtLib2Interface can actually be read by any Horn solver that reads smtlib2.
We don't have direct tests for that, because:
t_ems
BUT