Let $f(x)=x$.
Let's say I want to show that this function is injective.
Assume
$$f(x_1)=f(x_2)\tag{1}$$
then I immediately get
$$x_1=x_2\tag{2}$$
and so
$$(f(x_1)=f(x_2)\implies (x_1=x_2)\tag{3}$$
which is the desired result.
But what does this mean exactly?
(3) is the same as
$$\lnot (f(x_1)= f(x_2)\lor (x_1= x_2)\tag{4}$$
$$(f(x_1)\neq f(x_2)\lor (x_1= x_2)\tag{5}$$
The truth table for logical or shows that (5) can be true with the first disjunct true (ie, $f(x_1)\neq f(x_2)$) and the second disjunct true (ie, $x_1=x_2$), but we know this is not true for our function.
In fact, if we assume $f(x_1)\neq f(x_2)$ then we immediately obtain $x_1\neq x_2$.
Thus it seems that what we ought to have is
$$(f(x_1)=f(x_2)\iff (x_1=x_2)\tag{6}$$
My question is then: how do we reason about the meaning of (3) in logical terms? In particular, does (3) not allow the mathematically impossible case of the antecedent being false and the consequent true?
What if I try the following proof
Assume $(f(x_1)=f(x_2)) \land (x_1\neq x_2)$.
Then $x_1=x_2$ and so $\bot$.
So what can we conclude?
That $\lnot [(f(x_1)=f(x_2)) \land (x_1\neq x_2)]$ which means
$$(f(x_1)\neq f(x_2) \lor (x_1=x_2)$$
Does this mean both disjuncts can be true? Mathematically they cannot.
How do we reconcile the truth of this statement with what we know to be mathematically true?
Edit: I personally believe the confusion arises when you're teaching a computer or a human what an injective function is, and whether you've already accounted for the implicit properties of a function, versus a relation for example. I can't think of a good way to edit my answer to unambiguously express this, so I recommend readers go through the comments on this answer also.
Yes, (3) by itself does not account for the fact that $f(x_1)=f(x_2)$ and $x_1=x_2$ are constrained by another relationship: the property of deterministic functions that if you provide the same input, you always get the same output. This is basically the converse of your relation, $(x_1= x_2)\implies (f(x_1) = f(x_2))$, and is a default property for every deterministic function. And so combining the two gives $(f(x_1)=f(x_2))\iff (x_1=x_2)$
So the way I would reason is that (3) is a necessary condition for injective functions. However, it isn't a sufficient condition. That's why you can't simply look at all scenarios which make just (3) true. Though in practice, conditions like $(x_1= x_2)\implies (f(x_1) = f(x_2))$ are usually taken for granted and so people may not bother to explicitly mention it.
Also, unless otherwise specified or known from context clues, functions are assumed to be deterministic.