My book gives the following definition:

A function $f$ from $A$ to $B$ is defined as $f\subseteq A\times B$ such that if $(a,b)\in f$ and $(a,b_1)\in f$ then $b=b_1$ and there exists a $(a,b)\in f$ for each $a \in A$ .

Now according to this definition, the function would be the same even if the codomains are different. Is it true?

  • 2
    $\begingroup$ Good question and good answers on it. Keep both possibilities in sight. E.g. in set-theory $f\subset A\times B$ s.t. $\forall a\in A\exists!b\in B\;\left(a,b\right)\in f$ is convenient. E.g. in categories $f=\left(A,G,B\right)$ where $G\subset A\times B$ s.t. $\forall a\in A\exists!b\in B\;\left(a,b\right)\in G$ is convenient. $\endgroup$
    – drhab
    Jul 19, 2014 at 8:59

4 Answers 4


Yes. You can change th codomain, and as long as it includes the range of $f$, the function is the same.

For example, $\sin\colon\Bbb R\to\Bbb R$ and $\sin\colon\Bbb R\to[-1,1]$ are the same function. Or $f(1)=1$ is the same whether or not $f\colon\{1\}\to\Bbb N$ to $f\colon\{1\}\to\{0,1\}$.

As the other answers indicate, in some contexts a function is a triplet where the codomain is specified explicitly. It can be useful to know the codomain as part of the function. In set theoretic contexts, it is sometimes better to treat a function as a set of ordered pairs with a certain property.

Why is it useful? For example, it dispenses the need to talk about "canonical injection", and we can just talk about inclusion. Now we can say that $f\subseteq g$ when $g$ is a larger function, or that $f\cap g$ is a function. It allows us to define partial functions more easily, especially in the context of predicate logic: we can define a predicate which is a function on its domain, and it is not necessary this domain is the entire universe of the structure (so the predicate cannot be a function symbol). This is very useful, for example, in computability theory.

  • 2
    $\begingroup$ An example of the use you mention for the codomain: it's often more convenient to say that the sine function "is not surjective", as opposed to saying it's "not surjective onto $\mathbb{R}$". Or one might say that the first sine function you define "is not surjective" and the second one "is surjective". If the codomain isn't part of the function, then trivially every function "is surjective"! $\endgroup$ Jul 19, 2014 at 13:43
  • 1
    $\begingroup$ @Steve: Yes, that is true. If you include the codomain in the definition then it is easier to talk about surjectivity. I don't find that a sufficient reason for doing so, though. :-) $\endgroup$
    – Asaf Karagila
    Jul 19, 2014 at 15:01
  • $\begingroup$ I don't think this is the correct answer because I don't think this is a matter of usefulness. This is a matter of consensus. Is there a consensus, or not? $\endgroup$
    – FCardelle
    May 15, 2021 at 18:31

