The full question is: Given a function $f:A\rightarrow B$, prove that: $f$ is injective if and only if $f^{-1}(f(X))= X$ for all $X \subset A$
I initially was thinking: If $f^{-1}(f(X))= X$, then $x \in f^{-1}(f(X))= X \iff x \in X$
But then I thought: What if there are $x_{1}$ and $x_{2}$ in X, with $x_{1}\neq x_{2}$ and $f(x_{1})=f(x_{2})$?
Then $f$ isn't injective and $f^{-1}(f(X))= X$ still seems valid.
What am I missing here?