3. Set Theory

This chapter was last updated on February 10, 2025.
Contents locked until 11:59 p.m. Pacific Standard Time on May 23, 2025.

Set theory, along with logic, is the foundation of mathematics in our time. In earlier eras, people tried to use arithmetic (e.g., counting and whole numbers) and geometry (e.g., measurement of lengths, areas, and volumes along with geometric constructions) as the foundations of all mathematics. However, over the last two centuries, mathematicians gained new understandings of issues with these traditional foundations which led them to seek a new, firmer foundation. For now, that firmer foundation uses set theory: The study of collections of objects and how those collections can be combined, associated, and themselves added to other collections.
NOTE: If you want to dig much more deeply into what the issues with using arithmetic or geometry as the foundation of mathematics are, you can start with this Wikipedia page which includes a a brief description of the "foundational crisis of mathematics."

Key terms and concepts covered in this chapter:

  • Sets

    • Subsets of a set

    • The empty set

    • The power set of a set

    • Cartesian products

  • Venn diagrams

  • Cardinality and countability of finite and infinite sets

    • Set cardinality and counting

  • Operations with sets: Union, intersection, complement, and others

    • DeMorgan’s laws

    • Inclusion-exclusion principle

3.1. Sets

A set is an unordered collection of objects, called elements or members . A set is said to contain its elements.

If \(x\) is an element of the set \(S,\) then we write \(x \in S\). If \(x\) is not an element of the set \(S\), then we write \(x \not\in S\). For example, if \(S\) is the set of names of states in the United States of America, then “New York” is an element of \(S\) and “Ontario” is not an element of \(S,\) that is \[ \text{“New York”} \in S \text{ and } \text{“Ontario”} \not\in S. \] As another example, if \(E\) is the set of even integers, then \(2 \in E\) and \(3 \not\in E.\)

3.1.1. Describing A Set: The Roster Method

One way of describing a set is the roster method: List all the elements of the set between curly braces. For example, \[A = \{1,-2,0,1,-3\} \] is the set whose elements are \(-3,\) \(-2,\) \(0,\) and \(1.\)

  • Notice that the set \(A\) contains exactly \(4\) elements, even though the element \(1\) appears twice in the roster - duplicate entries do not matter.

  • Also, the order of the elements in the list does not matter. That is, \(\{-3,-2,0,1 \}\) and \(\{0, 1,-2,-3\}\) are two more ways of describing the same set \(A.\)

Example 1 - Checking Set Membership in Python

The code below checks to see if \(5\) and \(0\) are elements of the set \(A = \{1,-2,0,1,-3\}.\) Since \(5 \not\in A\) and \(0 \in A,\) the code prints False followed by True.

Example 2 - Listing the Elements of a Set in Python

The code below lists all of the elements of the set \(A = \{1,-2,0,1,-3\}.\)

Notice that 1 appears in the set once even though it appears in the roster twice.

A WARNING ABOUT THE PYTHON EXAMPLES INVOLVING SETS : The mathematical set \(A = \{1,-2,0,1,-3\}\) is a constant - you cannot change the set by removing elements or inserting new elements. However, Python objects of type set are mutable so it is possible to remove elements or insert new elements, as shown in the following code example. The mathematically correct implementation of sets in Python uses objects of type frozenset because objects of type frozenset are immutable, just like mathematical sets. But there are advantages to using type set instead of frozenset : The roster method notation can be used to initialize or print a Python set , but cannot be used with a Python frozenset : You must call the frozenset constructor to create and initialize a frozenset . The authors of the original “Discrete Math” chose to use Python sets instead of frozensets in the code examples; the author of this remix made the same choice.

WARNING: Python Sets Are Mutable, Mathematical Sets Are "Frozen"

The mathematical set \(A\) does not allow removals or insertions, but the Python set \(A\) does. The frozenset \(F\) is a more faithful implementation of the mathematical set \(A\), but notice that the symbolism for Python sets more closely matches the symbolism used for mathematical sets.

3.1.2. Describing A Set: Set Builder Notation

Another way of describing a set is the use of set builder notation. We write a set as \[\{x \in D : P(x)\}.\] This is the set of all elements \(x\) from a domain \(D\) that satisfy the predicate \(P(x).\) We can use either the colon \(:\) or the vertical bar \(|\) as the separator in this notation. For example, \(\{ x \in \mathbb{N} \, | \, x^{2} \leq 50 \}\) is the set of natural numbers that are less than \(\sqrt{50}.\)

Yet another way of describing a set is to use a function or an algebraic expression, as in \[\{ f(x) : x \in D \}.\]This is the set of all values \(f(x)\) for \(x\) in the domain \(D\). For example, \(\{ 2n : n \in \mathbb{N} \}\) is the set of the even natural numbers. Again, we can use either the colon \(:\) or the vertical bar \(|\) as the separator.

Example 3 - Set Builder Notation in Python

The set \(\{x \in D: P(x)\}\) can be expressed in Python as {for x in D if P(x)}. For example, the code below defines the set \(B\) as the set of positive elements of the set \(A = \{1,-2,0,1,-3\}.\)

3.1.3. Describing A Set: Special Sets Of Numbers

You may already be familiar with the following sets of numbers, which are listed here for reference.

Special sets of numbers
  • \(\mathbb{N} = \{0, 1, 2, 3,...\}\), the set of natural numbers

  • \(\mathbb{Z} = \{...,-2, -1, 0, 1, 2,...\}\) , the set of integers

  • \(\mathbb{Z}^+ = \{1, 2, 3,...\}\), the set of positive integers

  • \(\mathbb{Q} = \left\{\left.\frac{a}{b}\right|a\in \mathbb{Z},b\in \mathbb{Z},b\neq 0\right\}\), the set of rational numbers

  • \(\mathbb{Q}^+\), the set of positive rational numbers

  • \(\mathbb{R}\), the set of real numbers

  • \(\mathbb{R}^+\), the set of positive real numbers

  • \(\mathbb{C} = \{a+bi : a\in \mathbb{R},b\in \mathbb{R},b\neq 0,i^{2}=-1\}\), the set of complex numbers.

Other special sets will be defined as needed.

3.1.4. Describing A Set: Switching Between Representations

A set can usually be described in more than one way, as shown in the following example.

Example 4 - Switching between representations

Consider the following set: \[\{x \in \mathbb{Z} : -2 \leq x < 4\}.\] This is the set of all integers \(x\) such that \(-2\) is less than or equal \(x\) and \(x\) is less than 4. Using the roster method, this set can be written as \[\{-2,-1,0,1,2,3\}.\]

You Try

Match each set described using set builder notation in parts (a) through (f) with the same set described using the roster method in parts (A) through (F).

  1. \(\{x \in \mathbb{Z} : x^2 = 1\}\)

  2. \(\{x \in \mathbb{Z} : x^3 = 1\}\)

  3. \(\{x \in \mathbb{Z} : |x| \leq 2\}\)

  4. \(\{x \in \mathbb{Z} : x^2 < 4\}\)

  5. \(\{x \in \mathbb{Z} : x < |x|\}\)

  6. \(\{x \in \mathbb{Z} : (x + 1)^2 = x^2 + 2x + 1\}\)

  1. \(\{-1,0,1\}\)

  2. \(\{\dots, -3,-2,-1,0,1,2,3,\dots\}\)

  3. \(\{1\}\)

  4. \(\{\dots, -3,-2,-1\}\)

  5. \(\{-1,1\}\)

  6. \(\{-2,-1,0,1,2\}\)

