Equivalence Relations and Partial Orders
Equivalence relations formalize sameness for a chosen purpose. Partial orders formalize comparison when not every pair must be comparable. Both are special kinds of relations, and both organize sets into useful structure.
The contrast is useful. Equivalence relations collapse a set into blocks of objects considered the same, such as integers with the same remainder modulo . Partial orders arrange objects by precedence or containment, such as tasks ordered by prerequisites or sets ordered by inclusion.
Definitions
A relation on is an equivalence relation if it is reflexive, symmetric, and transitive.
The equivalence class of is
A partition of is a collection of nonempty, pairwise disjoint subsets whose union is .
A relation on is a partial order if it is reflexive, antisymmetric, and transitive. A set with a partial order is a poset.
In a poset, elements and are comparable if or . A partial order in which every pair is comparable is a total order.
A Hasse diagram represents a finite poset by drawing only cover relations and omitting reflexive loops and edges implied by transitivity. An element covers if and no element lies strictly between them.
A minimal element has no strictly smaller element. A maximal element has no strictly larger element. A least element is below every element, and a greatest element is above every element. Least and greatest elements, if they exist, are unique; minimal and maximal elements need not be.
Key results
Equivalence relations and partitions are two views of the same structure.
If is an equivalence relation on , then its equivalence classes partition . Every element belongs to its own class by reflexivity. If two classes overlap, say , then and . Symmetry gives , and transitivity gives . Then any element related to is related to , and conversely, so the classes are equal. Thus distinct classes are disjoint.
Conversely, given a partition of , define if and lie in the same block. This relation is reflexive because each element lies in a block, symmetric because "same block" has no direction, and transitive because if and share a block and and share a block, then all three are in the same block.
For a partial order, antisymmetry prevents cycles among distinct elements: if and , then . This is why Hasse diagrams can be drawn upward without directed cycles.
Every finite nonempty poset has at least one minimal element and at least one maximal element. Starting from any element and repeatedly moving downward must eventually stop because the set is finite; where it stops is minimal. The upward argument gives a maximal element.
Topological sorting takes a finite partial order and produces a linear order compatible with it. This is fundamental for scheduling tasks with prerequisites.
Visual
This Hasse diagram represents divisibility on . Edges point upward from smaller to larger elements; implied transitive edges such as are omitted.
| Structure | Relation properties | Output structure | Example |
|---|---|---|---|
| equivalence relation | reflexive, symmetric, transitive | partition into classes | congruence modulo |
| partial order | reflexive, antisymmetric, transitive | ranked or constrained comparison | subset inclusion |
| total order | partial order plus comparability | linear order | on integers |
| strict order | irreflexive and transitive | directed acyclic comparison | on integers |
Worked example 1: Find equivalence classes modulo 4
Problem. On , define if . Prove this is an equivalence relation and list its classes.
Method.
- Reflexive: for every integer , , and . Thus .
- Symmetric: if , then . Since , , so .
- Transitive: if and , then and . Adding gives
so and .
- The possible remainders modulo are .
- Therefore the classes are
Checked answer. Congruence modulo is an equivalence relation, and its four equivalence classes partition the integers.
Worked example 2: Analyze a subset poset
Problem. Consider ordered by inclusion. Find the least element, greatest element, minimal elements, maximal elements, and determine whether it is a total order.
Method.
- The elements are all subsets of .
- The least element must be contained in every subset. The empty set satisfies this, so is least.
- The greatest element must contain every subset. The full set satisfies this, so it is greatest.
- Since a least element is below every element, it is the only minimal element:
- Since a greatest element is above every element, it is the only maximal element:
- The order is not total because and are incomparable:
Checked answer. The least and only minimal element is ; the greatest and only maximal element is ; the poset is not totally ordered.
Code
from itertools import combinations
def powerset(s):
items = list(s)
for r in range(len(items) + 1):
for combo in combinations(items, r):
yield frozenset(combo)
def equivalence_classes(items, related):
unseen = set(items)
classes = []
while unseen:
a = next(iter(unseen))
cls = {x for x in items if related(x, a)}
classes.append(cls)
unseen -= cls
return classes
print(equivalence_classes(range(12), lambda a, b: (a - b) % 4 == 0))
P = list(powerset({"a", "b", "c"}))
incomparable = [(x, y) for x in P for y in P if not x <= y and not y <= x]
print(incomparable[:5])
The first computation builds residue classes modulo on a finite sample. The second finds incomparable pairs in a subset poset.
Common pitfalls
- Calling a relation an equivalence relation after checking only two of reflexive, symmetric, and transitive.
- Confusing equivalence classes with individual representatives. Many representatives can name the same class.
- Forgetting that partition blocks must be nonempty, disjoint, and cover the whole set.
- Confusing antisymmetric with asymmetric. A partial order is reflexive, so it is not asymmetric unless the set is empty.
- Treating minimal as the same as least. There can be many minimal elements and no least element.
- Drawing all transitive edges in a Hasse diagram. Hasse diagrams omit edges implied by transitivity.
For equivalence relations, the fastest way to understand a relation is often to identify its invariant. Congruence modulo preserves remainder. Same birthday preserves month and day. Same connected component in a graph preserves reachability. The invariant tells you what the equivalence classes should be and helps prove the three required properties.
Equivalence classes are either identical or disjoint. They cannot partially overlap. This fact is often the key step when moving from a relation to a partition. If two classes share even one element, transitivity and symmetry force every member of one class to be a member of the other. This is why residue classes modulo cleanly split the integers.
For partial orders, draw a few comparable and incomparable pairs before looking for least or greatest elements. A least element must compare below every other element, not merely have nothing below it. A minimal element only needs no smaller element. In a set of tasks with two independent starting tasks, both can be minimal while neither is least.
Hasse diagrams are transitive reductions of finite posets. They omit loops because reflexivity is understood, and they omit long edges implied by shorter upward paths. If and , the diagram does not need a direct edge from to . The relation still contains ; the diagram simply avoids redundancy.
Topological sorting converts a finite partial order into one compatible linear order. There may be many valid linear extensions. If two tasks are incomparable, either order may be acceptable. This flexibility is useful in scheduling but also means that a topological order is not usually unique.
When proving a relation comes from a partition, use the phrase "same block" as the rule. This immediately gives reflexivity, symmetry, and transitivity because blocks are sets and each element lies in exactly one block. Conversely, when proving an equivalence relation creates a partition, the key is to show overlapping classes are equal.
For posets, examples with small power sets are useful test cases. In , the sets and are incomparable. This single example prevents the mistaken belief that subset inclusion is always a total order. Many scheduling and dependency orders have the same incomparability.
Connections
- Relations defines reflexive, symmetric, antisymmetric, and transitive.
- Modular arithmetic and cryptography supplies congruence classes.
- Sets and set operations supplies partitions and power sets.
- Graphs basics gives graph representations of relations and Hasse diagrams.
- Algorithms and complexity connects partial orders to topological sorting and scheduling.