-
Notifications
You must be signed in to change notification settings - Fork 73
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
negate #127
Comments
Victor, yes, negating a formula with auxiliary variables is non-trivial as you need to account for them when applying the negation. In the best-case scenario, you have a single Boolean variable To encode a not-equals constraint, you can use one at-most constraint and one at-least constraint. Say you want to encode not-equals- The simplest way (but not the best) to do this via the facilities provided by PySAT is to have these two constraints separately encoded into CNFs |
Alexey, Thank you. That was a help. I wonder if a function for disjunctions of formulas would be useful to have standard instead of making the user figure it out on their own. |
Good point. This should be more-or-less easy to implement as a method of class |
The following has been puzzling me for days, until I saw a subtlety. I wanted to generate a not equals constraint. So I took the clauses generated by
CardEnc.equals
, and fed them throughnegate
. Much to my surprise I found out that those clauses were satisfied by something which also satsified the equals clauses. Eventually I realized that the following occurred: Suppose thatF(X,Y)
is a formula, whereY
are auxilliary variables. It can happen that, for a given assignmentx
toX
that there are assignmentsy_1
andy_2
forY
so thatF(x,y_1)
is true, andF(x,y_2)
is false, so that using negate doesn't really effect the complement. So do you know of a not-equals constraint?After I posted this I thought that I could do this by using the OR of an atmost and an atleast. Alas that suffers from the same problem that I described above. The most immediate way to make a not equals constraint that I can think of would use a BDD and the Tseitin encoding. I'm sure that there are others.
So I cobbled together a BDD generation of the not equals constraint. Actually, in my problem, I wanted an OR of a bunch of these. Fortunately, in the Tseitin encoding of a BDD, the values of the auxilliary variables are all functions of the input variables, so that the anomaly that I noted above doesn't happen. So far it seems to be working.
The text was updated successfully, but these errors were encountered: