When do union and intersection commute?

They distribute but they don't commute.

To make things simple, suppose we have just four sets $A_{ij}, i=1\ldots 2, j=1\ldots 2$. On the left side you have $$ L = \bigcap_{m=1}^2 \bigcup_{n=1}^2 A_{mn} = (A_{11} \cup A_{12}) \cap (A_{21} \cup A_{22})$$ On the right you have $$ R = \bigcup_{n=1}^2 \bigcap_{m=1}^2 A_{mn} = (A_{11} \cap A_{21}) \cup (A_{12} \cap A_{22})$$ Using the distributive law in $L$ gives you $$ L = (A_{11} \cap A_{21}) \cup (A_{11} \cap A_{22}) \cup (A_{12} \cap A_{21}) \cup (A_{12} \cap A_{22})$$ So $R$ is missing the terms $A_{11} \cap A_{22}$ and $A_{12} \cap A_{21}$. In order for $L=R$, those must be contained in some of the terms that are present.

Similarly in the infinite case, the condition for equality is that $\bigcap_{m=1}^\infty A_{m,n_m} \subseteq \bigcup_{n} \bigcap_{m} A_{mn}$ for every sequence $n_1, n_2, \ldots$ of positive integers.


I know it is an old topic, but I was computing $\left(\bigcup_{i=1}^m A_i\right)\setminus\left(\bigcup_{j=1}^n B_j\right)$ and found something similar to this question. One can calculate $\left(\bigcup_{i=1}^m A_i\right)\setminus\left(\bigcup_{j=1}^n B_j\right)=\bigcap_{j=1}^n\left(\left(\bigcup_{i=1}^m A_i\right)\setminus B_j\right)=\bigcap_{j=1}^n \bigcup_{i=1}^m (A_i\setminus B_j)$. But one can also calculate $\left(\bigcup_{i=1}^m A_i\right)\setminus\left(\bigcup_{j=1}^n B_j\right)=\bigcup_{i=1}^m\left(A_i\setminus \bigcup_{j=1}^n B_j\right)=\bigcup_{i=1}^m\bigcap_{j=1}^n(A_i\setminus B_j)$. Then we conclude that $\bigcap_{j=1}^n \bigcup_{i=1}^m (A_i\setminus B_j)=\bigcup_{i=1}^m\bigcap_{j=1}^n(A_i\setminus B_j)$.