What is the order of operations for set complements?

229 Views Asked by At

Suppose I have something like:

$A\backslash B\backslash C$

Does that mean $(A\backslash B)\backslash C$ ,elements in A, but neither in B nor C

Or does it mean $A\backslash(B\backslash C)$ ,elements in A not in B, unless they are also in C

As always, creating such a construction is a bad idea, as it is always best to state what you mean clearly, but in what order would chained set complements be interpreted?

1

There are 1 best solutions below

1
On BEST ANSWER

I'm not sure, but it would make perfect sense to treat the relative complement operator as left-associative.

When we say $A - B - C$ for numbers, we never expect it to mean $A - (B - C)$, unless specifically written that way.

If you're defining it yourself, say in a programming language, then of course it depends on your intention, which should ideally reflect in your grammar.

<compl>$ \ \rightarrow$ <set> <compl-chain>

<compl-chain> $ \ \rightarrow$ \ <set> | \ <set> <compl-chain>

The parse tree for this grammar would be leaning to the right, so the most intuitive evaluation would be right-associative.