-
Notifications
You must be signed in to change notification settings - Fork 46
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
Formula with same string representation compares as unequal #315
Comments
On a broader note: we should have tests for this and some other basic cases. |
@baierd I looked into it and found: I added some tests, but as it was mentioned above, simplification is missing, so they fail for every solver, except |
Formula::toString can be exponentially (!) bad in runtime and memory consumption. This is no acceptable solution. |
Just as reminder, please take a look at the JavaDoc for Formula::equals : /**
* checks whether the other object is a formula of the same structure. Does not apply an expensive
* SAT-check to check equisatisfiability.
*
* <p>Two formulas that are structured in the same way, are determined as "equal". Due to
* transformations and simplifications, two equisatisfiable formulas with different structure
* might not be determined as "equal".
*/
@Override
boolean equals(Object other); Is it really true that JavaSMT does violate this rule for the given formulas? If really urgently required, we can use a FormulaVisitor to traverse formulas for equality in structure. |
I would say yes. The formulas have "the same structure" as we can see when we print them. I would also expect that traversing them yields the same structure (but I have not checked this). I would suggest to check why the usual memoization of formulas does not happen as expected inside Z3 here, and potentially file a bug for Z3, if it violates its promises. |
The following test fails with Z3:
(It also fails with some other solvers because JavaSMT is missing simplifications, but this is a different issue.)
The problem with Z3 is that both
bmgr.and(bmgr.and(var1, var2), bmgr.and(var3, var4))
andbmgr.and(var1, var2, var3, var4)
create the same formula, specifically(and var1 var2 var3 var4)
, but thatequals()
on these two instances returns false. Objects representing the same syntactic formula should compare as equal.(This even works in other cases. If I call
bmgr.and(bmgr.and(var1, var2), bmgr.and(var3, var4))
twice, I do get formula instances that compare as equal, just in the above case not.)The text was updated successfully, but these errors were encountered: