Set Difference is not Associative

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

The expression:


 * $\paren {R \setminus S} \setminus T = R \setminus \paren {S \setminus T}$

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

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 = \relcomp {\Bbb U} 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 \paren {S \setminus T} = \paren {\paren {R \setminus S} \setminus T} \cup \paren {R \cap T}$

It directly follows from Intersection with Empty Set that:


 * $R \setminus \paren {S \setminus T} = \paren {R \setminus S} \setminus T \iff R \cap T = \O$

Also see

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