24.7 KB · commit a9602da
Two, or more, sets can be combined in many different ways. For instance, starting with the set of mathematics majors at your school and the set of computer science majors at your school, we can form the set of students who are mathematics majors or computer science majors, the set of students who are joint majors in mathematics and computer science, the set of all students not majoring in mathematics, and so on.
An element x belongs to the union of the sets A and B if and only if x belongs to A or x belongs to B. This tells us that A∪B={x∣x∈A∨x∈B}.
The Venn diagram shown in Figure 1 represents the union of two sets A and B. The area that represents A∪B is the shaded area within either the circle representing A or the circle representing B.
We will give some examples of the union of sets.
The union of the sets {1,3,5} and {1,2,3} is the set {1,2,3,5}; that is, {1,3,5}∪{1,2,3}={1,2,3,5}. ◀
The union of the set of all computer science majors at your school and the set of all mathematics majors at your school is the set of students at your school who are majoring either in mathematics or in computer science (or in both). ◀
An element x belongs to the intersection of the sets A and B if and only if x belongs to A and x belongs to B. This tells us that A∩B={x∣x∈A∧x∈B}.
![]() | ![]() |
|---|---|
| FIGURE 1 — Venn Diagram of the Union of A and B (Source: Page 127) | FIGURE 2 — Venn Diagram of the Intersection of A and B (Source: Page 127) |
The Venn diagram shown in Figure 2 represents the intersection of two sets A and B. The shaded area that is within both the circles representing the sets A and B is the area that represents the intersection of A and B.
We give some examples of the intersection of sets.
The intersection of the sets {1,3,5} and {1,2,3} is the set {1,3}; that is, {1,3,5}∩{1,2,3}={1,3}. ◀
The intersection of the set of all computer science majors at your school and the set of all mathematics majors is the set of all students who are joint majors in mathematics and computer science. ◀
Let A={1,3,5,7,9} and B={2,4,6,8,10}. Because A∩B=∅, A and B are disjoint. ◀
We are often interested in finding the cardinality of a union of two finite sets A and B. Note that ∣A∣+∣B∣ counts each element that is in A but not in B or in B but not in A exactly once, and each element that is in both A and B exactly twice. Thus, if the number of elements that are in both A and B is subtracted from ∣A∣+∣B∣, elements in A∩B will be counted only once. Hence, ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣.
The generalization of this result to unions of an arbitrary number of sets is called the principle of inclusion–exclusion. The principle of inclusion–exclusion is an important technique used in enumeration. We will discuss this principle and other counting techniques in detail in Chapters 6 and 8.
There are other important ways to combine sets.
Remark: The difference of sets A and B is sometimes denoted by A∖B.
An element x belongs to the difference of A and B if and only if x∈A and x∈/B. This tells us that A−B={x∣x∈A∧x∈/B}.
The Venn diagram shown in Figure 3 represents the difference of the sets A and B. The shaded area inside the circle that represents A and outside the circle that represents B is the area that represents A−B.
We give some examples of differences of sets.
The difference of {1,3,5} and {1,2,3} is the set {5}; that is, {1,3,5}−{1,2,3}={5}. This is different from the difference of {1,2,3} and {1,3,5}, which is the set {2}. ◀
The difference of the set of computer science majors at your school and the set of mathematics majors at your school is the set of all computer science majors at your school who are not also mathematics majors. ◀
![]() | ![]() |
|---|---|
| FIGURE 3 — Venn Diagram for the Difference of A and B (Source: Page 129) | FIGURE 4 — Venn Diagram for the Complement of the Set A (Source: Page 129) |
Once the universal set U has been specified, the complement of a set can be defined.
An element belongs to A if and only if x∈/A. This tells us that A={x∈U∣x∈/A}.
In Figure 4 the shaded area outside the circle representing A is the area representing A.
We give some examples of the complement of a set.
Let A={a,e,i,o,u} (where the universal set is the set of letters of the English alphabet). Then A={b,c,d,f,g,h,j,k,l,m,n,p,q,r,s,t,v,w,x,y,z}. ◀
Let A be the set of positive integers greater than 10 (with universal set the set of all positive integers). Then A={1,2,3,4,5,6,7,8,9,10}. ◀
It is left to the reader (Exercise 19) to show that we can express the difference of A and B as the intersection of A and the complement of B. That is, A−B=A∩B.
Table 1 lists the most important set identities. We will prove several of these identities here, using three different methods. These methods are presented to illustrate that there are often many different approaches to the solution of a problem. The proofs of the remaining identities will be left as exercises. The reader should note the similarity between these set identities and the logical equivalences discussed in Section 1.3. (Compare Table 6 of Section 1.6 and Table 1.) In fact, the set identities given can be proved directly from the corresponding logical equivalences. Furthermore, both are special cases of identities that hold for Boolean algebra (discussed in Chapter 12).
One way to show that two sets are equal is to show that each is a subset of the other. Recall that to show that one set is a subset of a second set, we can show that if an element belongs to the first set, then it must also belong to the second set. We generally use a direct proof to do this. We illustrate this type of proof by establishing the first of De Morgan’s laws.
| TABLE 1 Set Identities. | |
|---|---|
| Identity | Name |
| A∩U=A A∪∅=A | Identity laws |
| A∪U=U A∩∅=∅ | Domination laws |
| A∪A=A A∩A=A | Idempotent laws |
| (A)=A | Complementation law |
| A∪B=B∪A A∩B=B∩A | Commutative laws |
| A∪(B∪C)=(A∪B)∪C A∩(B∩C)=(A∩B)∩C | Associative laws |
| A∪(B∩C)=(A∪B)∩(A∪C) A∩(B∪C)=(A∩B)∪(A∩C) | Distributive laws |
| A∩B=A∪B A∪B=A∩B | De Morgan’s laws |
| A∪(A∩B)=A A∩(A∪B)=A | Absorption laws |
| A∪A=U A∩A=∅ | Complement laws |
Prove that A∩B=A∪B.
Solution: We will prove that the two sets A∩B and A∪B are equal by showing that each set is a subset of the other.
First, we will show that A∩B⊆A∪B. We do this by showing that if x is in A∩B, then it must also be in A∪B. Now suppose that x∈A∩B. By the definition of complement, x∈/A∩B. Using the definition of intersection, we see that the proposition ¬((x∈A)∧(x∈B)) is true.
By applying De Morgan’s law for propositions, we see that ¬(x∈A) or ¬(x∈B). Using the definition of negation of propositions, we have x∈/A or x∈/B. Using the definition of the complement of a set, we see that this implies that x∈A or x∈B. Consequently, by the definition of union, we see that x∈A∪B. We have now shown that A∩B⊆A∪B.
Next, we will show that A∪B⊆A∩B. We do this by showing that if x is in A∪B, then it must also be in A∩B. Now suppose that x∈A∪B. By the definition of union, we know that x∈A or x∈B. Using the definition of complement, we see that x∈/A or x∈/B. Consequently, the proposition ¬(x∈A)∨¬(x∈B) is true.
By De Morgan’s law for propositions, we conclude that ¬((x∈A)∧(x∈B)) is true. By the definition of intersection, it follows that ¬(x∈A∩B). We now use the definition of complement to conclude that x∈A∩B. This shows that A∪B⊆A∩B.
Because we have shown that each set is a subset of the other, the two sets are equal, and the identity is proved. ◀
We can more succinctly express the reasoning used in Example 10 using set builder notation, as Example 11 illustrates.
Use set builder notation and logical equivalences to establish the first De Morgan law A∩B=A∪B.
Solution: We can prove this identity with the following steps.
A∩B={x∣x∈/A∩B}={x∣¬(x∈(A∩B))}={x∣¬(x∈A∧x∈B)}={x∣¬(x∈A)∨¬(x∈B)}={x∣x∈/A∨x∈/B}={x∣x∈A∨x∈B}={x∣x∈A∪B}=A∪Bby definition of complementby definition of does not belong symbolby definition of intersectionby the first De Morgan law for logical equivalencesby definition of does not belong symbolby definition of complementby definition of unionby meaning of set builder notationNote that besides the definitions of complement, union, set membership, and set builder notation, this proof uses the second De Morgan law for logical equivalences. ◀
Proving a set identity involving more than two sets by showing each side of the identity is a subset of the other often requires that we keep track of different cases, as illustrated by the proof in Example 12 of one of the distributive laws for sets.
Prove the second distributive law from Table 1, which states that A∩(B∪C)=(A∩B)∪(A∩C) for all sets A, B, and C.
Solution: We will prove this identity by showing that each side is a subset of the other side.
Suppose that x∈A∩(B∪C). Then x∈A and x∈B∪C. By the definition of union, it follows that x∈A, and x∈B or x∈C (or both). In other words, we know that the compound proposition (x∈A)∧((x∈B)∨(x∈C)) is true. By the distributive law for conjunction over disjunction, it follows that ((x∈A)∧(x∈B))∨((x∈A)∧(x∈C)). We conclude that either x∈A and x∈B, or x∈A and x∈C. By the definition of intersection, it follows that x∈A∩B or x∈A∩C. Using the definition of union, we conclude that x∈(A∩B)∪(A∩C). We conclude that A∩(B∪C)⊆(A∩B)∪(A∩C).
Now suppose that x∈(A∩B)∪(A∩C). Then, by the definition of union, x∈A∩B or x∈A∩C. By the definition of intersection, it follows that x∈A and x∈B or that x∈A and x∈C. From this we see that x∈A, and x∈B or x∈C. Consequently, by the definition of union we see that x∈A and x∈B∪C. Furthermore, by the definition of intersection, it follows that x∈A∩(B∪C). We conclude that (A∩B)∪(A∩C)⊆A∩(B∪C). This completes the proof of the identity. ◀
Set identities can also be proved using membership tables. We consider each combination of sets that an element can belong to and verify that elements in the same combinations of sets belong to both the sets in the identity. To indicate that an element is in a set, a 1 is used; to indicate that an element is not in a set, a 0 is used. (The reader should note the similarity between membership tables and truth tables.)
Use a membership table to show that A∩(B∪C)=(A∩B)∪(A∩C).
Solution: The membership table for these combinations of sets is shown in Table 2. This table has eight rows. Because the columns for A∩(B∪C) and (A∩B)∪(A∩C) are the same, the identity is valid. ◀
Additional set identities can be established using those that we have already proved. Consider Example 14.
| TABLE 2 A Membership Table for the Distributive Property. | |||||||
|---|---|---|---|---|---|---|---|
| A | B | C | B∪C | A∩(B∪C) | A∩B | A∩C | (A∩B)∪(A∩C) |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Let A, B, and C be sets. Show that A∪(B∩C)=(C∪B)∩A.
Solution: We have
A∪(B∩C)=A∩(B∩C)=A∩(B∪C)=(B∪C)∩A=(C∪B)∩Aby the first De Morgan lawby the second De Morgan lawby the commutative law for intersectionsby the commutative law for unions.◀
Because unions and intersections of sets satisfy associative laws, the sets A∪B∪C and A∩B∩C are well defined; that is, the meaning of this notation is unambiguous when A, B, and C are sets. That is, we do not have to use parentheses to indicate which operation comes first because A∪(B∪C)=(A∪B)∪C and A∩(B∩C)=(A∩B)∩C. Note that A∪B∪C contains those elements that are in at least one of the sets A, B, and C, and that A∩B∩C contains those elements that are in all of A, B, and C. These combinations of the three sets, A, B, and C, are shown in Figure 5.
FIGURE 5 — The Union and Intersection of A, B, and C (Source: Page 132)
Let A={0,2,4,6,8}, B={0,1,2,3,4}, and C={0,3,6,9}. What are A∪B∪C and A∩B∩C?
Solution: The set A∪B∪C contains those elements in at least one of A, B, and C. Hence, A∪B∪C={0,1,2,3,4,6,8,9}. The set A∩B∩C contains those elements in all three of A, B, and C. Thus, A∩B∩C={0}. ◀
We can also consider unions and intersections of an arbitrary number of sets. We introduce these definitions.
We use the notation A1∪A2∪⋯∪An=i=1⋃nAi to denote the union of the sets A1,A2,…,An.
We use the notation A1∩A2∩⋯∩An=i=1⋂nAi to denote the intersection of the sets A1,A2,…,An. We illustrate generalized unions and intersections with Example 16.
For i=1,2,…, let Ai={i,i+1,i+2,…}. Then, i=1⋃nAi=i=1⋃n{i,i+1,i+2,…}={1,2,3,…}, and i=1⋂nAi=i=1⋂n{i,i+1,i+2,…}={n,n+1,n+2,…}=An. ◀
We can extend the notation we have introduced for unions and intersections to other families of sets. In particular, we use the notation A1∪A2∪⋯∪An∪⋯=i=1⋃∞Ai to denote the union of the sets A1,A2,…,An,…. Similarly, the intersection of these sets is denoted by A1∩A2∩⋯∩An∩⋯=i=1⋂∞Ai.
More generally, when I is a set, the notations ⋂i∈IAi and ⋃i∈IAi are used to denote the intersection and union of the sets Ai for i∈I, respectively. Note that we have i∈I⋂Ai={x∣∀i∈I(x∈Ai)}andi∈I⋃Ai={x∣∃i∈I(x∈Ai)}.
Suppose that Ai={1,2,3,…,i} for i=1,2,3,…. Then, i=1⋃∞Ai=i=1⋃∞{1,2,3,…,i}={1,2,3,…}=Z+ and i=1⋂∞Ai=i=1⋂∞{1,2,3,…,i}={1}.
To see that the union of these sets is the set of positive integers, note that every positive integer n is in at least one of the sets, because it belongs to An={1,2,…,n}, and every element of the sets in the union is a positive integer. To see that the intersection of these sets is the set {1}, note that the only element that belongs to all the sets A1,A2,… is 1. To see this note that A1={1} and 1∈Ai for i=1,2,…. ◀
There are various ways to represent sets using a computer. One method is to store the elements of the set in an unordered fashion. However, if this is done, the operations of computing the union, intersection, or difference of two sets would be time-consuming, because each of these operations would require a large amount of searching for elements. We will present a method for storing elements using an arbitrary ordering of the elements of the universal set. This method of representing sets makes computing combinations of sets easy.
Assume that the universal set U is finite (and of reasonable size so that the number of elements of U is not larger than the memory size of the computer being used). First, specify an arbitrary ordering of the elements of U, for instance a1,a2,…,an. Represent a subset A of U with the bit string of length n, where the ith bit in this string is 1 if ai belongs to A and is 0 if ai does not belong to A. Example 18 illustrates this technique.
Let U={1,2,3,4,5,6,7,8,9,10}, and the ordering of elements of U has the elements in increasing order; that is, ai=i. What bit strings represent the subset of all odd integers in U, the subset of all even integers in U, and the subset of integers not exceeding 5 in U?
Solution: The bit string that represents the set of odd integers in U, namely, {1,3,5,7,9}, has a one bit in the first, third, fifth, seventh, and ninth positions, and a zero elsewhere. It is 10 1010 1010. (We have split this bit string of length ten into blocks of length four for easy reading.) Similarly, we represent the subset of all even integers in U, namely, {2,4,6,8,10}, by the string 01 0101 0101. The set of all integers in U that do not exceed 5, namely, {1,2,3,4,5}, is represented by the string 11 1110 0000. ◀
Using bit strings to represent sets, it is easy to find complements of sets and unions, intersections, and differences of sets. To find the bit string for the complement of a set from the bit string for that set, we simply change each 1 to a 0 and each 0 to 1, because x∈A if and only if x∈/A. Note that this operation corresponds to taking the negation of each bit when we associate a bit with a truth value—with 1 representing true and 0 representing false.
We have seen that the bit string for the set {1,3,5,7,9} (with universal set {1,2,3,4,5,6,7,8,9,10}) is 10 1010 1010. What is the bit string for the complement of this set?
Solution: The bit string for the complement of this set is obtained by replacing 0s with 1s and vice versa. This yields the string 01 0101 0101, which corresponds to the set {2,4,6,8,10}. ◀
To obtain the bit string for the union and intersection of two sets we perform bitwise Boolean operations on the bit strings representing the two sets. The bit in the ith position of the bit string of the union is 1 if either of the bits in the ith position in the two strings is 1 (or both are 1), and is 0 when both bits are 0. Hence, the bit string for the union is the bitwise OR of the bit strings for the two sets. The bit in the ith position of the bit string of the intersection is 1 when the bits in the corresponding position in the two strings are both 1, and is 0 when either of the two bits is 0 (or both are). Hence, the bit string for the intersection is the bitwise AND of the bit strings for the two sets.
The bit strings for the sets {1,2,3,4,5} and {1,3,5,7,9} are 11 1110 0000 and 10 1010 1010, respectively. Use bit strings to find the union and intersection of these sets.
Solution: The bit string for the union of these sets is 11 1110 0000∨10 1010 1010=11 1110 1010, which corresponds to the set {1,2,3,4,5,7,9}. The bit string for the intersection of these sets is 11 1110 0000∧10 1010 1010=10 1010 0000, which corresponds to the set {1,3,5}. ◀