Q:

$f(X \setminus A) = X \setminus f(A)$?

I want to generalize the following result: if $(X , d)$ is a metric space, $f : (X , d) \to (X , d)$ is an homeomorphism and $A \subset X$, then $f(X \setminus A) = X \setminus f(A)$, so I have thought that if $X$ is an abstract set, $f : X \to X$ is a suprajective map and $A \subset X$, then also $f(X \setminus A) = X \setminus f(A)$ and I have tried to prove that: we begin proving $f(X \setminus A) \subset X \setminus f(A)$, so let $y \in f(X \setminus A)$. On the one hand, by the suprajectivity of $f$, exists $x \in X \setminus A$ such that $f(x) = y$, so $f(x) \notin f(A)$ because $x \notin A$. Equivalently, $y \in X \setminus f(A)$. To prove $X \setminus f(A) \subset f(X \setminus A)$, let $z \in X \setminus f(A)$. Again, by the suprajectivity of $f$, exists $w \in X$ such that $f(w) = z \notin f(A)$, so $w \notin A$ and it proves that $z \in f(X \setminus A)$; in fact, if $w \in A$, then $f(w) \in f(A)$, so $z \in f(A)$. Do you think it is correct? Thank you very much.

A:

No your proof is not correct. You actually need to use the fact that $f$ is bijective (ie both surjective and injective), surjective is not enough. 
Take for example $X = \mathbb R$ and $A=[-1,1]$ and $f(x) = x\sin(\pi x/2)$, the function is certainly surjective. Now $f(X\setminus A) = X \ne X \setminus f(A)$. This function however is not bijective.
The actual error happens when you try to prove that $f(X\setminus A)\subset X\setminus f(A)$. It's the actual part where injectivity is required. The exact error is that you conclude that $f(x)\notin f(A)$ because $x\notin A$. On the other hand surjectivity is not required to prove this part.
To prove it you observe that since $y\in f(X\setminus A)$ there exists an $x\in X\setminus A$ such that $f(x) = y$ (by definition of the image of a set). Now to conclude that $f(x)\notin f(A)$ we use the fact that if it were in $f(A)$ we would have a $\xi\in A$ such that $f(\xi)=f(x)$ (by definition of image of a set), but due to $f$ being injective that would mean that $x = \xi$ since $f(x)=f(\xi)$ which would mean that $x\in A$ which contradicts $x\in X\setminus A$ - so we can conclude that $f(x)\notin f(A)$.
To sum up with $f$ being surjective we can conclude that $f(X\setminus A)\supset X\setminus f(A)$ and if $f$ is injective we can conclude that $f(X\setminus A)\subset X\setminus f(A)$.

