For a set of binary variables X = {x1, x2, ..., xn} (n>=1). Lets define sum operation for simplicity: sum(X) = x1 + x2 + ... + xn
For another binary variable y, I want to write a constraint or more to represent this NOR behaviour:
if sum(X) = 0 then y = 1
if sum(X) > 0 then y = 0
I have achived this behaviour, but my solution needs an extra binary variable z that satisfies y + z = 1
By adding an extra variable I transformed my original requirement to OR gate.
if sum(X) = 0 then z = 0
if sum(X) > 0 then z = 1
My solution is:
0 <= n*z ā sum(X) <= nā1
y + z = 1
I need another solution that does not require an extra variable.
Mathematical representation of the constraint: 1 <= ny + sum(X) <= n
If any of the Xs are 1, then y has to be 0; if all of the Xs are 0, then y has to be 1.