Formal Methods 101: Binary Relations

This is part 2 of 11 in the Formal Methods 101 series. It builds on the sets and Cartesian products from part 1.

Introduction

Relations (R) are a generalization of functions (f), such that f ⊂ R. A relation specifies a set of pairs, or more intuitively the relationship between a domain and a codomain. The inclusion is strict because every function is a relation, but not every relation is a function.

Standard notation

For a relation R and set elements a and b:

(a, b) ∈ R, where a, b ∈ S

The easy way to read this is that element a is related to element b if and only if (iff) the ordered pair (a, b) is contained in the set R. For example, (1, 2) ∈ < where 1, 2 ∈ ℕ.

Shorthand notation

The shorthand is more intuitive:

a R b, where a, b ∈ S

For example, 1 < 2 where 1, 2 ∈ ℕ.

Functions

A function is a relation in which an element of a domain (set) maps to only one element of the codomain (set). If an element maps to more than one, it is strictly a relation, not a function.

Functions are broken down into partial and total functions. In a partial function, each element of the domain maps to at most one element of the codomain, so some elements may have no image. In a total function, every element of the domain maps to exactly one element of the codomain.

Four mappings from the domain {1, 2, 3, 4} to the codomain {1, 2, 3, 4}. A relation where 1 maps to both 1 and 2 is not a function. A partial function leaves 4 unmapped. A total function maps 1 to 1, 2 to 3, 3 to 4 and 4 to 3. A bijection maps each element to itself.
The same domain and codomain with four different mappings. In the relation, 1 has two images; in the partial function, 4 (circled pink) has none; the total function maps every element once, and the bijection also uses every codomain element once.

A function has a one-to-one correspondence (a bijective function) if each element of the domain is mapped to exactly one element of the codomain, and each element of the codomain is mapped to exactly one element of the domain. A bijection is also a total function.

For example, a function from the set of all real numbers (the domain) to the set of all real numbers (the codomain) is bijective if it pairs the two sets up one-to-one, such as:

f: ℝ → ℝ, f(x) = 2x + 10

Properties

In what follows, a, b and c are elements of the set X, and R is a relation on X.

  • Inverse. The inverse of a relation R is denoted R⁻¹. For example, the inverse of < is >.
  • Transitive. If aRb and bRc, then aRc. For example, 1 < 2 and 2 < 3, therefore 1 < 3.
  • Reflexive. aRa holds for every a. For example, 3 ≤ 3 holds, so ≤ is reflexive.
  • Irreflexive (or anti-reflexive). aRa never holds. For example, 3 < 3 does not hold, so < is irreflexive.
  • Coreflexive. aRb holds only when a = b. For example, a relation on integers where each even number is related to itself and there are no other relations. Equality is the only relation that is both reflexive and coreflexive.
  • Quasi-reflexive. aRb implies aRa and bRb. For example, the relation "has the same limit as" on sequences: if two sequences have the same limit, then each of them has a limit.
  • Antisymmetric. If aRb and bRa both hold, then a = b. There is no guarantee that aRb holds at all. For example, 3 ≤ 3 holds both ways, but 3 ≤ 4 holds while 4 ≤ 3 does not.
  • Symmetric. aRb holds exactly when bRa holds. For example, = is symmetric: a = b means b = a.
  • Asymmetric. When aRb holds, bRa does not hold. For example, < is asymmetric. A relation is asymmetric exactly when it is irreflexive and antisymmetric.
  • Connex. For all a, b ∈ X, aRb or bRa holds (every pair of domain elements is comparable). For example, ≤ is a connex relation.
  • Semiconnex. For all a, b ∈ X with a ≠ b, aRb or bRa holds (every pair of distinct elements is comparable). For example, < is semiconnex but not connex, because 3 < 3 fails.

Written out in symbols, the three most used properties are:

Reflexive: ∀a (aRa)
Symmetric: ∀a ∀b (aRb → bRa)
Transitive: ∀a ∀b ∀c ((aRb ∧ bRc) → aRc)

Types of relation

Particular combinations of these properties have names. The table lists the properties each type requires.

TypePropertiesExample
Preorder (or quasiorder)Reflexive, transitive
Strict order (strong or strict partial order)Irreflexive, transitive (so also asymmetric, and antisymmetric)< on ℝ
Partial order (POSET, weak or non-strict partial order)Antisymmetric, reflexive, transitive≤ on ℝ
Total orderAntisymmetric, reflexive, transitive, connex≤ on ℝ
Equivalence relationSymmetric, reflexive, transitive=

The relation ≤ on {1, 2, 3} shows how the properties of a total order look when the relation is drawn as arrows.

The relation less-than-or-equal on {1, 2, 3} drawn as arrows. Each element has a loop (reflexive), 1 points to 2 and 2 points to 3, and a curved arrow from 1 to 3 is forced by transitivity. No pair of different elements has arrows both ways (antisymmetric) and every two elements are joined (connex).
The loops are reflexivity, and the curved arrow from 1 to 3 exists because 1 ≤ 2 and 2 ≤ 3 force it. With no two-way arrows between different elements and every pair joined, the relation is a total order.

Other properties

  • Equivalence classes. An equivalence relation naturally splits a set into subsets called equivalence classes. For example, consider the relation "has the same color as": all green elements are lumped into one equivalence class, all blue elements into another, and so on.
  • Closure. The closure of a relation with respect to a property is a new relation created by adding as few pairs as possible to give the original relation that property.
  • Dual (or inverse, or opposite order). The dual of a relation is the relation obtained by flipping the ordering, or by applying the definition in inverse order.