When there are too many elements in a set for us to be able to list each one, we often use ellipses (\(\dots\)) when the pattern is obvious. For example, we have \[\mathbb{Z} = \{\dots,-3,-2,-1,0,1,2,3,\dots\}.\]

3.2. Equality Of Sets

We say that two sets are equal if and only if they contain the same elements. When \(A\) and \(B\) are equal sets, we write \(A = B\). When \(A\) and \(B\) are not equal sets, we write \(A \neq B\).

The three sets \(\{2,3,5,7\},\) \(\{5,2,7,3\},\) and \(\{x \in \mathbb{N} : x \text{ is prime and } x < 10 \}\) are equal sets because they contain the same elements. In fact, \(\{2,3,5,7\},\) \(\{5,2,7,3\},\) and \(\{x \in \mathbb{N} : x \text{ is prime and } x < 10 \}\) are really just three different descriptions of the same set, in the same way that \(1 + 3,\) \(5 - 1,\) and \(2^{2}\) are three different descriptions of the same number, 4. The extended equality \[\{2,3,5,7\} = \{5,2,7,3\} = \{x \in \mathbb{N} : x \text{ is prime and } x < 10 \}\] is a true statement for the same reason the extended equality \(1 + 3 = 5 - 1 = 2^{2}\) is a true statement.
Note: You may be used to using the equal sign "=" as if it means "simplifies to" in your previous math experience, but "=" actually means "represents the same thing as."

3.3. The Empty Set

Consider the set of all natural numbers whose square is equal to 2, described using set builder notation: \(\{x \in \mathbb{N} : x^2 = 2\}.\) If you use the roster method to list all the elements you will get the set \(\{ \}\) because there are no natural numbers whose square is equal to 2!

The set \(\{ \}\) is called the empty set, or the null set. The symbol \(\emptyset\) is used to represent the empty set, too, that is, \[ \emptyset = \{ \}. \]

Example 5 - Listing the Elements of a Nonempty Set

To define the empty set in Python, we must call the constructor set(). Python interprets the empty curly braces {} as an empty object of type dict , called a dictionary, that is used to represent mappings of key:value pairs.

The function in the code below checks to see if a set is empty. If the set is nonempty, its elements are listed.

It is important to note that \(\{\}\) and \(\emptyset\) are both ways to write the empty set. However, the mathematical set \(\{ \emptyset \}\) is not the empty set because it contains one element, namely the empty set. In general, the set \(A\) is not the same as the set \(\{ A \}.\)

Python Tip: The mathematical set \(\{ \emptyset \}\) must be implemented as \(\{ \text{frozenset()} \}\), which is the Python set that contains the empty frozenset . In general, anytime we want to implement a mathematical set \(B\) as an element of another mathematical set \(A\) in Python, we need to implement \(B\) as a frozenset in order to be used as an element of the Python set \(A\). This is due to the fact that elements of Python sets must be hashable ; further explanation is beyond the scope of this textbook.

3.4. Subsets of a Set

Suppose \(A\) and \(B\) are two sets, and that every element \(x\) of the set \(A\) is also an element of set \(B.\) We say that \(A\) is a subset of a set \(B,\) and write \(A \subseteq B\). If a set \(C\) is not a subset of \(B,\) we write \(C \not\subseteq B\).

If \(A \subseteq B\) but \(B\) contains at least one element that is not in A, then \(A\) is called a proper subset of \(B\), denoted \(A \subset B\). That is, \(A\) is a proper subset of \(B\) if it is a subset of \(B\) but is not equal to \(B.\)

Example 6

Suppose that we have three sets \(R = \{1,5\},\) \(S = \{1,3,5\},\) and \(T = \{1,4,7\}.\)

  • \(R \subseteq S,\) since each element \(x\) of \(R\) also is an element of \(S.\)

  • \(R \subset S\) since \(3\) is an element of \(S\) but is not an element of \(R.\)

  • \(S \not\subseteq T\) since \(3\) is an element of \(S\) but is not an element of \(T.\) Likewise, \(T \not\subseteq S\) since \(4\) is an element of \(t\) but is not an element of \(S.\)

Theorem

For any set \(A\) \[\emptyset \subseteq A\] \[A \subseteq A\]

For any sets \(A\) and \(B\) \[ A = B \text{ if and only if both } A \subseteq B \text{ and } B \subseteq A\]

Example 7 - Subsets in Python

In Python, we can check whether a set \(A\) is a subset of a set \(B\) in one of the following ways:

A.issubset(B)
A <= B.

3.5. The Power Set of a Set

Given a set \(A,\) we can define a new set by collecting together all subsets of \(A\). This new set is called the power set of \(A.\) The power set of \(A\) is denoted by \(\mathcal{P}(A).\) That is, \[ \mathcal{P}(A) = \{ B \, | \, B \subseteq A \}. \] Notice that \(\mathcal{P}(A)\) is a set whose elements are themselves sets.

Example 8 - The Power Set Of A Set

Suppose that \(A = \{0,1,2\},\) then \[\mathcal{P}(A) = \{\emptyset, \{ 0 \}, \{ 1 \}, \{ 2 \}, \{0,1\}, \{0,2\}, \{1,2\}, \{0,1,2\}\}.\] Notice that the empty set is an element of \(\mathcal{P}(A)\) along with all the other subsets of \(A.\)

The empty set has only one subset, namely itself. Thus, we see that \[\mathcal{P}(\emptyset) = \{\emptyset\}.\]

We can also find the power set of a power set. For example, we have the following:

\[\begin{split} \mathcal{P}(\{ 3 \}) &= \{\emptyset, \{ 3 \}\},\\ \\ \mathcal{P}(\mathcal{P}(\{ 3 \}) &= \mathcal{P}(\{\emptyset, \{ 3 \})\\ &= \{\emptyset, \{\emptyset\}, \{ \{ 3 \} \}, \{\emptyset, \{ 3 \}\}\}. \end{split}\]

3.6. Cartesian Products

The Cartesian product of two sets \(A\) and \(B\) is the set of ordered pairs defined by,

\( A\times B=\{(a,b) \, | \, a\in A \text{ and } b\in B)\}\),

Example 9

Consider the sets, \(B=\{0,1\}\), \(T=\{0,1,2\}\), and, \(C=\{a,\ b,\ c, d\}\). Determine how many elements are in each set using the product rule, and verify by writing out each set using the roster method.

  1. \(B\ \times\ C\)

  2. \(C\times B\)

  3. \(B\ \times\ T\)

  4. \(B\ \times\ B\)

  5. \(B\ \times\ B\ \times B\)

Solution

For the set, \( B\ \times C \), notice that this will be all ordered pairs of the form, \((a,b)\), with \(a \in B\), and \(b \in C\), giving,

\(B\ \times\ C=\{(0,a), (0,b), (0,c), (0,d),(1,a), (1,b), (1,c), (1,d))\}\), which has \(2 × 4=8\), elements.

