Functions as Special Relations
What exactly is a function? Calculus students learn to think of a function as a rule, a formula, or a machine. It takes inputs and produces outputs. This picture works well enough for polynomials and sines and cosines. But it collapses the moment we ask about functions with no formula at all. Consider a function assigning to each person their birth mother. Or a function encoding an infinite binary sequence. Foundations demands a single precise object that covers every case uniformly. It must do so without appeal to the vague word "rule." The resolution comes from the set-theoretic reworking of mathematics in the early twentieth century. It is to identify a function with its graph: the set of all input–output pairs it produces. A set of ordered pairs is precisely a relation. So a function becomes a special kind of relation. It obeys a single-valuedness condition that forbids one input from having two different outputs. This move is quietly radical. It means "function" is not a primitive concept but a derived one. It is built entirely out of sets and the membership relation. This reduction matters because it makes function into a genuinely rigorous, checkable notion. Given any candidate set of ordered pairs, we can verify whether it is a function. We do this by checking one condition, rather than debating whether it "counts" as a legitimate rule. It also unifies functions given by formulas, functions given by infinite tables, and functions defined by cases or by recursion. All fall under one definition. This uniformity is exactly what is needed later. We need it when we classify functions by their behavior — into injections, surjections, and bijections. We also need it when we compare the sizes of infinite sets via cardinality. This article gives the precise definition of a function as a relation with the single-valued property. It carefully distinguishes domain, codomain, and range. It proves the basic existence-and-uniqueness theorem that licenses "function value" notation. It works through examples designed to expose the traps students most often fall into. Especially the confusion between codomain and range. Also the subtlety of when a relation defined by a formula actually deserves to be called a function on its stated domain.
- A function is a relation in which every element of the domain is related to exactly one element of the codomain.
- Formally: is a function from to if for every there is a unique with .
- The graph of is itself as a set of ordered pairs; "" is just shorthand for "."
- The domain is fixed by the definition of ; the range (image) can be a proper subset of the codomain .
- Single-valuedness is what separates a function from an arbitrary relation; it is the only extra axiom imposed.
- Key idea: a function is nothing more than a set of ordered pairs satisfying "no two pairs share a first coordinate with different second coordinates," together with a specified domain and codomain.
Where this lives today
The relational definition of function is the silent backbone of essentially all of modern mathematics and its applications, precisely because it is the only definition precise enough to survive contact with infinite, arbitrary, or algorithmically inexpressible correspondences.
- Set theory and cardinality. Comparing the sizes of infinite sets — the subject this chapter is heading toward — is done entirely via functions between them: injections and surjections are defined as extra properties layered on top of the single-valuedness condition developed here, and cardinal arithmetic is built from bijections, which are functions that are simultaneously injective and surjective.
- Computer science. In functional programming and formal semantics, a program's meaning is often modeled as a (possibly partial) function from inputs to outputs; the totality/partiality distinction traces directly back to whether clause (1) above holds on the stated domain, and type systems are designed precisely to catch "undefined at some inputs" errors at compile time.
- Database theory. A relational database table enforces "functional dependencies" — constraints stating that one column's value determines another's — which are exactly instances of the single-valuedness clause applied to projections of a relation.
- Cryptography. Hash functions, encryption maps, and pseudorandom generators are all functions in this exact sense: total, single-valued maps between finite sets (bit-strings of fixed length), and security proofs frequently hinge on properties like injectivity (collision-resistance) built on top of this base definition.
- Probability and statistics. Random variables are defined as measurable functions from a sample space to ; the single-valuedness clause is what guarantees a random variable assigns one, not several, numerical outcomes to each sample point.
- Physics and engineering. Physical laws expressed as functions of state (e.g., pressure as a function of volume and temperature) implicitly rely on this same single-valuedness: a genuine state function cannot take two different values for one and the same state, which is exactly the mathematical content of clause (2).
Ask the tutor: How does the definition of function as a relation change when we move to partial functions, and why do computer scientists care about that distinction?
Let and be sets. A function from to , written , is a triple where is a set of ordered pairs — called the graph of — satisfying two conditions: 1. (Totality on ) For every , there exists such that . 2. (Single-valuedness) For every and all , if and , then . The set is called the domain of , written . The set is called the codomain. The set
is called the range (or image) of ; in general , with equality not required. By conditions (1) and (2) together, for each there is a unique with ; this unique element is denoted , and we write . Two functions and are equal iff , , and they have the same graph — equivalently, iff they have the same domain, same codomain, and for every in that common domain.
Intuition
Think of a relation as a bipartite "wiring diagram": draw the elements of on the left, elements of on the right, and an edge from to whenever . An arbitrary relation allows any pattern of wires whatsoever — an element of might have no wires, one wire, or five wires leaving it. A function is the special case where the wiring is tidy on the left: every element of has exactly one wire coming out of it. There is no restriction at all on the right-hand side — an element of may have zero incoming wires (it lies outside the range), one incoming wire, or many incoming wires (several elements of can share the same output). This is precisely what "single-valued and total" is encoding, and it is worth internalizing as a picture: totality forbids missing wires from the left, single-valuedness forbids forked wires from the left. Neither condition says anything about the right side of the diagram — that asymmetry is exactly what later gets named and studied as injectivity (no two left-elements share a wire) and surjectivity (every right-element receives a wire).
The central theorem
Let be a function with graph , in the sense of the definition above. Then for every there exists a unique such that . Consequently the notation , defined by " is the unique with ," is well-defined: it names exactly one object of for every input , and this assignment recovers the graph, in the sense that
Technique: direct proof from the two defining clauses, followed by a set-equality argument (double inclusion) for the closing identity. Existence. Fix . By clause (1) of the definition (totality), there exists at least one with . This establishes existence of a witnessing membership. Uniqueness. Suppose both satisfy and . By clause (2) of the definition (single-valuedness), applied to this same , we conclude . Hence any two witnesses coincide, so the witness is unique. Having shown existence and uniqueness of a with , for each , the description "the unique such that " picks out a single well-defined element of ; this justifies introducing the symbol for that element, with the defining property
(The forward direction of is uniqueness; the backward direction holds because is one of the witnesses, by existence.) Closing identity. We show by mutual inclusion. () Let . Since , we have . By the forward direction of , . Hence , which lies in the right-hand set. () Let be an arbitrary element of the right-hand set, where . By the backward direction of (existence, restated), . Both inclusions hold, so the two sets are equal.
∎Two functions and with the same domain and codomain are equal as functions if and only if for every .
Technique: unfold the definition of equality of graphs using the theorem above. By the closing identity of the theorem, 's graph is and 's graph is , both subsets of . () If as functions their graphs coincide as sets. Fix ; then lies in 's graph, hence in 's graph, so by uniqueness of the -witness for input (the theorem applied to ), . () Suppose for all . Then termwise, hence as sets (any element of the left set is , an element of the right set, and symmetrically). By the theorem's closing identity applied to both and , their graphs are equal, and since domain and codomain were assumed equal, .
∎Worked examples
Example 1 (a genuinely finite, asymmetric function). Let and . Define
Check totality: every element of — namely — appears as a first coordinate in some pair of . Indeed appears in , in , in , in . Totality holds. Check single-valuedness: we must confirm no first coordinate appears twice with different second coordinates. Scanning , the first coordinates used are , each occurring exactly once. So there is no possibility of a conflict; single-valuedness holds vacuously well (there is simply nothing to conflict). Hence is (the graph of) a function , with , , , . Now examine domain, codomain, range carefully, since this is where the asymmetry of the example matters:
- .
- Codomain is the declared target , a set of size .
- , a set of size .
Note are never hit: . Note also is hit twice (by both and ) — this is completely permitted, since single-valuedness constrains only the left side of the wiring diagram. This example shows concretely that codomain and range are different objects in general: a codomain is a choice made when the function is declared, while the range is computed after the fact from the graph.
Example 2 (when a "formula" fails to define a function on a stated domain, and how to fix it). Let , , and consider the candidate rule
Set , i.e. we attempt to make by including a pair for every integer where the formula is defined. Test totality on : does every appear as a first coordinate? Take : the formula gives , undefined, so there is no pair for any . Totality on fails. Hence, strictly, is not a function from to — the formula does not deserve to be called "" as declared, and a homework answer asserting this without comment is an error of exactly the kind this article is built to catch. The fix: restrict the domain to and declare . Now recheck both clauses.
- Totality on : for every (so ), , so is a well-defined rational number; a pair exists in . Totality holds.
- Single-valuedness: for fixed , the expression names one specific rational number (division of specific integers by a specific nonzero integer produces one rational number, by the definition of as equivalence classes of pairs, per Quotient Sets and Well-Definedness). So there cannot be two different both equal to . Single-valuedness holds.
So is a function. Let's compute a few values to see the range is a proper, and rather sparse, subset of :
Notice for all in the domain — a genuine algebraic fact about this particular function, not something guaranteed by the definition of "function" itself; it is a special feature (oddness) of this graph, illustrating that the bare definition of function says nothing about such symmetries — they must be proved separately from the formula.
Claim under attack: "A relation satisfying only totality (every has some with ) already deserves to be called a function, and the function-value notation can be used safely."
Why this fails. Take , , and
Totality holds: has a partner (, or indeed ), and has a partner (). But single-valuedness fails at : both and , with . If we tried to use the notation "" as in the Existence and Uniqueness theorem, we would be asserting there is one object deserving that name — but the proof of that theorem used single-valuedness essentially, in the uniqueness half, to rule out exactly this situation. Concretely: is supposed to be or ? Both are equally licensed by membership in , and nothing in the data of breaks the tie. Any further reasoning that manipulates "" as though it names a single fixed object — for instance, substituting it into another expression, or asserting trivially as if this pins down one value — becomes unsound, because the symbol secretly denotes two different things depending on which occurrence of you mean. This is not a pathological edge case: it is exactly the failure mode of "multi-valued rules" that beginners sometimes propose, such as "let be a square root of " over the reals — for there are two square roots, and without single-valuedness, "" is ambiguous between and . The fix is always the same: either restrict to a genuine single-valued selection (e.g., "the nonnegative square root," recovering a true function), or abandon function notation and work with the relation directly, quantifying over all pairs rather than writing .
Scope, edge cases & common traps
| Situation | What to check | Common error |
|---|---|---|
| Function given by explicit list of pairs | Totality and single-valuedness on the stated domain | Assuming totality without checking every domain element is covered |
| Function given by a formula | Domain must exclude every input where the formula is undefined | Declaring , , and forgetting |
| Range vs. codomain | Range is computed from the graph; codomain is chosen | Treating "range" and "codomain" as synonyms |
| Multi-valued "functions" (e.g. square root, arcsine before branch choice) | Must pick a single-valued branch to get a genuine function | Writing and calling a function on without fixing sign |
| Two functions with same formula, different declared domain/codomain | These are formally different functions | Claiming , equals , |
| Empty domain | The empty relation is (vacuously) a function | Assuming a function must have nonempty domain |
The mathematician behind it
Origins · 1 minRichard Dedekind and how this was discovered
Richard Dedekind, a German mathematician working at Braunschweig and closely associated with Göttingen, was among the first to insist on treating a function purely extensionally — as determined entirely by its input–output pairs rather than by any expression or "law" producing them. In Was sind und was sollen die Zahlen? (1888), Dedekind develops the theory of mappings ("Abbildungen") between sets in essentially the modern style, laying groundwork that Ernst Zermelo and later set theorists would formalize fully within axiomatic set theory, where a function is literally identified with its graph — a set of ordered pairs satisfying single-valuedness. This reduction of "function" to "special relation" is the culmination of a longer historical shift, from Euler's functions-as-formulas, through Dirichlet's and Riemann's arbitrary correspondences, to Dedekind's and Zermelo's fully extensional, set-theoretic object.
Is a function literally the same thing as its graph, or are they different objects?
In the strict Bourbaki-style formalization used here, a function is the triple — domain, codomain, and graph — not the graph alone. Two functions with the same graph but different declared codomains are formally different objects, even though they agree on every input. In practice, many textbooks (and this one, informally) speak of "the graph of " as if it were , because the graph determines everything about the input–output behavior; the codomain is extra bookkeeping that matters mainly for defining surjectivity later. When precision is needed — e.g., asking whether a function is surjective — you must remember the codomain is part of the data, not recoverable from the graph alone.
Why does the definition require totality — why not allow a "function" to be undefined at some domain points?
If you allow this, you get the useful but distinct notion of a partial function: a relation satisfying single-valuedness but not necessarily totality on , together with the convention that it is a genuine (total) function on the smaller set , called its domain of definition. Foundationally, "function from to " is reserved for the total notion precisely so that unambiguously equals the declared set ; partial functions are a useful generalization but are named differently to avoid exactly the domain-restriction confusion illustrated in Example 2 above.
Can two different formulas give the same function?
Yes, and this is expected, since equality of functions is decided by equality of graphs (equivalently, agreement of all values, by the Function Equality Criterion), not by syntactic similarity of formulas. For instance and , both as functions , are the same function, because for every real — even though the formulas look different before algebraic simplification. This is exactly why the graph, not the formula, is taken as the true identity of a function.
Does single-valuedness say anything about elements of the codomain being hit only once?
No — that is a completely separate condition, called injectivity, which will be defined and studied on its own once functions are classified further (see Injections, Surjections). Single-valuedness constrains only how many outputs a single input can have (exactly one); it places no constraint on how many inputs may share a single output. In Example 1 above, both and map to , and this is entirely consistent with being a function — it merely means is not injective.
How does this relational definition interact with equivalence classes and well-definedness, as in quotient constructions?
When a function is defined on a quotient set by a formula referencing representatives, e.g. , one must prove single-valuedness explicitly: if (i.e. ) then must be checked, precisely because the graph of is only legitimately a function if no two representative choices for the same class produce different outputs. This is exactly the Quotient Sets and Well-Definedness issue: "well-definedness" of a function on a quotient is single-valuedness of its would-be graph, checked at the level of equivalence classes rather than raw elements.
Is the empty set a function?
The empty set is a function from to any set : totality holds vacuously (there is no to produce a counterexample), and single-valuedness holds vacuously for the same reason. However, is generally not a function from a nonempty to , since totality then fails outright — some has no partner at all. This shows domain matters even when the graph itself, as a bare set, is the same object () in both cases.
Why bother with codomain at all if only the range matters for "what values are actually produced"?
The codomain records the space the function was declared to land in, which matters for composing functions and for defining surjectivity. If and , the composite is only guaranteed sensible because every output of lies in , the stated domain of — a fact guaranteed by the codomain declaration, not by the (possibly much smaller) range. Surjectivity is likewise a statement about the codomain ("range equals codomain"), so discarding the codomain would make that entire classification impossible to state.