# 4.3: Set Operations

- Page ID
- 19383

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

\( \newcommand{\Span}{\mathrm{span}}\)

\( \newcommand{\id}{\mathrm{id}}\)

\( \newcommand{\Span}{\mathrm{span}}\)

\( \newcommand{\kernel}{\mathrm{null}\,}\)

\( \newcommand{\range}{\mathrm{range}\,}\)

\( \newcommand{\RealPart}{\mathrm{Re}}\)

\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

\( \newcommand{\Argument}{\mathrm{Arg}}\)

\( \newcommand{\norm}[1]{\| #1 \|}\)

\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)

\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)

\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vectorC}[1]{\textbf{#1}} \)

\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)In this section, we’ll continue to develop the correspondence between Logic and Set theory.

The logical connectors \(∧\) and \(∨\) correspond to the set-theoretic notions of union \((∪)\) and intersection \((∩)\). The symbols are designed to provide a mnemonic for the correspondence; the Set theory symbols are just rounded versions of those from Logic.

Explicitly, if \(P(x)\) and \(Q(x)\) are open sentences, then the union of the corresponding truth sets \(S_P\) and \(S_Q\) is defined by

\[S_P ∪ S_Q = \{x ∈ U P(x) ∨ Q(x)\}.\]

Suppose two sets \(A\) and \(B\) are given. Re-express the previous definition of “union” using their membership criteria, \(M_A(x) = “x ∈ A”\) and \(M_B(x) = “x ∈ B.”\)

The union of more than two sets can be expressed using a big union symbol. For example, consider the family of real intervals defined by \(I_n = (n, n + 1]\).^{1} There’s an interval for every integer \(n\). Also, every real number is in one of these intervals. The previous sentence can be expressed as

\[\mathbb{R} = \bigcup_{n∈\mathbb{Z}} I_n.\]

The intersection of two sets is conceptualized as “what they have in common” but the precise definition is found by considering conjunctions,

\[A ∩ B = \{x ∈ U x ∈ A ∧ x ∈ B\}.\]

With reference to two open sentences \(P(x)\) and \(Q(x)\), define the intersection of their truth sets, \(S_P ∩ S_Q\).

There is also a “big” version of the intersection symbol. Using the same family of intervals as before,

\[∅ = \bigcap_{n∈\mathbb{Z}} I_n. \]

Of course, the intersection of any distinct pair of these intervals is empty so the statement above isn’t particularly strong.

Negation in Logic corresponds to complementation in Set theory. The complement of a set \(A\) is usually denoted by \(\overline{A}\) (although some prefer a superscript \(c\) – as in \(A^c\)), this is the set of all things that *aren’t* in \(A\). In thinking about complementation one quickly sees why the importance of working within a well-defined universal set is stressed. Consider the set of all math textbooks. Obviously, the complement of this set would contain texts in English, Engineering and Evolution – but that statement is implicitly assuming that the universe of discourse is “textbooks.” It’s equally valid to say that a very long sequence of zeros and ones, a luscious red strawberry, and the number \(\sqrt{\pi}\) are not math textbooks and so these things are all elements of the complement of the set of all math textbooks. What is really a concern for us is the issue of whether or not the complement of a set is well-defined, that is, can we tell for sure whether a given item is or is not in the complement of a set. This question is decidable exactly when the membership question for the original set is decidable. Many people think that the main reason for working within a fixed universal set is that we then have well-defined complements. The real reason that we accept this restriction is to ensure that both membership criteria, \(M_A(x)\) and \(M_{\overline{A}}(x)\), are decidable open sentences. As an example of the sort of strangeness that can crop up, consider that during the time that I, as the author of this book, was writing the last paragraph, this text was nothing more than a very long sequence of zeros and ones in the memory of my computer. . .

Every rule that we learned in Chapter 2 (see Table \(2.3.1\)) has a set-theoretic equivalent. These set-theoretic versions are expressed using equalities (i.e. the symbol \(=\) in between two sets) which is actually a little bit funny if you think about it. We normally use = to mean that two numbers or variables have the same numerical magnitude, as in \(12^2 = 144\), we are doing something altogether different when we use that symbol between two sets, as in \(\{1, 2, 3\} = \{ \sqrt{1}, \sqrt{4}, \sqrt{9}\}\), but people seem to be used to this so there’s no sense in quibbling.

Develop a useful definition for set equality. In other words, come up with a (quantified) logical statement that means the same thing as “\(A = B\)” for two arbitrary sets \(A\) and \(B\).

What symbol in Logic should go between the membership criteria \(M_A(x)\) and \(M_B(x)\) if \(A\) and \(B\) are equal sets?

In Table \(4.3.1\) the rules governing the interactions between the set-theoretic operations are collected.

We are now in a position somewhat similar to when we jumped from proving logical assertions with truth tables to doing two-column proofs. We have two different approaches for showing that two sets are equal. We can do a so-called “element chasing” proof (to show \(A = B\), assume \(x ∈ A\) and prove \(x ∈ B\) and then vice versa). Or, we can construct a proof using the basic set equalities given in Table \(4.3.1\). Often the latter can take the form of a two-column proof.

Table \(4.3.1\): Basic Set Theoretic Equalities | ||
---|---|---|

\(\cap\) | \(\cup\) | |

Commutative Laws | \(A \cap B = B \cap A\) | \(A \cup B = B \cup A\) |

Associative Laws | \(A \cap (B \cap C) = (A \cap B) \cap C\) | \(A \cup (B \cup C)= (A \cup B) \cup C\) |

Distributive Laws | \(A \cap (B \cup C) = (A \cap B) \cup (A \cap C)\) | \(A \cup (B \cap C) = (A \cup B) \cap (A \cup C)\) |

DeMorgan's Laws | \(\overline{A \cap B} = \overline{A} \cup \overline{B}\) | \(\overline{A \cup B} = \overline{A} \cap \overline{B}\) |

Double Complement | \(\overline{\overline{A}} = A\) | \(\text{same}\) |

Complementarity | \(A \cap \overline{A} = ∅\) | \(A \cup \overline{A} = U\) |

Identity Laws | \(A \cap U = A\) | \(A \cup ∅ = A\) |

Domination | \(A \cap ∅ = ∅\) | \(A \cup U = U\) |

Idempotence | \(A \cap A = A\) | \(A \cup A= A\) |

Absorption | \(A \cap (A \cup B) = A\) | \(A \cup (A \cap B) = A\) |

Before we proceed much further in our study of set theory it would be a good idea to give you an example. We’re going to prove the same assertion in two different ways — once via element chasing and once using the basic set-theoretic equalities from Table \(4.3.1\).

The statement we’ll prove is \(A ∪ B = A ∪ (A ∩ B)\).

First, by chasing elements:

*Proof: *Suppose \(x\) is an element of \(A ∪ B\). By the definition of union we know that

\(x ∈ A ∨ x ∈ B.\)

The conjunctive identity law and the fact that \(x ∈ A ∨ x \notin A\) is a tautology gives us an equivalent logical statement: \((x ∈ A ∨ x \notin A) ∧ (x ∈ A ∨ x ∈ B)\).

Finally, this last statement is equivalent to

\(x ∈ A ∨ (x \notin A ∧ x ∈ B)\)

which is the definition of \(x ∈ A ∪ (A ∩ B)\).

On the other hand, if we assume that \(x ∈ A ∪ (A ∩ B)\), it follows that

\(x ∈ A ∨ (x \notin A ∧ x ∈ B).\)

Applying the distributive law, disjunctive complementarity and the identity law, in sequence we obtain

\(\begin{array} x ∈ A ∨ (x \notin A ∧ x ∈ B) &\cong (x ∈ A ∨ x \notin A) ∧ (x ∈ A ∨ x ∈ B) \\ &\cong t ∧ (x ∈ A ∨ x ∈ B) \\ &\cong x ∈ A ∨ x ∈ B \end{array}\)

The last statement in this chain of logical equivalences provides the definition of \(x ∈ A ∪ B\).

Q.E.D.

A two-column proof of the same statement looks like this:

*Proof: *

\(A ∪ B \tag{Given} \)

\(= U ∩ (A ∪ B) \tag{Identity law} \)

\(= (A ∪ A) ∩ (A ∪ B) \tag{Complementarity}\)

\( = (A ∪ (A ∩ B) \tag{Distributive law}\)

Q.E.D.

There are some notions within Set theory that don’t have any clear parallels in Logic. One of these is essentially a generalization of the concept of “complements.” If you think of the set A as being the difference between the universal set \(U\) and the set \(A\) you are on the right track. The difference between two sets is written \(A \setminus B\) (sadly, sometimes this is denoted using the ordinary subtraction symbol \(A − B\)) and is defined by

\(A \setminus B = A ∩ \overline{B}.\)

The difference, \(A \setminus B\), consists of those elements of \(A\) that aren’t in \(B\). In some developments of Set theory, the difference of sets is defined first and then complementation is defined by \(A = U \setminus A\).

The difference of sets (like the difference of real numbers) is not a commutative operation. In other words \(A \setminus B \neq B \setminus A\) (in general). It is possible to define an operation that acts somewhat like the difference, but that is commutative. The **symmetric difference** of two sets is denoted using a triangle (really a capital Greek delta).

\[A \triangle B = (A \setminus B) ∪ (B \setminus A).\]

Show that \(A \triangle B = (A \cup B) \setminus (A \cap B).\)

Come on! You read right past that exercise without even pausing!

What? You say you did try it and it was too hard?

Okay, just for you (and this time only) I’ve prepared an aid to help you through. . .

On the next page is a two-column proof of the result you need to prove, but the lines of the proof are all scrambled. Make a copy and cut out all the pieces and then glue them together into a valid proof.

So, no more excuses, just do it!

\(= (A ∩ B) ∪ (B ∩ A)\) | Identity Law |

\(= (A ∪ B) ∩ (A ∩ B)\) | Def. of Relative Difference |

\((A ∪ B) \setminus (A ∩ B)\) | Given |

\(= ((A ∩ A) ∪ (A ∩ B)) ∪ ((B ∩ A) ∪ (B ∩ B))\) | Distributive Law |

\(= (A \setminus B) ∪ (B \setminus A)\) | Def. of Relative Difference |

\(= (A ∩ (A ∩ B)) ∪ (B ∩ (A ∩ B))\) | Distributive Law |

\(= A \triangle B\) | Def. of Relative Difference |

\(= (A ∩ (A ∪ B) ∪ (B ∩ (A ∪ B))\) | DeMorgan's Law |

\(= (∅ ∪ (A ∩ B)) ∪ ((B ∩ A) ∪ ∅)\) | Complementarity |

## Exercises:

Let \(A = \{1, 2, \{1, 2\}, b\}\) and let \(B = \{a, b, \{1, 2\}\}\). Find the following:

- \(A ∩ B\)
- \(A ∪ B\)
- \(A \setminus B\)
- \(B \setminus A\)
- \(A \triangle B\)

In a standard deck of playing cards, one can distinguish sets based on face-value and/or suit. Let \(A, 2, . . . 9, 10, J, Q\) and \(K\) represent the sets of cards having the various face-values. Also, let \(♥, ♠, ♣\) and \(♦\) be the sets of cards having the possible suits. Find the following

- \(A ∩ ♥\)
- \(A ∪ ♥\)
- \(J ∩ (♠ ∪ ♥)\)
- \(K ∩ ♥\)
- \(A ∩ K\)
- \(A ∪ K\)

The following is a screenshot from the computational geometry program OpenSCAD (very handy for making models for \(3\)-d printing. . . ) In computational geometry, we use the basic set operations together with a few other types of transformations to create interesting models using simple components. Across the top of the image below we see \(3\) sets of points in \(\mathbb{R}^3\), a ball, a sort of \(3\)-dimensional plus sign, and a disk. Let’s call the ball \(A\), the plus sign \(B\) and the disk \(C\). The nine shapes shown below them are made from \(A\), \(B\) and \(C\) using union, intersection and set difference. Identify them!

Do element-chasing proofs (show that an element is in the left-hand side if and only if it is in the right-hand side) to prove each of the following set equalities.

- \(A ∩ B = A ∪ B\)
- \(A ∪ B = A ∪ (A ∩ B)\)
- \(A \triangle B = (A ∪ B) \setminus (A ∩ B)\)
- \((A ∪ B) \setminus C = (A \setminus C) ∪ (B \setminus C)\)

For each positive integer \(n\), we’ll define an interval \(I_n\) by

\(I_n = [−n, \dfrac{1}{n}).\)

Find the union and intersection of all the intervals in this infinite family.

\( \bigcup_{n∈ \mathbb{Z}^+} I_n =\)

\( \bigcap_{n∈ \mathbb{Z}^+} I_n =\)

There is a set \(X\) such that, for all sets \(A\), we have \(X \triangle A = A\). What is \(X\)?

There is a set \(Y\) such that, for all sets \(A\), we have \(Y \triangle A = A\). What is \(Y\)?

In proving a set-theoretic identity, we are basically showing that two sets are equal. One reasonable way to proceed is to show that each is contained in the other. Prove that \(A ∩(B ∪ C) = (A ∩ B)∪(A ∩ C)\) by showing that \(A∩(B ∪ C) ⊆ (A∩B)∪(A∩ C) and (A∩B)∪(A∩ C) ⊆ A ∩ (B ∪ C)\).

Prove that \(A∪(B∩C) = (A∪B)∩(A∪C)\) by showing that \(A∪(B∩C) ⊆ (A ∪ B) ∩ (A ∪ C)\) and \((A ∪ B) ∩ (A ∪ C) ⊆ A ∪ (B ∩ C)\).

Prove the set-theoretic versions of DeMorgan’s laws using the technique discussed in the previous problems.

The previous technique (showing that \(A = B\) by arguing that \(A ⊆ B ∧ B ⊆ A\)) will have an outline something like

*Proof:* First we will show that \(A ⊆ B\).

Towards that end, suppose \(x ∈ A\). . . .

Thus \(x ∈ B\).

Now, we will show that \(B ⊆ A\).

Suppose that \(x ∈ B\). . . .

Thus \(x ∈ A\).

Therefore \(A ⊆ B ∧ B ⊆ A\) so we conclude that \(A = B\).

Q.E.D.

Formulate a proof that \(A \triangle B = (A ∪ B) \setminus (A ∩ B)\) that follows this outline.