Simplify list of rules
Or @@ And @@@ r /. Rule -> Equal // LogicalExpand
To explain the other answerer's response, what you need to do is convert the rules into logical expressions, as a Rule
in the Wolfram Language just turns the left hand side into the right hand side. So the first step is to make all the Rule
s into Equal
s:
rules = {{a -> 0},{a -> 0, b -> 0}, {a -> 0, c -> 0}};
rules2 = ReplaceAll[rules, Rule -> Equal]
(*{{a == 0}, {a == 0, b == 0}, {a == 0, c == 0}}*)
ReplaceAll takes anything matching a given pattern, in this case Rule
, and replaces it with another expression, in this case Equal
Then you need to make this a logical And
expression, like this:
rules3 = Apply[And, rules2, {1}]
(*{a == 0, a == 0 && b == 0, a == 0 && c == 0}*)
Apply
changes the head of the second argument to the first argument. The third argument defines which level it happens on
Then you need to make the list into a logical Or
expression:
rules4 = Apply[Or, rules3]
(*a == 0 || (a == 0 && b == 0) || (a == 0 && c == 0)*)
Finally you use LogicalExpand
to convert this statement into it's simplest form:
LogicalExpand[rules4]
(*a == 0*)
The shorthand posted previously is from the shorthands of ReplaceAll
and Apply
.
@@
means Apply
@@@
means Apply
at level one
/.
means ReplaceAll
//
is suffix notation, so it does the right hand side on the left hand side.
Put together this makes the short version:
Or @@ And @@@ rules /. Rule -> Equal // LogicalExpand