# Mathbook: Functions as Sets

In this little tutorial, we’ll expand on what we’ve learned about sets and functions. Specifically, we’ll double-down on the claim that sets are vital to everything we do in mathematics. Functions are not just a way to describe interactions between sets: functions are sets!

Many people will be familiar with the idea of an ordered pair. This is often how we describe “points” created by the function. When we write the ordered pair $(x,y)$ in the context of an existing function $f$, we typically mean $f(x)=y$. In this way, a function can be completely described by its set of ordered pairs: $\displaystyle f = \{(x,y) \mid f(x)=y\}$.

This “set-builder” notation is new, so let’s take a tangent and describe it briefly.

The first term, $(x,y)$ is the type, or form, of each element in the set. So, each element in $f$ will be an ordered pair. The vertical line can be read as “such that”, and whatever follows are the conditions on the elements in the set. Therefore, the set notation for $f$ can be read as “All ordered pairs $(x,y)$ such that $f(x)=y$.

Now, we have a way to describe a function as a set. Namely, a function is just a set where every element is an ordered pair; each ordered pair describes a rule of the form $f(x)=y$.

This is a great first step! We are back to sets being the backbone of everything. Yet, we can go further. An ordered pair is an arbitrary object, not immediately associated with sets. As you may recall from the Introduction to Sets, a set is unordered. In set notation, we would write $\{x,y\} = \{y,x\}$. So, how do ordered pairs relate to sets? Let’s find out.

This will be our first dive into further abstraction, analyzing an object we are familiar with and want to express differently. Consider two ordered pairs, $(x_1,y_1)$ and $(x_2,y_2)$. What does it mean for $(x_1,y_1) = (x_2,y_2)$? We could describe this equality by stating $(x_1,y_1) = (x_2,y_2)$ whenever $x_1=x_2$ and $y_1=y_2$.

Next, we want to determine how to capture this information using sets, which are inherently unordered, and cannot have two of the same element. This means we will need at least one set inside of our set, in order to differentiate between the pairs.

##### Definition

We define an ordered pair $(x,y)$ as the set $\{ \{x\}, \{x,y\}\}.$

This strikes most people as quite strange at first. Upon further thought though, it gives us a sense of order. The first element is $x$, the one that exists in both sets. The second element is the element that remains.

The payoff is we now have a description definition of a function. Earlier, we discussed how a function is just a set of ordered pairs. Now, we see that an ordered pair is just a set as well (which happens to contain two more sets!) , so a function can be completely described using sets.

##### Definition

A function $f: A\to B$, with a collection of rules of the form $f(a) =b$, where $a\in A, b\in B$, is a set:

$\displaystyle f = \large{\{} \{ \{a\}, \{a,b\}\} \mid f(a) = b\large{\}}.$

When doing mathematics, most people do not concern themselves with this definition. It is crucial to having a rigorous development of math, and is a good way to begin understanding how mathematicians build objects to work with. However, once it is understood, it does not typically need to be something to worry about in the future.