Tutorials › Topology (Undergraduate) › Unions, Intersections, and Set Difference

Sets, Functions and Relations for Topology · Tutorial 3 of 799

Unions, Intersections, and Set Difference

Use membership conditions to calculate unions, intersections, and set differences, and check the results element by element.

Beginner 8 min read

What You'll Learn

  • Distinguish the membership tests for a union, an intersection, and a set difference.
  • Compute these operations for overlapping finite sets.
  • Track which elements belong to each set using a membership table.
  • Separate the elements of a set into those shared with another set and those not shared.
  • Recognize why reversing the order of a set difference can change the result.

Three Operations, Three Membership Tests

Sets can be combined by asking whether an element belongs to at least one of them, to both of them, or to one while being excluded from the other. These questions define union, intersection, and set difference. The most reliable way to calculate any of them is to test the membership condition for each candidate element.

Throughout, let \(X\) be an ambient set, and let \(A,B\subseteq X\). The ambient set gives a common collection of possible elements to examine. The results of the three operations are also subsets of \(X\).

Definition: The union \(A\cup B\) consists of the elements that belong to \(A\), to \(B\), or to both. The intersection \(A\cap B\) consists of the elements that belong to both \(A\) and \(B\). The set difference \(A\setminus B\) consists of the elements that belong to \(A\) and do not belong to \(B\).

In the union definition, “or” is inclusive: an element in both sets still belongs to the union, but appears only once because a set records membership, not repetitions. An intersection keeps only shared elements. A difference starts with its first set and removes any elements that also belong to the second set. In particular, the order in \(A\setminus B\) matters.

Theorem (Membership tests): For every \(x\in X\), \(x\in A\cup B\) if and only if \(x\in A\) or \(x\in B\); \(x\in A\cap B\) if and only if \(x\in A\) and \(x\in B\); and \(x\in A\setminus B\) if and only if \(x\in A\) and \(x\notin B\).

Proof. Each equivalence follows by unpacking the definition of the set on its left. By definition, membership in \(A\cup B\) means membership in at least one of \(A\) and \(B\), which is exactly the stated “or” condition. Membership in \(A\cap B\) means membership in each of \(A\) and \(B\), which is exactly the “and” condition. Finally, the definition of \(A\setminus B\) requires membership in \(A\) and exclusion from \(B\), giving \(x\in A\) and \(x\notin B\). Conversely, each of these conditions is precisely the defining membership condition for the corresponding set. \(\square\)

A Reliable Calculation Method

For finite sets, first list the elements that could be relevant, then test each one against the membership conditions. For a union, include an element if either test is yes. For an intersection, include it only if both tests are yes. For a difference \(A\setminus B\), include it only if the test for \(A\) is yes and the test for \(B\) is no. Do not count an element twice if it belongs to both sets.

Worked Example: Two Overlapping Finite Sets

Let \(X=\{1,2,3,4,5,6,7,8\}\), \(A=\{1,2,4,7\}\), and \(B=\{2,3,4,8\}\). Find \(A\cup B\), \(A\cap B\), \(A\setminus B\), and \(B\setminus A\).

Check the elements of \(X\) one at a time. The membership information is:

ElementIn \(A\)?In \(B\)?
1YesNo
2YesYes
3NoYes
4YesYes
5NoNo
6NoNo
7YesNo
8NoYes

The union includes every element with at least one “Yes,” so \(A\cup B=\{1,2,3,4,7,8\}\). The intersection includes only elements with “Yes” in both columns, so \(A\cap B=\{2,4\}\). For \(A\setminus B\), keep elements that are in \(A\) and not in \(B\), giving \(A\setminus B=\{1,7\}\). Reversing the roles gives \(B\setminus A=\{3,8\}\).

Check: The listed union contains the four elements of \(A\), namely \(1,2,4,7\), and the elements of \(B\) not already listed, namely \(3,8\). The intersection \(\{2,4\}\) is contained in each set. The elements \(1,7\) belong to \(A\) and not \(B\), while \(3,8\) belong to \(B\) and not \(A\), as required.

Reading Conditions in Set-Builder Notation

The same membership tests apply when a set is described by a condition rather than by listing its elements. For instance, to decide whether an integer belongs to a set defined by an inequality, substitute that integer into the inequality. Then apply the union, intersection, or difference test to the resulting membership answers.

Worked Example: Overlapping Sets of Integers

Let \(X=\mathbb{Z}\), \(A=\{n\in\mathbb{Z}:-2\leq n\leq 3\}\), and \(B=\{n\in\mathbb{Z}:0\leq n\leq 5\}\). Find the union, intersection, and both differences. The inequalities are inclusive, so their endpoints are included.

For \(A\), the integers from \(-2\) through \(3\), in order, are \(-2,-1,0,1,2,3\). Thus \(A=\{-2,-1,0,1,2,3\}\). For \(B\), the integers from \(0\) through \(5\) are \(0,1,2,3,4,5\). Thus \(B=\{0,1,2,3,4,5\}\).

