How can a function be a set? Intuitively, a function is a rule that takes something as an input and gives an output. It can also be stated as that a function is a rule that maps elements from a set to the elements of a different or the same set. Both the above statement can be regarded as almost same. Everything was a fine till I came to know the set-theoritic definition of a function.
According to that, a function is a set of ordered pairs such that all the first component of pairs which come from the same set, is related to the second component of pairs which also come from a common set. But function is like something I stated above and set is just a collection of things having something common. How can set do the work of function?
I understand that each function can correspond to a set of oredered pairs in which first component is input and second component is the output but still set can't be thought same as a function. Function is a rule. Set is just a collection. How does the intuition of function connect to the set theoritic definition of function?
Apologies if I sound like a overthinker.
Thanking in advance.
EDIT: Function takes something and if function is defined as a set that it should behave in the same way but set does not behave in that way.
Also, I think that the definition might be for checking whether something is function or not. Since we can create a unique set out of every function, so may be the definition is not for defining what a function is (because we understand that informally) but for defining what can be a function.
 A: There are indeed two ways to look at a function intuitively.
(I prefer the word "mapping" to "function", incidentally, as it allows one to mentally step back from the first way and allow a wider context.)
The first way is, as you say, a "process" which "does something" to a number, pushing it through a black box and poking another number out of the other end.
This is the usual way of introducing them at school, and while it is adequate for those purposes, it's a bit limiting.
So, rather than think of a function as a "dynamic" thing, which works by (metaphorically) "turning a handle", consider it like this.
Let $f$ be an arbitrary function.
Let $A$ be the set of numbers $f$ "works on". This is known as the "domain" of $f$.
Let $B$ be the set of all the numbers of which could possibly come out of the "output" of $f$, given that you poke an element of $A$ into the "input". This is known as the "codomain" of $f$.
(At this stage we don't know whether, for any $y \in B$, that there are any $x \in A$ such that $f(x) = y$ -- this is often one of the things we are going to have to work out specifically.)
We know that $A$ and $B$ are sets, and "exist" in our minds statically.
If we conceptually lay all the elements of $A$ down the left hand side of the page, and all the elements of $B$ down the right hand side of the page, we can (in theory) draw a line from each element $x$ of $A$ to the element $y$ of $B$ such that $f(x) = y$. Each line is uniquely defined by its end points: the $x$ in $A$ and the $y$ in $B$.
So, we can define that "line" by writing it as $(x, y)$, where it is understood that $x$ comes from $A$ and $y$ comes from $B$. The order matters -- the first element must be from $A$, and the second element must be from $B$. This is called an ordered pair.
Now, the set of every ordered pair from $A$ to $B$ is written as $A \times B$, and in set-theoretical shorthand can be defined as:
$$A \times B = \{(a, b): a \in A, b \in B\}$$
Now, a function is a subset of $A \times B$ where for every $a \in A$, there is only one $(a, b)$, where $b$ can be any element of $B$.
In fact, it is those specific values of $b$, of which only one is associated with any given value of $a$, which define $f$.
Note of course that the same value of $b$ can be associated with more than one value of $a$, and some elements of $B$ may not be associated with any value of $a$ at all.
Does this help?
A: I agree that conceptually it feels like there is a difference: a function does something, while a set just sort of sits there.
Still, there is an important way in which a function can be represented by a set.
First, think of how we can represent a function by a table, for example:
\begin{array}{c|c}
n&f(n)=n^2\\
\hline
0&0\\
1&1\\
2&4\\
…&…\\
\end{array}
Ok, but looking at a function that way, we can also see it as a set of pairs:
$$\{<0,0>,<1,1>,<2,4>,…\}$$
… and that’s really all there is to it: given such a set, you can always figure out the function that it represents: the left wlement of each pair is the argument that goes into the function, and the right element is the function value for that argument. Of course, as others have pointed out, you can’t have two pairs $<a,b>$ and $<a,c>$ with  different $a$ and $b$ in the set of pairs.
A: A function is a relation $f\subseteq A\times B$, where $A\times B$ is the cartesian product of sets $A$ and $B$, which has two additional properties:

*

*$f$ is left-total, i.e. $\forall a\in A\exists b\in B : afb$.

For each $a\in A$ there exists $b\in B$ with $afb$.


*$f$ is right-unique, i.e., $\forall a\in A\forall b,b'\in B: afb\wedge afb'\Rightarrow b=b'$.

For each $a\in A$ and $b,b'\in B$, if $afb$ and $afb'$, then $b=b'$. (If there exist two, they are equal).
Thus for each $a\in A$, there exists at least one (left-total) and at most one (right-unique) $b\in B$ such that $afb$. Hence, we can write $f(a)=b$.
This definition is purely set-theoretical.
