# For $f:X\to Y$ and $A$ a subset of $X$, why are $A$ and $f^{-1}(f(A))$ not necessarily equal?

I need help with this question:

Let $$f: X \to Y$$ be a function, and let $$A$$ be a subset of $$X$$. Why are the sets $$A$$ and $$f^{-1}(f(A))$$ not necessarily equal? Under what conditions are they equal?

Thanks!

Consider the function $$f:\{1,2,3\}\rightarrow\{2,3,4\}, f(1)=2, f(2)=f(3)=3$$ and let $$A=\{1,2\}\subseteq\{1,2,3\}$$.
$$f(A)=f(\{1,2\})=\{2,3\}\implies f^{-1}(f(A))=f^{-1}(\{2,3\})=\{1,2,3\}\neq\{1,2\}=A$$
We define the direct image of $$A\subseteq X$$ as $$f(A)=\{f(x): x\in A\}$$ and the inverse image of $$B\subseteq Y$$ as $$f^{-1}(B)=\{x: x\in X, f(x)\in B \}$$. Clearly, the inverse image of $$f(A)$$, that is $$f^{-1}(f(A)),$$ contains all the elements of $$A$$ as $$f(x)\in f(A),\ \forall x\in A$$. This means $$A\subseteq f^{-1}(f(A))$$. But this is not to say that $$f^{-1}(f(A))$$ contains only the elements of $$A$$. If $$\exists\ y\in X-A$$ such that $$f(y)\in f(A)$$, then $$y\in f^{-1}(f(A))$$ but $$y\notin A$$.
The sufficient and necessary condition for $$f^{-1}(f(A))=A,\ \forall A\subseteq X$$, is that $$f$$ is injective. You already know from above that $$A\subseteq f^{-1}(f(A))$$. Can you prove the converse: $$f^{-1}(f(A))\subseteq A,\forall A\subseteq X$$ given $$f$$ is injective?