Definition of binary relations
A binary relation connects elements from one set to elements of another. It gives you a precise way to say "this element is related to that element," which turns out to be the foundation for functions, orderings, equivalence, and many other structures in mathematics.
Sets and ordered pairs
A binary relation from set to set is defined as a subset of the Cartesian product . In practice, that means is just a collection of ordered pairs where and .
- Notation: Writing or both mean " is related to under ."
- Order matters: unless the relation specifically makes them equal. The first element comes from , the second from .
For example, if and , then is a binary relation from to .
Domain and codomain
Three terms come up constantly when working with relations:
- Domain of : the set of all first elements that actually appear in the relation.
- Codomain of : the entire set , whether or not every element of shows up in a pair.
- Range of : the set of second elements that actually appear in the relation.
The distinction between codomain and range trips people up. The codomain is the whole target set; the range is only the part of it that gets "hit" by the relation.
Types of binary relations
Different types of relations are defined by specific properties they satisfy. Recognizing which properties a relation has tells you a lot about how it behaves.
Reflexive relations
A relation on set is reflexive if every element relates to itself:
The identity relation on any set is always reflexive. The "less than or equal to" relation () on real numbers is reflexive because every number is itself. By contrast, the strict "less than" relation () is not reflexive, since no number is strictly less than itself.
Symmetric relations
A relation on is symmetric if whenever is related to , then is also related to :
"Is a sibling of" is symmetric: if Alice is a sibling of Bob, then Bob is a sibling of Alice. Equality () is also symmetric. But "is a parent of" is not symmetric, since the relationship only goes one direction.
Transitive relations
A relation on is transitive if relating to and to forces to relate to :
The "greater than" relation () on real numbers is transitive: if and , then . Ancestry works the same way. A common counterexample: "is a friend of" in a social network is typically not transitive.
Equivalence relations
A relation that is reflexive, symmetric, and transitive all at once is called an equivalence relation. These are especially important because they partition a set into disjoint subsets called equivalence classes.
A classic example: "has the same remainder when divided by " defines an equivalence relation on the integers. Congruence of geometric shapes is another. Equivalence relations show up throughout abstract algebra when constructing quotient structures.
Properties of binary relations
Beyond reflexivity, symmetry, and transitivity, relations can have additional properties that connect them to functions and mappings.
Functionality
A relation from to is functional if each element of relates to at most one element of :
Functions are exactly the relations that have this property (and where every element of the domain has an output). On a graph, the vertical line test checks functionality: if any vertical line crosses the graph more than once, the relation isn't functional.
Injectivity
An injective (one-to-one) relation maps distinct domain elements to distinct codomain elements:
No two different inputs share the same output. The exponential function is injective. The function on all real numbers is not, because . Graphically, the horizontal line test checks this.
Surjectivity
A relation from to is surjective (onto) if every element of is related to by at least one element of :
The linear function from to is surjective because every real number is an output. But from to is not surjective, since negative numbers never appear as outputs.
Bijectivity
A bijective relation is both injective and surjective. It creates a perfect one-to-one correspondence between domain and codomain, meaning every element pairs up exactly once. Bijections are the only relations that have a well-defined inverse function.
For example, on the reals is bijective. Bijections are crucial in set theory for proving that two sets have the same cardinality.
Representation of binary relations
There are several ways to represent a relation, and each one makes different properties easier to see.