For \(C\ \times\ B\), switch the ordering, for \(B\ \times\ C\), to obtain the set with \(8\), elements,

\(C\ \times B=\{(a,0), (b,0), (c,0),(d,0),(a,1), (b,1), (c,1), (d,1)\}\),

The set \(B \times T\), will be all ordered pairs of the form, \((a,b)\), with \(a \in B\), and \(b \in T\), giving, the set with \(2 × 3=6\), elements,

\(B \times T=\{(0,0),(0,1),(0,2),(1,0),(1,1),(1,2)\}\),

The set \(B \times B\), will be all order pairs of the form, \((a,b)\), with \(a, b \in B\), giving the set with \(2 × 2=4\), elements,

\(B \times T=\{(0,0),(0,1),(1,0),(1,1)\}\),

Finally the set \(B \times B \times B\), will be the set of all ordered triples of the form, \((a,b,c)\), with \(a, b, c \in B\), giving the set with \(2 × 2 × 2=8\), elements,

\(B \times B \times B=\{(0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0),(1,1,1)\}\),

Cartesian products are created using ordered pairs, so if \(A\) and \(B\) are different sets, then \(A \times B\) is different from \(B \times A\).

The Cartesian coordinate systems are Cartesian products.

The two-dimensional \(xy\)-plane is represented by \(\mathbb{R}^2=\mathbb{R}\times \mathbb{R}=\{(x,y)|x,y\in \mathbb{R}\}\), and, the three-dimensional \(xyz\)-space are represented by \(\mathbb{R}^3=\mathbb{R}\times \mathbb{R}\times \mathbb{R}=\{(x,y,z)|x,y,z\in \mathbb{R}\}\)

3.7. Cardinality Of Sets: Finite Sets

Cardinality is the formalization of the idea of the count of the number of elements in a set.
In this section, we will prefer counting from 1 instead of 0. You will see below why this makes no difference.

Set \(A\) is called a finite set if either

  • \(A\) is the empty set or

  • there is a one-to-one correspondence between \(A\) and the set \(\{ i \in \mathbb{N} \, | \, 0 < i \leq n \} = \{1, 2, \ldots , n \}\) for some positive integer \(n.\)

FingersToNumerals

This definition of "finite set" may seem abstract, but it’s just a formal description of what is likely the way you learned to count when you were young: You matched objects with number names (that is, numerals) as shown in the image.

04to15

The cardinality of a finite set \(A,\) denoted by \(|A|,\) is

  • 0 if \(A = \emptyset\) or

  • the value of \(n\) for which there is a one-to-one correspondence between \(A\) and \(\{1, 2, \ldots , n \}.\)

For a finite set \(A\) the cardinality \(|A|\) is just the number of elements in the set. The image shows that \(|\{0,1,2,3,4\}| = 5.\)

Example 10 - Cardinality of Finite Sets in Python

The cardinality of a finite set \(A\) can be computed in Python as follows:

len(A)

Example 11

Suppose that \(A\) and \(B\) are finite sets.

  • The cardinality of the Cartesian product \(A × B\) is \(|A × B|=|A| \cdot |B|\).

  • The cardinality of the power set of \(A\) is \(\left|\mathcal{P}(A)\right| = 2^{|A|}.\)

Challenge
Give informal arguments to justify each of the two bulleted statements.
Hint
Your arguments can use some of the rules introduced in Counting: Arithmetic Techniques chapter
Answer
For the Cartesian product, the elements of \(A × B\) are ordered pairs of the form \((x,y)\) where \(x\in A\) and \(y\in B.\) There are \(|A|\) choices for the first coordinate, and for each of those choices there are \(|B|\) choices for the second coordinate. Use the product rule to conclude that there are \(|A| \cdot |B|\) different ways to choose an ordered pair, so that \(|A × B|=|A| \cdot |B|.\)

For the power set of \(A,\) to choose a subset of \(A\) you must decide for each of the \(|A|\) elements in \(A\) whether to include that element in the subset. There are 2 choices for each element, so using the product rule repeatedly you can conclude that there are \((2)(2)\cdots(2)\) ways to choose a subset, where the number of factors of \(2\) is \(|A|\). So \(\left|\mathcal{P}(A)\right| = 2^{|A|}.\) You can also think of this as counting all possible bitstrings of length \(n,\) where a 1 bit means "include the corresponding element" and a 0 bit means "omit the corresponding element."

3.8. Venn Diagrams

A Venn diagram, named after the English mathematician John Venn, consists of one or more circles, with each circular region representing a set. An example can be seen here.

We write the elements of a set within the circular region that represents the set; anything written outside the circular region is not an element of the set. If an element is written in the overlap of two or more regions, then it is an element of each of the sets.

The circles are often drawn inside a larger rectangle which represents a universal set \(U\) that we are focusing on. In the example linked above, the rectangle was omitted because every glyph was an element of at least one of the sets represented by a circular region, but if we introduced addition glyphs like ہ we would need to draw the rectangle because that glyph would need to be written outside all three circular regions.

VennVsEulerDiagrams

In this textbook, a Venn diagram must show all the possible overlaps of the sets. This is consistent with Venn’s paper from 1880.
That is, you should NOT be able to answer the question "Is x an element of set A? " when x is written in the circular region for a different set, B. In the image, the upper right example shows a Venn diagram because you could write x in the overlap of the two regions or you could write x in the the part of the region for B that is outside the circular region for A. The lower two diagrams are not Venn diagrams: In either one of those, if x is written in the region for set B, it must be true that x is not an element of A (on the lower left) or that x is an element of A (the example on the lower right). Diagrams like the lower two examples will be called Euler diagrams in this textbook.
Some sources use the term Venn diagram for all four of the examples shown in the image, but you should always assume when reading this textbook that the lower two are NOT Venn diagrams. Click here to see the light!

3.9. Set Operations

We can obtain new sets by performing operations on other sets. When performing set operations, it is often helpful to consider all of our sets as subsets of a universal set \(U.\) We can think of the universal set as the set of all of the objects under consideration.

We can represent set operations visually using Venn diagrams.

3.9.1. Union

The union of the sets \(A\) and \(B\) is the set containing those elements that are in \(A\) or \(B\) or both, and is denoted by \(A \cup B\). More formally, \[A \cup B = \{x \in U : x \in A \text{ or } x \in B\}.\]

Note that "or" is read here as the "inclusive or". We have the following Venn Diagram for \(A \cup B\):

Union

Note that, for any sets \(A\) and \(B,\) \[A \cup B = B \cup A.\]

Example 12

If we let \(A = \{1,2,3,4,5,6\}\) and \(B = \{1,3,5,7,9\},\) then \[A \cup B = \{1,2,3,4,5,6,7,9\}.\]

Example 13 - Union in Python

