You are confusing your act of finding out the value of the function at a particular element of the domain with the function. That would be like thinking that a person does not have a telephone number until you look them up in the telephone directory and dial. Whether or not you look them up in the telephone directory does not determine whether or not they have a phone number.
In mathematics, a function $f\colon X\to Y$ is a subset of $X\times Y$ such that
- For all $x\in X$ there exists $y\in Y$ such that $(x,y)\in f$; and
- If $x\in X$, $y,y'\in Y$ and $(x,y),(x,y')\in f$, then $y=y'$.
When this happens, we write $f(x)=y$ to signify that $(x,y)\in f$; this is unambiguous by $2$.
Now consider what happens if we "dualize" the two parts of the definition:
- For all $y\in Y$ there exists $x\in X$ such that $(x,y)\in f$;
- If $y\in Y$, $x,x'\in X$ and $(x,y),(x',y)\in f$, then $x=x'$.
A function that satisfies the first property is said to be "onto" or "surjective." (Note that you have the definition wrong; you are using the first property that defines a function to be a function instead of this extra condition). A function that satisfies the second property is said to be "one-to-one" or "injective.
Your function, viewed as a function $f\colon \mathbb{N}\to\mathbb{N}$ is the set
$$\{(0,0), (1,0)\}\cup\{ (n+1,n)\mid n=1,2,3,4,\ldots\}.$$
As such, you are absolutely correct that the function is onto (though not for the reason you state: it's onto because for every $n\in\mathbb{N}$, the codomain, there exists $x\in\mathbb{N}$, the domain, with $f(x)=n$: if $n=0$, we can take $x=0$; if $n\gt 0$, we can take $x=n+1$), and is not one-to-one (because $f(0)=f(1)$, even though $0\neq 1$).
Now, $f$ is just a set. It is. It is not a procedure, it is not a process, it is not the act of you evaluating the function. It's a set. Its functional properties depend only on its properties as a set, and not on what we do with it. We don't "call" a functionn
(What "causes [you] mental dissonance" would likewise cause you mental dissonance when you consider the one-to-one and onto function $f\colon \mathbb{R}\to\mathbb{R}$ given by $f(x)=x$...)
Not quite.
For the one-to-one function, each element in $X$ is mapped to a unique element in $Y$. Therefore, there are $M$ ways to map the first element in $X$, and $M-1$ ways to map the second one, etc. There should be totally $M!/(M-N)!$ ways of one-to-one mapping when $M\geq N$. When $M<N$, you cannot get any one-to-one mapping.
For the onto function, there seems to be no simple, non-recusive formula for the number of onto functions.
See Stirling number
Best Answer
(This is really an answer to your comment, but I think it may be what you need for your question.)
I think the issue is that you may not be clear on the difference between range and codomain of a function. The codomain is simply "the set written second" in the function: if you have $$f:A\to B$$ then the codomain is $B$. That's it - nothing to work out, nothing to calculate, just look at it. The range, on the other hand, is the set of all $f(x)$ values which are actually achieved.
In your example, both $f$ and $g$ have codomain $\Bbb R$. (Why? - simply because you said so! You could have specified different codomains, but then you would have, strictly speaking, different functions, and ones that were not relevant to the question.) Therefore $f+g$ also has codomain $\Bbb R$, because this is part of the definition of the sum of two functions. However, as you have observed, $f+g$ only takes the value $0$, and so its range is $\{0\}$. The fact that the range is different from the codomain shows that $f+g$ is not onto.
Hope this helps!!