-
Notifications
You must be signed in to change notification settings - Fork 54
Quickfix for array model generation in Bitwuzla #541
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
base: master
Are you sure you want to change the base?
Conversation
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.
LGTM. But i would like to test this with at least the 2 tests from the related CVC5 branch, if possible more.
|
@daniel-raffler could you maybe add a test that (for Integer and BV if possible) that uses multi-dimensional arrays, but with at least 1 store instruction? Bonus points if the store itself stores a multi-dimensional 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.
Thanks for adding the tests! I think many can be combined to test the behavior in 2 tests (per theory). Something like:
- Nested arrays with UFs (you can combine store and select)
- Nested arrays with UFs and non UFs (store and select combined)
(The CVC5 branch already has tests for only nested arrays w select, so no need for that)
| } | ||
|
|
||
| /** Evaluate the UF or array constraint and check that the model contains the expected values. */ | ||
| private <T> void checkModelContains( |
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.
Methods like this already exist AFAIK. Could you check and reuse the existing ones?
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.
Sure, I can rewrite the tests to use testModelGetters just as on the CVC5 branch
|
|
||
| checkModelContains( | ||
| bmgr.and( | ||
| bvmgr.equal(amgr.select(array, idxA), valA), |
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.
Is this not covered by existing tests?
(It might be that there are only Integer based tests for this)
| } | ||
|
|
||
| @Test | ||
| public void testArray1BvBV() { |
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.
A description, e.g. SMTLIB2, of whats tested should be added to all new tests.
I've added 68cb59c from the modelArrayGeneration branch and two more tests for 3d arrays that use stores. Is that what you had in mind?
The tests from the CVC5 branch also seem to be working |
These will be added later. The quickfix is just about array values in the model
I've removed the UF tests again as they were meant to test assignments for uninterpreted functions and aren't needed here. Other than that there is some overlap with the tests from the CVC5 branch and I'm not if we can't just remove all of the tests here. What do you think still needs testing that isn't already covered by the CVC5 branch? I'm getting different results for |
| // Should be unreachable | ||
| // We assume that array values are made up of "const" and "store" nodes with non-array | ||
| // constants as leaves | ||
| throw new AssertionError(); |
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.
A more expressive exception and message could be added here.
| } | ||
|
|
||
| /** Returns the arguments of an UF or array definition from the model. */ | ||
| private Iterable<Formula> getFunctionArgs(Formula pValue) { |
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.
Actually why don't we have a visitor method for retrieving all UFs, including all applications? @kfriedberger do you know? Seems like this might be helpful in general.
| new DefaultFormulaVisitor<>() { | ||
| @Override | ||
| protected Iterable<Formula> visitDefault(Formula f) { | ||
| throw new IllegalArgumentException(); |
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.
Are you sure this is correct?
Since you don't override all methods of the super-class, this can be called!
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.
Yeah, that's fine. The argument to this function is a "key" formula from the model. So it's either (f 1 2 3) for a UF mapping f(1,2,3) or (Select (Select (Select 1 arr) 2) 3) for an array mapping arr(1,2,3). We then get the arguments 1, 2 and 3 by simply returning them for the UF mapping: this is the else branch in visitFunction. Or descending the term recursively if we have an array: that's the if part of visitFunction and visitFreeVariable for the base case
The whole function could be removed if we rewrite the tests to use testModelGetters
| return FluentIterable.concat( | ||
| getFunctionArgs(args.get(0)), ImmutableList.of(args.get(1))); | ||
| } else { | ||
| // Assume its an UF value |
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.
visitFunction() is defined to be called on any function, including UFs. I would recommend explicitly checking for UFs. You could take a look at the VariableAndUFExtractor for inspiration.
…an array value for the model
This MR adds Bitwuzla multi-dimensional array model evaluation.
(Similar to #539 for CVC5)
Also, more tests for this not based on SMTLIb2 parsing are added.