Sets and Set Theory
Contents
2.1. Sets and Set Theory#
Most of mathematics is built up from the very basic concept of a set. It is so basic in fact, that the concept of a set is rarely defined formally rather something thought of intuitively as just “a collection of objects”. Defining sets formally is outside the scope of this course and is described by “axiomatic set theory” and, in particular, Zermelo-Fraenkel Set Theory. Rather, we will follow naive set theory, and use the previously mentioned intuitive definition.
From grade school mathematics we have already been exposed to certain sets, although maybe not defined rigorously.
The set of natural numbers \(\mathbb{N}\) are the “whole numbers”: \(0, 1, 2, 3, \ldots\).
The set of integers \(\mathbb{Z}\) are the whole numbers and their negatives: \(\ldots, -2, -1, 0, 1, 2, \ldots\).
The set of real numbers \(\mathbb{R}\) are “all” the numbers, including fractions, decimals, and irrational numbers like \(\pi\).
The set of complex numbers \(\mathbb{C}\) are all numbers of the form \(a + bi\), where \(i = \sqrt{-1}\) and \(a,b\) are real numbers.
Important
Note that including \(0\) as a natural number is not universal. Some authors and writings consider \(0\) to be a natural number. Others consider the natural numbers to only be the positive integers. Meaning \(0\) is an integer but not a natural number. To be explicit, one can use the notation \(\mathbb{N}_0\) or \(\mathbb{Z}_{\geq 0}\) to say natural numbers including 0. This is often the case in computer science.
In this text, we will include 0 as a natural number.
From these different sets of numbers, we already have an intuitive definition of sets of numbers. But sets are more general than that. Sets are unordered collections (of unique) things. These “things” are called elements or members. To see how and why ordering (and unicity) are or are not important, we have to discuss things like equality of sets and the construction of sets. They will all come in the next section.
2.1.1. Set Construction#
Constructing a set is the first and foremost part of set theory. Naturally, we cannot use sets, or perform operations on sets, without having a set in the first place. We will see 3 ways to construct a set:
Roster method
Set builder notation
Interval notation
Roster Method#
The roster method for set construction is the most simple. We simply write down all of the members of a set between curly braces.
The set \(A\) consists of four members: \(a\), \(b\), \(c\), and \(d\).
When there is an obvious pattern to the elements of a set, one can abbreviate the roster method using an ellipse (i.e. \(\ldots\)). For example, the set of positive integers less than \(100\) may be written as:
The set of all positive multiples of \(3\) could be written as:
Notice that the set does not need to be finite to use the roster method. Generally, sets can have a finite or infinite number of members, as we will see.
Moreover, sets do not necessarily need to contain numbers or only numbers. Sets are collections of any “thing” or “object”. Those objects could be any combination of letters, strings, colors, shapes, matrices, etc. Sets can even contain other sets! (see Set Properties). As an example, the following as also valid sets:
Using the roster method, we can describe some well-known mathematical sets as follows.
Roster method for sets of numbers
Set Builder#
The second, and more general way of describing a set is using set builder notation. You have likely seen this notation used implicitly in previous math courses.
Set builder notation
Set builder notation specifies elements that should be included in a set based on a variable (respectively, some expression) and a condition on that variable (respectively, expression). The variable and condition are separated by a vertical bar \(|\).
In this notation the vertical bar \(|\) is read as “such that”. The following notation defines the set of positive integers less than 100 using set builder notation. It can be read as “the set containing x, where x is an integer, such that x is greater than 0 and less than 100”.
This notation may have included a new symbol for you: \(\in\). This symbol means “in” or “belongs to” and denotes that an object is a member of a set. Therefore, \(x \in \mathbb{Z}\) can be read as “\(x\) belongs to the integers” or “\(x\) in the set of integers” or “\(x\) is an integer”. We will examine membership in the next section.
The set of rational numbers or complex numbers are easily defined using set builder notation, but are quite complicated to define using the roster method.
Set of rational numbers and complex numbers
Note
In set builder notation, conditions which should simultaneously be satisfied are often simply listed after the \(|\) and separated by commas. Their conjunction is implied. Alternatively, one can explicitly write “and”.
Set builder and conjunctions
The following sets are equivalent.
Set builder notation has one strong benefit over the roster method: you do not need to know the precise members of a set in order to construct the set. For example, maybe you want the set of roots of a polynomial. We know from grade school mathematics that a quadratic equation can be solved using
But what about cubics? Quadratics? Quintics? The following example shows that we can construct a set without necessarily knowing its elements.
Set of roots of a polynomial
Let \(f(x) = 15x^4 + 5x^3 - 2x^2 + 4x - 3\). Its set of roots can be defined as:
Similarly, consider some examples from predicate logic. The condition or property that we use within the set builder notation can be a predicate. We do not need to know ahead of time the set of objects for which that predicate holds.
Predicates and set builder notation
Let \(P(x) :=\) “\(x\) lays eggs”. Let \(Q(x) := (x-2)(x^2+1) = 0\).
Let \(U_1\) be all species of animals. Let \(U_2\) be all species of mammals. The following are valid sets:
Notice from this previous example that specifying the domain of discourse is very important and can drastically change the objects in a set. \(A\) would be many species of birds, reptiles, and others. Meanwhile, \(C\) would be almost all animals in the domain \(U_2\). Notice \(A\) and \(C\) could not (easily) be written using the roster method since the sets would be very large and without a clear pattern to use \(\ldots\). The other sets, however, could be written using the roster method:
Natural language description#
Just as we can translate between Natural language and predicates, we can similarly use natural language in place of the explicit set builder notation. This is often called a semantic description of the set, where a sentence is used to describe the properties of objects contained in a set.
Semantic descriptions
The following are valid semantic descriptions of sets.
Let \(A\) be the set of three primary colors.
Let \(B\) be the set of five smallest positive integers.
Let \(C\) be the set of positive rational numbers with 1 as a numerator.
\(A = \{\text{red}, \text{blue}, \text{yellow}\}\)
\(B = \{1, 2, 3, 4, 5\}\)
\(C = \{1, \frac{1}{2}, \frac{1}{3}, \frac{1}{4}, \ldots\}\)
When using semantic descriptions, it is important that the sentence be as clear as possible and unambiguous. We have already seen in Section 1 how natural language can cause troubles and ambiguity when taken formally.
Interval Notation#
For sets of real numbers, a particularly useful notation is interval notation. We are probably familiar with this notation from calculus. For two real numbers \(a\) and \(b\), such that \(a < b\), we have the following possible intervals:
The choice of including the end point or an interval or not determines if the interval is closed or open.
Definition (closed interval)
A closed interval is the set of all numbers between two end points, including those endpoints. It is denoted by square brackets. \([a,b]\) is all numbers \(x\) such that \(a \leq x \leq b\).
Definition (open interval)
An open interval is the set of all numbers between two end points, excluding those endpoints. It is denoted by round brackets. \((a,b)\) is all numbers \(x\) such that \(a < x < b\).
A half-open or half-closed interval is where one end point is included and one end point is excluded. To be more precise, we can say left-open or right-closed to mean only the right end point is included, e.g. \((a, b]\). We can say left-closed or right-open to mean only the left end point is included, e.g. \([a, b)\).
When we want to describe intervals which are unbounded on one side (i.e. go until positive or negative infinity) we use a round bracket and the infinity symbol.
Integer intervals
In computer science, it is increasingly common to define intervals over integers. Such notations have grown as programming languages become higher-level and compiler and interpreters get more sophisticated.
In Python, the function call range(a,b)
defines the integer interval (i.e. the set) starting at and including a
, and up to but excluding b
: {a, a+1, a+2, ..., b-2, b-1}
.
We can also use the function call range(a,b,step)
to define the integer interval {a, a + step, a + 2*step, b-step}
.
In MATLAB, we can use the colon operator. i:j
defines the closed integer interval from i
to j
: i, i+1, i+2, ..., j
. One can also increment by a step size other than one using i:step:j
to
obtain the interval i, i + step, i + 2*step, ..., i + m*step
, where m
is (j-i)/step
rounded down.
2.1.2. Set Properties#
Now that we know how to construct sets, it is time to discuss particular sets and their properties.
Membership and Equality#
Membership is the basic property of sets from which all other operations and properties can be defined. A set either contains an object or does not contain an object. Sets define a clear and unambiguous description of its members.
We have already see the notation \(\in\) which is used say that an element is included in the set. The notation \(\not\in\) says an element is not included in a set.
Again, membership is a strict binary. An object is either in a set or is not in a set. Because of that, we have the following interesting results.
Definition (equality of sets)
Two sets \(A\) and \(B\) are equal if every member of \(A\) is a member of \(B\) and every element of \(B\) is a member of \(A\).
Stated in predicate logic, two sets are equal if \(\forall x (x \in A \leftrightarrow x \in B)\).
Because the only basic property of a set is membership, a set does not care about the order in which elements are listed or the number of times each element appears in the set construction. For example, the following sets are equal.
To avoid this awkward and “non-canonical” description of sets, it is often said that sets should only contain unique, distinct, or distinguishable objects. In particular, when using the roster method, one should only write each unique element once. Therefore \(\{1,2\}\) or \(\{2,1\}\) is the most “correct” description of the previous set.
Exercise
In Python, sets are a particular kind of data structure. They follow much of the semantics of the mathematical set. Sets are generic collections of objects. However, for many reasons associated with simplicity and efficiency of programming, Python requires a canonical form for their sets. In particular, Python requires that every element in a set is unique. This avoid the previously described ambiguity of multiple copies of the same element being in a set.
set1 = {'a', 'b', 'c'}
set2 = {'b', 'c', 'c', 'a', 'c', 'b'}
print("set1:", set1)
print("set2:", set2)
print(set1 == set2);
set1: {'a', 'b', 'c'}
set2: {'a', 'b', 'c'}
True
Special Sets: Empty and Universal#
Some important sets have special names. In particular, the empty set and the universal set. Thinking again about set membership, their names suggest that these sets contain nothing or everything.
Definition (empty set)
The empty set is the unique set containing no elements. It is denoted by \(\varnothing\).
The empty set can also be denoted by \(\emptyset\) or, using the roster method, \(\{\}\). A very important concept to wrap one’s head around is that the empty set, while empty, is still a thing in and of itself.
In contrast with the empty set, the universal set is the set which contains every element. How can one thing contain everything? It may seem paradoxical. Does a thing containing everything contain itself? In formal set theory, such a universal set does not exist.
For practical purposes, we can instead consider a particular universe of things. That is, a universe or domain of discourse. Indeed, we have already seen the set \(U\) to represent the domain of discourse in predicate logic. It is the same here, where the elements in (or not in) a set \(A\) all come from some common universe.
Such a universe can be implicit, for example the set containing days of the week \(D = \{\text{Monday}, \text{Wednesday}, \text{Friday}\}\), implicitly has \(U = \{\text{Monday},\text{Tuesday},\text{Wednesday},\text{Thursday},\text{Friday},\text{Saturday},\text{Sunday}\}\).
In other cases, we have seen the universe being described explicitly in set building notation. For example, the following has the set of positive integers as its universe.
Sets and empty sets
Are the following equalities true or false?
\(\varnothing = \{\}\)
\(\varnothing = \{ x \in \mathbb{Z} \ |\ 2x = 3\}\)
\(\varnothing = \{\{\}\}\)
\(\varnothing = \{ x \in \mathbb{R} \ |\ x^2 + 2 = 0\}\)
\(\varnothing = \{\varnothing\}\)
Sets and empty sets
True.
True. No integer satisfies the equation \(2x=3\).
False. The left-hand side is the empty set. The right-hand side is the set containing the empty set.
True. No real number satisfies the equation \(x^2 + 2 = 0\).
False. The left-hand side is the empty set. The right-hand side is the set containing the empty set.
Subsets#
Subsets describe sets which are “contained within” other sets. Intuitively, subsets are something between set membership and set equality.
Definition (subset)
A set \(A\) is a subset of the set \(B\), written \(A \subseteq B\), if every member of \(A\) is also a member of \(B\).
Notice that this definition is a one-way relation. Unlike equality, a subset only requires that every member of the subset is also a member of the superset.
Subsets
The following are valid subsets.
Tip
By the definition of subset, we have \(\varnothing \subseteq A\) for any set \(A\). Indeed, since \(\varnothing\) has no elements, it is the subset of anything.
Notice that the definition of subset does not restrict the subset to being strictly “smaller” than its superset. Indeed, the symbol \(\subseteq\) is similar to \(\leq\), and means “is a subset of or is equal to”.
Indeed, we can define set equality using subsets. Two sets \(A\) and \(B\) are equal if \(A \subseteq B \land B \subseteq A\)
Equality as subsets
Let \(A = \{1,3,5,7,9\}\). Let \(B = \{3,5\}\). Let \(C\) be the positive odd integers less than \(10\). Let \(D\) be the positive odd integers less than \(100\).
We have: \(B \subseteq A,\quad B \subseteq A,\quad B \subseteq C,\quad B \subseteq D\).
We also have \(A \subseteq C,\quad A \subseteq D,\quad C \subseteq A,\quad C \subseteq D\).
Therefore, \(A = C\).
Notice in this previous example that one set may be the subset of two other sets without those two supersets being equal. Using the notation of the previous example, we have \(B \subseteq A \subseteq D\) with \(A \neq D\).
This describes the case of proper subsets where a subset is strictly smaller than its superset. We have the following terms and notations:
Proper subset
Superset
Proper superset
\( A \subset B\) or \(A \subsetneq B\)
\( A \supseteq B\)
\( A \supset B\) or \(A \supsetneq B\)
Important
The use of subset symbols is not consistent throughout texts. Some authors use \(\subset\) to mean a subset. Others use \(\subset\) to mean proper subset. Some authors use \(\subseteq\) to mean a subset and \(\subset\) to mean a proper subset. Further still, some use \(\subsetneq\) to mean proper subset.
To align with the standard notation of \(<\) and \(\leq\) we will use \(\subset\) to mean proper subset and \(\subseteq\) to mean subset.
Size of a Set#
The last basic property of a set is its size. Sets are crucial in counting and combinatorics, so being able to discuss their size concretely is important. The terms “cardinality” and “size” are often used interchangeably.
Definition (cardinality)
The cardinality of a finite set is the number of distinct elements contained in the set. For a set \(A\) its cardinality is denoted \(|A|\).
The cardinality of any set is non-negative. When the cardinality of a set is some non-negative integer \(n\), we say that the set is finite. If a set is not finite, then it is infinite. We will discuss the cardinality of infinite sets in a later chapter.
As a teaser for that topic, we can say that any set is finite if its cardinality is less than the cardinality of the natural numbers \(\mathbb{N}\).
A special kind of finite set is a singleton.
Definition (singleton)
A singleton is a set with cardinality one. That is, it is a set with exactly one member.
Finite cardinality
What is the cardinality of the following sets?
Finite cardinality
\(|A| = 5\)
\(|B| = 26\)
\(|C| = 110\)
Power Set#
A power set is a special kind of set whose members are all sets themselves. The power set of a set \(A\) is the set of all subsets of \(A\). That’s a lot of “sets”.
Definition (power set)
The power set of a set \(A\) is the set of all possible subsets of \(A\). The power set of \(A\) is denoted by \(\mathcal{P}(A)\).
In set builder notation, \(\mathcal{P}(A) = \{S \ |\ S \subseteq A\}\)
A power set
Let \(A = \{a,b,c\}\). The members of \(\mathcal{P}(A)\) are:
\(\varnothing\)
\(\{a\}\)
\(\{b\}\)
\(\{c\}\)
\(\{a,b\}\)
\(\{a,c\}\)
\(\{b,c\}\)
\(\{a,b,c\}\)
Moreover, \(\mathcal{P}(A) = \left\{\varnothing, \{a\}, \{b\}, \{c\}, \{a,b\}, \{a,c\}, \{b,c\}, \{a,b,c\} \right\}\)
How do we know if we have found ever possible subset? We can count!
Theorem
For a finite set \(A\) with \(|A| = n\), \(|\mathcal{P}(A)| = 2^n\).
2.1.3. Operations on Sets#
There are many possible ways to manipulate, combine, and operate on sets to produce another. Some operations even produce multiple sets.
Before we the operations in particular, we will introduce a graphical representation of sets: Venn diagrams.
In Venn diagrams, a set is represented by a circle. It may or may not have its members indicated within the circle by labelled dots. If we want to be explicit about the universe from which a set is constructed, we draw the Venn diagram inside of a large rectangle. Circles are sets, dots are members, and a rectangle is the universe.
Subsets can also be shown using Venn diagrams.
Union and Intersection#
The union of two sets is the “joining” of two sets together.
Definition (set union)
The union of two sets \(A\) and \(B\) is the set of elements which are members of \(A\) or members of \(B\), or members of both. The union of \(A\) and \(B\) is denoted \(A \cup B\).
In set builder notation, the union of two sets \(A\) and \(B\) can be written as:
The intersection of two sets is about finding their overlap.
Definition (set intersection)
The intersection of two sets \(A\) and \(B\) is the set of elements which are members of both \(A\) and \(B\). The intersection of \(A\) and \(B\) is denoted \(A \cap B\).
In set builder notation, the intersection of two sets \(A\) and \(B\) can be written as:
Union and Intersection
Let \(A = \{1,2,a,b,c\}\) and \(B = \{2,4,6,x,a\}\).
Union and intersection are both associative and commutative operations. Therefore, given multiple sets, say \(A_1, A_2, A_3\), the following are equivalent.
When we have many sets, we can use \(\bigcup\) and \(\bigcap\) to represent union or intersection over a sequence of sets. This is akin to \(\sum\) for summation and \(\prod\) for product.
Although union and intersect are individually associative, they do not mix. Indeed, \((A \cup B) \cap C)\), in general, does not equal \(A \cup (B \cap C)\)
Union and Intersection, together
Let \(A = \{1,2,3,4,5\}\), \(B = \{4,5,6,7,8,9\}\), and \(C = \{1,3,5,7,9\}\).
Finally, we have one more definition.
Definition (disjoint sets)
Sets \(A\) and \(B\) are said to be disjoint if \(A \cap B = \varnothing\).
Set union and intersect
Let:
\(A = \{a,b,y,a,c\}\)
\(B = \{4,5,6,c,z\}\)
\(C = \{a,2,3,4,5,b\}\)
\(D = \{1,2,3,4\}\)
What is the result of the following unions and intersections?
\(A \cup B\)
\(A \cup B \cup C\)
\(A \cup C\)
\(A \cap D\)
\((A \cup C \cup B) \cap D\)
Set union and intersect
\(\{a,b,c,y,z,4,5,6\}\)
\(\{a,b,c,y,z,2,3,4,5,6\}\)
\(\{a,b,c,y,2,3,4,5\}\)
\(\varnothing\)
\(\{2,3,4\}\)
Set union and intersection also have some important identities.
\(A \cup \varnothing = A\)
\(A \cap \varnothing = \varnothing\)
\(A \cup A = A \cap A = A\)
\((A \cup B) \cap A = A\)
\((A \cap B) \cup A = A\)
The latter two are the absorption laws for sets. We have seen these already in the context of propositional logic. Visually, absorption for sets is easier to understand than in propositional logic.
As a final property of union and intersect, we have the inclusion-exclusion principle. Later, we will see this principle in its full generality. Here we state the special case for two sets.
Proposition
For two sets \(A\) and \(B\) the cardinality of \(A \cup B\) is given by:
Informally, the inclusion-exclusion principle says the size of two sets together is the size of each set individually, minus the size of their overlap. We subtract the size of the overlap to avoid double counting. Indeed, with just \(|A| + |B|\), we are counting each element in \(A \cap B\) twice.
Difference and Complement#
Set difference is the analogue of subtraction to sets. \(A \setminus B\) is the set which results from removing every element of \(B\) form \(A\).
Definition (set difference)
The difference between two sets \(A\) and \(B\) is the set of elements which are members of \(A\) which are not members of \(B\). The difference of \(A\) by \(B\) is denoted \(A \setminus B\).
In set builder notation, the set difference \(A \setminus B\) can be written as:
The complement of a set is everything not in a set. To compute the complement we need a universe \(U\) in which the set was constructed. The complement of a set \(\overline{A}\) is the same as \(U \setminus A\).
Definition (set complement)
The complement of a set \(A\) is the set of elements which are not members of \(A\). The set complement is denoted by \(\overline{A}\) or \(A^c\).
In set builder notation, the set complement \(\overline{A}\) can be written as:
Set difference and complement
Let \(A = \{a,b,c\}\), \(B = \{1,2,3\}\), \(C = \{x \in \mathbb{Z} \ |\ | x - 2 | \geq 4\}\)
Notice that the universe for \(C\) is the set of integers.
Set difference and complement also have some important identities.
\(A \setminus B = A \cap \overline{B}\)
\((A^c)^c = A\)
\(\overline{\varnothing} = U\)
\(A \setminus \varnothing = A\)
\(A \setminus U = \varnothing\)
Review Fig. 2.6 again with the first identity in mind. Can you see how the complement of \(B\) intersected with \(A\) gives \(A \setminus B\) ?
Difference and Complement
What is the result of the following difference and complement?
\(\{x \in \mathbb{Z}^+ \ |\ x \text{ is even}\} \setminus \{4, 8, 12, 16,\ldots\}\)
\(\{x \in \mathbb{Q} \ |\ x \not\in \mathbb{Z}\}^c\)
Difference and Complement
\(\{2, 6, 10, 14, 18, \ldots\}\)
\(\mathbb{Z}\). The original set is all rational numbers which are not integers (where \(U = \mathbb{Q}\)). The complement of that is surely all integers.
Symmetric Difference#
A special kind of difference is symmetric difference. It is the set-equivalent of “exclusive or” from propositional logic.
Definition (symmetric difference)
The symmetric difference of two sets \(A\) and \(B\) is the set of elements which are members of \(A\) or members of \(B\) but not both. The symmetric difference of \(A\) and \(B\) is denoted \(A \oplus B\).
The “symmetric” in symmetric difference comes from the following identity:
However, a more intuitive way to think about symmetric difference is as the union of two sets minus their intersection.
Which leads to the following Venn diagram.
Cartesian Product#
The final set operation we will consider is their Cartesian product. But first, we need a new kind of discrete structure.
Tuples#
Definition (tuple)
A tuple is a finite ordered sequence of elements (from a set). An \(n\)-tuple is a tuple with \(n\) elements.
We have special names for tuples of certain lengths:
a \(1\)-tuple is a monuple or a singleton,
a \(2\)-tuple is a couple or a pair,
a \(3\)-tuple is a triple or triplet,
a \(4\)-tuple is a quadruple,
a \(5\)-tuple is a pentuple, and so on \(\ldots\)
Tuples are denoted using parentheses. For example, \((a,b)\) is a tuple, \((c,b,a)\) is a tuple, and \((c,c,a,b,a,c)\) is a tuple.
Tip
Unlike sets, ordering is important for tuples. Moreover, the same element may appear more than once in a tuple. Therefore, \((a,b)\), \((b,a)\), and \((a,b,a)\) are all different tuples.
The elements of a tuple are called coordinates. In a tuple \((a,b,c)\), \(a\) is the first coordinate, \(b\) is the second coordinate, and \(c\) is the third coordinate. Two tuples are equal if and only if every coordinate is equal.
Tuple equality
The tuples \((3,7,5)\) and \((3,7,5)\) are equal. However, \((3,5,7) \neq (3,7,5)\).
Tuples will become increasingly important in Relations and Functions.
Back to Cartesian products.
The Cartesian product of two (not necessarily different) sets is a new set of tuples constructed from the elements of the two input sets.
Definition (Cartesian product)
The Cartesian product of two sets \(A\) and \(B\) is the set of all pairs \((a,b)\) where \(a \in A\) and \(b \in B\). The Cartesian product is denoted \(A \times B\).
The Cartesian product \(A \times B\) is read “\(A\) cross \(B\)”. The Cartesian product is also called a direct product. The result of a Cartesian product is all possible pairs where the first coordinate ranges over all elements of \(A\) and the second coordinate ranges over all elements of \(B\). We can define the Cartesian product using set builder notation:
Notice that if either \(A\) or \(B\) is the empty set, then \(A \times B = B \times A = \varnothing\). For two non-empty sets, unless \(A = B\), \(A \times B \neq B \times A\).
Cartesian product
Let \(A = \{1,2,3\}\) and \(B = \{x,y\}\).
One way of viewing the Cartesian product \(A \times B\) is as a table. The columns range over all possible values of \(A\) and the rows range over all possible values of \(B\).
If \(A = \{1,2,3\}\) and \(B = \{x,y,z\}\) we have:
\(\ \) |
\(x\) |
\(y\) |
\(z\) |
\(1\) |
\((1,x)\) |
\((1,y)\) |
\((1,z)\) |
\(2\) |
\((2,x)\) |
\((2,y)\) |
\((2,z)\) |
\(3\) |
\((3,x)\) |
\((3,y)\) |
\((3,z)\) |
A Cartesian product also extends to more than two sets.
When a Cartesian product is made between a set and itself, i.e. \(A \times A\), we can also write it as \(A^2\). This continues for \(A^3, A^4, \ldots, A^n\).
Cartesian and Complex planes
The Cartesian plane can be described by \(\mathbb{R}^2\), all ordered pairs of real numbers. You are probably already familiar with this from calculus. Three-dimensional space is similarly described by \(\mathbb{R}^3\).
We can also identify the complex plane with \(\mathbb{R}^2\). Indeed, the complex numbers \(\mathbb{C}\) are of the form \(a + bi\) where \(a, b \in \mathbb{R}\). Therefore, each complex number \(a + bi\) can be identified with a tuple \((a,b) \in \mathbb{R}^2\) (that is, \(\mathbb{R}^2\) and \(\mathbb{C}\) are isomorphic).
2.1.4. Proofs with Sets#
Because sets are so fundamental to every area of mathematics, many proofs rely on arguments related to set membership. In this section we will examine how to use sets and set membership to prove some theorems.
The first step to most proofs involving sets is to remember the definition of set equality. Two sets \(A\) and \(B\) are equal when we have \(x \in A \leftrightarrow x \in B\). To prove this biconditional, we must show \(x \in A \rightarrow x \in B\) and \(x \in B \rightarrow x \in A\).
Most proofs about sets follow this structure. Assume some condition, like \(x \in A\), and then somehow show (typically by direct proof) that \(x \in B\). Try it yourself now.
Proving subsets
Prove the following proposition.
Proposition
If \(A \subseteq B\) then \(A \cup B = B\).
Proving subsets
We look to prove \(A \subseteq B \rightarrow A \cup B = B\)
Proof:
Assume \(A \subseteq B\). We look to prove \(x \in A \cup B \leftrightarrow x \in B\)
\((\rightarrow)\) Assume \(x \in A \cup B\). Then \(x \in A\) or \(x \in B\). Proceed by cases:
If \(x \in B\), we are done.
If \(x \in A\), we know \(A \subseteq B\), therefore \(x \in B\).
\((\leftarrow)\) Assume \(x \in B\). Therefore, \(x\) must surely be in \(A \cup B\). \(\blacksquare\)
Let’s now examine and prove some more complex laws than just associativity and commutativity. These are examples we have already seen from propositional logic: distribution and De Morgan’s laws.
Distribution#
For sets, we have the following identities.
Visually, these laws can be seen in the following Venn diagrams.
Important
We cannot rely on visuals alone as proofs. Grant Sanderson and the famous 3Blue1Brown YouTube channel has an entire video on the fallacy of visual proofs.
Here is an example of a correct proof using sets to prove one of the distribution laws.
Proving set distribution
Proposition
For any sets \(A, B, C\), \(A \cup (B \cap C) = (A\cup B) \cap (A \cup C)\)
Proof:
Let \(X = A \cup (B \cap C)\) and \(Y = (A\cup B) \cap (A \cup C)\) Since we are proving a set equality we must prove a biconditional: \(\forall x\ (x \in X \leftrightarrow x \in Y)\).
\((\rightarrow)\) We first prove that \(x \in X \rightarrow x \in Y\). Assume \(x \in X\). By union, we have that \(x \in A\) or \(x \in (B \cap C)\). Proceed by cases:
If \(x \in A\) then surely \(x \in A \cup B\) and \(x \in A \cup C\). Therefore \(x \in Y\).
If \(x \in (B \cap C)\) then \(x \in B\) and \(x \in C\). Thus, \(x\) belongs to both \(A \cup B\) and \(A \cup C\). Therefore \(x \in Y\).
\((\leftarrow)\) We now prove \(x \in Y \rightarrow x \in X\). Assume \(x \in Y\). Therefore, \(x\) is a member of both \(A \cup B\) and \(A \cup C\). By union of \(A \cup B\):
If \(x \in A\) then surely \(x \in A \cup (B \cap C)\) and \(x \in X\).
If \(x \not\in A\) then \(x \in B\). We also have \(x \in A \cup C\); but since \(x \not\in A\) then \(x \in C\). Hence, \(x \in B \cap C\) and surely \(x \in X\). \(\blacksquare\)
De Morgan’s Laws#
For sets, we have the following identities.
Must like propositional logic, De Morgan’s laws flip intersection to union, and vice versa. A visual proof of the former De Morgan’s law \(\overline{(A \cup B)} = \overline{A} \cap \overline{B}\) is shown below as Venn diagrams.
De Morgan’s laws for sets
Draw two Venn diagrams showing \(\overline{A \cap B}\) and \(\overline{A} \cup \overline{B}\). Convince yourself that these are the same sets.
De Morgan’s laws for sets
2.1.5. Exercises#
Write out the following sets using the roster method.
Let \(Q(x,y) := x(2y+4) = 0\)
\(\{x \ \vert\ x \in \mathbb{Z}^+ \text{ and } x < 5\}\)
\(\{x \in \mathbb{Q} \ \vert\ 2x \in \mathbb{Z}\}\)
\(\{x \ \vert\ x, y \in \mathbb{Z}, \forall y\ Q(x,y)\}\)
\(\{y \ \vert\ x, y \in \mathbb{Z}, \exists x\ Q(x,y)\}\)
Solution to Exercise 2.1
\(\{1, 2, 3, 4\}\)
\(\{\ldots, \frac{-3}{2}, -1, \frac{-1}{2}, 0, \frac{1}{2}, 1, \frac{3}{2}, \ldots\}\)
\(\{0\}\)
\(\{\ldots, -2, -1, 0, 1, 2, \ldots\}\)
Write out the following sets using interval notation. Note some may require the union of several intervals.
\([-4,4] \setminus [0,5]\)
\([0,5] \setminus [-4,4]\)
\({[-4,4]}^c\)
\((2,5] \cup (4,10)\)
\([1,3] \cup (0,4)\)
\([1,3] \cap (0,4)\)
Solution to Exercise 2.2
\([-4,0)\)
\((4,5]\)
\((-\infty,-4) \cup (4, \infty)\)
\((2,10)\)
\((0,4)\)
\([1,3]\)
Let \(A = \{x \ |\ x \text{ is an odd integer and } 2x + 5 > 20\}\).
Let \(B = \{x \in \mathbb{Z}^+ \ |\ x > 7 \text{ and } \exists k \in \mathbb{Z} x = 2k+1\}\).
Is \(A\) a subset of \(B\)? Is \(B\) a subset of \(A\)?
Solution to Exercise 2.3
Both. \(A = B\). Indeed, we have: \(A = \{9, 11, 13, 15, \ldots\}\) and \(B = \{9, 11, 13, 15, \ldots\}\).
Let \(U = \{x \in \mathbb{Z}_{\geq 0} \ |\ x \leq 10\}\). Let \(A = \{1,2,3,4,5\}\) and \(B = \{4,5,6,7,8\}\)
Write out the following sets using the roster method.
\(A \cup B\)
\(A \cap B\)
\(\overline{A}\)
\(\overline{B}\)
\(A \setminus B\)
\(B \setminus A\)
Solution to Exercise 2.4
\(\{1,2,3,4,5,6,7,8\}\)
\(\{4,5\}\)
\(\{0,6,7,8,9,10\}\)
\(\{0,1,2,3,9,10\}\)
\(\{1,2,3\}\)
\(\{6,7,8\}\)
Let \(A = \{2,3,5,7,9\}\), \(B = \{1,3,5,6,8\}\) and \(C = \{x \in \mathbb{Z}_{\geq 0} \ |\ x < 8\}\). Let \(U = \{x \in \mathbb{Z} \ |\ 0 \leq x \leq 12\}\).
Write out the following sets using the roster method.
\((A \cap B) \cup C\)
\(A \setminus C\)
\((B \cup C) \setminus A\)
\((B \cap C) \setminus C\)
\(\overline{A} \cup {B}\)
Solution to Exercise 2.5
\(\{0, 1, 2, 3, 4, 5, 6, 7\}\)
\(\{9\}\)
\(\{0,1,4,6,8\}\)
\(\varnothing\)
\(\{0, 1, 3, 4, 5, 6, 8, 10, 11, 12\}\)
For any positive integer \(i\), let \(A_i = \{i, i+1, i+2, i+3, \ldots\}\) and \(B_i = \{i+2, i+3, i+4, \ldots\}\).
What are the following sets? Write your answers using set builder notation or the roster method.
\(\bigcup_{i=1}^\infty A_i\)
\(\bigcap_{i=1}^{100} A_i\)
\(\bigcup_{i=1}^{10} (A_i \cap B_i)\)
Solution to Exercise 2.6
\(\{ x \ |\ x \in \mathbb{Z}^+\}\)
\(\{ x \in \mathbb{Z}^+ \ |\ x \geq 100\}\)
\(\{3,4,5,6,\ldots\}\)
Prove the following proposition.
Proposition
If \(A \subseteq B\) then \(A \cap B = A\).
Solution to Exercise 2.7
We look to prove \(A \subseteq B \rightarrow A \cap B = A\)
Proof:
Assume \(A \subseteq B\). We look to prove \(x \in A \cap B \leftrightarrow x \in A\)
\((\rightarrow)\) Assume \(x \in A \cap B\). Then \(x \in A\).
\((\leftarrow)\) Assume \(x \in A\). We look to prove \(x \in A \cap B\), and thus \(x\in A\) and \(x\in B\). The former holds by assumption. For the latter, we have \(x \in A\) and \(A \subseteq B\). Therefore, it must be that \(x \in B\). \(\blacksquare\)
Prove the following proposition.
Proposition
If \(A \subseteq B\) then \(A \cup B = B\).
Solution to Exercise 2.8
We look to prove \(A \subseteq B \rightarrow A \cup B = B\)
Proof:
Assume \(A \subseteq B\). We look to prove \(x \in A \cup B \leftrightarrow x \in B\)
\((\rightarrow)\) Assume \(x \in A \cup B\). Then \(x \in A\) or \(x \in B\). If \(x \in B\), we get the desired result. If \(x \in A\), we have that \(A \subseteq B\), thus \(x \in B\).
\((\leftarrow)\) Assume \(x \in B\). We look to prove \(x \in A \cup B\), and thus \(x\in A\) or \(x\in B\). The latter holds by assumption. \(\blacksquare\)
Prove the following proposition.
Proposition
Let \(A\), \(B\), and \(C\) be sets. \(A \cap (B \cup C) = (A\cap B) \cup (A \cap C)\)
Solution to Exercise 2.9
Proof:
Let \(X = A \cap (B \cup C)\) and \(Y = (A\cap B) \cup (A \cap C)\) Since we are proving a set equality we must prove a biconditional: \(\forall x\ (x \in X \leftrightarrow x \in Y)\).
\((\rightarrow)\) We first prove that \(x \in X \rightarrow x \in Y\). Assume \(x \in X\). We must prove \(x\) is in \(A \cap B\) or \(A \cap C\). By intersect, we have that \(x \in A\) and \(x \in (B \cup C)\). By union, proceed in cases:
If \(x \in B\) then \(x \in A \cap B\), therefore \(x \in Y\).
If \(x \in C\) then \(x \in A \cap C\), therefore \(x \in Y\).
\((\leftarrow)\) We now prove \(x \in Y \rightarrow x \in X\). Assume \(x \in Y\). We must prove \(x\) is in \(A\) and in \(B \cup C\). By union, \(x\) is a member of either \(A \cap B\) or \(A \cap C\). Proceed by cases:
If \(x \in A \cap B\) then \(x \in A\) and \(x \in B\). Since \(x \in B\), we have \(x \in B \cup C\) and therefore \(x \in X\).
If \(x \in A \cap C\) then \(x \in A\) and \(x \in C\). Since \(x \in C\), we have \(x \in B \cup C\) and therefore \(x \in X\). \(\blacksquare\)
Prove the following proposition.
Proposition
For any two sets \(A\) and \(B\), \(\overline{A \cap B} = \overline{A} \cup \overline{B}\)
Solution to Exercise 2.10
Proof: To show equality we will show \(\overline{A \cap B} \subseteq \overline{A} \cup \overline{B}\) and \(\overline{A} \cup \overline{B} \subseteq \overline{A \cap B}\)
\(\overline{A \cap B} \subseteq \overline{A} \cup \overline{B}\)
\[\begin{split} x \in \overline{A \cap B} \\ x \not\in A \cap B \\ \neg ( x \in A \land x \in B) \\ \neg(x \in A) \lor \neg (x \in B) \\ x \not\in A \lor x \not\in B \\ x \in \overline{A} \lor x \in \overline{B} \\ x \in \overline{A} \cup \overline{B} \end{split}\]\(\overline{A} \cup \overline{B} \subseteq \overline{A \cap B}\)
\[\begin{split} x \in \overline{A} \cup \overline{B} \\ (x \in \overline{A}) \lor (x \in \overline{B}) \\ (x \not\in A) \lor (x \not\in B) \\ \neg(x \in A) \lor \neg(x \in B) \\ \neg(x \in A \land x \in B) \\ \neg(x \in A \cap B) \\ x \in \overline{A \cap B} \end{split}\]
Prove the following proposition.
Proposition
Let \(A, B, C\) be sets. \(A \times (B \cup C) \subseteq (A \times B) \cup (A \times C)\)
Solution to Exercise 2.11
Proof: We look to show that \(p \in A \times (B \cup C) \rightarrow p \in (A \times B) \cup (A \times C)\).
Let \(p = (x,y)\) and assume \(p \in A \times (B \cup C)\). Therefore, \(x \in A\) and \(y \in B \cup C\). In turn, \(y \in B\) or \(y \in C\). Proceed by cases.
Let \(y \in B\). Then, \((x,y) \in A \times B\) and \(p \in (A\times B) \cup (A \times C)\).
Let \(y \in C\). Then, \((x,y) \in A \times C\) and \(p \in (A\times B) \cup (A \times C)\). \(\blacksquare\)
Prove the following proposition.
Proposition
Let \(A\) and \(B\) be non-empty sets. \(A \times B = B \times A\) if and only if \(A = B\).
Solution to Exercise 2.12
Proof: We must prove a biconditional.
\((\rightarrow)\) Assume \(A \times B = B \times A\). We look to show \(A = B\). Without loss of generality, suppose \(x \in A\). Since \(B \neq \varnothing\), there must be some \(y \in B\) such that \((x,y) \in A \times B\). Since \(A \times B = B \times A\), then \((x,y) \in B \times A\). Therefore, \(x \in B\). Hence, \(A = B\).
\((\leftarrow)\) Assume \(A = B\). Then, \(A \times B = A \times A = B \times A\) as required. \(\blacksquare\)
Let \(A,B,C,D\) be sets. Prove that: