A set is a basic structure for storing collections of unordered elements. A set is a structure with ``low overhead’’ for keeping track of distinct elements that do not need to be accessed in a particular order. Here are some important things to keep in mind about sets:
Figure 1: The set of decimal digits
Figure 1 shows the set of ten decimal digits. The set is named \(\mathbf{D}\). The members of this set are the ten decimal digits – \(1,2,3,4,5,6,7,8,9\). The members are also referred to as the elements of the set. Note that the elements are not listed in any particular order.
To indicate that the digit 6 is a member of \(\mathbf{D})\), we write \(6 \in bathbf{D}\). The fact that 10 is not a member of the set is written as \(6 \notin \mathbf{D}\). The number of elements in the set is called its . More formally, the size of a set is its and is denoted as \(\vert \mathbf{D} \vert\). For the decimal digits set, \(\vert \mathbf{D} \vert = 10\).
Another example of a set that you may relate to is a collection of songs to form a non-repeating, random playlist. Other common sets are: the set of all Real numbers, the set of all right triangles, the set of Marsupials, and the set of all reserved keywords in the Python programming language. In applications, a set can be used to collect information from business transactions or data comprising a patient’s health record.
Set theory entails the study of sets, the interaction of elements within a set, the operations that can be performed on sets and the truths that are implied from the assumptions made about a set or collection of sets. Set theory lays the foundation for studying mathematics.
There are a couple of ways to create a set. If the set is small or the elements have a pattern between them that can be explicitly written, the set can be defined with an comma-separated list wrapped in curly brackets.
Example 1: We create a set named \(\mathbf{A}\) by listing the elements in the set, \(\mathbf{A} = \{1, 2, 3, 4\}\). The set \(\mathbf{A}\) contains four elements: 1, 2, 3, and 4. To emphasize that ordering in a set does not matter, the set \(\mathbf{A}\) can also be written equivalently as \(\mathbf{A} = \{2, 3, 4, 1\} = \{2, 4, 1, 3\}.\)
A second method to create a set is to specify a rule that must be satisfied by the element, that is the statement must be true for the element, in order for the element to be in the set.
In Example 2, we define a set within the context of a web browser. Web content is inspected (crawled) and indexed by service providers to help users find information. A part of that process is knowing what words are on a webpage.
Example 2: Define the rule “\(r(x)\) = If \(x\) is a word on the current page, then \(x\) is in the set \(\mathbf{S}\)”. Here the set \(\mathbf{S}\) is a collection of words that we can then use to index the page with. Even though the words on the page have a contextual ordering, \(\mathbf{S}\) will be an unordered collection. Also, on our current page, the word set'' appears many times, butset’’ will only be included in \(\mathbf{S}\) once.
There are many sets in mathematics that are so common they have reserved names. The following two examples discuss sets that are used frequently.
Example 3: The set \(\mathbb{Z}^+\) is the set of all positive integers. Note that there is no end to the list of positive integers. The set \(\mathbb{Z}^+\) has an infinite number of elements, but we can still define \(\mathbb{Z}^+\) with set notation using an ellipse, a set of three lower dots, at the end to suggest the pattern. \(\mathbb{Z}^+ = \{ 1, 2, 3, \ldots \}\)
Example 4: The set \(\mathbb{Z}\) is the set of all integers. An ellipse is used at the beginning and the end of the list to indicate that the list is infinite in both directions and continues the pattern. \(\mathbb{Z} = \{ \ldots , -3, -2, -1, 0, 1, 2, 3, \ldots \}\).
The sets \(\mathbb{Z}\) and \(\mathbb{Z}^+\) are both infinite sets since the listing of elements continues without stopping. However, we could number these elements so the size of these sets is said to be ``countably infinite.’’ We will cover the idea of a set’s size later. The important point for now is that you can list out elements in an infinite set if there is a clear pattern for the next element. Our final example illustrates another important countably infinite set of numbers. What would you call the following set?
Example 5: A number \(x\) is in the set \(\mathbf{E}\) if and only if \(x = 2y\) for some element \(y\) in \(\mathbb{Z}\).
\[\mathbf{E} = \{ \ldots , -4, -2, 0, 2, 4, \ldots \}\]
A note about the language used in Example 5. The phrase “if and only if” is used to help break down the statement used to define the set \(\mathbf{E}\) in a way that will come in handy when proving an element is in the set \(\mathbf{E}\) and when examining the structure of any element we know to be in the set \(\mathbf{E}\).