Set Difference is not Associative

Theorem
Let $R, S, T$ be sets.

The expression:


 * $\left({R \setminus S}\right) \setminus T = R \setminus \left({S \setminus T}\right)$

holds exactly when $R \cap T = \varnothing$.

Here $R \setminus S$ denotes set difference.

Thus, set difference is not associative.

Proof
We assume a universe $\mathbb U$ such that $R, S, T \subseteq \mathbb U$.

We have the identity Set Difference as Intersection with Complement:


 * $R \setminus S = R \cap \overline S$

where $\overline S$ is the set complement of $S$: $\overline S = \mathbb U \setminus S$.

Thus we can represent the two expressions as follows:

For the second:

As can be seen, this full expansion of the second expression can be expressed:


 * $R \setminus \left({S \setminus T}\right) = \left({\left({R \setminus S}\right) \setminus T}\right) \cup \left({R \cap T}\right)$

It directly follows from Intersection with Empty Set that:


 * $R \setminus \left({S \setminus T}\right) = \left({R \setminus S}\right) \setminus T \iff R \cap T = \varnothing$

Also see

 * Intersection is Associative
 * Union is Associative
 * Symmetric Difference is Associative