In Python, we can compute the union of sets \(A\) and \(B\) in one of the following ways:

A.union(B)
A | B

3.9.2. Intersection

The intersection of the sets \(A\) and \(B\) is the set containing those elements that are in \(A\) and \(B\) and is denoted by \(A \cap B\). More formally, \[A \cap B = \{x \in U : x \in A \text{ and } x \in B\}.\]

We have the following Venn Diagram for \(A \cap B\):

Intersection

Note that, for any sets \(A\) and \(B,\) \[A \cap B = B \cap A.\] If it is the case that \(A \cap B = \emptyset,\) then we say that \(A\) and \(B\) are disjoint . In other words, two sets are disjoint if and only if they contain no elements in common.

Example 14

If we let \(A = \{1,2,3,4,5,6\}\) and \(B = \{1,3,5,7,9\},\) then \[A \cap B = \{1,3,5\}.\]

Example 15 - Intersection in Python

In Python, we can compute the intersection of sets \(A\) and \(B\) in one of the following ways:

A.intersection(B)
A & B

3.9.3. Complement

The complement of a set \(A\) is the set of all elements in the universal set \(U\) which are not elements of \(A\) and is denoted by \(\overline{A}.\) More formally, \[\overline{A} = \{x \in U: x \not\in A\}.\] Note that other textbooks and internet sources may use different notation for the complement of \(A\), such as \(A'\) and \(A^{c}\), but these all stand for the same set, so that \(\overline{A} = A' = A^{c}\).

We have the following Venn Diagram for \(\overline{A}\):

ComplementA

For any set \(A,\) \[ \overline{\overline{A}} = A \] \[ \overline{A} \cup A = U \] \[ \overline{A} \cap A = \emptyset. \]

Example 16

Suppose that our universal set is \(U = \{0,1,2,3,4,5,6,7,8,9\},\) the set of all decimal digits. If we let \(A = \{1,2,3,4,5,6\}\) and \(B = \{1,3,5,7,9\},\) then \[\overline{A} = \{0,7,8,9\}\] and \[\overline{B} = \{0,2,4,6,8\}.\]

Example 17

Suppose that our universal set is \(\mathbb{Z}.\) If we let \(E\) be the set of all even integers, then \(\overline{E}\) is the set of all odd integers.

3.9.4. Other Operations

The three operators complement, intersection, and union are the most commonly used to define subsets of a universal set. You will see why this is so later in the chapter.

However, there are some other operators you should be familiar with.

Difference

The difference of the sets \(A\) and \(B\) is the set containing those elements that are in \(A\) but not in \(B\) and is denoted by \(A \setminus B\). Set difference is also denoted by \(A - B\). More formally, \[A \setminus B = \{x \in U: x \in A \text{ and } x \not\in B\}.\]

We have the following Venn Diagram for \(A \setminus B\):

A Subtract B

Note that, for any sets \(A\) and \(B\), if \(A \neq B,\) then \[A \setminus B \neq B \setminus A.\] However, if \(A = B,\) then \(A\setminus B = B \setminus A = \emptyset\).

Example 18

If we let \(A = \{1,2,3,4,5,6\}\) and \(B = \{1,3,5,7,9\},\) then \[A \setminus B = \{2,4,6\}\] and \[B \setminus A = \{7,9\}.\]

Example 19 - Difference in Python

In Python, we can compute the difference of sets \(A\) and \(B\) in one of the following ways:

A.difference(B)
A - B

Symmetric Difference

The symmetric difference of the sets \(A\) and \(B\) is the set containing those elements that are in \(A\) or \(B\) but not both \(A\) and \(B\). It is denoted by \(A \oplus B\) in this textbook, but other books and sources may use different notation such as \(A \Delta B\). More formally, \[A \oplus B = \{x \in U: (x \in A \text{ and } x \not\in B) \text{ or } (x \in B \text{ and } x \not\in A)\}.\]

We have the following Venn Diagram for \(A \oplus B\):

A symdif B

Note that, for any sets \(A\) and \(B,\) \[A \oplus B = B \oplus A.\]

Example 20

If we let \(A = \{1,2,3,4,5,6\}\) and \(B = \{1,3,5,7,9\},\) then \[A \oplus B = \{2,4,6,7,9\}.\]

Example 21 - Symmetric Difference in Python

In Python, we can compute the difference of sets \(A\) and \(B\) in one of the following ways:

A.symmetric_difference(B)
A ^ B

3.9.5. Multiple Set Operations

We can also perform more than one set operation on a collection of sets. For example, let \(A,\) \(B,\) and \(C\) be sets and consider the following set: \[(A \setminus B) \cup (C \setminus B).\]This is the set that is obtained by taking the union of the sets \(A \setminus B\) and \(C \setminus B.\) We have \[(A \setminus B) \cup (B \setminus A) = \{x \in U: (x \in A \text{ and } x \not\in B) \text{ or } (x \in C \text{ and } x \not\in B)\}.\]

We have the following Venn Diagram for \((A \setminus B) \cup (C \setminus B)\):

AminusBunionCminusB

Note that the Venn Diagram also represents \((A \cup C ) \setminus B\). In general, there are multiple ways to describe the result of multiple set operations.

Video Examples

The following two video examples feature Dr. Katherine Pinzon, Professor of Mathematics at Georgia Gwinnett College.

Video Example 1

Video Example 2

You Try

Draw Venn Diagrams for each of these combinations of the sets \(A\), \(B\), and \(C\).

  1. \(A \cap (B \cup C)\)

  2. \((A \cap B) \cup C\)

  3. \((\overline{A} \cap \overline{C}) \cup B\)

  4. \((B \cup C) \setminus A\)

3.10. Set Identities

Here is a collection of additional properties of the operations on sets. Each of these can be verified by drawing two Venn diagrams, one that represents the left-hand side of the equation and another that represents the right-hand side of the equation and showing that the resulting shadings of the Venn diagrams are the same.

Note that it is traditional to focus on complement, union, and intersection as the three primary set operations because the other operations such as difference and symmetric difference can be written in terms of those three primary operations, for example, \(A \setminus B = A \cap \overline{B}\) and \(A \oplus B = (A \cap \overline{B}) \cup (\overline{A} \cap B)\).

Associative laws: \[ A ∪ (B ∪ C) = (A ∪ B) ∪ C \] \[ A ∩ (B ∩ C) = (A ∩ B) ∩ C \]

Distributive laws: \[ A ∪ (B ∩ C) = (A ∪ B) ∩(A ∪ C) \] \[ A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) \]

De Morgan’s laws: \[ \overline{A \cup B} = \overline{A} \cap \overline{B} \] \[ \overline{A \cap B} = \overline{A} \cup \overline{B} \]

3.10.1. Operator Precedence (Order Of Operations)

To ensure that we can properly interpret an expression involving multiple set operations, we can either use parentheses or rely on operator precedence .

When an expression for sets involves parentheses, complementation, intersection, and union, we start by evaluating all expressions enclosed in parentheses from left to right, then all complementations from left to right, then all intersections from left to right, and finally all unions from left to right. (Set difference and symmetric difference were left out of this discussion because there does not seem to be a standard definition for where they fit in! But, as shown earlier, those two operations can be rewritten in terms of complementation, union, and intersection.)

