-
Notifications
You must be signed in to change notification settings - Fork 274
Fix quantifiers for arrays only works with Z3 and CVC4 #6270
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
Conversation
MathSAT does not support |
Now we only produce the |
// The code below only works in Z3 and CVC4, it was added (and | ||
// approved/merged) despite breaking other solvers. | ||
// This conditional removes this for other solvers | ||
if(solver == solvert::CVC4 || solver == solvert::Z3) |
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.
Thanks for fixing this. In my original commit, I didn't realize that we also support solvers that do not have quantifier support.
Instead of checking for specific solvers, should we introduce use_quantified_array_init
? This can be set to true
for Z3
and CVC4
in the case split we have in the constructor, and we wouldn't need the solver-specific checks or the comments above and below. We use the same pattern for other solver-specific features, e.g. array of Bools support, as const support etc.
Actually, may be we should have a use_quantifier
flag instead to track solvers that support quantifiers. The issue here is with the use of quantifiers, not really specific to array initialization. May be we should also go over other uses of quantifiers in this file and guard them with use_quantifier
.
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.
Agree that a flag for quantifiers is probably the better approach, the PR above is a bit limited and incomplete (also we should have a flag and not solver specific code in random places).
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.
I've gone with a very lightweight (minimum) fix and rebase for now. Is this still blocking?
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.
Thank you! No this isn't a blocker currently.
This commit fixes an error introduced in diffblue#5974 where quantifiers were produced for all SMT2 solvers despite only being supported by Z3 and CVC4. The fix here reverts to the older behaviour for other solvers. Fixes diffblue#6263
4a1fab6
to
650d458
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6270 +/- ##
===========================================
- Coverage 77.79% 77.76% -0.03%
===========================================
Files 1567 1567
Lines 179707 179780 +73
===========================================
+ Hits 139797 139807 +10
- Misses 39910 39973 +63
Continue to review full report at Codecov.
|
src/solvers/smt2/smt2_conv.cpp
Outdated
// else | ||
// { | ||
// // This is where an alternate for other solvers that does not use | ||
// // quantifiers should go. | ||
// } |
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.
We should not silently do this. It's ok to fail an invariant, but let's please not generate incomplete formulae without telling the user.
@TGWDB Thank you for adding the invariant. This is now, not unexpectedly, failing in some tests. I'd suggest to reinstate the regex pattern in the test, and mark the test as known-broken. |
This adds an invariant failure when correct SMT output would not be produced.
This marks two tests as KNOWNBUG due to them failing here.
b342ddc
to
52829ee
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.
This needs more work -- the array_of
expression is an array constructor for an array that maps all indices to one value. Various solvers do support SMT2-LIB array constructor expressions, which should be used here.
Perhaps a bit more controversial, we could consider dropping support for solvers that support neither |
@kroening I agree that this PR does not correctly solve all the issues with various solvers. This was intended to be a sport fix for an issue introduced in a prior PR that allowed us to crash some solvers. Instead now this produces an error from CBMC (where we should be building something better). With that in mind, would you be willing to accept this spot fix since in practice this is a fix to the output/failure behaviour? (Also in the context where a new SMT backend is being developer, which may deprecate this code path or enable a better solution in future.) |
This commit fixes an error introduced in #5974 where quantifiers
were produced for all SMT2 solvers despite only being supported by
Z3 and CVC4. The fix here reverts to the older behaviour for other
solvers.
Fixes #6263