Surjection/Examples/Floor of Half x+1 on Integers

Example of Surjection
Let $f: \Z \to \Z$ be the mapping defined on the set of integers as:
 * $\forall x \in \Z: \map f x = \floor {\dfrac {x + 1} 2}$

where $\floor {\, \cdot \,}$ denotes the floor function.

Then $f$ is a surjection, but not an injection.

Proof
Let $y \in \Z$ be an integer.

Consider the integer $x = 2 y$.

Then:

Thus:
 * $\forall y \in \Z: \exists x \in \Z: \map f x = y$

Thus $f$ is a surjection by definition.

Let $n \in \Z$ be an integer.

Let $x_1 = 2 n - 1$ and $x_2 = 2 n$.

Then:

while:

Thus we have that $x_1 \ne x_2$ but $\map f {x_1} = \map f {x_2}$.

Hence by definition $f$ is not an injection.