Skip to content

A rule that assigns to each element of one set exactly one element of another set.

A function from a set A to a set B is a rule that assigns to each element of A exactly one element of B. Written f:ABf : A \to B. The set A is the domain — what the function accepts. The set B is the codomain — where the output lives. For every aAa \in A, there is exactly one bBb \in B such that f(a)=bf(a) = b. Exactness is the defining constraint: every input gets an output, and that output is unique.

A function is a special kind of relation. A relation between A and B is any subset of A×BA \times B — any collection of pairs. A function is a relation where each element of A appears in exactly one pair. Every function is a relation. Most relations are not functions.

Functions compose. If f:ABf : A \to B and g:BCg : B \to C, the composition gf:ACg \circ f : A \to C sends each aa to g(f(a))g(f(a)). Composition is associative: h(gf)=(hg)fh \circ (g \circ f) = (h \circ g) \circ f. Every set A has an identity function idA:AA\mathrm{id}_A : A \to A sending each element to itself. Identity is neutral under composition: fidA=ff \circ \mathrm{id}_A = f and idBf=f\mathrm{id}_B \circ f = f.

A function is not an operation. An operation maps a set into itself: ω:AnA\omega : A^n \to A. A function maps between sets that may be different. The distinction is between internal transformation (operation) and external mapping (function). Both are present in any nontrivial algebraic structure — the operations give a set its internal structure, and the functions relate it to other sets.

A function can be injective (different inputs always give different outputs), surjective (every element of the codomain is hit), or bijective (both). A bijection has an inverse: a function f1:BAf^{-1} : B \to A such that f1f=idAf^{-1} \circ f = \mathrm{id}_A and ff1=idBf \circ f^{-1} = \mathrm{id}_B.

In the category Set, sets are objects and functions are morphisms. Composition of functions is composition of morphisms. The identity function is the identity morphism. This is the standard example of a category — and the reason category theory generalizes set-theoretic reasoning.

Relations

Composes with
Function
Contrasts with
Operation
Date created
Date modified
Defines
Function
Maps
Element, element
Specializes
Relation