I think this function is not injective, but I am unsure if I've correctly proven that.
Determine if the following statement is true or false and provide a proof to justify the answer. \begin{align*} g: \mathbb{R} & \to \mathbb{R} \\ g(x) &= \begin{cases} -x+1 & x>0\\ -x^2 & x \leq 0 \end{cases} \end{align*}
Here's my attempt. Proof: $g(-1)=-1=-1=g(2)$. $-1=-1$, but since $g(-1)=g(2)$, we can say that $g(-1)=g(2)\implies -1=2$ is false, and therefore for generic $x_1,x_2\in \mathbb{R}$, $g(x_1)=g(x_2)\implies x_1=x_2$ is false, so the function $g$ is not injective. $\blacksquare$
Am I missing something?
You have exposed two distinct points in the domain, $x=-1$ and $x=2$, with the same image under $g$. So $g$ is not injective. Done. A counterexample suffices.