Partial order
This article aims to provide an introduction to partial orders suitable for programmers. It is not intended to be a comprehensive overview of the mathematical theory. Changes to this should be discussed on the talk page.
A partial order or partial ordering is a structure imposed on a set, which may imply that some elements are smaller, less, or before other elements, in some sense of these words. It generalizes the familiar notion of less than or equal to on numbers and is represented by the symbol ≤.
Contents
Definition and properties
Formally, a partial order satisfies the following three properties:
- Reflexivity: for any element .
- Antisymmetry: If and , then .
- Transitivity: If and , then .
The first property tells us that an element is always less than or equal to itself. The second tells us that two elements cannot each be strictly less than the other. The third generalizes the familiar property of "chaining together" comparisons (the property that allows us to write and so on).
Two elements are said to be comparable under the partial order if and only if either or . Otherwise they are incomparable. A subset in which every pair of elements is comparable is known as a chain.
A set, taken together with a partial order on that set, is known as a partially ordered set or poset. Any subset of a poset is itself a poset under the same relation ≤.
A strict partial order is similar to a partial order, but instead defines a relation, usually denoted <, which satisfies the following three properties:
- Irreflexivity: for any element .
- Antisymmetry: If , then .
- Transitivity: If and , then .
We can convert a partial order into a strict partial order and vice versa by toggling reflexivity.
Examples of partially ordered sets
The following (and all their subsets) are (non-strict) posets:
- The set of all subsets of a given set, where if and only if .
- The set of all subgraphs of a given graph, where if and only if is a subgraph of .
- The set of all strings on a given alphabet, where if and only if is a substring of .
- The real numbers.
- The complex numbers, where if and only if and .
- The integers, where if and only if . (Note that this is not the familiar sense of "less than or equal to" on integers.)
- The Cartesian product of any number of posets, using the lexicographic ordering.
The following are strictly partially ordered sets:
- The set of human beings, where if and only if is an ancestor of .
- The set of employees in a corporate hierarchy, where if and only if supervises
- The set of courses in a university curriculum, where if and only if is a prerequisite for
- The set of all subsets of a given set, where if and only if .
- The set of all subgraphs of a given graph, where if and only if is a proper subgraph of .
- The set of all substrings of a given string, where if and only if is a proper substring of .
- The real numbers.
- The integers, where if and only if is a proper divisor of .
(The fact that some examples appear in one list but not the other does not suggest that some sets are non-strictly partially ordered but not strictly partially ordered, or vice versa; it just implies that the conversion is not meaningful.)
The following are not posets.
- The set of human beings, where if and only if is 's parent. This fails to be transitive.
- The set of human beings, where if and only if and are siblings. (This is actually an equivalence relation.) This fails to be antisymmetric.
- The complex numbers, where if and only if . This fails to be antisymmetric.
Representation as DAG
A cyclic relationship cannot exist among elements of a strict poset: if , then, by transitivity, we obtain , which violates irreflexivity. Therefore, if we now let each element of a poset correspond to a vertex in a digraph, with a path existing from to only if , we obtain a directed acyclic graph (DAG). (The fact that reachability is transitive is really what allows this correspondence to exist.) Note that this does not necessarily specify where the edges are in the DAG. If there are not enough edges, then the DAG will not fully represent the equivalence relation, because some paths might not exist between pairs of nodes even if they correspond to comparable elements. But there also cannot be too many; we must ensure that we do not add edges that cause a path to exist from to where or and are not comparable. Still, there may be many DAGs that correspond to, and uniquely specify, a given partial order; if edges and already exist, for example, then the edge would be redundant by transitivity (i.e, it would not alter the reachability properties of the DAG). Given the family of DAGs corresponding to and uniquely specifying a given partial order, the one with no redundant edges, that is, the least number of edges possible, is called the transitive reduction, and the one with all possible redundant edges, that is, the greatest number of edges possible, is called the transitive closure. A path in a the transitive closure of a DAG corresponds to a chain in the poset.
Total order
A totally ordered set is a partially ordered set in which every pair of elements is comparable, or, equivalently, the entire set is a chain. The structure is known as a total order or total ordering. Examples of totally ordered sets are the following, and subsets thereof:
- The real numbers.
- The complex numbers, where if and only if either or and .
- The words in a dictionary, where if and only if precedes in the dictionary. (Note that and represent words, not the literal strings a and b.)
- The Cartesian product of any number of totally ordered sets, using the lexicographic ordering.
- The people in a queue, where if and only if is ahead of .
The following are not totally ordered:
- The set of all subsets of a given set, where if and only if .
- The set of all subgraphs of a given graph, where if and only if is a subgraph of .
- The set of all strings on a given alphabet, where if and only if is a substring of .
- The complex numbers, using the usual relation — this is not defined on .
- The integers, where if and only if .
- The set of human beings, where if and only if is an ancestor of .
- The set of employees in a corporate hierarchy, where if and only if supervises .
- The set of courses in a university curriculum, where if and only if is a prerequisite for .
The transitive closure of a DAG corresponding to a total order looks like the complete graph, but with each edge oriented in the appropriate direction. The transitive reduction consists of a single path that contains all vertices.
Wellorder
A wellordered set (sometimes written with an intervening space or hyphen) is a totally ordered set with the property that every nonempty subset has a unique least element. The natural numbers are wellordered, as are the integers in any bounded interval, and the characters of the ASCII character set. We can also construct wellorderings on Cartesian products of wellordered sets using the lexicographic ordering. The reals are not wellordered using the usual relation ; consider for example the set of positive real numbers, which has no least element. Only elements of wellordered sets may be used to index arrays. (This explains why, for example, Pascal will allow integers, characters, and enumerated types as array indices, but not reals.)