Every element in either list belongs to the union, so \(A\cup B=\{-2,-1,0,1,2,3,4,5\}\). The elements that occur in both lists are \(0,1,2,3\), so \(A\cap B=\{0,1,2,3\}\). The elements in the list for \(A\) but not in the list for \(B\) are \(-2,-1\), giving \(A\setminus B=\{-2,-1\}\). The elements in the list for \(B\) but not in the list for \(A\) are \(4,5\), giving \(B\setminus A=\{4,5\}\).

Check: Each listed element of \(A\setminus B\) satisfies \(-2\leq n\leq3\) and fails \(0\leq n\leq5\). Each element of \(B\setminus A\) satisfies \(0\leq n\leq5\) and fails \(-2\leq n\leq3\). The shared elements \(0,1,2,3\) satisfy both inequalities, and the union lists all integers from \(-2\) through \(5\) without omissions.

How a Difference Splits a Set

A useful way to interpret \(A\setminus B\) is as the part of \(A\) left after the elements shared with \(B\) have been separated off. The next result makes that description precise. It also gives a check on difference calculations: the shared part and the part remaining in \(A\) together recover all of \(A\), and no element belongs to both parts.

Proposition: For any \(A,B\subseteq X\), the sets \(A\cap B\) and \(A\setminus B\) have no elements in common, and their union is \(A\).

Proof. First suppose \(x\in(A\cap B)\cap(A\setminus B)\). Membership in \(A\cap B\) gives \(x\in B\), while membership in \(A\setminus B\) gives \(x\notin B\). These two statements cannot both hold. Therefore there is no element in the intersection of the two sets.

For the union equality, take any \(x\in A\). If \(x\in B\), then \(x\in A\cap B\). If \(x\notin B\), then \(x\in A\setminus B\). In either case \(x\in(A\cap B)\cup(A\setminus B)\). This proves that every element of \(A\) belongs to that union. Conversely, membership in either \(A\cap B\) or \(A\setminus B\) includes the condition \(x\in A\), so every element of the union belongs to \(A\). The two sets are therefore equal. \(\square\)

Worked Example: Separating Shared and Unshared Elements

Let \(X=\{a,b,c,d,e,f\}\), \(A=\{a,b,d,e\}\), and \(B=\{b,c,e,f\}\). Use the proposition to split \(A\) into its shared and unshared parts.

Test the elements of \(A\) against \(B\). The element \(a\) is not in \(B\), so it belongs to \(A\setminus B\). The element \(b\) is in \(B\), so it belongs to \(A\cap B\). The element \(d\) is not in \(B\), so it belongs to \(A\setminus B\). The element \(e\) is in \(B\), so it belongs to \(A\cap B\). Hence \(A\cap B=\{b,e\}\) and \(A\setminus B=\{a,d\}\).

The union of these two parts is \(\{b,e\}\cup\{a,d\}=\{a,b,d,e\}=A\). They share no element: \(a,d\) are not among \(b,e\). This verifies both claims of the proposition for these sets.

A Common Mistake: Reversing a Difference

Set difference is not a way to report all elements that are different between two sets without specifying an order. In \(A\setminus B\), membership in \(A\) is required and membership in \(B\) is forbidden. In \(B\setminus A\), those roles are reversed. The two answers can differ, as the first worked example showed.

Common mistake. With \(A=\{1,2,4,7\}\) and \(B=\{2,3,4,8\}\), a wrong calculation might say \(A\setminus B=\{1,2,4,7\}\), on the grounds that all four listed elements belong to \(A\). This checks only half of the condition. The elements \(2\) and \(4\) also belong to \(B\), so they must be excluded. Applying both conditions gives \(A\setminus B=\{1,7\}\). Reversing the order instead gives \(B\setminus A=\{3,8\}\), not \(\{1,7\}\).

When checking any answer, choose an element claimed to be in the result and verify the relevant condition. For a union, verify membership in at least one input set; for an intersection, verify membership in both; for a difference, verify membership in the first set and nonmembership in the second. Also check that no candidate satisfying the condition has been left out.

Check Your Understanding

For each question, use the membership conditions directly and check the result against the given sets.

  1. Let \(A=\{0,1,3\}\) and \(B=\{1,2,3\}\). Find \(A\cup B\), \(A\cap B\), and \(A\setminus B\).
  2. Let \(A=\{n\in\mathbb{Z}:1\leq n\leq4\}\) and \(B=\{n\in\mathbb{Z}:3\leq n\leq6\}\). Find \(A\cap B\), \(A\setminus B\), and \(B\setminus A\).
  3. Explain why an element in \(A\cap B\) cannot also belong to \(A\setminus B\).
  4. Give finite sets \(A\) and \(B\) for which \(A\setminus B\neq B\setminus A\), and calculate both differences.