Post · 6 min read· pp. 24–32

1.2.2 Set Operations


Video Available Video Available

The union of two sets is a set containing all elements that are in AA or in BB (possibly both). For example, {1,2}∪{2,3}={1,2,3}\{1,2\}\cup\{2,3\}=\{1,2,3\}. Thus, we can write x∈(A∪B)x\in(A\cup B) if and only if (x∈A)(x\in A) or (x∈B)(x\in B). Note that A∪B=B∪AA \cup B=B \cup A. In Figure 1.4, the union of sets AA and BB is shown by the shaded area in the Venn diagram.

Union

Fig.1.4 - The shaded area shows the set B∪AB \cup A.

Similarly we can define the union of three or more sets. In particular, if A1,A2,A3,⋯ ,AnA_1, A_2, A_3,\cdots, A_n are nn sets, their union A1∪A2∪A3⋯∪AnA_1 \cup A_2 \cup A_3 \cdots \cup A_n is a set containing all elements that are in at least one of the sets. We can write this union more compactly by

⋃i=1nAi.\bigcup_{i=1}^{n} A_i.
For example, if A1={a,b,c},A2={c,h},A3={a,d}A_1=\{a,b,c\}, A_2=\{c,h\}, A_3=\{a,d\}, then $\bigcup_{i} A_i=A_1 \cup A_2 \cup A_3={a,b,c,h,d}$. We can similarly define the union of infinitely many sets A1∪A2∪A3∪⋯A_1 \cup A_2 \cup A_3 \cup\cdots.

The intersection of two sets AA and BB, denoted by A∩BA \cap B, consists of all elements that are both in AA and‾\underline{\textrm{and}} BB. For example, {1,2}∩{2,3}={2}\{1,2\}\cap\{2,3\}=\{2\}. In Figure 1.5, the intersection of sets AA and BB is shown by the shaded area using a Venn diagram.

Intersection

Fig.1.5 - The shaded area shows the set B∩AB \cap A.

More generally, for sets A1,A2,A3,⋯A_1,A_2,A_3,\cdots, their intersection ⋂iAi\bigcap_i A_i is defined as the set consisting of the elements that are in all AiA_i's. Figure 1.6 shows the intersection of three sets.

Intersection of 3 sets

Fig.1.6 - The shaded area shows the set A∩B∩CA \cap B \cap C.

The complement of a set AA, denoted by AcA^c or Aˉ\bar{A}, is the set of all elements that are in the universal set SS but are not in AA. In Figure 1.7, Aˉ\bar{A} is shown by the shaded area using a Venn diagram.

Complement

Fig.1.7 - The shaded area shows the set Aˉ=Ac\bar{A}=A^c.

The difference (subtraction) is defined as follows. The set A−BA-B consists of elements that are in AA but not in BB. For example if A={1,2,3}A=\{1,2,3\} and B={3,5}B=\{3,5\}, then A−B={1,2}A-B=\{1,2\}. In Figure 1.8, A−BA-B is shown by the shaded area using a Venn diagram. Note that A−B=A∩BcA-B=A \cap B^c.

Difference

Fig.1.8 - The shaded area shows the set A−BA-B.

Two sets AA and BB are mutually exclusive or disjoint if they do not have any shared elements; i.e., their intersection is the empty set, A∩B=∅A \cap B=\emptyset. More generally, several sets are called disjoint if they are pairwise disjoint, i.e., no two of them share a common element. Figure 1.9 shows three disjoint sets.

Disjoint sets

Fig.1.9 - Sets A,B,A, B, and CC are disjoint.

If the earth's surface is our sample space, we might want to partition it to the different continents. Similarly, a country can be partitioned to different provinces. In general, a collection of nonempty sets A1,A2,⋯A_1, A_2,\cdots is a partition of a set AA if they are disjoint and their union is AA. In Figure 1.10, the sets A1,A2,A3A_1, A_2, A_3 and A4A_4 form a partition of the universal set SS.

Partition

Fig.1.10 - The collection of sets A1,A2,A3A_1, A_2, A_3 and A4A_4 is a partition of SS.

Here are some rules that are often useful when working with sets. We will see examples of their usage shortly.


Theorem : De Morgan's law

For any sets A1A_1, A2A_2, ⋯\cdots, AnA_n, we have

  • (A1∪A2∪A3∪⋯An)c=A1c∩A2c∩A3c⋯∩Anc(A_1 \cup A_2 \cup A_3 \cup \cdots A_n)^c=A_1^c \cap A_2^c \cap A_3^c\cdots \cap A_n^c;
  • (A1∩A2∩A3∩⋯An)c=A1c∪A2c∪A3c⋯∪Anc(A_1 \cap A_2 \cap A_3 \cap \cdots A_n)^c=A_1^c \cup A_2^c \cup A_3^c\cdots \cup A_n^c.

Theorem : Distributive law

For any sets AA, BB, and CC we have

  • A∩(B∪C)=(A∩B)∪(A∩C)A \cap (B \cup C)=(A \cap B) \cup (A\cap C);
  • A∪(B∩C)=(A∪B)∩(A∪C)A \cup (B \cap C)=(A \cup B) \cap (A\cup C).

