Access to auxiliary variables in Tseytin transformation
acoader opened this issue · comments
Hello,
The auxiliary variables in Tseytin are non-independent variables, i.e. they are composed of the originals. How can one get access to this composition?
In other words, how can one verify equisatisfiability? (https://en.wikipedia.org/wiki/Tseytin_transformation#Approach)
Thanks.
I need to understand this better.
Let's just create a Tseytin transformation, and look at it closely:
# auxiliary variable context
>>> aux = Context()
>>> w, x, y, z = map(bx.get_var, 'wxyz')
>>> f = bx.xor(w, x, y, z)
>>> g = f.tseytin(aux)
>>> list(g.iter_sat())
[{a_0: 1, w: 1, x: 0, y: 0, z: 0},
{a_0: 1, w: 1, x: 1, y: 0, z: 1},
{a_0: 1, w: 1, x: 1, y: 1, z: 0},
{a_0: 1, w: 0, x: 1, y: 0, z: 0},
{a_0: 1, w: 0, x: 0, y: 0, z: 1},
{a_0: 1, w: 0, x: 0, y: 1, z: 0},
{a_0: 1, w: 1, x: 0, y: 1, z: 1},
{a_0: 1, w: 0, x: 1, y: 1, z: 1}]
So you can see that the 'a_0' variable is the auxiliary variable. It is not in the same context as variables w, x, y, z. In this particular example, equisatisfiability looks fine. But for more complicated examples you may need to do some filtering based on the variable names in the sat solutions.
Thanks for your response!
I will provide more detail.
To restate what I’m trying to do:
Let’s say we assign particular values to: w,x,y,z. Let’s say the value of original equation is 1 with this assignment.
How do we find out the aux values in corresponding tseytin equivalent ? One way is to iterate all points from tseytin.iter_sat() until we find the same w,x,y,z assignment. Then we can get a satisfying assignment for the remaining aux vars. But this technique does exhaustive iteration.
On the other hand if we know the equations for aux in terms of the original , we can simply find the aux values using restrict, for each aux. Does the question make sense?
Thanks.
Sorry for delayed response.
If you already have a satisfying assignment, I'm not sure what you need the auxiliary variable values for, but I don't think it's a problem. Here is what I would do:
>>> import boolexpr as bx
>>> ctx = bx.Context()
>>> w, x, y, z = map(ctx.get_var, 'wxyz')
>>> F = bx.xor(w, x, y, z)
>>> G = F.tseytin()
# One SAT model of 4-input XOR is {0, 0, 0, 1}
>>> G.restrict({w: 0, x: 0, y: 0, z: 1})
a_0
So you restrict the Tseytin transform for the particular known solution, and it will give you the assignments to all auxiliary variables. In this case, a_0=1
.
I am going to close this as "not a bug". Feel free to email me or ask more questions on StackOverflow.
On a related note, I agree that the current methodology for dealing with auxiliary variables is not sufficient. The current idea of a "context" seems slightly wrong. What we really need is nestable namespaces. All variables belong to a namespace, which all have parents up to a "null" namespace at the root of the tree. This might make it easier to deal with things like auxiliary variables. Unfortunately, it will have to remain just an idea for a while, as I have been too busy for hobby coding lately.