Introduction
Order theory is the branch of mathematics that formalizes the concept of order using binary relations. This page introduces its basic definitions.
Definitions
Binary relations
Definition
A binary relation on sets and , denoted , is defined as the tuple , where is called the domain, the codomain, and the graph of the binary relation . holds if and only if .
If , the binary relation is called a homogeneous relation or an endorelation.
Unless stated otherwise, all binary relations below are homogeneous relations.
For example, on , divisibility and less-than-or-equal-to are both binary relations.
When studying binary relations, we are often interested in whether they have certain special properties. For a set and a binary relation on it, define the following properties:
- Reflexive: ,
- Irreflexive (anti-reflexive): ,
- Symmetric: ,
- Antisymmetric: ,
- Asymmetric: ,
- Transitive: ,
- Connected: ,
- Well-founded: (that is, a nonempty set contains a minimal element ),
- Transitive of incomparability: (if , then and are called incomparable).
We also define several special binary relations:
| Binary relation | Reflexive | Irreflexive | Symmetric | Antisymmetric | Asymmetric | Transitive | Connected | Well-founded | Transitive of incomparability |
|---|---|---|---|---|---|---|---|---|---|
| Equivalence relation | Yes | Yes | Yes | ||||||
| Preorder (quasiorder) | Yes | Yes | |||||||
| Partial order | Yes | Yes | Yes | ||||||
| Total order | Yes | Yes | Yes | Yes | |||||
| Well-order | Yes | Yes | Yes | Yes | Yes | ||||
| Strict preorder | Yes | Yes | |||||||
| Strict partial order | Yes | Yes | Yes | ||||||
| Strict weak order | Yes | Yes | Yes | Yes | |||||
| Strict total order | Yes | Yes | Yes | Yes |
Operations on relations
For sets and , and binary relations and on them, we can define the following operations:
- The union of and , , satisfies (for example, is the union of and ),
- The intersection of and , , satisfies ,
- The complement of , , satisfies ,
- The dual of , , satisfies .
For sets and with a binary relation , and sets and with a binary relation , we can define their composition by .
Partially ordered sets
Definition
If, on a set , a binary relation is reflexive, antisymmetric, and transitive, then is called a partially ordered set (poset), and is a partial order on it.
If the partial order is also connected, it is called a total order. The corresponding set is called a totally ordered set, a linearly ordered set (loset), or a simply ordered set.
It is easy to see that , , , and are all totally ordered sets under .
Visual representation of a poset: Hasse diagrams
For a finite poset, we can use a Hasse diagram to visualize its partial order.
Definition
For a finite poset with partial order , define . Its corresponding Hasse diagram is a graph satisfying:
- ,
For example, for the power set , denoted , with the subset relation , the corresponding Hasse diagram is:
Because a partial order is antisymmetric, a Hasse diagram is necessarily a directed acyclic graph. We can therefore construct a total order for any finite poset using topological sorting.
Chains and antichains
Definition
For a poset with partial order , a totally ordered subset of is called a chain. If has a subset in which every pair of distinct elements is incomparable (that is, ), then is called an antichain.
For a poset with partial order , we call the length of the longest antichain of the width (partial-order width).
For example, for the power set , denoted , with the subset relation , is a chain, is an antichain, and the width of is .
Special elements in preordered sets
In a preordered set, we can define concepts such as maximal and minimal elements, upper and lower bounds, and suprema and infima. These concepts extend to other order relations.
Definition
For a preordered set with preorder , take an element of , :
- If , then is a maximal element,
- If satisfies , then is an upper bound of ,
- If satisfies that is an upper bound of and every upper bound of , , satisfies , then is the supremum of .
The concepts of a minimal element, lower bound, and infimum are defined analogously.
For example, is a minimal element and a lower bound of .
It can be proved that:
-
In a preordered set, maximal and minimal elements, upper and lower bounds, and suprema and infima need not exist; even when they exist, they need not be unique.
-
If a poset has a subset with a supremum or infimum, it is unique.
We denote the supremum and infimum of by and , respectively. If a poset has both an upper bound and a lower bound, then is called bounded.
In an infinite poset, a maximal element need not exist. Zorn's Lemma can be used to determine whether an infinite poset has a maximal element.
Zorn's Lemma
Zorn's Lemma, also called the Kuratowski–Zorn Lemma, states that if every chain of a nonempty poset has an upper bound, then the poset has a maximal element.
Zorn's Lemma is equivalent to the axiom of choice and the well-ordering theorem.
Directed sets and lattices
We know that if a subset of a poset has a supremum or infimum, it is unique. This does not hold for maximal and minimal elements. For example, consider the poset under the partial order . It is easy to see that it has maximal elements and minimal elements.
We would like to add conditions to a poset so that whenever a maximal or minimal element exists, it is unique; this would let us define greatest and least elements.
Directed sets
For a preordered set with preorder , if , then is called a direction on , and is called a directed set or a filtered set.
A set satisfying the definition above is sometimes called an upward directed set; a downward directed set is defined similarly.
Directed sets can also be defined as follows:
Equivalent definition of a directed set
For a preordered set with preorder , if every finite subset of (denoted ) has an upper bound, then is called a direction on , and is called a directed set.
It is easy to see that:
- If an upward directed set has a maximal element, it is unique. We call the maximal element of an upward directed set its greatest element.
- If a downward directed set has a minimal element, it is unique. We call the minimal element of a downward directed set its least element.
In a directed poset, for any elements , the set has an upper bound. Replacing “upper bound” with “supremum” gives the definition of a join-semilattice.
For a poset with partial order :
Join-semilattice
If is such that, for any elements , the set has a supremum , then is called a join-semilattice (upper semilattice), and is called the join of and , denoted .
Meet-semilattice
If is such that, for any elements , the set has an infimum , then is called a meet-semilattice (lower semilattice), and is called the meet of and , denoted .
Lattice
If is both a join-semilattice and a meet-semilattice, then is called a lattice.
For example, the set of positive divisors of , , forms a poset under divisibility. For any positive integers in it, is the join of and , while is the meet of and , so is a lattice.
Duality
Duality is a common concept in order theory. Examples mentioned above include the duality between maximal and minimal elements, between upper and lower bounds, and between suprema and infima.
For a poset with partial order , define its dual (opposite) poset by: holds in if and only if holds in . Reversing the edges of the Hasse diagram of gives the Hasse diagram of .
Dilworth's theorem and Mirsky's theorem
For a finite poset with partial order , we have the following pair of dual theorems:
Dilworth's theorem
The width of (the length of its longest antichain) equals the minimum number of chains in a chain cover.
Proof
Consider induction. When , the claim is obvious.
Assume the claim holds for every poset with fewer than elements, and let the width of be . If all elements are pairwise incomparable, the claim is obvious; otherwise, choose in a chain of length greater than , and let its minimal and maximal elements be and .
Let . If the width of is at most , then by induction can be covered by at most chains, so can be covered by those chains together with the chain , proving the claim. Otherwise, the width of is also ; let the longest antichain in be .
Consider the following two sets:
It is easy to see that:
- ,
- ,
- , (because and ).
Applying the induction hypothesis to both and , their minimum chain-cover number is , and each of these covers contains exactly one element of the antichain , say . Denote the corresponding chains by and . Then is a minimum chain cover of , proving the claim.
Mirsky's theorem
The length of the longest chain in equals the minimum number of antichains in an antichain cover.
Proof
Let the length of the longest chain in be . By definition, the minimum number of antichains in a cover is at least .
Let be the length of the longest chain whose minimal element is . If , then and are incomparable, so is an antichain, where is called a level set.
It follows that is an antichain cover, so the minimum number of antichains in a cover is at most .
Dilworth's theorem is equivalent to Hall's marriage theorem.
We can use Dilworth's theorem to prove the following theorem:
Erdős–Szekeres theorem
A real sequence with at least elements, , either has a nondecreasing subsequence of length or a nonincreasing subsequence of length .
Proof
Let the sequence length be , and define the poset with partial order given by:
If the width of this poset is at most , then by Dilworth's theorem it can be covered by at most chains. If all those chains have length at most , the sequence contains at most elements, contradicting the assumption.
Examples
Luogu P1020 [NOIP 1999 Advanced Group] Missile Interception
To defend against missile attacks from an enemy country, a country developed a missile-interception system. However, the system has a defect: although its first shell can reach any altitude, every later shell cannot be higher than the preceding shell. One day, radar detected incoming enemy missiles. Since the system was still in a trial phase, there was only one system, so it might not be possible to intercept all the missiles.
Given the altitudes of the missiles in arrival order, compute how many missiles this system can intercept at most, and how many such systems are needed at minimum to intercept all missiles.
For all test data, missile altitudes are positive integers no greater than .
Solution
Suppose there are missiles, and the altitude of the -th missile is . Then is a poset with partial order defined by:
By Dilworth's theorem, the minimum number of nonincreasing subsequences covering the sequence equals the length of its longest increasing subsequence. Thus the problem can be solved using the method for the longest nondecreasing subsequence.
Reference code
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> a;
int x;
while (cin >> x) a.push_back(x);
vector<int> f, g;
for (int i : a) {
if (f.empty() || -i >= f.back())
f.push_back(-i);
else
*upper_bound(f.begin(), f.end(), -i) = -i;
if (g.empty() || i > g.back())
g.push_back(i);
else
*lower_bound(g.begin(), g.end(), i) = i;
}
cout << f.size() << '\n' << g.size() << '\n';
return 0;
}
[TJOI2015] Combinatorics
Given an -row, -column grid, with some treasures in every cell. Starting from the upper-left corner, one may move only right or down, and may collect at most one treasure each time a cell is visited. What is the minimum number of traversals needed to collect all treasures?
, , and each cell contains at most treasures.
Solution
Ignoring vertex weights, it is easy to see that walking on the grid under the given rules is equivalent to walking on a DAG. We can therefore regard it as a Hasse diagram to construct a poset, and Dilworth's theorem gives: the minimum chain-cover number of a DAG equals the size of its largest vertex-independent set.
Therefore, the answer is the total weight of a maximum-weight independent set in the given grid graph.
Let be the weight of grid vertex , and let be the answer for the subgrid from to . Since each vertex is nonadjacent to its upper-right vertex, the state transition is:
The answer is .
Reference code
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int t = 0;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector<vector<int64_t>> a(n, vector<int64_t>(m));
for (auto &i : a)
for (auto &j : i) cin >> j;
vector<vector<int64_t>> f(n, vector<int64_t>(m));
for (int i = 0; i < n; ++i)
for (int j = m - 1; j >= 0; --j)
f[i][j] =
max({(i == 0 ? 0 : f[i - 1][j]), (j == m - 1 ? 0 : f[i][j + 1]),
(i == 0 || j == m - 1 ? 0 : f[i - 1][j + 1]) + a[i][j]});
cout << f[n - 1][0] << '\n';
}
return 0;
}
Exercises
Applications in C++
See also: STL related to sorting — Basic algorithms.
The C++ STL algorithms and data structures requiring comparisons apply order theory. We often need to define custom comparators in C++; the STL requires them to be a strict weak order. Let be a custom comparator; then we can define:
- as ;
- as ;
- as ;
- as .
References and further reading
- Order theory - From Academic Kids
- Binary Relation - Wikipedia
- Order Theory - Wikipedia
- Hasse diagram - Wikipedia
- Directed set - Wikipedia
- Order Theory, Lecture Notes by Mark Dean for Decision Theory
- Kaicheng Lu, Huaming Lu, Combinatorics (3rd ed.), 2006
- List of Order Theory Topics - Wikipedia
- A discussion of applications of adjacent-swap sorting and points to note by ouuan
- One thing you should know about comparators—Strict Weak Ordering
- Dilworth's theorem - Wikipedia
- Dilworth's Theorem | Brilliant Math & Science Wiki
- Hall's marriage theorem - Wikipedia
- Hall's Marriage Theorem | Brilliant Math & Science Wiki
- Dilworth study notes - Selfish