# Does $f(X \setminus A)\subseteq Y\setminus f(A), \forall A\subseteq X$ imply $f$ is injective ?

I know that if $f:X\to Y$ is injective then $f(X \setminus A)\subseteq Y\setminus f(A), \forall A\subseteq X$ . Is the converse true i.e.

if $f:X \to Y$ is a function such that $f(X \setminus A)\subseteq Y\setminus f(A), \forall A\subseteq X$ , then is it true that $f$ is

injective ?

Yes. We prove the contrapositive. Suppose that $f$ is not injective; then there are distinct $x_0,x_1\in X$ such that $f(x_0)=f(x_1)$. Let $A=\{x_0\}$; then
$$f[X\setminus A]=f[X]\nsubseteqq Y\setminus f[A]=Y\setminus\{f(x_0)\}\;.$$