Matrix representation
You can represent a relation from a finite set to a finite set as a Boolean matrix :
- Rows correspond to elements of , columns to elements of .
- Entry if , and otherwise.
This representation makes certain properties easy to check. A reflexive relation has all 1s on the main diagonal. A symmetric relation has a matrix equal to its own transpose.
Graph representation
Relations can be visualized as directed graphs (digraphs). Each element becomes a vertex, and a directed edge from to means . This is especially useful for spotting cycles, paths, and connectivity patterns.
Set notation
The most direct representation: list the relation as a set of ordered pairs.
This is the standard way to define relations in proofs and formal definitions, and it supports set-theoretic operations like union, intersection, and complement.
Operations on binary relations
You can build new relations from existing ones using several operations.
Composition of relations
Given a relation from to and a relation from to , the composition (sometimes written depending on convention) is:
Think of it as chaining: connects to some through , and that connects to through . In matrix form, you compute (using Boolean multiplication). Composition is generally not commutative.
Inverse relations
The inverse of a relation from to simply flips every pair:
In matrix form, is the transpose of . Note that even if is a function, might not be (it could map one element to multiple elements).
Complement of relations
The complement contains every pair in that is not in :
In matrix form, , where is the all-ones matrix. Complements are useful for analyzing properties like irreflexivity and asymmetry.
Special binary relations
Some relations have specific combinations of properties that make them particularly important.
Partial orders
A partial order is a relation that is reflexive, antisymmetric, and transitive. Antisymmetry means: if and , then .
- The subset relation on the power set of any set is a partial order.
- Hasse diagrams provide a compact visual representation of partial orders.
- Not all elements need to be comparable. Two elements and might have neither nor .
Total orders
A total order is a partial order where every pair of elements is comparable:
The natural numbers under form a total order. Lexicographic (dictionary) ordering of strings is another example. Total orders are what let you meaningfully talk about "minimum" and "maximum" elements.
Equivalence classes
Given an equivalence relation on set , the equivalence class of an element is:
Every element in the class is related to every other element in that class. The equivalence classes partition into non-overlapping groups that cover the entire set.
In modular arithmetic, for instance, the equivalence classes mod 3 are , , and . These classes are the building blocks of quotient structures in abstract algebra.
Applications of binary relations
Binary relations appear throughout mathematics and computer science as a modeling tool.
Databases and relational algebra
Relational databases are built on binary (and more generally, -ary) relations. Tables represent relations, and operations like join, projection, and selection come from relational algebra. Functional dependencies, which drive database normalization, are a special type of relation between attributes.

Graph theory connections
Directed graphs are essentially binary relations visualized. The adjacency relation of a graph is a binary relation, and computing the transitive closure of that relation tells you which vertices can reach which others. Graph algorithms like shortest path and cycle detection rely on relational operations.
Social network analysis
Social connections between people can be modeled as binary relations. From there, you can compute centrality measures, detect communities through clustering, model how influence propagates (using transitivity), and predict new links based on the structure of existing relations.
Binary relations vs functions
Functions are a special case of binary relations, so understanding how they relate helps you choose the right tool.
Similarities and differences
- Both map elements from one set to another using ordered pairs.
- A function requires exactly one output for each input; a general relation allows multiple outputs, no output, or one output per input.
- Domain, codomain, and range apply to both, but a function's domain is the entire source set.
- Every relation has an inverse relation; a function's inverse only exists as a function if the original is bijective.
- Composition works for both, but composing general relations can produce results that aren't functions.
When to use each concept
- Use relations when you need to model general associations: symmetric relationships, many-to-many connections, or situations where not every element needs a partner.
- Use functions when each input must produce exactly one output: deterministic processes, mathematical operations, transformations.
Proofs involving binary relations
Proving properties of relations is a core skill in this course. Most proofs follow a predictable structure.
Proving relation properties
Here's the standard approach for each property:
- Reflexivity: Take an arbitrary and show , usually by applying the definition of .
- Symmetry: Assume and show follows.
- Transitivity: Assume and , then show .
- Antisymmetry: Assume and , then show (proof by contradiction often works here).
- Equivalence relation: Prove all three of reflexivity, symmetry, and transitivity.
To disprove a property, you only need one counterexample.
Constructing relation examples
When you need to build a relation with specific properties:
- Work with small finite sets (like ) to keep things manageable.
- Use set-builder notation for precise definitions.
- Check each required property systematically after constructing the relation.
- You can modify existing relations or combine them using union, intersection, or composition to get the properties you need.
Binary relations in set theory
Relations connect deeply to foundational set theory concepts.
Power sets and relations
The power set contains all subsets of . Since a binary relation from to is any subset of , the set of all possible relations from to is . For finite sets, the number of possible relations is , which grows very fast.
Cartesian products
The Cartesian product is the foundation: every binary relation is a subset of it. Properties of Cartesian products (like how they distribute over union and intersection) directly affect how relation operations work. Projections from onto or recover the domain and range of a relation.
Computational aspects
When relations are implemented in software, efficiency matters.
Algorithms for relation operations
- Composition: Matrix multiplication gives you the composition. Naive approach runs in ; advanced algorithms can do better.
- Transitive closure: Warshall's algorithm computes this in .
- Union/intersection: for matrix representations (element-wise OR or AND).
- Property checking: Verifying reflexivity or symmetry on a matrix is .
- Graph traversal: DFS and BFS for reachability analysis run in .
- Topological sorting of partially ordered sets also runs in .
Complexity considerations
- Matrix representations use space; sparse representations (adjacency lists) use , which is better when the relation has few pairs relative to .
- Some relational problems are NP-complete (e.g., finding the largest clique in a graph), meaning no known efficient algorithm exists for them.
- The choice between matrix and graph representations involves a time-space tradeoff that depends on how dense the relation is and what operations you need to perform.