-
Notifications
You must be signed in to change notification settings - Fork 71
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
Fix Neg clausify #168
Fix Neg clausify #168
Conversation
I can't check this behaviour right now - will be back to my computer on Monday. But negation should return a clause if it is a highest level (outer most) term. |
I suppose this is caused by the use of the duplicate literal. I should have handled it properly and this is what requires a fix. I can't try it now without a computer but my guess is it will work if you consider a non-repeated |
If my guess is correct then fixing should be done by changing the condition for |
When listing the clauses Also, this could be extended to other classes.
|
I agree! |
So if you think you can reimplement the patch implementing these changes and taking into account that |
I fixed for Neg.
I will look for other classes too. |
Thanks! |
Should a single atom return itself as a clause when it is outermost? (basically a single atom formula)
|
add _clauses_tseitin
I finished to fix all classes.
This fix avoids all the inner/outermost clause problems and avoid recomputing clausification multiple times. I made edit: The build fails for python 3.11 and 3.12 only, I don't know why. |
But why do you need to have another variable for storing clauses? Why is Yes, |
It may not be important, but if you read the subformula clauses, you may get different results.
I aimed to have always the same results when called directly (still return Tseitin variables when called as a subformula)
|
I see what you mean. This makes sense although I feel somehow uneasy doubling the number of clauses. Do you make it work uniformly across all the formula types, including UPDATE: No worries, I can see now that |
I think I can make that only the requested clauses ( |
Well, re-encoding every time is a problem. 🙂 |
So I think it is a lesser evil to do the work once (although it spends more memory). |
I was thinking more as re-encoding twice at most. Once for |
Yes, but every time a sub-formula appears in a larger formula, you have to "re-tseitinize" it. |
But if we store the tseitin result inside |
My current solution was to keep the clauses representing a non-tseitinized (unnamed) variant of the clauses and then give it a name by applying Tseitin transformation on demand. You correctly pointed out that a user may want to consider clauses representing not only the most complex formula but also its specific sub-formulas, which requires one to keep both versions of the clauses after clausification or re-clausifying on the fly every time. I don't see how you can do it by keeping a single version only and encoding on the fly only once. |
In this case, there is no problem of re-encoding but there is a problem of a duplicate of the clauses. 🙂 |
There is a duplicate only if the user asks both regular clauses and tseistin clauses on the same formula. |
I could aim that clausifying a big formula gives the result without extra computing or memory. |
I presume this is what your current patch is doing? |
For the moment, it's doubling the memory, but I think I can achieve this goal relatively easily. |
But the thing is you never know if a user will need that clausal representation of the sub-formula. It is safer to keep it. |
They will have access to the tseitin clauses of subformula at no cost, but accessing the regular clause will add cost. To be fair I have now idea how regular users will use the code (I am not a SAT expert). The most common case can guide how the code is optimized for. |
I updated with the memory saving. The results seem convincing to me. And example to display the new behaviour:
|
This looks good, thank you! |
Just in case you will continue working on something related to these changes, I've renamed the variable |
Neg clausify is broken, it returns itself as a clause but I don't think it should ever do that.
An example:
This assume that all models contain -2, but [1, 2] is a valid model. (The correct clause should be only [1, -2, -2], without the [-2]).
I propose a fix where Neg clauses is always empty. An extra variable
clausified
is used to avoid multiple clausify of the subformula.