9. Relations
CAUTION - CHAPTER UNDER CONSTRUCTION!
NOTICE: If you are NOT enrolled in the CSC 230 course that I teach at SFSU, you probably are looking for the “public version” of the book, which I only update between semesters. The version you are looking at now is the “CSC230 version” of the book, which I will be updating throughout the semester.
This chapter was last updated on August 22, 2025.
added information to the subsection on the well-ordering of \(\mathbb{N}\)
Relations are used to describe an association of data.
For example, imagine a university database of students. The database needs to have a record for each student, and the student’s record needs to include fields for the student’s name(s), the unique student ID number for the student, the student’s current status, a list of courses that the student has enrolled in or has completed (along with the grade earned in each completed course,) and possibly other data associated with the student. One way to visualize the database is as a two-dimensional table, similar to a spreadsheet worksheet, where each row corresponds to a record and each column corresponds to a field; each row can be treated as an ordered \(n\)-tuple, where \(n\) is the number of fields.
In this chapter, you will learn about the formal definition of relation, operations and properties of relations. You will also learn about some special types of relations, namely partial orderings and equivalence relations. As a special case of equivalence relations, you will learn aobut congruence relations of integers as well as modular arithmetic.
Key terms and concepts covered in this chapter:
-
Relations
-
Properties of relations (reflexivity, symmetry, transitivity, and other properties)
-
Equivalence relations
-
Equivalence classes
-
-
Modular arithmetic
-
Congruences
-
-
Partial orders
-
Well orderings
9.1. Definition of Relation
Informally, a relation on two or more sets is an association between elements of those sets.
Formally, a relation is a subset of a Cartesian product of two or more sets.
For simplicity, it is assumed in this textbook that the number of sets used to form the Cartesian product is finite. It
is
possible to define relations as subsets of a Cartesian product of infinitely many sets, in which case the elements of the relation are infinite sequences.
Here are several examples of relations.
Notice that for any sets \(A_{1}, \, A_{2}, \, \ldots \, A_{n},\) where \(n \geq 2\) is a natural number, we always have the following two relations:
-
\(\emptyset,\) called the empty relation. This relation is also called the void relation and trivial relation in other sources.
-
\(A_{1} \times A_{2} \times \cdots \times A_{n},\) called the universal relation.
9.2. Binary Relations on a Single Set
In many cases, the two domains of a binary relation are the same set; for example, the relation may involve comparing two elements of a set S in some way. In this case, the domain \(S\) is mentioned only once: A binary relation on set S is any subset \(R\) of the cartesian product \(S \times S\), that is, \(R \subseteq S \times S.\)
In the case of a binary relation on \(S,\) we often write \(aRb\) to mean the same thing as \((a,b) \in R.\) This notation may make more sense after reading the following example.
9.2.1. Operations on Binary Relations on a Set
Given binary relations \(Q\) and \(R\) on a set \(S,\) we can define several other relations in terms of \(Q\) and \(R.\) These operations are likely familiar to you as operations on functions but they also work for binary relations on a single set.
-
The inverse of \(R\) is the relation \(R^{-1} = \{ (b,a) \, | \, (a,b) \in R \}.\)
-
The composition of Q and R is \(R \circ Q = \{ (a,c) \, | \, (a,b) \in Q \land (b,c) \in R \}.\)
-
The n th power of \(R\) is defined recursively for all \(n \in \mathbb{N}\) as follows.
-
\(R^{0} = \mathbf{id}_S\)
-
\(R^{k+1} = R \circ R^{k}\) for natural numbers \(k > 0.\)
The recursion step uses \(k\) instead of \(n\) in preparation for the type of arguments used in the chapter on proof by mathematical induction.
-
Building on the \(n\)th powers of \(R,\) we can define two relations.
-
\(R^{+}\) is the relation \(\{ (a,b) \in S \times S \, | \, (a,b) \in R^{k} \text{ for some positive integer } k \}.\) That is, \(R^{+}\) is the union of all the positive \(n\)th powers of \(R.\)
-
\(R^{*}\) is the relation \(\{ (a,b) \in S \times S \, | \, (a,b) \in R^{k} \text{ for some natural number } k \}.\) That is, \(R^{*}\) is the union of all the natural number \(n\)th powers of \(R.\)
Notice that \(R^{*} = \mathbf{id}_S \cup R^{+}.\)
9.2.2. Properties of Binary Relations on a Set
In this subsection we define five properties that a relation may satisfy.
The following theorem can make it easier to determine when a relationship has each of the five properties. The proof of the theorem is an exercise.
9.2.3. Closures of Binary Relations with Respect to a Property
For each of the properties reflexivity, symmetry, and transitivity, we define the closure with respect to the property of a relation \(R\) as follows: The closure is the smallest relation that has the property and includes all the elements of \(R.\) That is, you start with \(R\) and try to insert in just enough ordered pairs, if any are needed, to make sure that the new relation has the desired property.
The following theorem justifies that the reflexive closure, symmetric closure, and transitive closure exist for any relation \(R.\) The proof of the theorem is an exercise.
Notice that we can also define the reflexive and transitive closure of a relation \(R\) as the relation \(R^{*},\) which is the reflexive closure of the transitive closure of \(R.\)
However, for some properties, the closure of a relation \(R\) with respect to the property may not exist!
9.3. Equivalence Relations
A binary relation \(R\) on a set \(S\) is called an equivalence relation on \(S\) if \(R\) is reflexive, symmetric, and transitive.
A first example of an equivalence relation is the diagonal, that is, the equality relation. Another example is given below.
Given an equivalence relation \(R\) on the set \(S\) and an element \(x \in S,\) we define the equivalence class of \(x\) to be \([ x ]_{R} = \{ y \in S \, | \, (x,y) \in R \}.\)
9.4. Order Relations on a Set
It is often useful to be able to compare elements of a set, based on some key property. In this subsection, several examples of such order relations will be discussed.
9.4.1. Partial Orderings
A binary relation \(R\) on a set \(S\) is called a partial order on \(S\) if \(R\) is reflexive, antisymmetric, and transitive.
Total Orderings
A total ordering of a set \(S\) is a partial order \(R\) on \(S\) that has the additional property \((\forall x \in S)(\forall y \in S)(xRy \lor yRx).\)
Well-Orderings
A well-ordering of a set \(S\) is a total ordering \(R\) on \(S\) that has the additional property that every nonempty subset of \(S\) contains a least element with respect to the order relation.
One of the most important examples of a well-ordering in mathematics is the relation \(\leq\) on the set of natural numbers \(\mathbb{N}.\)
In the Remix, the Well-Ordering Principle is treated as an axiom, a statement that is assumed to be True about the set of natural numbers.
The Well-Ordering Principle may seem like an “obviously True” statement. To understand why mathematicians would make it clear that they are assuming that this principle is True is to understand what “infinity” means.
-
For example, suppose that you are told that a nonempty subset \(S\) of \(\mathbb{N}\) contains the element 10. A brute-force way to determine the least element of \(S\) is to ask a sequence of 10 questions: \[ \text{“Is 0 in \(S?,\)” “Is 1 in \(S?,\)” \(\ldots\), “Is 9 in \(S?\)”} \] If the answer is “No” to all 10 of these questions, then 10 itself is the least element in \(S\), otherwise, the least number in \(S\) is the first value of \(k\) for which the answer to the question “Is \(k\) in \(S?\)” is “Yes.”
-
Now, suppose that it takes 1 nanosecond to ask and answer each question of the form “Is \(k\) in \(S?\)” for each integer \(k,\) and suppose that you are given a new set, also called \(S,\) and told that the the number you can be sure is in \(S\) is \(10^{10^{10^{10^{10}}}}\) which is an integer greater than the number of nanoseconds estimated for our universe to reach its final energy state! If you try to use the brute-force method of asking a sequence of \(10^{10^{10^{10^{10}}}}\) questions: \[ \text{“Is 0 in \(S?,\)” “Is 1 in \(S?,\)” \(\ldots\), “Is \(\left( 10^{10^{10^{10^{10}}}}-1 \right)\) in \(S?\)”} \] it is possible that the answer to one of the questions is “Yes” but that you would never be able to ask that question before the universe ends. Notice that you can use formal logic to justify that either the answers to all the questions would be “No” or that at least one of the questions would have the answer “Yes” - asking the sequence of questions would determine the least element in \(S\) if you had time to ask enough of the questions, but you (or humanity itself!) may not have that much time. For this reason, mathematicians assume that the least element of \(S\) exists (Notice that a “timeless being” could know all the answers.)
9.5. Modular Arithmetic
For any positive integer \(m,\) you can define congruence modulo \(m\) as the relation \[\{ (a, b) \in \mathbb{Z} \times \mathbb{Z} \, : \, m \text{ divides } (a-b) \}.\] The symbol \(\equiv_{m}\) is used to represent this relation, that is \[a \equiv_{m} b \text{ if and only if } m \text{ divides } (a-b)\]
For each positive integer \(m,\) \(\equiv_{m}\) is an equivalence relation.
For any integer \(a,\) you can use the division algorithm to find the quotient and remainder such that \(a = q \cdot m + r\), where \(q\) and \(r\) are integers and \(0 \leq r < m,\) so every integer is congruent modulo \(m\) to one of the integers in the set \(\{ 0, 1, \ldots, m-1 \}.\) The set of equivalence classes \(\{ [ 0 ]_{\equiv_{m}}, \, [ 1 ]_{\equiv_{m}}, \, [ 2 ]_{\equiv_{m}}, \, \ldots \, [ m-1 ]_{\equiv_{m}} \}\) is the partition of \(\mathbb{Z}\) that corresponds to to the relation \(\equiv_{m}.\)
The following theorem proves that you can do addition and multiplication with the remainders (or, what amounts to the same thing, the equivalence classes) in the same way as was done with Evens and Odds in the previous example for the relation \(\equiv_{m},\) where \(m\) can be any integer greater than 1.
For example, we can write \(9 + 5 \equiv_{12} 2\) (This is an example of "clock arithmetic" using a 12-hour clock: 5 hours after 9 o’clock will be 2 o’clock.)
MORE TO COME!