If you look at a function as a pure set of ordered pairs, then yes your observation is true. If you look at it as a triple $(A,B,\text{set of ordered pairs})$ then $B$ matters. If you replace $B$ in the triple by the image (some books call it range) of $f$ (some $B' \subseteq B$), then again your observation is true.

Basically, this is a nit you should not worry too much about.


This really depends on how you formally define "the same". In mathematics, this is done by specifying an equivalence relation giving rise to equivalence classes of functions. It is possible to specify an equivalence relation between functions that requires them to have the same codomain in order to be considered "the same" (i.e., functions with different codomain are not the same), and it is possible to specify an equivalence relation that ignores the codomain (i.e., functions can be the same even if they have different codomains).

Formally, functions with specified codomains are triples $(\mathcal{X}, \mathcal{Y}, \mathscr{G})$ containing a domain $\mathcal{X}$, a codomain $\mathcal{Y}$, and a graph $\mathscr{G} \equiv \{ (x,f(x)) | x \in \mathcal{X} \}$. You can define the equivalence relations $\sim$ and $\overset{*}{\sim}$ respectively by:

$$\begin{matrix} f_0 \sim f_1 & & \iff & & (\mathcal{X}_0, \mathcal{Y}_0, \mathscr{G}_0) = (\mathcal{X}_1, \mathcal{Y}_1, \mathscr{G}_1), \\[6pt] f_0 \overset{*}{\sim} f_1 & & \iff & & (\mathcal{X}_0, \mathscr{G}_0) = (\mathcal{X}_1, \mathscr{G}_1). \\[6pt] \end{matrix}$$

The first equivalence relation requires equivalence of the codomains of the two functions, whereas the second does not. Both give a well-defined notion of when two functions are "the same".

So, the real question here is, which of these two equivalence relations is more useful? Well, it turns out that the codomain isn't really important for most properties of functions. Indeed, the "meat" of a function is given by the graph $\mathscr{G}$ that shows all pairs of values (i.e., all the combinations of a value in the domain and the value it maps to). (However, for some cases where the codomain is important, see here.) Consequently, we tend to adopt the convention that two functions are considered "the same" if they have the same domain and graph, but we do not require the same codomain. This means that we adopt the above equivalence relation $\sim$ as specifying when two functions are "the same".

  • $\begingroup$ Usually when people say "the same", without any additional qualifiers, they mean equality. Now, you could argue that from a categorical perspective that may very well be "too strong" and the right answer should be "isomorphic", or some variant of that, but nevertheless "the same" is "equality". $\endgroup$
    – Asaf Karagila
    Jul 22, 2020 at 9:52
  • $\begingroup$ I also wouldn't say that "Formally, functions with specified codomains are triples ...", because I can very well specify $p\colon X\to Y$ and still work under the assumption that the function is a set of ordered pairs, and then I can extend, shrink, or otherwise manipulate $Y$ as my pleasure dictates (and as I said in my answer, this is useful and we do end up doing that in some situations throughout mathematics). $\endgroup$
    – Asaf Karagila
    Jul 22, 2020 at 9:54
  • 2
    $\begingroup$ I don't disagree with either of those comments. You can certainly enlarge or shrink the codomain (down as far as the range) as your pleasure dictates, but if the function is conceived to have a codomain then that is still part of the specification of the function. (And if it is not part of the function then the function is one without a codomain.) I also agree that sameness is equality, but equality of what? The specification of the function can include or exclude the codomain, so the equality can include or exclude this part. $\endgroup$
    – Ben
    Jul 22, 2020 at 10:10
  • $\begingroup$ Two things are equal if they are the same thing. It's the connection between syntax and semantics. And yes, I am well aware of the HTT approach to equality is that "some equalities are more equal than others", but in non-category/type theory based approaches, equality is equality, not "whatever reasonable equivalence relation you want". $\endgroup$
    – Asaf Karagila
    Jul 22, 2020 at 10:29
  • $\begingroup$ Yes, and as I said, what are the two things in question here? If we are talking about equality of functions, are the functions just the double of their domain and graph, or are they they triple of their domain, graph and codomain? $\endgroup$
    – Ben
    Jul 22, 2020 at 23:29

Let's stand back a bit -- sometimes it is worth thinking what's behind a convention.

So: start by thinking how, in practice, we informally prove that there's exactly one function that satisfies a certain description --- e.g. is a unique order-isomorphism between $(A, <)$ and $(B,\prec)$. We need to show that there's at least one such function, and that there is at most one. How do we do the second bit? We show that if $f$ and $f'$ are candidates, then they are the same function. And how do we do that? We show that for every $a$ among the objects $A$, $f(a) = f'(a)$. But why does that show that $f$ and $f'$ are the same function?

It only does so on an extensional understanding of what a function is: we are taking it that functions aren't individuated by the rules we give for associating an argument with value but by the resulting association. So, even if we have two different rules of association, if they both generate the same collection of pairings between arguments and values, we count the rules as two different ways of presenting the same function.

Now this doesn't yet warrant defining functions as collections of argument/value pairings; that identification involves another idea beyond extensionality, call it plenitude. This is the further idea that any old association of arguments with values (one value per argument) determines a function, even if that association is beyond any possibility that we could describe it. It is one thing to say that different rules can determine the same function (extensionality), it is another thing to say that there can be functions which have no describable rule that determines their values (that functions are as plenitudinous as arbitrary argument/value pairings). Taking the second step might seem natural in hindsight, but its almost universal acceptance was the result of hard won achievements in 19th century mathematics.

OK: if we go for extensionality and plentitude, it becomes entirely natural to define a function from $A$ into $B$ -- or perhaps we should really say "model" or "implement" a function -- as a set of ordered pairs $(a, b)$ with only one pair for each $a$. That fixes functions as extensional items, and is naturally understood as making the functions as plenitudinous as the relevant sets.

Hence the characterization of functions we find in elementary analysis texts which implements functions as sets of ordered pairs in such a way that changing the co-domain doesn't change the function. That's because what matters in the elementary context is to emphasize an extensional understanding of what functions and to stress that you can have functions associated with no describable rule for associating argument to function.

Now sure, in further non-so-elementary contexts it can be useful to explicitly build into our characterization of a function the domain (if we are going to start seriously dealing with partial functions) and codomain. That refinement doesn't make the implementation in (some of) the elementary texts wrong -- that serves perfectly to make the points the elementary texts need to make.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .