Proof showing $f(x)$ is injective confusion

I started to learn about injectivity, and was somewhat confused as to how you show that a mapping is injective. From what I understand, injectivity is where $f: \Bbb X \mapsto \Bbb Y$ given that the one value of $\Bbb X$ maps to one value of $\Bbb Y$ i.e. the function is one to one. I am told the proof for showing a function is injective you must state that whenever $x_1,x_2\in \Bbb X$ are such that $f(x_1)=f(x_2)$ and hence $x_1=x_2$, but surely this is showing that 2 different inputs give the same output and is hence not injective as it is not one to one i.e outputs are equal?

I may be missing out a key piece of information here but at face value I don't understand how this shows $f(x)$ is injective?

As you said, to show that a function $f: X \to Y$ is injective you need to show that if $x_1,x_2 \in X$ such that $f(x_1) = f(x_2)$, then $x_1 = x_2$.
This shows that each element in the range of $f$ is mapped to from $\textit{only one}$ element in the domain, because you will have shown that if $y_0 \in Y$ with $y_0 = f(x_1)$ and $y_0 = f(x_2)$ then it must be that $x_1 = x_2$.
• I'mprobably just being stupid here,but when you say $y_0=f(x_1)$ and $y_0=f(x_2)$ aren't you saying that 2 values of $x$ being $x_1$ and $x_2$ give the same output $y_0$ which again shows that the function is not one to one and hence not injective? – JayVB Nov 1 '17 at 15:50
• A priori $x_1$ and $x_2$ can be different values. But to show that a function is injective you need to show that under the assumption that $f(x_1) = f(x_2)$ in fact $x_1 = x_2$. i.e. you show that these are not actually two different values; you show that they have to be the same. – wgrenard Nov 1 '17 at 15:53
• @JayVB It depends on what you mean by 'fabricating your own answer.' If you mean to claim that the logic is circular, then no, it isn't. What you are trying to prove is that under the assumption that $f(x_1) = f(x_2) \textit{ then } x_1 = x_2$. This is precisely what it means for a function to be injective. Simply assuming that $f(x_1) = f(x_2)$ doesn't mean that you are assuming the function is injective, so there is no circular logic. You are just assuming that $x_1$ and $x_2$ get mapped to the same place. From there you $\textit{deduce}$ whether or not $x_1 = x_2$. – wgrenard Nov 1 '17 at 18:45
• Be careful with the last step. $x_1^2 = x_2^2 \implies x_1 = \pm x_2$. It doesn't imply that $x_1 = x_2$. – wgrenard Nov 1 '17 at 19:00
Every function $f$ from $X$ to $Y$ has the property that every value of $X$ is mapped to a value of $Y$. That is basically what being a function means. Being injective means that any two distinct elements of $X$ are mapped to two distinct elements of $Y$. For instance, the function $q\colon\mathbb{R}\longrightarrow\mathbb R$ defined by $q(x)=x^2$ is not injective because $1\neq-1$, but $q(1)=q(-1)$.