Set Theory
A set is a collection of distinct objects. To create a set you simply list the objects between curly brackets. The objects in a set are called elements or members of the set. The order of the elements in the set is not important, and an element can only appear once in a set. If an element appears more than once, it is considered only once in the set.
- The set of the first three positive numbers is .
- The order doesn't matter, therefore, is the same as .
- Each element can only appear once, so is the same as .
However, a set doesn't have to contain numbers. A set also doesn't have to have a certain amount of elements it could also be infinite. This allows us to differentiate between finite and infinite sets. A set can also have no elements at all, the so-called empty set, and is represented by the symbol . You may also see the notation of or (phi) for the empty set. However I will be using .
- The infinite set of all positive integers is .
- The finite set of all colors in the rainbow is .
- The set of the three primary colors is .
Because a set is a collection of distinct objects it can also contain other sets. This is called a nested set.
- A set of sets:
- A set of sets of colors:
Cardinality
The cardinality of a set is the number of elements/members in that set. The cardinality of the empty set is 0. The cardinality of a finite set is a positive integer. The cardinality of an infinite set is infinity. Importantly becuase of the definition of a set repeated elements are not counted. The cardinality of the set is denoted by:
Not to be confused with the absolute value of a number.
Membership
To indicate that an element is a member of a set the symbol is used. To indicate that an element is not a member of a set the symbol is used.
If then:
- Is a member of the set: or
- Is not a member of the set: or
Equality
Because sets are characterized by their elements, two sets are only equal if they have the exact same elements. More formally, two sets and are equal if and only if every element of is an element of and every element of is an element of :
For sets to be equal, they must also have the same cardinality:
- because the order of the elements doesn't matter.
- because the second set has an element that is not in the first set.
- because only the distinct elements are considered.
Venn Diagrams
When working with sets, it can be very helpful to visualize them with venn diagrams. The sets are usually represented by circles. By creating a venn diagram, you can easily see the relations between sets.
Sub and Superset
is a subset of a set if all elements of are also elements of . is then also the so-called superset of . This is written as:
The superset relation is the opposite of the subset relation, so . This is written as:
If is not a subset of , then we write , and if is not a superset of , then we write .
- because all elements of the first set are also in the second set.
- because all elements of the first set are also in the second set.
- because not all elements of the first set are in the second set.
- because all elements of the second set are also in the first set.
If we analyse the cardinality of a subset and its superset, we can see that the cardinality of the subset has to be less than or equal to the cardinality of the superset:
If the symbol is underlined, then the sets can also be equal.
If is a subset of but not equal to , then is called a proper subset of . The same goes for the superset relation, if is a superset of but not equal to , then is called a proper superset of . However, a set is never a proper subset or superset of itself because it is equal to itself and can therefore not be a proper subset or superset.
- because all elements of the first set are also in the second set but the sets are not equal.
- because all elements of the first set are also in the second set and the sets are equal. Therefore it is not a proper subset but just a subset.
- because not all elements of the first set are in the second set.
- because all elements of the second set are also in the first set but the sets are not equal.
We can refine the above statement regarding the cardinality of a subset if it is a proper subset:
Because if the cardinality of the subset is equal to the cardinality of the superset, then the sets are equal and not a proper subset.
Because the empty set has no elements, it is a subset of every set, including itself. Therefore or for every set .
- because the sets are equal.
Defining a Set
There are multiple ways to define a set.
Roster Notation
The roster or also called enumeration notation defines a set by listing its elements between curly brackets separated by commas. This is the most common way to define a set and is what I have been using in the examples above.
- The set of the first three positive numbers is .
- The set of the first three positive even numbers is .
Semantic Definition
Sets can be described semantically using words and rules. This notation is less preffered as it can be more confusing, unclear and ambiguous.
Let be the first 3 positive integers that are odd. Therefore the set is then Let be the set of colors of the French flag. Therefore the set is then
Set-Builder Notation
This is probably the hardest notation to understand. The set-builder notation specifies a set as a selection from a larger set, determined by a condition on those elements. It commonly uses the following form:
Where is the variable, and is the statement or condition that must satisfy to be an element of the set. The vertical bar "|" is read as "such that". So the description can be read as "the set of all elements such that satisfies ".
If we define the set as the set of all integers, then the set of all positive integers that are less than 5 can be defined as:
Another example is the set of all even numbers:
We could mathmatically define when a number is even:
Sets of Numbers
The most common use of sets is to define the different types of numbers. The following are the most common sets of numbers and their notation:
- Natural Numbers : The set of positive integers. Depending on the author, this set can include 0 or not.
- Integers : The set of positive and negative whole numbers, including zero.
- Rational Numbers : The set of numbers that can be expressed as a fraction of two integers.
- Real Numbers : The set of all rational and irrational numbers.
- Complex Numbers : The set of numbers that can be expressed in the form where and are real numbers and is the imaginary unit.
If we visualize these sets with a venn diagram, we can see how they are related to each other and are all subsets of each other.
Natural Numbers
The natural numbers are the set of positive integers. The set of natural numbers is denoted by:
Depending on the author, 0 is included or not in the set of natural numbers. I prefer to include 0 in the set of natural numbers, as it makes more sense to me. This can cause confusion, so it is important to know some of the different notations used:
- If then 0 is not included in the set of natural numbers. The authors that do not include 0 in the set of natural numbers use the following notation to then include it .
- If then 0 is included in the set of natural numbers. The authors that include 0 in the set of natural numbers then commonly use the following notation to exclude it .
Integers
The integers are the set of positive and negative whole numbers, including zero. The set of integers is denoted by:
Multiple restrictions can be applied to the set of integers, for example:
Rational and Irrational Numbers
Rational numbers are numbers that can be expressed with a fraction of two integers. Importantly the denominator can not be zero as this is an undefined operation. Another way to remember them is that they can be written as terminating or repeating decimals. The set of rational numbers is denoted by:
The number is a rational number because it can be written as a fraction of two integers but also because it is a terminating decimal:
This fraction is also unique to each number, as for example the fraction can be shortened to the above solution by dividing the denominator an nominator by the common factor 2.
Another example is , which is a repeating decimal and can be written as the following fraction:
On the other hand, irrational numbers are numbers that cannot be expressed as a fraction of two integers. They can also not be written as terminating or repeating decimals, as their decimal expansions go on infinitely without repeating. Irrational numbers are usually denoted by the symbol .
For example, , not a rational number but an irrational number:
Another example of an irrational number is :
This however does not mean that all square roots are irrational numbers!
How do we know that is irrational and therefore doesn't repeat or terminate and can't be expressed as a fraction of two integers?
To prove that the square root of 2 is irrational, we need to assume that it is rational and then derive a contradiction. That is, we assume that can be expressed as a fraction of two integers, and then show that this assumption is wrong and leads to a contradiction. Suppose that is rational, and can be expressed as:
where and are integers with no common factors. We can assume that and are in lowest terms, meaning that they have been divided by their greatest common factor. After squaring both sides of this equation, we get:
Then multiplying both sides by , we get:
This means that is even, which implies that is also even (because the square of an odd number is odd). So we can write as for some integer . Substituting into the equation , we get:
Dividing both sides by 2, we get:
This means that is even, which implies that is also even (because the square of an odd number is odd). But this contradicts our assumption that and have no common factors, since they both have a factor of 2. Therefore, our initial assumption that is rational must be false, and we conclude that is irrational.
Real Numbers
Real numbers are the combination of rational and irrational numbers, i.e. all numbers from both sets. The set of real numbers is denoted by .
This can also be thought of as the set of all points on the number line.
Infinity is not a number in the traditional sense, but rather a concept that refers to something, limitless i.e. without end. Therefore it is not an element of any set of numbers, including the real numbers.
Heron's Method
Using Heron's method we can approximate a real number by a rational number with any desired accuracy. The idea is that a square with an area of has a side length of .
To approximate we start by creating a rectangle which we know the area of and then slowly adjust the sides to get closer to a square with the area of and therefore the side length of .
We start with a guess and then calculate the next guess by taking the average of the previous guess and the area divided by the previous guess.
This can be repeated until the desired accuracy is reached:
To approximate we start with a guess of . We then calculate the next approximation:
If we then repeat this process we get for which is a good approximation of .
Complex Numbers
The set of complex numbers is denoted by . You can see what complex numbers are and how they are used here.
Set Operations
There are several operations that can be performed on sets. These operations are similar to the operations that can be performed on numbers such as addition and subtraction.
Intersection
A new set can also be constructed by determining which elements two sets have "in common", this results in the so called intersection of and . This is written as . The intersection is the set of all things that are elements of both and .
To remember the difference between the union and intersection symbols, you can think of the union symbol as a "U" for "union".
We can also observe that the cardinality of the intersection of two sets has to be less than or equal to the cardinality of the set with the least amount of elements:
Disjoint Sets
If , then we call and disjoint sets. This means that the sets have no elements in common. This also means that the cardinality of the intersection of two disjoint sets is 0. Therefore two sets are disjoint if and only if the cardinality of their intersection is 0.
- so and are disjoint sets.
- so and are not disjoint sets.
- so and are disjoint sets.
Arbitrary Intersections
Union
Two sets can be joined together, this results in a so-called union of and . This is written as . The union is the set containing all elements that are in or or both.
From the definition and image above we can also make some statements regarding the cardinality of the union of two sets. The cardinality of the union of two sets has to be greater than or equal to the cardinality of the set with the most amount of elements:
We can also see that the cardinality of the union of two sets can be calculated by adding the cardinalities of the two sets and then subtracting the cardinality of the intersection of the two sets. This is because the intersection is counted twice when adding the cardinalities of the two sets:
This also means that if the two sets are disjoint, then the cardinality of the union of the two sets is equal to the sum of the cardinalities of the two sets:
Arbitrary Unions
Difference
If and are sets, then the relative complement (or short difference) of and , is the set of elements in without the elements of . This is written as .
We can observe that the cardinality of the difference of two sets has to be less than or equal to the cardinality of orginal set we are taking the difference from.
If and are disjoint sets, then the difference of and is just . Therefore the cardinality of the difference of two disjoint sets is equal to the cardinality of the first set:
We can also see that the cardinality of the difference of two sets can be calculated by subtracting the cardinality of the intersection of the two sets from the cardinality of the first set:
Symmetric Difference
The symmetric difference of two sets (also known as the disjunctive union), is the set of elements which are in either of the sets, but not in both sets (their intersection). This can be written as .
To calculate the cardinality of the symmetric difference of two sets we can use the following:
The intersection of two sets is counted twice when adding the cardinalities of the two sets, so we have to subtract it twice.
Complements
The so called absolute complement of (or simply the complement of ) is the set of elements not in . In other words, let be a set that contains all the elements under study, also called the universal set. The universal set is not always explicitly mentioned, but is rather implied or obvious such as one of the defined sets of numbers. The complement of is the difference between the universal set and and is denoted by .
Given the universal set :
Cartesian Product
The cartesian product of two sets and , denoted by . The cartesian product is the set of all possible ordered pairs where is an element of and is an element of . This can be thought of as the set of all possible combinations of elements from the two sets i.e. if we start with the first element of the first set and then combine it with all the elements of the second set, then we move to the second element of the first set and combine it with all the elements of the second set and so on.
This could also be used if say we had two dice and we wanted to know all the possible outcomes of rolling them both. We could then define the set to represent a dice and then calculate the cartesian product . All the possible outcomes would then be the elements of the cartesian product.
From the image we can see that the cardinality of the cartesian product of two sets is as if we were calculating the area of a rectangle. The cardinality of the cartesian product of two sets is the product of the cardinalities of the two sets:
Cartesian Power
The idea of the cartesian product can be extended to a so called cartesian power of a set. If we take the cartesian product of a set with itself we get the cartesian power of to the power of 2, denoted by .
This can then be generalized to the cartesian power of to the power of , denoted by .
This is especially useful if for example we wanted to define all the possible points in 2D space. This could be done with the cartesian power of the set of real numbers to the power of 2, . Where the first element of the ordered pair would represent the x-coordinate and the second element the y-coordinate. This could then be extended to 3D space with and so on hence the name cartesian power and cartesian plane.
Operation Properties
such as commutative, associative, distributive also for example when are brackets needed.
Power Set
The power set or also called super set of a set is the set containing all possible subsets of . Importantly the empty set and itself are also elements of the power set of , because these are also both subsets of . The power set of the set is commonly written as: , , or . I will use the notation .
To create the power set of a set, we can use either a tree diagram or a hasse diagram. The tree diagram is the most common way to create a power set, but the hasse diagram is a more compact way to represent the power set.
For the tree diagram, we start with the empty set and then add the elements of the original set one by one. For each element we have two choices, either include it in the subset or not.
This results in a binary tree with leaves, where is the number of elements in the original set. This also tells us that the cardinality of the power set of a set with elements is .
To create the hasse diagram, we start at the bottom with the empty set and then add the elements of the original set one by one. We then connect the subsets that are related to each other, i.e. if one subset is a subset of another subset. This also results in a diagram where the subsets are ordered by their cardinality from top to bottom.
Importantly the power set of the empty set is the set containing only the empty set. This also means that the cardinality of the power set of the empty set is 1 not 0.
If we have , the power set of the cartesian plane, then this would be the set of all possible subsets of the cartesian plane. This would be the set of all possible shapes and areas that can be created in 2D space. So an element of this power set could be a point, a line, a circle, a square, a triangle, a function and so on.
Partitions
A partition of a set is a set of non-empty subsets of such that every element is only exactly in one of the subsets in . This means that the subsets in are disjoint and their union is equal to . Therefore the partition of a set can be thought of as a way to divide the set into non-overlapping parts. This can be summarized as the following:
- P does not contain the empty set, so .
- The union of all the sets in is equal to , so .
- The elements of don't overlap i.e the sets in are disjoint, so for all .
The set has 5 possible partitions:
The following are not partitions of {1,2,3}:
- is not a partition because one of its elements is the empty set.
- is not a partition because the element 2 is contained in more than one block.
- is not a partition of because none of its blocks contains the element 3.
De Morgan's Laws in Sets
Indexed Sets
https://faculty.etsu.edu/gardnerr/3000/notes-MR/Gerstein-2-6.pdf (opens in a new tab)
Multisets or Bags
A multiset in maths or bag in computer science is a set that allows for multiple instances of the same element. This means that the elements of a multiset are not unique and can be repeated. Think of it is a big bag where you can throw in pretty much anything and the order doesn't matter.
In maths multisets are rarely seen or used, but in computer science they are used to represent collections of objects where the order doesn't matter and the same object can appear multiple times.