Example

If the universal set is given by S={1,2,3,4,5,6}S=\{1,2,3,4,5,6\}, and A={1,2}A=\{1,2\}, $B={2,4,5}, C={1,5,6} $ are three sets, find the following sets:

  1. A∪BA \cup B
  2. A∩BA \cap B
  3. A‾\overline{A}
  4. B‾\overline{B}
  5. Check De Morgan's law by finding (A∪B)c(A \cup B)^c and Ac∩BcA^c \cap B^c.
  6. Check the distributive law by finding A∩(B∪C)A \cap (B \cup C) and (A∩B)∪(A∩C)(A \cap B) \cup (A\cap C).
  • Solution
      1. A∪B={1,2,4,5}A \cup B=\{1,2,4,5\}.
      2. A∩B={2}A \cap B=\{2\}.
      3. A‾={3,4,5,6}\overline{A}=\{3,4,5,6\} (A‾\overline{A} consists of elements that are in SS but not in AA).
      4. B‾={1,3,6}\overline{B}=\{1,3,6\}.
      5. We have
        (A∪B)c={1,2,4,5}c={3,6},(A \cup B)^c=\{1,2,4,5\}^c=\{3,6\},
        which is the same as
        Ac∩Bc={3,4,5,6}∩{1,3,6}={3,6}.A^c \cap B^c=\{3,4,5,6\} \cap \{1,3,6\}=\{3,6\}.
      6. We have
        A∩(B∪C)={1,2}∩{1,2,4,5,6}={1,2},A \cap (B \cup C)=\{1,2\} \cap \{1,2,4,5,6\}=\{1,2\},
        which is the same as
        (A∩B)∪(A∩C)={2}∪{1}={1,2}.(A \cap B) \cup (A\cap C)=\{2\} \cup \{1\}=\{1,2\}.

A Cartesian product of two sets AA and BB, written as A×BA\times B, is the set containing ordered pairs from AA and BB. That is, if C=A×BC=A \times B, then each element of CC is of the form (x,y)(x,y), where x∈Ax \in A and y∈By \in B:

A×B={(x,y)∣x∈A and y∈B}.A \times B = \{(x,y) | x \in A \textrm{ and } y \in B \}.
For example, if A={1,2,3}A=\{1,2,3\} and B={H,T}B=\{H,T\}, then
A×B={(1,H),(1,T),(2,H),(2,T),(3,H),(3,T)}.A \times B=\{(1,H),(1,T),(2,H),(2,T),(3,H),(3,T)\}.
Note that here the pairs are ordered, so for example, (1,H)≠(H,1)(1,H)\neq (H,1). Thus A×BA \times B is not the same as B×AB \times A.

If you have two finite sets AA and BB, where AA has MM elements and BB has NN elements, then A×BA \times B has M×NM \times N elements. This rule is called the multiplication principle and is very useful in counting the numbers of elements in sets. The number of elements in a set is denoted by ∣A∣|A|, so here we write $|A|=M, |B|=N$, and ∣A×B∣=MN|A \times B|=MN. In the above example, ∣A∣=3,∣B∣=2|A|=3, |B|=2, thus ∣A×B∣=3×2=6|A \times B|=3 \times 2 = 6. We can similarly define the Cartesian product of nn sets A1,A2,⋯ ,AnA_1, A_2, \cdots, A_n as

A1×A2×A3×⋯×An={(x1,x2,⋯ ,xn)∣x1∈A1 and x2∈A2 and ⋯xn∈An}.A_1 \times A_2 \times A_3 \times \cdots \times A_n = \{(x_1, x_2, \cdots, x_n) | x_1 \in A_1 \textrm{ and } x_2 \in A_2 \textrm{ and }\cdots x_n \in A_n \}.
The multiplication principle states that for finite sets A1,A2,⋯ ,AnA_1, A_2, \cdots, A_n, if
∣A1∣=M1,∣A2∣=M2,⋯ ,∣An∣=Mn,|A_1|=M_1, |A_2|=M_2, \cdots, |A_n|=M_n,
then
∣A1×A2×A3×⋯×An∣=M1×M2×M3×⋯×Mn.\mid A_1 \times A_2 \times A_3 \times \cdots \times A_n \mid=M_1 \times M_2 \times M_3 \times \cdots \times M_n.

An important example of sets obtained using a Cartesian product is Rn\mathbb{R}^n, where nn is a natural number. For n=2n=2, we have

R2\mathbb{R}^2=R×R= \mathbb{R}\times \mathbb{R}
={(x,y)∣x∈R,y∈R}= \{(x,y) | x \in \mathbb{R}, y \in \mathbb{R} \}.

Thus, R2\mathbb{R}^2 is the set consisting of all points in the two-dimensional plane. Similarly, R3=R×R×R\mathbb{R}^3=\mathbb{R}\times \mathbb{R} \times \mathbb{R} and so on.