Relations as Sets of Ordered Pairs
What does it mean to say two things are "related"? Consider some examples. A student takes a course. A number divides another. A person is the parent of another. These all express a connection between elements of some collection. Mathematics needs a precise, unified way to capture any such connection. This way must not depend on the informal meaning of words like "divides" or "is the parent of." The surprising and powerful answer comes from the set-theoretic foundations of mathematics. It is to identify a relationship entirely with the set of pairs of objects that stand in it. This move — collapsing a relationship into a set of Ordered Pairs — is one of the great economizing ideas in the foundations of mathematics. It means we never need a primitive notion of "relatedness" beyond set membership. Once relations are subsets of a Cartesian Product, every property of a relation becomes a property of a set. This includes reflexivity, symmetry, transitivity, being a function, and being an order. Such properties become provable by ordinary set-theoretic reasoning rather than appeals to intuition. The big picture is this: relations sit at the hinge between raw set theory and the rest of mathematics. Equivalence relations partition sets into classes. Order relations organize sets into hierarchies. Functions — the single most important mathematical objects — turn out to be nothing more than relations satisfying an extra uniqueness condition. Understanding relations as sets of ordered pairs is therefore a prerequisite for everything downstream. This includes equivalence classes, partial orders, graphs, and the rigorous definition of a function. This article gives the formal definition of a relation from a set to a set . It defines domain and range rigorously, and introduces the infix notation . It proves basic structural facts, such as the count of possible relations between finite sets. It works through concrete examples, and shows exactly which hypotheses are needed. It does this by exhibiting what fails when they are dropped.
- A relation from to is defined to be a subset — nothing more, nothing less.
- The statement is shorthand for the set-membership fact .
- The domain of is the set of first coordinates that actually occur; the range is the set of second coordinates that occur.
- Domain and range can be proper subsets of and ; distinguishing (or ) from the domain (or range) is essential.
- If and are finite, there are exactly relations from to , since a relation is exactly a subset of the -element set .
- Key idea: a relation is not a rule or a description — it is a set of ordered pairs, and everything about the relation is read off from that set.
Where this lives today
The relation-as-set-of-pairs viewpoint underlies enormous swaths of mathematics and computer science. In pure mathematics it is the immediate precursor to Properties of Relations (reflexivity, symmetry, transitivity), to equivalence relations and quotient constructions, and to partial and total orders that structure everything from cardinal arithmetic to lattice theory. It is also the precursor to Functions as Special Relations: a function is defined as a relation satisfying together with a uniqueness clause (for each , at most one with ) — so functions are a special case, not a separate primitive notion. In computer science, relational databases are literally implementations of finite relations: a database table is a finite subset of a Cartesian product of column domains, and relational algebra (joins, projections, selections) is set-theoretic manipulation of these subsets. Graph theory identifies a directed graph with a relation on its vertex set. In logic and model theory, relational structures (models of a first-order language) interpret relation symbols as exactly such subsets of Cartesian powers of a domain. In cryptography and complexity theory, one-way functions, hard relations, and NP-relations are formalized as subsets of pairs satisfying a checkable condition, directly generalizing this definition to computational contexts. In statistics and probability, a joint distribution can be viewed as living on a relation-like structure — the support of a joint random pair is a subset of a product space, echoing the same set-of-pairs idea underlying correlation and dependence between variables.
Ask the tutor: How does adding the properties of reflexivity, symmetry, and transitivity to a relation on a set lead to the definition of an equivalence relation and equivalence classes?
Let and be sets.
Relation. A relation from to is any subset of the Cartesian product :
If , we call a relation on .
Infix notation. For and , we write
and we write to mean . This is purely a notational convention: is defined to abbreviate the membership statement , so all logical facts about reduce to facts about set membership in .
Domain. The domain of is
Range. The range (also called the image) of is
By definition and ; these containments need not be equalities. The set is sometimes called the codomain of the source, and the codomain of the target, though terminology varies by author; the essential objects are , , and .
Intuition
Think of as a grid: rows indexed by elements of , columns indexed by elements of . Every possible ordered pair is one cell of this grid. A relation is a choice of some cells to "shade in" — nothing about why those cells are chosen matters to the mathematics; only the resulting shaded set matters. The domain is the set of rows containing at least one shaded cell; the range is the set of columns containing at least one shaded cell. This grid picture immediately explains several facts that otherwise feel mysterious. Two relations described by completely different English sentences are the same relation if they shade exactly the same cells. A relation need not touch every row or every column — hence domain and range can be strictly smaller than and . And since a relation is just a subset of a set with elements, counting relations is counting subsets: there are exactly of them when are finite.
Theorem
Let and be finite sets with and . Then the number of distinct relations from to equals
If and are finite sets with and , then .
Proof of the Lemma, by the multiplication principle for finite sets (induction on ). Base case : then , and since there is no to pair with any . So . Inductive step: suppose the claim holds whenever the second set has elements. Let have elements; write where has elements and . Then
and this union is disjoint, because any pair in has second coordinate while no pair in does (as ). The map is a bijection from to , so . By the inductive hypothesis . Since the union is disjoint,
This completes the induction, proving the lemma for all .
Proof of the Theorem. By the definition of a relation, a relation from to is precisely a subset of ; thus the set of all relations from to is exactly the power set . We use the standard fact — provable by induction on the size of a finite set, or by a bijective correspondence between subsets and functions into — that for any finite set with ,
(Proof sketch of this standard fact, by induction on : if then and has exactly element. If the claim holds for sets of size , let have elements, with , . Every subset either contains or does not; the subsets not containing are exactly the subsets of , of which there are by hypothesis; the subsets containing are exactly for , again of them, and this is a bijection . These two classes are disjoint and exhaust , so .) Applying this fact with , and using from the Lemma, we conclude
∎
If , the number of relations on (i.e. from to ) is .
Apply the Theorem with , so , giving .
∎Worked examples
Example 1 (an explicit small relation with domain and range strictly smaller than , ). Let and . Define
Checking is genuinely a relation from to : each listed pair has first coordinate in and second coordinate in , so indeed . Domain. An element belongs to iff some pair in has as first coordinate. Scanning : first coordinates appearing are (twice) and (twice). Elements never appear as a first coordinate. Hence
Range. Second coordinates appearing in are — in fact all three elements of occur (namely from , from or , and from ). Hence
Reading off statements. By definition (since ), , , , while (since ), and indeed is unrelated by to every element of , consistent with . Cardinality check. Here , , so by the Theorem there are relations from to in total; , with pairs, is just one particular subset among these , namely one of the subsets of size exactly .
Example 2 (a relation defined by a condition, converted into explicit pair form). Let and , and define the "divides" relation
Here means for some integer — this is the rule used to decide membership, but itself is the resulting set of pairs, not the rule. We compute explicitly by checking each against each :
- : divides among . Pairs: .
- : divides among . Pairs: .
- : divides among . Pairs: .
- : divides none of that are multiples of within — check: is true since ! Recheck: divides . Pair: .
- : divides among (does divide ? not in ). Pair: .
So
This has ordered pairs. Domain. First coordinates occurring: — every element of occurs (each divides itself, and for , while divide larger elements of ). Hence
Range. Second coordinates occurring: (from ), (from ), (from ), (from ), (from ). Collecting distinct values: . Note never appears — indeed no divides , since is prime and none of equal or . Hence
because . Infix notation in use. We may write (true, since ) and (false, since ); both are just restatements of and respectively.
Counterexample
The Theorem and Definition rely on first specifying the ambient sets and , not merely the set of pairs . If this hypothesis — that comes equipped with a fixed and with — is dropped, and one instead tries to recover "the domain" and "the range" from alone by declaring them to be exactly the first and second coordinates occurring in , subtle but important information is lost, and statements like "" become vacuous or ill-posed. Concretely: let
As a relation from to , we have , with and ; here happens to touch every row and every column. But the very same set of ordered pairs is also a perfectly good relation from to — again — except now
So whether (a property relevant to, e.g., whether can be a function defined on all of , foreshadowing the notion of a total function) is not a fact about in isolation — it is a fact about relative to a chosen . Dropping the requirement of specifying the ambient sets makes "domain equals " an ill-formed or context-dependent question, and destroys the theorem's counting statement as well: the number of relations "from 's coordinates to itself" is not even meaningful without fixing and first, so the formula cannot even be stated. This shows the hypothesis " for specified " is not a mere bookkeeping convenience — it is essential to the definitions of domain, range, and to any counting statement about relations.
Scope, edge cases & common traps
| Situation | What is true | Common error |
|---|---|---|
| is a relation from to for any ; | Thinking a relation must relate something; the empty relation is perfectly legitimate | |
| The "full" relation; every relates to every | Confusing "full relation" with "identity relation" (these coincide only in degenerate cases) | |
| or infinite | Definition still applies verbatim: | Assuming domain/range must be finite, or that the counting formula applies (it needs finiteness) |
| Perfectly allowed; some elements of relate to nothing | Assuming always — this is a special property, not automatic | |
| is a relation on ; still just | Confusing with — order in the pair matters, need not be symmetric | |
| Same pairs, different codomain | depends on only insofar as ; the set of second coordinates present is intrinsic to | Treating itself (rather than ) as "the range" |
The mathematician behind it
The rigorous reduction of "relation" to "set of ordered pairs" is a product of the broader foundational program that reduced essentially all mathematical objects to pure sets, carried out especially through the work of Felix Hausdorff, Kazimierz Kuratowski, and Norbert Wiener on the set-theoretic definition of the ordered pair itself, combined with the systematic set-theoretic treatment of functions and relations that crystallized in the early-to-mid twentieth century. Kuratowski's 1921 definition of the ordered pair, , made it possible to define purely as a set built from and , and once that was in hand, "relation" could be defined with no further primitives — simply as a subset of .
Origins · 1 minKazimierz Kuratowski and how this was discovered
A Polish mathematician central to the Warsaw School, Kuratowski worked on set theory, topology, and the foundations of mathematics. His 1921 definition of the ordered pair as a set is the technical device that makes the definition of a relation as "just a subset of " fully rigorous within pure set theory, with no unreduced primitive notion of "pairing."
Is a relation the same thing as a function?
No — every function is a relation, but not every relation is a function. A relation from to is simply any subset ; nothing requires each element of to appear as a first coordinate, and nothing forbids an element of from appearing paired with two different elements of . A function additionally requires (i) (every input is used, "totality") and (ii) uniqueness: if and then . So functions are exactly the relations satisfying these two extra conditions — this is the precise sense in which Functions as Special Relations are a special case of the material here.
Why define a relation as a set of pairs instead of as a "rule" or "predicate"?
Defining relations via rules or predicates seems more intuitive, but it hides an ambiguity: different-looking rules can produce the same set of pairs, and mathematics wants two relations to be considered identical exactly when they relate the same elements — no more, no less. By defining to literally be the set of pairs, extensional equality of relations becomes ordinary set equality: . This also lets all of set theory's machinery (unions, intersections, complements, power sets) apply directly to relations, since they are just sets.
Can domain and range be empty even if and are not?
Yes. Take for any nonempty . Then no pair belongs to , so no satisfies "there exists with ," giving , and symmetrically . This is a completely legitimate relation — it is the "nothing is related to anything" relation, sometimes called the empty relation, and it satisfies the subset condition vacuously.
If and also for different , is "the same relation"?
As a set, yes — is identical as a set of ordered pairs regardless of which ambient product it is regarded as a subset of. But the phrase "relation from to " packages together with the chosen and , and properties like are properties of this pairing, not of alone (see the counterexample above). In careful treatments, some authors define a relation as the triple precisely to avoid this ambiguity, though many introductory treatments (as here) suppress once fixed by context.
Does automatically imply ?
No, and this is one of the most important points about the definition. Since consists of ordered pairs, and are in general entirely different membership questions — even when so both pairs make sense. For example with " divides " on positive integers, holds (since ) but fails (since ). Relations for which always implies are called symmetric, a special property studied under Properties of Relations, not a automatic consequence of the basic definition.
Why does the counting formula require and to be finite?
The proof rests on two facts: for finite (proved by induction on ), and for finite (also proved by induction on ). Both inductions are inductions on a natural number and simply do not apply when or is infinite — indeed if is infinite, is infinite, and comparing its size to "" requires cardinal arithmetic (defining for infinite cardinals ) rather than the elementary combinatorial argument given here.
Is "domain" here the same as "domain of definition" for a function later on?
Yes, and this consistency is exactly the point of building the theory in this order. Once a function is defined as a relation with , the domain of the relation (as just defined) coincides with the usual "domain of the function ." So the definition of domain given here is not a mere analogy to the later functional notion — it is the same definition, and the functional case is simply the special case where the domain equals all of and uniqueness of outputs holds.