Update: An alternative method inspired by Roman's answer:
f0 = Reduce[{# == 1, ##& @@ Equal @@@ #, ##& @@ Thread[0<=Variables[#]<=1]}, Integers]&;
f0[x y z + t u v + a b c]
(a == 0 && b == 0 && c == 0 && t == 0 && u == 0 && v == 0 && x == 1 &&
y == 1 && z == 1) ||
(a == 0 && b == 0 && c == 0 && t == 1 &&
u == 1 && v == 1 && x == 0 && y == 0 && z == 0) ||
(a == 1 &&
b == 1 && c == 1 && t == 0 && u == 0 && v == 0 && x == 0 &&
y == 0 && z == 0)
f0[x y + t u v + a b c d;]
(a == 0 && b == 0 && c == 0 && d == 0 && t == 0 && u == 0 && v == 0 &&
x == 1 && y == 1) ||
(a == 0 && b == 0 && c == 0 && d == 0 &&
t == 1 && u == 1 && v == 1 && x == 0 && y == 0) ||
(a == 1 &&
b == 1 && c == 1 && d == 1 && t == 0 && u == 0 && v == 0 &&
x == 0 && y == 0)
Original answer:
You can use the approach in this answer after pre-processing the input expression to replace Plus
with List
:
e1 = x y z + t u v + a b c;
l1 = e1 /. Plus -> List
{a b c, t u v, x y z}
Or @@ Inner[Sequence @@ Thread[Equal[List @@ #2, #]] &,
IdentityMatrix[Length@l1], l1, And]
(a == 1 && b == 1 && c == 1 && t == 0 && u == 0 && v == 0 && x == 0 &&
y == 0 && z == 0) ||
(a == 0 && b == 0 && c == 0 && t == 1 &&
u == 1 && v == 1 && x == 0 && y == 0 && z == 0) ||
(a == 0 &&
b == 0 && c == 0 && t == 0 && u == 0 && v == 0 && x == 1 &&
y == 1 && z == 1)
This approach works for arbitrary number of terms in the input expression and arbitrary number of variables in each term:
e2 = x y + t u v + a b c d;
l2 = e2 /. Plus -> List
{a b c d, t u v, x y}
Or @@ Inner[Sequence @@ Thread[Equal[List @@ #2, #]] &,
IdentityMatrix[Length@l2], l2, And]
(a == 1 && b == 1 && c == 1 && d == 1 && t == 0 && u == 0 && v == 0 &&
x == 0 && y == 0) ||
(a == 0 && b == 0 && c == 0 && d == 0 &&
t == 1 && u == 1 && v == 1 && x == 0 && y == 0) ||
(a == 0 &&
b == 0 && c == 0 && d == 0 && t == 0 && u == 0 && v == 0 &&
x == 1 && y == 1)