For example, the expression \(\overline{A} \cup B \cap C\) represents the same set as \((\overline{A}) \cup (B \cap C)\). Parentheses must be used if you want to represent a different set such as \((\overline{A} \cup B) \cap C\).

This is the same way arithmetic expressions like \(-3 + 5 \cdot 2\) are evaluated: The value of \(-3 + 5 \cdot 2\) is \((-3) + (5 \cdot 2) = 7\), not \((-3 + 5) \cdot 2 = 4\).

3.11. Venn Diagrams, Partitions, and Bitstrings

A partition of a set \(U\) is a set of subsets of \(U\) such that each element \(x \in U\) is a member of exactly one of the subsets in the partition.

As an example you already know, one partition of the set of integers \(\mathbb{Z}\) is the set of subsets \[\{ \text{the set of even integers}, \text{the set of odd integers} \}\] Notice that every integer \(n\) belongs to exactly one of the two elements of this set.

As another example, for any subset \(A \subseteq U\) you have a partition of \(U\) into the 2 sets that are elements of \[\{ A,\,\overline{A} \}\] Note that each element of \(U\) must be in exactly one of the subsets \(A\) and \(\overline{A}\).

For two subsets \(A\) and \(B\) of a universal set \(U\), consider the Venn diagram of \(A\) and \(B\). Notice that, by considering all possible intersections of these two sets and their complements, \(U\) is partitioned into 4 subsets, namely, the 4 elements of \[\{ \overline{A} \cap \overline{B},\, \overline{A} \cap B,\,A \cap \overline{B},\,A \cap B \}\] We can refer to each of these 4 subsets by using bitstrings of length 2 as follows:

  • The leftmost bit is 1 if an element of the subset is an element of \(A\), and is 0 if an element of the subset is not an element of \(A\).

  • The rightmost bit is 1 if an element of the subset is an element of \(B\), and is 0 if an element of the subset is not an element of \(B\).

For example, in the following Venn diagram, the subset \(A \cap \overline{B}\) is labeled with the bitstring \(10\) because an element of \(A \cap \overline{B}\) is an element of \(A\) and not an element of \(B\).

ABbitstrings

If you had instead three subsets \(A\), \(B\), and \(C\) of the universal set \(U,\) you could partition the universe \(U\) into 8 subsets. In detail, if you have an element \(x \in U\), either \(x \in A\) or \(x \not\in A\), and for each of those possibilities, either \(x \in B\) or \(x \not\in B\), and for each of those possibilities, either \(x \in C\) or \(x \not\in C\). We can apply (twice) the multiplication principle that was first mentioned in chapter 2 to show that there are \(2 \cdot 2 \cdot 2\) possible subsets determined by the Venn diagrams of the 3 sets \(A\), \(B\), and \(C\). Using bitstrings of length 3, we can label these 8 subsets as shown.

ABCbitstrings

For an integer \(n > 3\), the Venn diagram is less useful for representing the partitioning of the universe created by \(n\) subsets, but we can still reason that there ought to be \(2^{n}\) subsets in the partition, where each of the subsets can be described by a unique bitstring of length \(n\) (We will be able give a formal mathematical proof of this for every positive integer \(n\) later in the textbook after we’ve discussed mathematical induction.)

3.11.1. Disjunctive Normal Form (Set Version)

Suppose you have three sets \(A\), \(B\), and \(C\), and have partitioned the universe \(U\) into the 8 subsets as discussed above. A subset of \(U\) that corresponds to any shading of the Venn diagram can be written as a union of intersections of three sets, with one set chosen from each of the pairs \(\{ A,\,\overline{A} \}\), \(\{ B,\,\overline{B} \}\), and \(\{ C,\,\overline{C} \}\).

ABC DNF EXAMPLE

As an example, consider the set shown in the image, which has 4 of the 8 regions of the Venn diagram shaded:

  • \(\overline{A} \cap \overline{B} \cap \overline{C}\) which is the region outside of all three sets,

  • \(A \cap \overline{B} \cap \overline{C},\) the region in set \(A\) but in neither \(B\) nor \(C,\)

  • \(\overline{A} \cap B \cap \overline{C},\) the region in set \(B\) but in neither \(A\) nor \(C,\)

  • \(\overline{A} \cap B \cap C,\) the region in both \(B\) and \(C\) but not in \(A.\)

Write the union of these 4 subsets to create an expression that describes the entire shaded region. \[(\overline{A} \cap \overline{B} \cap \overline{C}) \cup (A \cap \overline{B} \cap \overline{C}) \cup (\overline{A} \cap B \cap \overline{C}) \cup (\overline{A} \cap B \cap C)\]

This type of expression is called a disjunctive normal form (or DNF) for the set that it represents. We will see an analog of these in a different context in the chapter on Logic.

The advantage of using the DNF is that you can write out an expression for the shaded subset using a simple algorithm. The DNF may be neither the shortest possible expression nor the most easily understood expression for the shaded part of the Venn diagram, but the DNF is a correct expression for the shaded subset.

3.12. The Principle Of Inclusion-Exclusion (PIE)

In certain application problems, we want to compute the cardinality \(|A \cup B|\) of the union of two given finite sets \(A\) and \(B\). It is tempting to simply add \(|A|\) and \(|B|\), but as the Venn diagram below shows, each element of the intersection \(|A \cap B|\) will be counted twice , once for each bit that is \(1\), if we do so.

ABbitstrings

The correct relationship between \(|A \cup B|\), \(|A|\), and \(|B|\) is given by \[ |A \cup B| = |A| + |B| - |A \cap B|. \]

Another way to see that this is the correct relationship is to use the partition \(\{ \overline{A} \cap \overline{B},\, \overline{A} \cap B,\,A \cap \overline{B},\,A \cap B \}\) to write

\(| A | = | A \cap \overline{B} | + | A \cap B |\),
\(| B | = | \overline{A} \cap B | + | A \cap B |\), and
\(| A \cup B | = | A \cap \overline{B} | + | A \cap B | + | \overline{A} \cap B |\), so

\(| A | + | B | = | A \cap \overline{B} | + | A \cap B | + | \overline{A} \cap B | + | A \cap B | = | A \cup B | + | A \cap B |\).

Example 22

Consider the set \(U = \{ n \in \mathbb{N} : 1 \leq n \leq 60 \}\). How many elements of \(U\) are divisible by either 2 or 3 or both? How many elements of \(U\) are divisible by neither 2 nor 3?

