Equivalences and Orderings
There are a number of special kinds of relations that are ubiquitous in mathematics. We have already studied functions-as-relations. Now we will explore two other kinds of common relations:
- The equivalence, which captures the notion of equality between objects in a universe
- The ordering, which captures the notion of, literally just that, ordering between objects.
Equivalences
Like functions, equivalences are a refinement of relations. In particular, a relation that enjoys these three properties, reflexivity, symmetry, and transitivity, is considered an equivalence.
A relation is reflexive if it relates every element in the universe to itself.
A relation is symmetric if any pair of related elements are also related "in the opposite direction."
A relation is transitive if whenever any pair of elements are related with a common element in the middle, the first and last elements are also related.
These three concepts form the definition of an equivalence relation.
The standard equality relation over the natural numbers is an equivalence relation as it fulfills all three properties of an equivalence:
Reflexive : Identical numbers are considered equal.
Symmetric : Order doesn't matter when asserting equality between numbers.
Transitive : When declaring and , we know that these two facts establish that and are the same number and and are the same number. From this, we can conclude that and must also be the same number.
Reasoning About Equivalences
To formally show that a relation is an equivalence, we must show that it obeys the three properties of an equivalence: reflexivity, symmetry, and transitivity. We show the outline of such a proof using the following real-world example, arithmetic expressions, e.g., or .
Let be the following relation:
Claim: is an equivalence relation.
To show that is an equivalence relation, we must show that it is reflexive, symmetric, and transitive.
Proof. We show that is a reflexive, symmetric, and transitive relation:
Reflexive : Because an arithmetic expression evaluates to a unique value, it must be the case that
Symmetric : Let and assume that . By the definition of , since the pair of expressions is related, they must evaluate to the same value . Because of this fact and the definition of , we know that the pair is related in the other direction, i.e., .
Transitive : Let and assume that and . By the definition of , this means that and evaluate to the same value, call it and and evaluate evaluate to the same value, call it . However, we know that an arithmetic expression evaluates to a unique value, so it must be the case that and are identical since they are both the result from evaluating . This means that as well.
Equivalence Closures
The closure of a set under a property is the (smallest) set whose elements all satisfy . The concept of closure lifts to relations in the expected way. For example, let and be the property of symmetry , then if is the relation:
Then the symmetric closure of is the relation :
We can compute the closure of any relation under a property by repeatedly applying the property to generate new pairs to add to the relation until we can no longer add new pairs.
We can apply the notion of closure to all the properties of an equivalence relation simultaneously to form an equivalence closure of a set of elements. Intuitively, the equivalence closure of a set of elements captures all the different equalities induced by the properties of equivalences.
For example, consider an artificial set and suppose we know that some relation relates the elements as follows:
If we furthermore know that ought to be an equivalence relation, then we can compute the equivalence closure of as follows:
- The reflexive closure of the relation relates every element to itself: .
- The symmetric closure of the relation relates every pair "in the other direction": .
- The transitive closure of the relation connects every transitive pair of elements: .
- Finally, we also have to consider the symmetric closure again for this new pair: .
In this particular case, the equivalence closure of is all nine possible pairs of with itself, i.e., . This case captures the intuition that the two original equalities are sufficient to deduce that all the elements of are equal.
Consider the following relation over universe :
Compute the equivalence closure of .
Equivalence Classes
Intuitively, an equivalence relation captures some notion of equality between objects. We can then think about grouping together sets of mutually equal objects. For example, let's return to arithmetic expressions. The following expressions are all equivalent to each other:
- .
- .
- .
Because they all evaluate to . Consider creating a set of such expressions, call it with the property that they all evaluate to :
Any pair of expressions within are equivalent to each other. We call such a set an equivalence class.
An equivalence class of an equivalence relation over universe is a set of elements drawn from that are pairwise equivalent according to , i.e.,
Recall that is the whole-number remainder of . Because of the nature of division, the result of takes on the values . Because of this, we can consider, e.g., the equivalences classes induced by taking a number and modding it by 3. takes on three values, , , and , and thus, induces three equivalence classes:
- .
- .
- .
In the context of the modulus operator, we can say that any pair of numbers in an equivalence class are equivalent modulo 3, e.g., and are equivalent modulo .
Orderings
There are many ways that we might order data. For a collection of strings, for example, we might order by:
- Simple length. For example, "dog" is less than "doghouse" since it is shorter.
- Lexicographical, i.e., dictionary order, comparing letter-by-letter. For example, "alphabet" is less than "zoo" in lexicographical ordering.
- A more arbitrary measure such as the number of consecutive trailing constants in the word. For example, "correctness" (-ss) comes before "algorithms" (-thms).
What is the essential nature of these relationships that make it a valid "ordering?" Let's start with the properties from an equivalence—reflexivity, symmetry, and transitivity—and use them In other words, which of the three properties of an equivalence—reflexivity, symmetry, and transitivity—are necessary for a relation to be considered an ordering? Let's consider numeric ordering as our quintessential example of orderings and each of these properties in turn:
- Reflexivity: appears to be reflexive because any number is equal to itself!
- Symmetry: appears to not be symmetric. For example, but .
- Transitivity: also appears to be transitive. If we establish that and , we form the following chain of comparisons with the understanding that this notation implies that , too.
So it seems like an ordering is reflexive, transitive, but not symmetric! However, it seems like we need to say something stronger than "not symmetric." To see this, observe that we never want different numbers to be related to each other in both directions. In other words, it should never be the case that and for different and ! We call this property anti-symmetry:
A relation is anti-symmetric if any pair of elements are related, at most, in one direction:
Observe how we have to define this "zero-or-one" property in the same way we do with uniqueness. Intuitively, the formal definition of anti-symmetry says that whenever two elements are related in both directions, they must be the same element.
With the definition of anti-symmetry, we can now formally define a partial ordering:
A relation is a partial ordering if it is reflexive, anti-symmetric, and transitive.
As an example of a partial ordering, consider a hierarchy of employees where an employee has a manager, their manager has a manager, and so forth. We say that one employee is higher in the hierarchy than another if the first employee is the direct or indirect manager (i.e., manager of their manager, manager of their manager's manager, etc.) of the second. We can consider the following notion of employee equality:
Along with an ordering based on the employee hierarchy:
We can show that this relation obeys the properties of a partial ordering:
Claim: is a partial ordering.
Proof. We show that is reflexive, anti-symmetric, and transitive.
: Reflexive. For any employee , since they have the same position.
: Anti-symmetric. Suppose we have two employees and and we know and . From the definition of , either it is the case that or and are mutually higher in the company hierarchy than the other. The former case is impossible because this would imply there is a cycle in the hierarchy, but that would violate the definition of a hierarchy. Thus, it must be the case that .
: Transitivity: Suppose we have three employees , , and and and . Since our definition of "higher-up" in the hierarchy includes both direct and indirect managerial relationships, since is higher-up than and is higher-up than , then is also higher up than . In other words, is either identical to or is at least one level of manager above .
Note that two employees that don't have a direct manager in common are incomparable by this definition because they don't appear in each other's chain of managers to the top of the hierarchy. This is why partial orders are named as such: some employees are incomparable to each other under this relation. To obtain this property, we add it directly to our definition, giving us a total ordering:
A relation is a total ordering if it is a partial ordering with the additional property that any pair of elements is related in either direction: