-
Notifications
You must be signed in to change notification settings - Fork 54
Re-enable Z3 4.5.0 for better interpolation #536
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
|
Thank you very much for the PR! It seems like the old Z3 version is beneficial to have. Could you also post the tables and/or quantile-plots from your experiments (for documentation purposes)? We need to make sure that there are no issues when running both Z3 instances at the same time! I'll try to start some tests in CPAchecker and report back. |
|
Sure! Here are some: |
|
Thank you very much! Btw. could you try using Z3 version 4.5 from our Ivy repo? |
|
I haven't used it, but I'd be cautious about using it. The libraries I built use the |
Good to know! So we need to compile and release it again. Thanks for the clarification! |
|
Well, I'd suggest just using the ones I linked to, but sure, I can also provide a patch on top of the 4.5.0 Z3 so that you can rebuild it if you'd prefer. |
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 can't find more issues than some small suggestions and quantifier visitation being outdated. Good job and thank you for all your work!
I suggest to import this into a branch in JavaSMT first, then add the binaries to Ivy, run a more complex test-setup in CPAchecker before merging.
| * an API wrapper for a collection of SMT solvers: | ||
| * https://github.com/sosy-lab/java-smt | ||
| * | ||
| * SPDX-FileCopyrightText: 2024 Dirk Beyer <https://www.sosy-lab.org> |
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.
2025 😉
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.
Nice catch, fixed!
| MATHSAT5, | ||
| SMTINTERPOL, | ||
| Z3, | ||
| Z3LEGACY, |
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.
@kfriedberger @PhilippWendler @leventeBajczi i kinda feel like Z3 legacy is a little unspecific. Since the version is fixed, should we use the actual version? I.e. Z3-3.5?
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 solver is able to provide its version string anyway. As it is a version of Z3 with interpolation support, we might name it Z3_INTERPOLATION or simply Z3_3_5 . Special chars like dots or hyphens are not allowed in Java enums.
The JavaSMT enum it independent of the native library, so the library can be called z3Legacy or similar.
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 like encoding the version (Z3_INTERPOLATION could I think be confused with iZ3), so I changed it to Z3_4_5_0.
| storedConstraints = new ArrayDeque<>(); | ||
| storedConstraints.push(PathCopyingPersistentTreeMap.of()); | ||
| } else { | ||
| storedConstraints = null; // we use NULL as flag for "no unsat-core" |
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.
Using Optional would reduce the chance of accidental null access.
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 could go through the whole code once and update to latest coding conventions, and include latest bugfixes from 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.
... i mean, including latest bugfixes for JavaSMT only, no bugfixes for an outdated 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.
I agree. This should include Z3 as well, since this for example is still present in our Z3. But this should be done independently of Levis work and help, as he/we want this for SVCOMP this year actually ;D
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 fixed it in this file; but this came directly from the Z3 implementation, and I did not touch that now. I agree this should probably be fixed globally in the project.
| Native.getAppDecl(environment, f))); | ||
| case Z3_VAR_AST: | ||
| int deBruijnIdx = Native.getIndexValue(environment, f); | ||
| return visitor.visitBoundVariable(formula, deBruijnIdx); |
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.
Please note that visitBoundVariable() has recently been deprecated.
visitQuantifier() now returns the free variable equivalents for all bound variables and the body with all the bound variables re-substituted.
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 think this should probably be fixed together with the up-to-date z3 formula creator, and I'd prefer to leave this part as close in the two implementations as possible. LMK if you don't agree!
We want to use a uniform build-process and build-system, as the dependencies used when building may depend on the system used. Also, the scripts do everything more or less automatically anyway, including the upload. @kfriedberger knows more about the publishing, but it might be more work to re-use your binaries compared to executing a command. You have to remember that even for a fixed Z3 version, the libraries behind it might be updated from time to time! |
|
Thanks for the reviews and the answers! I'll get to fixing the code soon, but in the meantime, I prepared a patch: (i.e., the usual build command back in 4.5.0 times 😅 ) Besides the package rename, this also fixes some weird issue in the |
Old versions of z3 were really good at interpolation, and I want to add support for it in JavaSMT.
To this end, I've added the implementation of a
Z3Legacysolver (to be renamed, as discussed with @baierd), which builds on the 4.5.0 release of z3, rebuilt to usecom.microsoft.z3legacyas its package name to avoid name collisions with new z3.Pre-built binaries with the modifications are available at https://github.com/leventeBajczi/z3/releases/tag/legacy-4.3.0-15644597379, which Theta already uses like this. This should be somehow integrated into the solver management of JavaSMT, which I have no experience with.
To demonstrate how good this version of Z3 is, I ran some preliminary tests in CPAchecker, and found that an NLA encoding of programs using Z3 as the interpolation solver in the predicate analysis configuration results in 510 successfully solved tasks, which are otherwise unsolved by the bitprecise encoding of the same tasks with mathsat5.
Also, I found that #381 (which I opened) is referenced in 3 of the tests, that now failed on this implementation. I removed the overly constraining line which expected the constraint IDs to be unique, which is not necessary IMO if the interpolation problem reported in that issue is otherwise handled - which it seems to be.