Let \(A\) stand for the subset of \(U\) that consists of multiples of 2, and let \(B\) stand for the subset of \(U\) that consists of multiples of 3. It’s not too difficult to see that \(|A| = \frac{60}{2} = 30\) and \(|B| = \frac{60}{3} = 20\). Also, \(A \cap B\) must be the subset of \(U\) that consists of multiples of 6, so \(| A \cap B | = \frac{60}{6} = 10\). (If these computations don’t make sense to you, just start counting off the pattern \(1,\,2,\,3,\,4,\,5,\,6,\,\ldots\) and notice that every 2nd number is divisible by 2, every 3rd number is divisible by 3, and every 6th number is divisible by both 2 and 3.) Now apply the Principle Of Inclusion-Exclusion to find the number of integers in \(U\) that are divisible by either 2 or 3 or both: \(|A \cup B| = |A| + |B| - |A \cap B| = 30 + 20 - 10 = 40\). There are 40 integers in \(U\) that are divisible by either 2 or 3 or both, so there are \(60 - 40 = 20\) integers in \(U\) that are divisible by neither 2 nor 3.

If we want to compute the cardinality \(|A \cup B \cup C|\) of the union of three given finite sets \(A\), \(B\), and \(C\), we can again look at the Venn diagram of the partition of \(U\) into 8 sets to see that some of the intersections will be counted one , two , or three times, once for each bit that is \(1\).

ABCbitstrings

We can derive the following formula in much that same way that we did above; in fact, we can just apply the formula we found for two sets to \(| (A \cup B) \cup C |\) and use some of the set identities to help simplify the formula. \[ |A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|. \]

Show me all the steps!
\begin{equation} \begin{aligned} | A \cup B \cup C | {} & = | (A \cup B) \cup C | \\ & = |A \cup B| + |C| - |(A \cup B) \cap C| \\ & = (|A| + |B| - |A \cap B|) + |C| - |(A \cup B) \cap C| \\ & = (|A| + |B| - |A \cap B|) + |C| - |(A \cap C) \cup (B \cap C)| \\ & = (|A| + |B| - |A \cap B|) + |C| - (|A \cap C| + |B \cap C| - |(A \cap C) \cap (B \cap C)|) \\ & = (|A| + |B| - |A \cap B|) + |C| - (|A \cap C| + |B \cap C| - |A \cap C \cap B \cap C|) \\ & = (|A| + |B| - |A \cap B|) + |C| - (|A \cap C| + |B \cap C| - |A \cap B \cap C|) \\ & = (|A| + |B| - |A \cap B|) + |C| - |A \cap C| - |B \cap C| + |A \cap B \cap C| \\ & = |A| + |B| - |A \cap B| + |C| - |A \cap C| - |B \cap C| + |A \cap B \cap C| \\ & = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C| \\ \end{aligned} \end{equation}
Example 23

Consider the set \(U = \{ n \in \mathbb{N} : 1 \leq n \leq 60 \}\) as in the previous example. How many elements of \(U\) are divisible by at least one of 2, 3, or 5?? How many elements of \(U\) are divisible by none of 2, 3, or 5?

As in the previous example, let \(A\) stand for the subset of \(U\) that consists of multiples of 2, let \(B\) stand for the subset of \(U\) that consists of multiples of 3, and now let \(C\) stand for the subset of \(U\) that consists of multiples of 5.

We have \(|A| = \frac{60}{2} = 30\), \(|B| = \frac{60}{3} = 20\), \(|C| = \frac{60}{5} = 12\), \(|A \cap B| = \frac{60}{6} = 10\), \(|A \cap C| = \frac{60}{10} = 6\), \(|B \cap C| = \frac{60}{15} = 4\), and \(|A \cap B \cap C| = \frac{60}{30} = 2\).

Apply Principle Of Inclusion-Exclusion to find the number of integers in \(U\) that are divisible by at least one of 2, 3, or 5:

\(|A \cup B \cup C| = |A| + |B| + |C| - |A \cap B| - |A \cap C| - |B \cap C| + |A \cap B \cap C|\)

\(|A \cup B \cup C| = 30 + 20 + 12 - 10 - 6 - 4 + 1 = 44\)

There are 44 integers in \(U\) that are divisible by at least one of 2, 3, or 5, and there are \(60 - 44 = 16\) integers in \(U\) that are divisible by none of 2, 3, or 5.

3.13. Cardinality Of Sets: Infinite Sets

Set \(A\) is called an infinite set if it not a finite set. That is, \(A\) is not the empty set, and for every positive integer \(n\) there is no one-to-one correspondence between \(A\) and \(\{1, 2, \ldots , n \}.\)

Intuitively an infinite set \(A\) is at least as big as the set of positive integers. You may think that \(A\) must have the same size as the set of positive integers, but cardinality is a much more …​ "interesting" concept for infinite sets, as you will see.

First, we will say that two infinite sets \(A\) and \(B\) have the same cardinality if and only if there is a one-to-one correspondence between the two sets. As an example, the set of positive integers and the set of negative integers have the same cardinality since each nonzero integer \(n\) can be paired with its additive inverse, \(-n.\)

For finite sets, if \(A\) is a proper subset of \(B\) then it must be true that the cardinality of \(A\) is not the same as the cardinality of \(B.\) This fails spectacularly for infinite sets as the next few examples show.

Example 24 - The Natural Numbers and The Positive Integers
NtoNstar

The image shows that there is a one-to-one correspondence between the natural numbers and the positive integers, so these two sets have the same cardinality. But this isn’t so bad, we only have one more number in the set of natural numbers, which is why we can just shift every thing over by 1 in the image.

Notice that this example also suggests why it really does not matter whether we start counting from 1 or 0…​ we can always "reindex" the counting if necessary.

Challenge
Write a formula for the function that represents the one-to-one correspondence between the natural numbers and the positive integers.
Hint
The function is a linear function. If you don’t remember how to find the equation of a linear function, see this appendix.
Example 25 - The Natural Numbers and The Integers
ZtoN

The image shows that there is a one-to-one correspondence between the set of all integers and the natural numbers.

NtoZ

The image shows the inverse of the one-to-one correspondence above, which is a one-to-one correspondence between the set of natural numbers and the set of integers.

These two sets have the same cardinality, which may surprise you since "intuitively" it would seem there should be about twice as many integers as natural numbers. However, this example shows that you can double (roughly) the size of an infinite set and get a new set that has the same cardinality.

Challenge
Write a formula for a function that represents one of the two one-to-one correspondences involving the natural numbers and the integers.
Hint
Either function will be defined by two linear expressions. The definition will be of the form \[ f(n) = \begin{cases} \text{some linear expression}, & \text{ if } n \geq 0 \\ \text{some linear expression}, & \text{ if } n < 0 \\ \end{cases} \] or \[ g(n) = \begin{cases} \text{some linear expression}, & \text{ if } n \text{ is even} \\ \text{some linear expression}, & \text{ if } n \text{ is odd} \\ \end{cases} \]
Example 26 - The Natural Numbers and Ordered Pairs of Natural Numbers
Cantor’s_Pairing_Function

This first image, which shows red points plotted in the \(xy\)-plane that have been labeled with natural numbers, suggests a way to define a one-to-one correspondence between the set of ordered pairs of natural numbers, \(\mathbb{N} × \mathbb{N},\) and the set of natural numbers \(\mathbb{N}.\)
Image credit: "Cantor’s Pairing Function" by crh23. The image is dedicated to the public domain under CC0 .

