Skip to main content
Mathematics LibreTexts

1.2: Basic Set Operations

  • Page ID
  • \( \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}}} \)


    Definition \(\PageIndex{1}\): Intersection

    Let \(A\) and \(B\) be sets. The intersection of \(A\) and \(B\) (denoted by \(A \cap B\)) is the set of all elements that are in both \(A\) and \(B\text{.}\) That is, \(A \cap B = \{x:x \in A \textrm{ and } x \in B\}\text{.}\)

    Example \(\PageIndex{1}\): Some Intersections

    • Let \(A = \{1, 3, 8\}\) and \(B = \{-9, 22, 3\}\text{.}\) Then \(A \cap B = \{3\}\text{.}\)
    • Solving a system of simultaneous equations such as \(x + y = 7\) and \(x - y = 3\) can be viewed as an intersection. Let \(A = \{(x,y): x + y = 7, x,y \in \mathbb{R}\}\) and \(B = \{(x,y): x - y = 3, x,y\in \mathbb{R}\}\text{.}\) These two sets are lines in the plane and their intersection, \(A \cap B = \{(5, 2)\}\text{,}\) is the solution to the system.
    • \(\mathbb{Z}\cap \mathbb{Q}=\mathbb{Z}\text{.}\)
    • If \(A = \{3, 5, 9\}\) and \(B = \{-5, 8\}\text{,}\) then \(A\cap B =\emptyset\text{.}\)

    Definition \(\PageIndex{2}\): Disjoint Sets

    Two sets are disjoint if they have no elements in common. That is, \(A\) and \(B\) are disjoint if \(A \cap B = \emptyset\text{.}\)

    Definition \(\PageIndex{3}\): Union

    Let \(A\) and \(B\) be sets. The union of \(A\) and \(B\) (denoted by \(A \cup B\)) is the set of all elements that are in \(A\) or in \(B\) or in both A and B. That is, \(A\cup B= \{x:x \in A\textrm{ or } x\in B\}\text{.}\)

    It is important to note in the set-builder notation for \(A\cup B\text{,}\) the word “or” is used in the inclusive sense; it includes the case where \(x\) is in both \(A\) and \(B\text{.}\)

    Example \(\PageIndex{2}\): Some Unions

    • If \(A = \{2, 5, 8\}\) and \(B = \{7, 5, 22\}\text{,}\) then \(A \cup B = \{2, 5, 8, 7, 22\}\text{.}\)
    • \(\displaystyle \mathbb{Z}\cup \mathbb{Q}=\mathbb{Q}.\)
    • \(A \cup \emptyset = A\) for any set \(A\text{.}\)

    Frequently, when doing mathematics, we need to establish a universe or set of elements under discussion. For example, the set \(A = \{x : 81x^4 -16 = 0 \}\) contains different elements depending on what kinds of numbers we allow ourselves to use in solving the equation \(81 x^4 -16 = 0\text{.}\) This set of numbers would be our universe. For example, if the universe is the integers, then \(A\) is empty. If our universe is the rational numbers, then \(A\) is \(\{2/3, -2/3\}\) and if the universe is the complex numbers, then \(A\) is \(\{2/3, -2/3, 2i/3, - 2i/3\}\text{.}\)

    Definition \(\PageIndex{4}\): Universe

    The universe, or universal set, is the set of all elements under discussion for possible membership in a set. We normally reserve the letter \(U\) for a universe in general discussions.

    Operations and their Venn Diagrams

    When working with sets, as in other branches of mathematics, it is often quite useful to be able to draw a picture or diagram of the situation under consideration. A diagram of a set is called a Venn diagram. The universal set \(U\) is represented by the interior of a rectangle and the sets by disks inside the rectangle.

    Example \(\PageIndex{3}\): Venn Diagram Examples

    \(A \cap B\) is illustrated in Figure \(\PageIndex{1}\) by shading the appropriate region.

    A two set Venn Diagram for intersection consisting of two overlapping circles with the part of the plane that is contained in both circles shaded to represent the intersection.

    A two set Venn Diagram for intersection consisting of two overlapping circles with the part of the plane that is contained in both circles shaded to represent the intersection.clipboard_ebb4fc51683d20d35b0f6cc76faa8ff97.png
    Figure \(\PageIndex{1}\): Venn Diagram for the Intersection of Two Sets

    The union \(A \cup B\) is illustrated in Figure \(\PageIndex{2}\).

    clipboard_ec14b38b3a01048b637c7c34657ce22ad.pngFigure \(\PageIndex{2}\): Venn Diagram for the Union \(A \cup B\)

    In a Venn diagram, the region representing \(A \cap B\) does not appear empty; however, in some instances it will represent the empty set. The same is true for any other region in a Venn diagram.

    Definition \(\PageIndex{5}\): Complement of a Set

    Let \(A\) and \(B\) be sets. The complement of \(A\) relative to \(B\) (notation \(B - A\)) is the set of elements that are in \(B\) and not in \(A\text{.}\) That is, \(B-A=\{x: x\in B \textrm{ and } x\notin A\}\text{.}\) If \(U\) is the universal set, then \(U-A\) is denoted by \(A^c\) and is called simply the complement of \(A\text{.}\) \(A^c=\{x\in U : x\notin A\}\text{.}\)

    Figure \(\PageIndex{3}\): Venn Diagram for \(B - A\)

    Example \(\PageIndex{4}\): Some Complements

    1. Let \(U = \{1,2, 3, \text{...} , 10\}\) and \(A = \{2,4,6,8, 10\}\text{.}\) Then \(U-A = \{1, 3, 5, 7, 9\}\) and \(A - U= \emptyset\text{.}\)
    2. If \(U = \mathbb{R}\text{,}\) then the complement of the set of rational numbers is the set of irrational numbers.
    3. \(U^c= \emptyset\) and \(\emptyset ^c= U\text{.}\)
    4. The Venn diagram of \(B - A\) is represented in Figure \(\PageIndex{3}\).
    5. The Venn diagram of \(A^c\) is represented in Figure \(\PageIndex{4}\).
    6. If \(B\subseteq A\text{,}\) then the Venn diagram of \(A- B\) is as shown in Figure \(\PageIndex{5}\).
    7. In the universe of integers, the set of even integers, \(\{\ldots , - 4,-2, 0, 2, 4,\ldots \}\text{,}\) has the set of odd integers as its complement.
    Figure \(\PageIndex{4}\): Venn Diagram for \(A^{c}\)
    Figure \(\PageIndex{5}\): Venn Diagram for \(A-B\) when \(B\) is a subset of \(A\)

    Definition \(\PageIndex{6}\): Symmetric Difference

    Let \(A\) and \(B\) be sets. The symmetric difference of \(A\) and \(B\) (denoted by \(A\oplus B\)) is the set of all elements that are in \(A\) and \(B\) but not in both. That is, \(A \oplus B = (A \cup B) - (A \cap B)\text{.}\)

    Example \(\PageIndex{5}\): Some Symmetric Differences

    1. Let \(A = \{1, 3, 8\}\) and \(B = \{2, 4, 8\}\text{.}\) Then \(A \oplus B = \{1, 2, 3, 4\}\text{.}\)
    2. \(A \oplus \emptyset = A\) and \(A \oplus A = \emptyset\) for any set \(A\text{.}\)
    3. \(\mathbb{R} \oplus \mathbb{Q}\) is the set of irrational numbers.
    4. The Venn diagram of \(A \oplus B\) is represented in Figure \(\PageIndex{6}\).
    Figure \(\PageIndex{6}\): Venn Diagram for the symmetric difference \(A \oplus B\)

    SageMath Note: Sets

    To work with sets in Sage, a set is an expression of the form Set(list). By wrapping a list with Set( ), the order of elements appearing in the list and their duplication are ignored. For example, L1 and L2 are two different lists, but notice how as sets they are considered equal:

    [L1==L2, Set(L1)==Set(L2) ]

    The standard set operations are all methods and/or functions that can act on Sage sets. You need to evaluate the following cell to use the subsequent cell.


    We can test membership, asking whether 10 is in each of the sets:

    [10 in A, 10 in B]

    The ampersand is used for the intersection of sets. Change it to the vertical bar, |, for union.

    A & B

    Symmetric difference and set complement are defined as “methods” in Sage. Here is how to compute the symmetric difference of \(A\) with \(B\text{,}\) followed by their differences.



    Exercise \(\PageIndex{1}\)

    Let \(A = \{0, 2, 3\}\text{,}\) \(B = \{2, 3\}\text{,}\) \(C = \{1, 5, 9\}\text{,}\) and let the universal set be \(U = \{0, 1, 2, . . . , 9\}\text{.}\) Determine:

    1. \(\displaystyle A \cap B\)
    2. \(\displaystyle A \cup B\)
    3. \(\displaystyle B \cup A\)
    4. \(\displaystyle A \cup C\)
    5. \(\displaystyle A - B\)
    6. \(\displaystyle B - A\)
    7. \(\displaystyle A^c\)
    8. \(\displaystyle C^c\)
    9. \(\displaystyle A\cap C\)
    10. \(\displaystyle A\oplus B\)
    1. \(\displaystyle \{2,3\}\)
    2. \(\displaystyle \{0,2,3\}\)
    3. \(\displaystyle \{0,2,3\}\)
    4. \(\displaystyle \{0,1,2,3,5,9\}\)
    5. \(\displaystyle \{0\}\)
    6. \(\displaystyle \emptyset\)
    7. \(\displaystyle \{ 1,4,5,6,7,8,9\}\)
    8. \(\displaystyle \{0,2,3,4,6,7,8\}\)
    9. \(\displaystyle \emptyset\)
    10. \(\displaystyle \{0\}\)

    Exercise \(\PageIndex{2}\)

    Let \(A\text{,}\) \(B\text{,}\) and \(C\) be as in Exercise 1, let \(D = \{3, 2\}\text{,}\) and let \(E = \{2, 3, 2\}\text{.}\) Determine which of the following are true. Give reasons for your decisions.

    1. \(\displaystyle A = B\)
    2. \(\displaystyle B = C\)
    3. \(\displaystyle B = D\)
    4. \(\displaystyle E=D\)
    5. \(\displaystyle A\cap B = B\cap A\)
    6. \(\displaystyle A \cup B = B \cup A\)
    7. \(\displaystyle A-B = B-A\)
    8. \(\displaystyle A \oplus B = B \oplus A\)

    Exercise \(\PageIndex{3}\)

    Let \(U= \{1, 2, 3, . . . , 9\}\text{.}\) Give examples of sets \(A\text{,}\) \(B\text{,}\) and \(C\) for which:

    1. \(\displaystyle A\cap (B\cap C)=(A\cap B)\cap C\)
    2. \(\displaystyle A\cap (B\cup C)=(A\cap B)\cup (A\cap C)\)
    3. \(\displaystyle (A \cup B)^c= A^c\cap B^c\)
    4. \(\displaystyle A \cup A^c = U\)
    5. \(\displaystyle A \subseteq A\cup B\)
    6. \(\displaystyle A\cap B \subseteq A\)

    These are all true for any sets \(A\text{,}\) \(B\text{,}\) and \(C\text{.}\)

    Exercise \(\PageIndex{4}\)

    Let \(U= \{1, 2, 3, . . . , 9\}\text{.}\) Give examples to illustrate the following facts:

    1. If \(A \subseteq B\) and \(B \subseteq C\text{,}\) then \(A\subseteq C\text{.}\)
    2. There are sets \(A\) and \(B\) such that \(A - B \neq B - A\)
    3. If \(U = A\cup B\) and \(A \cap B = \emptyset\text{,}\) it always follows that \(A = U - B\text{.}\)

    Exercise \(\PageIndex{5}\)

    What can you say about \(A\) if \(U = \{1, 2, 3, 4, 5\}\text{,}\) \(B = \{2, 3\}\text{,}\) and (separately)

    1. \(\displaystyle A \cup B = \{1, 2, 3,4\}\)
    2. \(\displaystyle A \cap B = \{2\}\)
    3. \(\displaystyle A \oplus B = \{3, 4, 5\}\)
    1. \(\displaystyle \{1, 4\} \subseteq A \subseteq \{1, 2, 3, 4\}\)
    2. \(\displaystyle \{2\} \subseteq A \subseteq \{1, 2, 4, 5\}\)
    3. \(\displaystyle A = \{2, 4, 5\}\)

    Exercise \(\PageIndex{6}\)

    Suppose that \(U\) is an infinite universal set, and \(A\) and \(B\) are infinite subsets of \(U\text{.}\) Answer the following questions with a brief explanation.

    1. Must \(A^c\) be finite?
    2. Must \(A\cup B\) be infinite?
    3. Must \(A\cap B\) be infinite?

    Exercise \(\PageIndex{7}\)

    Given that \(U\) = all students at a university, \(D\) = day students, \(M\) = mathematics majors, and \(G\) = graduate students. Draw Venn diagrams illustrating this situation and shade in the following sets:

    1. evening students
    2. undergraduate mathematics majors
    3. non-math graduate students
    4. non-math undergraduate students


    Figure \(\PageIndex{7}\): Solution to Exercise \(\PageIndex{7}\) of Section 1.2.

    Exercise \(\PageIndex{8}\)

    Let the sets \(D\text{,}\) \(M\text{,}\) \(G\text{,}\) and \(U\) be as in exercise 7. Let \(\lvert U \rvert = 16,000\text{,}\) \(\lvert D \rvert = 9,000\text{,}\) \(|M|= 300\text{,}\) and \(\lvert G \rvert = 1,000\text{.}\) Also assume that the number of day students who are mathematics majors is 250, 50 of whom are graduate students, that there are 95 graduate mathematics majors, and that the total number of day graduate students is 700. Determine the number of students who are:

    1. evening students
    2. nonmathematics majors
    3. undergraduates (day or evening)
    4. day graduate nonmathematics majors
    5. evening graduate students
    6. evening graduate mathematics majors
    7. evening undergraduate nonmathematics majors

    This page titled 1.2: Basic Set Operations is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Al Doerr & Ken Levasseur via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.