Given a function $f: \mathbf{N}_0 \to \mathbf{N}_0$, defined $$ f(x) = \begin{cases} x+3 & \text{if } x \in \mathbf{N}_{\text{even}} \\ x-1 & \text{if } x \in \mathbf{N}_{\text{odd}} \end{cases} $$
I have to prove that the function is injective.
My attempt:
Suppose that $f(a) = f(b), \forall a,b \in N_{even}$
$a+3=b+3 \implies a = b$
Suppose that $f(a) = f(b), \forall a,b \in N_{odd}$
$a-1=b-1 \implies a = b$
Since $a,b$ are arbitrary, $f$ is injective.
Sorry, but your attempt is incomplete.
What you have to prove is that, if $f(a)=f(b)$, then $a=b$.
There are four cases:
In case 1, we have $a+3=b+3$, hence $a=b$.
In case 4, we have $a-1=b-1$, hence $a=b$.
You’re missing the other two cases, which actually are the same, so I’ll only deal with 2. In this case, $a-1=b+3$, therefore $$ a=b+4 $$ which is a contradiction.
The fact that cases 2 and 3 can’t happen doesn’t allow you to skip them without justification.