Section 1 · 9 min read
Sets, relations, functions, partial orders and lattices
Set identities, properties and counts of relations, equivalence relations and partitions, function types and their counts, posets, Hasse diagrams and lattices.
On this page
This topic produces counting questions (how many relations have property X, how many onto functions), property checks on a given relation, and questions on posets and lattices. The counting formulas below cover most of them.
Sets
Operations and identities
For sets inside a universe :
- De Morgan: , .
- Distribution: and the dual.
- Difference: .
- Symmetric difference: . It is associative and .
Sizes:
- , .
Countability
, , , the set of all finite strings over a finite alphabet, and a countable union of countable sets are countable. , and the set of all functions are uncountable (Cantor's diagonal argument). This links to theory of computation: there are countably many Turing machines but uncountably many languages.
Relations
A relation on a set is a subset of . With there are ordered pairs and relations.
Properties
| Property | Definition | In the 0-1 matrix |
|---|---|---|
| Reflexive | for all | diagonal all 1 |
| Irreflexive | for all | diagonal all 0 |
| Symmetric | matrix equals its transpose | |
| Antisymmetric | no off-diagonal pair has both 1 | |
| Asymmetric | antisymmetric and irreflexive | |
| Transitive | (Boolean product) |
Symmetric and antisymmetric are not opposites. The empty relation and the identity relation are both. "Not reflexive" is also different from "irreflexive".
Counting relations on an -element set
The diagonal has pairs. The off-diagonal has pairs, forming unordered pairs .
| Relations that are | Count |
|---|---|
| All | |
| Reflexive | |
| Irreflexive | |
| Symmetric | |
| Reflexive and symmetric | |
| Antisymmetric | |
| Asymmetric | |
| Both symmetric and antisymmetric | (subsets of the diagonal) |
The idea behind every row: decide each diagonal pair independently, then decide each unordered off-diagonal pair. For antisymmetric, each off-diagonal pair has 3 allowed states: neither, only , only .
There is no simple closed formula for the number of transitive relations or partial orders. For small , memorise: partial orders on 1, 2, 3, 4 elements number 1, 3, 19, 219.
Closures
- Reflexive closure: , where is the identity relation.
- Symmetric closure: .
- Transitive closure: ; computed by Warshall's algorithm in .
Equivalence relations and partitions
An equivalence relation is reflexive, symmetric and transitive. Its classes partition , and every partition comes from exactly one equivalence relation. So
- the number of equivalence relations on elements is the Bell number : for ;
- the number with exactly classes is the Stirling number of the second kind , with .
Useful values: , .
The intersection of two equivalence relations is an equivalence relation. The union need not be (transitivity can fail).
Functions
assigns exactly one element of to each element of . With and :
| Type | Count |
|---|---|
| All functions | |
| One to one (injective), | |
| Onto (surjective), | |
| Bijections, |
Composition facts used in "which is always true" questions, for , :
- injective injective.
- surjective surjective.
- Both injective injective; both surjective surjective.
A function has an inverse exactly when it is a bijection.
Partial orders and lattices
Posets
A partial order is reflexive, antisymmetric and transitive. A Hasse diagram draws only the covering pairs (no loops, no edges implied by transitivity), with larger elements higher.
Terms: maximal (nothing strictly above), greatest (above everything, unique if it exists), and the duals minimal and least. A finite poset always has at least one maximal and one minimal element, but may lack a greatest or least one. A chain is a totally ordered subset; an antichain is a set of pairwise incomparable elements.
A topological sort (linear extension) of a finite poset always exists.
Lattices
A poset is a lattice if every pair has a least upper bound (join) and a greatest lower bound (meet). Every finite lattice is bounded: it has a least element and a greatest element .
- Distributive: for all elements. A lattice is distributive iff it contains no sublattice isomorphic to (the diamond: 0, three incomparable atoms, 1) or (the pentagon).
- Complemented: every has some with and .
- In a distributive lattice each element has at most one complement.
- Boolean algebra: a complemented distributive lattice. Every finite Boolean algebra has elements and looks like .
Standard examples:
| Poset | Lattice? | Notes |
|---|---|---|
| yes | Boolean algebra, meet , join | |
| , divisors of | yes | distributive; Boolean iff is square free |
| Any chain | yes | distributive, complemented only if at most 2 elements |
| yes | meet , join ; no greatest element |
Worked examples
Worked example 1: Counting antisymmetric relations
How many antisymmetric relations are there on ?
- Diagonal: 4 pairs, each in or out: .
- Unordered off-diagonal pairs: , each with 3 allowed states: .
- Total .
Worked example 2: Onto functions
How many onto functions are there from a 5-element set to a 3-element set?
Inclusion-exclusion over the codomain elements that are missed: Check: .
Worked example 3: Is the relation an equivalence?
On , define iff .
- Reflexive and symmetric: clear.
- Transitive: and give .
So is an equivalence relation. Squares mod 5 take values : residue 0 gives 0; residues 1, 4 give 1; residues 2, 3 give 4. So there are 3 classes.
Any relation of the form " iff " is an equivalence relation, with one class per value of that is actually hit.
Worked example 4: Complements in a divisor lattice
In , find the complement of 6. In , does 2 have a complement?
- is square free. Complement of 6 is : , .
- In we need and . The lcm forces , which contradicts . So 2 has no complement, and is not a Boolean algebra.
Worked example 5: Is this poset a lattice?
Poset on with , , , , and no other strict relations.
Upper bounds of are and , which are incomparable, so there is no least upper bound. Not a lattice. This "bowtie" shape is the smallest example where pairs have upper bounds but no join.
Common traps
- Confusing symmetric and antisymmetric as opposites.
- Forgetting that divisibility on all nonzero integers is not antisymmetric ( and ).
- Using for symmetric relations. That count is for reflexive and symmetric; plain symmetric is .
- Counting onto functions as or similar. Use inclusion-exclusion.
- Assuming a complemented lattice is distributive. The diamond is complemented but not distributive, and its atoms have two complements each.
- Mixing up maximal and greatest. A poset can have several maximal elements and no greatest one.
- Assuming the union of two equivalence relations is an equivalence relation.
Quick revision
- Relations on elements: . Reflexive: . Symmetric: .
- Reflexive and symmetric: . Antisymmetric: . Asymmetric: .
- Equivalence relations: Bell numbers . With classes: .
- Functions : . Injective: . Onto: .
- Partial orders on 3 elements: 19.
- injective forces injective; onto forces onto.
- Lattice: every pair has join and meet. Distributive iff no or sublattice.
- is Boolean iff is square free.
- Boolean algebra = complemented + distributive; finite ones have elements.