Showing if $f$ is an injection then $A=f^{-1}(f(A))$ and if $f$ is onto $Y$ then $B=f(f^{-1}(B))$ 
We the sets and subsets $X,Y, \ A\subseteq X, B\subseteq Y$and a function $ f:X\to Y$.
We'll define the sets: $$f(A)=\{b\in Y : \exists a\in A, \ b=f(a)\}\\ 
                         f^{-1}(B)=\{a\in X : f(a)\in B\}$$ 
(1) Show that if $f$ is an injection then $A=f^{-1}(f(A))$ and (2) if $f$ is onto $Y$ then $B=f(f^{-1}(B))$.

I end up with just writing the defintions for injection and surjection and that $A=X, B=Y$ which is probably wrong. How can show it in the the right way ?
 A: (1) Assume $f$ is injective, that is $f(x)=f(y)$ with $x,y\in X$ implies $x=y$.
To show $A=f^{-1}(f(A))$ it is convenient to show $A\subseteq f^{-1}(f(A))$ and $A\supseteq f^{-1}(f(A))$.
To show $A\subseteq f^{-1}(f(A))$, let $x\in A$. We have to show that $x\in f^{-1}(f(A))$. By definition of $f^{-1}$ this is equivalent to $f(x)\in f(A)$, i.e. (by defineition of $f(A)$) that there exists $a\in A$ with $f(x)=f(a)$. Since $x\in A$, we can soiimply pick $a=x$ and are done. We didn't even use injectivity, that is: $A\subseteq f^{-1}(f(A))$ holds for all functions $f\colon X\to Y$.Now to show $A\supseteq f^{-1}(f(A))$, let $x\in f^{-1}(f(A))$. We have to show $x\in A$. But $x\in f^{-1}(f(A))$ means that $f(x)\in f(A)$, and this means that there exists $a\in A$ such that $f(x)=f(a)$. By injectivity of $f$, we conclude $x=a$ and hence $x\in A$.
(2) Assume $f$ is surjective.  Let $y\in f(f^{-1}(B))$, that is $y=f(x)$ for some $x\in f^{-1}(B)$. Then by definition fo $f^{-1}(B)$, we have $f(x)\in B$, so $y\in B$. This shows $f(f^{-1}(B))\subseteq B$, and again we find that one direction holds for all functions, not just surjective ones.
Now let $y\in B$. We have to show $y\in f(f^{-1}(B))$. That is, we want top show that there exists $x\in f^{-1}(B)$ with $f(x)=y$. Now we can make use of surjectivity, which guarantees us that there exists $x\in X$ with $f(x)=y$. All we need to ensure is that $x$ is in fact in $f^{-1}(B)$. But that just requires that $f(x)\in B$, which is the case as $f(x)=y\in B$.
A: Suppose that $f$ is an injection, and $A \subset X$. We always have $A \subset f^{-1}[f[A]]$, regardless of $f$, because $x \in f^{-1}[f[A]]$ iff $f(x) \in f[A]$ iff $\exists_{a \in A} f(a) = f(x)$, which obviously holds for $x \in A$ (as we can just take $a = x$), but for injective $f$ we can conclude more: suppose $f(x) = f(a)$ for some $a \in A$ (which is exactly what it means, by definition, for $x$ to be in $f^{-1}[f[A]]$), then by injectiveness, $x = a$, and so $x \in A$, and we have the other inclusion.
We always have $f[f^{-1}[B]] \subset B$: take $y \in f[f^{-1}[B]]$, which means that for some $x \in f^{-1}[B]$ we have $f(x) = y$. But $x \in f^{-1}[B]$ means that $f(x) \in B$ by definition, so $y \in B$.
Suppose that $f$ is surjective and $y \in B$. Then for some $x \in X$, $f(x) = y$ by surjectiveness. This $x$ is in $f^{-1}[B]$, as its image is $y$ which lies in $B$. So we know that $y \in f[f^{-1}[B]]$ by definition.
