Real-world examples of the role of functions in set theory
Simple examples of the role of functions in set theory
Set theory treats a function as a special kind of set: a set of ordered pairs with a very strict rule — each input appears with exactly one output. That sounds abstract, so let’s start with a down-to-earth example of how this plays out.
Take two finite sets:
Set of students:
\(S = {\text{Alex}, \text{Bianca}, \text{Carlos}}\)Set of ID numbers:
\(I = {101, 102, 103}\)
Define a function \(f : S \to I\) by:
- \(f(\text{Alex}) = 101\)
- \(f(\text{Bianca}) = 102\)
- \(f(\text{Carlos}) = 103\)
In set-theoretic language, \(f\) is literally the set of ordered pairs
[
f = {(\text{Alex},101), (\text{Bianca},102), (\text{Carlos},103)}.
]
This is one of the best examples of the role of functions in set theory: a function is not just a rule, it is a set with a specific structure. You can study it using all the usual tools of set theory — subsets, unions, intersections — while still thinking of it as a mapping.
Classic examples of functions as special sets of ordered pairs
To see why mathematicians care so much, look at a few more concrete examples of the role of functions in set theory as sets of ordered pairs.
Example of a function on a finite set
Let \(A = {1,2,3,4}\). Define \(g : A \to A\) by \(g(x) = 5 - x\). Written as a set of ordered pairs, this is
[
g = {(1,4), (2,3), (3,2), (4,1)}.
]
Here, \(g\) is a bijection: every element of \(A\) appears exactly once as an input and exactly once as an output. In set theory, bijections are the best examples of functions that let you say “these two sets have the same size,” even when the sets are infinite.
Example of a function that is not a function
Consider the set
[
R = {(1,2), (1,3), (2,4)}.
]
This is a relation on the set \({1,2,3,4}\), but it is not a function, because the input 1 is paired with both 2 and 3. This contrast gives one of the clearest examples of the role of functions in set theory: a function is a relation with extra structure — single-valued and defined where you need it.
For a nice formal treatment of functions as special relations, you can compare with standard set theory notes from MIT OpenCourseWare: https://ocw.mit.edu/courses/mathematics/.
Best examples of injective, surjective, and bijective functions
Students often memorize these words without really seeing why they matter. Set theory gives a clean way to organize examples of the role of functions in set theory through these three types.
Injective (one-to-one) examples
Take \(f : \mathbb{N} \to \mathbb{N}\) defined by \(f(n) = 2n\), where \(\mathbb{N}\) is the set of natural numbers.
- Each input \(n\) has a single output \(2n\).
- If \(f(n_1) = f(n_2)\), then \(2n_1 = 2n_2\), so \(n_1 = n_2\).
So \(f\) is injective. This is one of the classic examples of how set theory uses functions to compare sizes of sets: \(\mathbb{N}\) and the set of even numbers have the same cardinality, because there is a bijection between them. The function \(f\) is half of that story.
Surjective (onto) examples
Let \(g : \mathbb{Z} \to {0,1}\) be defined by
[
g(n) = \begin{cases}
0, & n \text{ even} \
1, & n \text{ odd}
\end{cases}
]
Every element of the target set \({0,1}\) is hit by some integer:
- All even integers map to 0.
- All odd integers map to 1.
So \(g\) is surjective. This gives an example of the role of functions in set theory as classifiers: a function can partition a set (here, \(\mathbb{Z}\)) into fibers (evens vs odds) over the codomain.
Bijective examples
The function \(h : \mathbb{R} \to \mathbb{R}\) given by \(h(x) = x + 1\) is both injective and surjective, hence bijective. In set theory, bijections are the best examples of the role of functions in comparing cardinalities: two sets are said to have the same cardinality exactly when there exists a bijective function between them.
For more on cardinality and bijections, see Stanford’s Encyclopedia of Philosophy entry on set theory foundations: https://plato.stanford.edu/entries/set-theory/.
Real examples of the role of functions in set theory and counting
Counting is where most people first meet these ideas, even if they don’t realize it.
Assigning labels: functions as counting tools
Imagine you are labeling seats in a small theater:
- Seats: \(S = {s_1, s_2, \dots, s_{100}}\)
- Ticket numbers: \(T = {1,2,\dots,100}\)
A function \(f : S \to T\) that pairs each seat with a single ticket number is a concrete example of the role of functions in set theory: it orders and indexes a set. If \(f\) is bijective, you know there are exactly 100 seats because you can match them one-to-one with the set \(T\), whose size you already understand.
Functions and combinatorics
In combinatorics, many counting problems are rephrased as: “How many functions satisfy these conditions?”
- Colorings of a map with 3 colors can be seen as functions from the set of regions to the set of 3 colors.
- Assignments of tasks to workers can be modeled as functions from the set of tasks to the set of workers.
These are strong real examples of the role of functions in set theory: once you view assignments or colorings as functions between sets, you can use set-theoretic reasoning to count and compare possibilities.
Examples of how functions structure infinite sets
Infinite sets are where set theory really earns its reputation, and functions are the main tool for comparing them.
Example: even numbers vs all natural numbers
We already saw \(f(n) = 2n\) as an injective function from \(\mathbb{N}\) to itself. In fact, it’s bijective from \(\mathbb{N}\) onto the set of even numbers \(E = {2,4,6,\dots}\).
That single bijection is one of the best examples of the role of functions in set theory: it shows that an infinite set can be put into one-to-one correspondence with a proper subset of itself, something impossible for finite sets.
Example: rational numbers are countable
Consider the set of rational numbers \(\mathbb{Q}\). A standard proof that \(\mathbb{Q}\) is countable uses a function
[
f : \mathbb{N} \to \mathbb{Q}
]
that lists all rational numbers without repetition. The existence of such a function shows there is a bijection between \(\mathbb{N}\) and \(\mathbb{Q}\), so they have the same cardinality.
This gives another example of the role of functions in set theory: they witness cardinality claims. When we say two sets have the same size, what we really mean is “there exists a bijective function between them.”
Example: uncountable sets and no such function
By contrast, Cantor’s diagonal argument shows there is no bijection between \(\mathbb{N}\) and the real numbers \(\mathbb{R}\). In other words, there is no function \(f : \mathbb{N} \to \mathbb{R}\) that hits every real number exactly once.
Here, the nonexistence of a function is as important as its existence. These are powerful examples of the role of functions in set theory: they mark the boundary between different sizes of infinity.
For a historically grounded discussion of Cantor’s work and modern set theory, you can look at resources from the American Mathematical Society: https://www.ams.org/.
Real examples of functions in databases and computer science
If you’ve ever worked with a database or written code, you’ve seen real examples of the role of functions in set theory without calling them that.
Database primary keys as functions
Take a table of employees:
- Set of employees: \(E\)
- Set of employee IDs: \(I\)
The mapping from employees to their unique ID numbers is a function \(f : E \to I\) that should be injective at minimum, and often bijective if every ID is used.
Thinking of this as a set-theoretic function helps clarify why duplicate IDs are a problem: they would violate the idea that each input (employee) should map to exactly one output (ID), and that no two employees share the same output.
Hash functions as set-theoretic functions
In computer science, a hash function maps a large set (all possible inputs) into a smaller set (hash values). Formally, that’s just a function
[
h : A \to B
]
where \(|B| < |A|\), so \(h\) can’t be injective.
This is a real example of the role of functions in set theory helping you reason about collisions and security: the pigeonhole principle — a basic set-theoretic idea about functions between finite sets — guarantees that some different inputs must share the same hash.
Examples of functions as building blocks for structure
Modern mathematics is built on the idea that structures (groups, rings, topological spaces) are sets with extra operations and relations. Functions between these structures preserve that extra information.
Example: homomorphisms as special functions
In group theory, a group homomorphism is a function between groups that respects the group operation. If \(G\) and \(H\) are groups, a function \(\phi : G \to H\) is a homomorphism if
[
\phi(xy) = \phi(x)\phi(y)
]
for all \(x,y \in G\).
This is a refined example of the role of functions in set theory: you start with a bare set-theoretic function and then add conditions that tie it to the algebraic structure. Set theory provides the underlying language; the structure sits on top.
Example: inverse images and preimages
Given a function \(f : X \to Y\) and a subset \(B \subseteq Y\), the preimage (or inverse image) is the set
[
f^{-1}(B) = {x \in X : f(x) \in B}.
]
This operation turns subsets of \(Y\) into subsets of \(X\). Many definitions in topology and measure theory are built exactly this way:
- A function is continuous if the preimage of every open set is open.
- A function is measurable if the preimage of every measurable set is measurable.
These are deep examples of the role of functions in set theory: they connect set operations to analytic and topological properties.
For more on measurable functions and preimages, see introductory notes in real analysis from universities such as Harvard: https://scholar.harvard.edu/ (search for real analysis lecture notes).
2024–2025 perspectives: why this still matters
You might wonder whether these examples of the role of functions in set theory are just historical trivia. They’re not.
- In formal verification and proof assistants (like Lean or Coq), mathematics is encoded almost entirely in terms of sets, types, and functions. Understanding set-theoretic functions is directly relevant to how modern theorems are formalized.
- In data science and machine learning, models are often treated abstractly as functions from input feature sets to output label sets. A clean set-theoretic view of these functions helps when you reason about generalization, overfitting, and mapping high-dimensional inputs to lower-dimensional outputs.
- In foundations of mathematics, ongoing work in large cardinals and determinacy still uses functions as the basic objects that witness or fail to witness equivalences between sets.
In other words, the best examples of the role of functions in set theory are not just classroom exercises. They’re the same patterns that show up in how we organize data, prove theorems, and build formal systems in 2024 and 2025.
FAQ: short answers with examples
Q: Can you give simple examples of the role of functions in set theory for beginners?
Yes. Think of assigning student IDs to students, or mapping every integer to its parity (even/odd). Both are examples of set-theoretic functions: each input is paired with exactly one output, and you can analyze them as sets of ordered pairs.
Q: What is an example of a function that is not injective?
The function \(f : \mathbb{Z} \to \mathbb{N}\) given by \(f(n) = n^2\) is not injective, because \(f(2) = f(-2) = 4\). This is a clear example of the role of functions in set theory when you study how different inputs can collapse to the same output.
Q: How do functions help compare sizes of infinite sets?
By building bijective functions between sets. A bijection between \(\mathbb{N}\) and the even numbers is one of the classic examples of the role of functions in set theory: it shows those two infinite sets have the same cardinality.
Q: Are all relations functions? Give an example of one that isn’t.
No. The relation \(R = {(1,2), (1,3)}\) on the set \({1,2,3}\) is not a function, because 1 is related to two different outputs. This example of a relation that fails to be a function highlights the extra condition required in the set-theoretic definition of function.
Q: How do preimages give examples of the role of functions in set theory?
Given a function \(f : X \to Y\) and a subset \(B \subseteq Y\), the preimage \(f^{-1}(B)\) is a subset of \(X\). This operation turns questions about subsets of \(Y\) into questions about subsets of \(X\), and it’s one of the most important examples of how functions interact with set operations in modern mathematics.
Related Topics
Explore More Logic and Set Theory Problem Solving
Discover more examples and insights in this category.
View All Logic and Set Theory Problem Solving