# What's the correct way to define a function? (codomain and surjectivity)

Here's a common definition of a function (for example, Wiki follows this definition):

A relation between sets $A$ and $B$ is any subset $R \subseteq A \times B$. We say that this relation is a function if it satisfies the property $$(a,b_1) \in R \text{ and }(a,b_2) \in R \implies b_1 = b_2$$

This definition of a function is good for most purposes. Certainly, we can find the domain and range of a function defined in this way. This also allows us to answer such questions as

Is the set $\{(1,2),(2,5),(3,5)\}$ a function? (answer: yes)

With such a definition, we could certainly go on to define a function's domain and range. The problem with this definition, however, is that it includes no notion of a codomain. This presents a problem when we want to answer a question such as

Are the functions $f:\Bbb R \to \Bbb R$ given by $f(x) = x^2$ and $g:\Bbb R \to [0,\infty)$ given by $g(x) = x^2$ the same function? (answer: no)

On the one hand, the "graphs" of the function are the same. If we are to believe that these functions are merely subsets of a Cartesian product, then we should say that $f = g$ since both are merely the set $\{(x,x^2) : x \in \Bbb R\}$. On the other hand, we would like to say that "the function $g$ is surjective, but the function $f$ is not". If surjectivity is a property of functions, then the fact that $f$ and $g$ do not share this property should mean that $f \neq g$.

So what gives? Is there a setting in which both of these questions are well-posed? If someone has a reference that handles all this well, I would appreciate it.

Edit: Wiki apparrarently has a discussion of this issue here

• There have been several discussions on this topic both here and on MathOverflow. Asking for "the correct" way is just not the right question. Like asking what garnish to put in your gin and tonic: there is no correct answer, with Hendrick's it's cucumber and with Bombay Sapphire it's lime. Same here, in some contexts one definition is better and other contexts other definitions might work better. – Asaf Karagila Jun 27 '17 at 7:01
• Comments are not for extended discussion; this conversation has been moved to chat. – user642796 Jun 27 '17 at 7:21

Forget about functions for a minute and go back to the definition of a relation.

A relation between a first set $A$ with a second set $B$ is any subset of $A \times B$. The set $A$ is called the domain of the relation and the set $B$ is called the codomain.

By definition, when you look at any relation $\tau$, it is not just a subset of a cartesian product. You have a map,

Domain($\tau$) = $A$
Codomain($\tau$) = $B$

Part of the definition/structure of a relation is this underlying concept of domain and codomain. You can't 'forget it'.

If you have any function $f$ between $A$ and $B$ you can define a new function between $A$ and $f(<A>)$. This is now a surjective function. What do you want to call this function. If there is no danger of getting into trouble, how about $f$?.

So this is part of the definition. If you want you can say,

Consider the 'functional graph' of $y = x^2$ in $\Bbb R \times \Bbb R$.

or

Consider the 'functional graph' of $y = \sqrt x$ in $\Bbb R \times \Bbb R$.

Depending on your audience this might be fine and nobody will get bent out of shape worried about domains and codomains. See wikipedia Codomain; you can 'blame' Nicolas Bourbaki for this.

• Thanks for the idea! Note that your interpretation of what defines a function is not universal. As is explained here, An alternative definition of function by Bourbaki [Bourbaki, op. cit., p. 77], namely as just a functional graph, does not include a codomain and is also widely used. – Omnomnomnom Jun 27 '17 at 2:56

Upon closer reading, I've found out how the text I'm teaching from resolves this paradox.

Indeed, a function is considered equal to its graph. Rather saying that a function is inherently surjective/onto, the text opts to define the phrase $f$ is "onto $B$" to mean that $f$ is surjective when $B$ is taken as the codomain. If we establish a codomain by writing $f:A \to B$, then "onto/surjective" means "onto $B$".

So, there is indeed a valid framework. We do forego the notion that surjectivity is a property of a function, but I think this is a reasonable compromise.