PairsToSingles This second image displays the same one-to-one correspondence in tabular form.

In the first image, notice that for each fixed value of the second coordinate \(y \in \mathbb{N},\) the horizontal row of red points of the form \(\{ (x, y) : x \in \mathbb{N} \} = \{ (0, y), (1, y), (2, y), (3, y), \ldots \}\) has the same cardinality as \(\mathbb{N}\) and that there is one such row for every natural number \(y \in \mathbb{N}.\) That is, the set of rows has the same cardinality as the set \(\mathbb{N},\) and each of the rows has the same cardinality as \(\mathbb{N}.\) There are, in essence, as many copies of \(\mathbb{N}\) (the rows of red points) as there are elements in \(\mathbb{N},\) and these copies are joined together to form the Cartesian product \(\mathbb{N} × \mathbb{N}\)…​ but this set still has the same cardinality as \(\mathbb{N}.\)

Notice something else about this example: It shows that each pair of natural numbers can be encoded as a single natural number. In fact, this example can be generalized to show that any element in the set of all finite-length sequences of natural numbers can be encoded uniquely to a natural number (so, for example, the set of all possible finite-length strings of Unicode characters/code points can be encoded to the set of natural numbers, which may or may not be surprising to you.)

Mega-challenge!
Try to find an algebraic formula for the function \(n = f(x,y)\) that describes the one-to-one correspondence described by the images, then show that the function must map two different inputs (ordered pairs of natural numbers) to two different outputs (natural numbers) and also that every natural number is an output from the function for some input ordered pair of natural numbers.
Hint
It’s possible to write \(f(x,y)\) as a quadratic polynomial in the two variables \(x\) and \(y.\)

You may want to read about triangular numbers to get an idea of how the mapping of ordered pairs to numbers is being done. In the first image, the red points form a "triangle of infinite height" with a vertex at \((0,0)\) and sides lying along the \(x-\) and \(y-\)axes. "Row 0" of the triangle is the single point \((0,0),\) and "row \(n\)" of the triangle is made up of the red points with natural number coordinates \((x,y)\) that add up to \(n\) (that is, \(x+y = n\).)

A proof that this mapping of ordered pairs of natural numbers to individual natural numbers is in fact a one-to-one correspondence will be presented later in the textbook.

So far, every infinite set presented has the same cardinality as \(\mathbb{N}.\)

Maybe all infinite sets have the same cardinality as \(\mathbb{N}?\) Nope!

The next theorem shows that \(\mathcal{P}(\mathbb{N})\) cannot have the same cardinality as \(\mathbb{N}\) so there must be at least two "infinities."

Theorem

There is no one-to-one correspondence between \(\mathbb{N}\) and \(\mathcal{P}(\mathbb{N}).\)

Proof
This proof uses a technique called "Cantor’s diagonal argument" and is an example of the proof by contradiction technique that will be discussed later in the Proofs: Basic Techniques chapter.

SeqOfSets Let’s suppose that we had such a one-to-one correspondence. As shown in the image, we could represent the one-to-one correspondence by a sequence \(S_0 , S_1 , S_2 , \ldots\) of subsets of \(\mathbb{N},\) which is what the elements of \(\mathcal{P}(\mathbb{N})\) are. In the one-to-one correspondence, every subset of \(\mathbb{N}\) (that is, every element of \(\mathcal{P}(\mathbb{N})\)) appears as one of the \(S_{n}\) in the sequence: Every subset has been paired with a natural number and every natural number has been paired with a subset.

Next, define a subset \(M \subseteq \mathbb{N}\) as \[M = \{ n \in \mathbb{N} : n \not\in S_n \}\] That is, \(M\) is defined by the rule that for each natural number \(n,\) we have \(n \in M\) if and only if \(n \not\in S_{n}.\) So, for example, 0 is an element of \(M\) if 0 is not an element of \(S_0,\) but is not an element of \(M\) if 0 is an element of \(S_0.\) Likewise, 1 is an element of \(M\) if 1 is not an element of \(S_1,\) but is not an element of \(M\) if 1 is an element of \(S_1.\) The same is true for each of the natural numbers 2, 3, and so on: The natural number \(n\) is an element of exactly one of the sets \(S_n\) and \(M.\)

Now we show that \(M\) must be missing from the sequence \(S_0 , S_1 , S_2 , \ldots\)
\(M\) cannot be \(S_0\) since one of those sets contains 0 and the other one does not. \(M\) cannot be \(S_1\) since one of those sets contains 1 and the other one does not. The same must be true for each of the natural numbers 2, 3, and so on. So, for every natural number \(n,\) \(n\) is an element of exactly one of the two sets \(S_n\) and \(M,\) which means \(M \neq S_n\) is true for every natural number \(n.\) This means that \(M\) cannot be any of the sets in the sequence…​ it is missing!

We assumed that every subset is listed in the sequence, but just showed that there is some subset that is not listed in the sequence. Notice that, even if we tried to use a new sequence (for example, insert \(M\) at position 0 and shift all the other subsets over by adding 1 to their subscripts) the diagonal argument could be used to define another subset that is missing from the new sequence. So, every possible sequence of subsets must be missing at least one subset.

Therefore, such a one-to-one correspondence cannot exist.

3.13.1. Countable and Uncountable Sets

Set \(A\) is called countable if

  • \(A\) is a finite set or

  • there is a one-to-one correspondence between \(A\) and \(\mathbb{N}.\) In this case, \(A\) is also called countably infinite.

Set \(A\) is called uncountable if it is not a countable set. That is, \(A\) is infinite and there is no one-to-one correspondence between \(A\) and \(\mathbb{N}.\)

Several examples of countably infinite sets were given in the examples in the preceding subsection:

  • The set of positive integers \(\{ i \in \mathbb{N} \, | \, i > 0 \},\)

  • the set of integers \(\mathbb{Z},\) and

  • the set of ordered pairs of natural numbers, \(\mathbb{N} × \mathbb{N}.\)

On the other hand, the theorem in the preceding subsection shows that \(\mathcal{P}(\mathbb{N})\) is an uncountable set.

Infinite Cardinal Numbers

In advanced mathematics, the concept of "infinite cardinal number" is developed and used to represent the sizes of infinite sets. Mathematicians use these infinite cardinal numbers to make sense of cardinalities like \(|\mathbb{N}|\) and \(|\mathcal{P}(\mathbb{N})|.\) It can be proven that \[|\mathbb{Q}| = |\mathbb{N}|\] \[|\mathbb{N}| < |\mathcal{P}(\mathbb{N})|\] \[|\mathcal{P}(\mathbb{N})| = |\mathbb{R}|\] and that \[\text{for any infinite set } A, |A| < |\mathcal{P}(A)|\] which shows that there must be infinitely-many infinite cardinal numbers.

3.14. Exercises

Remixer’s Note: This section is taken from the original “Discrete Math” book with only minor changes.

  1. Consider as universal set, the set of all \(26\), lowercase letters of the English alphabet, \(U=\{a,b,c,…,v,w,x,y,z\}\), and the sets \(A=\{a,b,c,d,e,f,g,h\}\), \(B=\{f,g,h,i,j,k\}\), and \(C=\{x,y,z\}\). For the sets given below:

    1. List the sets below using roster form, and

    2. Draw Venn Diagrams for each of the sets

      1. \(A\cup B\)

      2. \(A\cap B\)

      3. \(A\cup C\)

      4. \(A\cap C\)

      5. \(A \setminus B\)

      6. \(B \setminus A\)

      7. \(A \setminus C\)

      8. \(C \setminus A\)

      9. \(A\cup C\)

      10. \(A\cap C\)

      11. \(\overline{A}\)

      12. \(\overline{B}\)

      13. \(\overline{C}\)

      14. \(\overline{B} \cap \overline{C}\)

      15. \( (\overline{A} \cap \overline{B}) \cup (\overline{B} \cap \overline{C})\)

  2. Using Venn Diagrams, determine which of the following are equivalent

    1. \(A \setminus (A \setminus B)),\)

      \(A\cup B,\) and

      \(A\cap B\)

    2. \(A\cup \overline{A},\)

      \(A\cap \overline{A},\)

      \(U,\) and

      \(\emptyset\)

    3. \(\overline{A}\cap \overline{B}, \)

      \(\overline{A\cap B},\)

      \(\overline{A}\cup \overline{B},\) and

      \(\overline{A\cup B}\)

    4. \(A\cup (B\cap C),\)

      \(A\cap (B\cup C),\)

      \((A\cap B)\cup (A\cap C),\) and

      \((A\cup B)\cap (A\cup C),\)

    5. \(\overline{\overline{A}\cup(C \setminus B) }),\)

      \(A\cap (B \cup \overline{C}),\) and

      \(A \setminus (C \setminus B)\)

  3. Write each of the following sets using set builder notation

    1. \(\{\ldots, -9, -7, -5, -3, -2, -1, 1, 3, 5, 7, 9, \ldots \}\)

    2. \(\{\ldots, -8, -6, -4, -2, 0, 2, 4, 6, 8, 10,\ \ldots \}\)

    3. \(\{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 \}\)

    4. \(\left\{ 1,\frac{1}{2},\frac{1}{3},\frac{1}{4},\frac{1}{5},\ldots \right\}\)

    5. \(\{0, 1, 4, 9, 16, 25, 36, 49, \ldots \}\)

    6. \(\{\ldots,-10,-6, -2, 2, 6, 10, 14, 18, 22, \ldots \}\)

    7. \(\{ 3, 9, 27, 81, 243,\ldots\}\)

    8. \(\{ 1, 9, 25, 49, 81, \ldots \}\)

  4. Write each of the following sets in roster form

    1. \(\{x \in \mathbb{R} : |2x+5|=7\}\)

    2. \(\{10n : n \in \mathbb{N}\}\)

    3. \(\{10n : n \in \mathbb{Z}\}\)

    4. \(\left\{2^n : n \in \mathbb{N}\right\}\)

    5. \(\left\{2^n : n \in \mathbb{Z}\right\}\)

    6. \(\left\{x \in \mathbb{R} : x^2=4\right\}\)

    7. \(\left\{x \in \mathbb{R} : x^3=64\right\}\)

    8. \(\left\{x \in \mathbb{Z} : x^2=5\right\}\)

    9. \(\left\{x \in \mathbb{R} : x^2= -4\right\}\)

    10. \(\left\{x \in \mathbb{Z} : |x-5|=3\right\}\)

    11. \(\left\{3n+4 : n \in \mathbb{N}\right\}\)

    12. \(\left\{3n+4 : n \in \mathbb{Z}\right\}\)

    13. \(\left\{i^n : n \in\mathbb{N}\right\}\), where \(i\) is such that \(i^2=-1\) (the imaginary unit).

  5. Consider the sets \(A=\{1, 3, 5, 7, 9, 11, 13, 15, 17\}\), \(B=\{2, 5, 7, 11\}\), and \(C=\{1, 2, 3\}\),

    1. Determine the cardinalities of following sets,

      1. \(|A|\)

      2. \(|A\cup B|\)

      3. \(|A\cap C|\)

      4. \(|\mathcal{P}(A)|\)

      5. \(|\mathcal{P}(B)|\)

      6. \(|\mathcal{P}(C)|\)

    2. Give the following power sets,

      1. \(\mathcal{P}(B)\)

      2. \(\mathcal{P}(C)\)

  6. Determine the cardinalities of following sets,

    1. \(\{n \in \mathbb{Z} : |n|\leq 10\}\)

    2. \(\{A,B, \emptyset,\{2,5,6\}\}\)

    3. \(\{\{A,B\},\{\},\{\{2,5,6\}\},\{\{2,5,6\},C\},\{A,B,C\}\}\)

    4. \(\{\{\{A,B\},\emptyset,\{\{2,5,6\},C\},\{A,B,C\}\}\}\)

  7. Consider the sets, \(B=\{0, 1\}\), \( S=\{spring, summer, fall, winter\}\), and \(C=\{ a, b, c, d,e\}\). For each of the following sets:

    1. Determine the following Cartesian products.

    2. Calculate the cardinality of each Cartesian product.

      1. \(B \times S\)

      2. \(S \times B\)

      3. \(B \times C\)

      4. \(C \times B\)

      5. \(B \times B \times B \times B\)

      6. \(S \times B \times B\)

  8. Determine the following power sets,

    1. \(\mathcal{P}(\{Alabama, Georgia, Florida, Louisiana\} )\)

    2. \(\mathcal{P}(\emptyset )\)

    3. \(\mathcal{P}(\{\emptyset\} )\)

    4. \(\mathcal{P}(\{Alabama \} )\)

    5. \(\mathcal{P}(\{Alabama, Georgia, Florida \} )\)

    6. \(\mathcal{P}(\{\{Alabama, Georgia \}, \{Florida \} \} )\)

  9. Write the shaded regions in each of the following Venn diagrams using set notation.

    GGC
  10. Determine if each of the following are true or false. Explain your reasoning.

    1. \(\{7,4,6,2,11,3,5\}\subseteq \{1,2,3,4,5,6,7,8,9,10,11,12,13\}\)

    2. \(\{1,2,3,4,5,6,7,8,9,10,11,12,13\}\subseteq \{7,4,6,2,11,3,5\}\)

    3. \(\{7,4,6,2,11,3,5\}\subseteq \{7,4,6,2,11,3,5\}\)

    4. \(\{3,8\}\nsubseteq \{7,4,6,2,11,3,5\}\)

    5. \( \{3n+4 : n \in \mathbb{N}\} \nsubseteq \mathbb{Z}\)

    6. \(\mathbb{N}\subseteq \mathbb{Z}\subseteq \mathbb{Q}\subseteq \mathbb{R}\)

    7. \(\{x \in \mathbb{R} : |x|<3\}\subseteq \{x \in \mathbb{R} \, | \, |x|<5\}\)

    8. \(\{x \in \mathbb{R} : |x|>3\}\subseteq \{x \in \mathbb{R} \, | \, |x|>5\}\)