A relation R on sets A and B is a subset of the Cartesian product A × B — a collection of ordered pairs (a, b) specifying which elements of A are related to which elements of B. When A = B, R is a relation on A. We write aRb to mean (a, b) ∈ R.

Relations are classified by their properties. A relation on A is reflexive if aRa for all a, transitive if aRb and bRc imply aRc, antisymmetric if aRb and bRa imply a = b, and symmetric if aRb implies bRa. A reflexive and transitive relation is a preorder; adding antisymmetry gives a partial order; adding symmetry instead gives an equivalence relation.

Functions are special relations: a relation R ⊆ A × B is a function if every a ∈ A appears in exactly one pair. In a category, a relation between objects generalizes to a span or a subobject of a product. In the semiotic universe, the ordering on the Heyting algebra H is a relation (a ≤ b means “a entails b”), and the accessibility relation in Kripke semantics is the modal-logic analogue.