In this cases double inclusion is the way: let $x \in f(f^{-1}(X))$, then there is $a \in f^{-1}(X)$ such that $f(a) = x$. By definition of the pre image, $x \in X$. This gives $$f(f^{-1}(X)) \subset X.$$
Note that we didn't use that the function is surjective to prove this inclusion, meaning that it holds in general.
Now let $x \in X$. Being $f$ surjective, we can find $a \in A$ such that $f(a) = x$. This gives $a \in f^{-1}(X)$ and hence $x = f(a) \in f(f^{-1}(X))$. This shows $$X \subset f(f^{-1}(X)).$$
The main thing to understand here is the logic. If you get that right you should find that everything else is pretty easy. Just a suggestion - others may disagree - but I find that writing these things in symbolic logic makes it harder, not easier. I would put them in words as far as possible.
There are a lot of "if-then" statements to prove here. In fact if you expand the definitions there are if-thens within if-thens. For example
$$\hbox{if $R\circ R\subseteq R$ then $R$ is transitive}$$
can be expanded as
$$\displaylines{
\hbox{if (if $(x,y)\in R\circ R$ then $(x,y)\in R$)}\cr
\hbox{then (if $(x,y)\in R$ and $(y,z)\in R$ then $(x,z)\in R$)}.\cr}$$
I hope this IS confusing because that's kind of my point - you wouldn't want to start off writing things like this, but on the other hand you do need to be aware that there are lots of if-thens around, and when you come to work out a proof you need to know how to deal with them.
So, how do you prove "if $X$ then $Y$"? There are various ways but the most straightforward is:
- Assume that $X$ is true.
- . . . [arguments] . . .
- Therefore $Y$ is true.
Let's apply this to the above statement. At a very basic level, your proof will be as follows.
- Assume that $R\circ R\subseteq R$.
- . . .
- Therefore $R$ is transitive.
How are you going to prove that $R$ is transitive? The same way, because it is also an if-then statement! So you could develop the previous proof a bit further.
- Assume that $R\circ R\subseteq R$.
- Now suppose that $(x,y)\in R$ and $(y,z)\in R$.
- . . .
- Therefore $(x,z)\in R$.
- Hence, $R$ is transitive.
Now you could go back to try and work out how the fact that $R\circ R\subseteq R$ is going to help you fill in the dots. You might start by writing in what it actually means according to the definition, and then expanding that a bit.
- Assume that $R\circ R\subseteq R$.
- That is, if $(a,b)\in R\circ R$, then $(a,b)\in R$.
- In other words, if $(a,c)\in R$ and $(c,b)\in R$ for some $c$, then $(a,b)\in R$.
- Now suppose that $(x,y)\in R$ and $(y,z)\in R$.
- . . .
- Therefore $(x,z)\in R$.
- Hence, $R$ is transitive.
Now if you look at what is given and what you want you should see that they are almost identical. In fact, if we replace $a,b,c$ by $x,z,y$ respectively then they are identical. So let's do that.
- Assume that $R\circ R\subseteq R$.
- That is, if $(x,z)\in R\circ R$, then $(x,z)\in R$.
- In other words, if $(x,y)\in R$ and $(y,z)\in R$ for some $y$, then $(x,z)\in R$.
- Now suppose that $(x,y)\in R$ and $(y,z)\in R$.
- . . .
- Therefore $(x,z)\in R$.
- Hence, $R$ is transitive.
Now the second last line follows immediately from the previous ones. In fact you can see that what we now have is rather a case of overkill as we have stated many things twice. So you could then edit the proof to streamline it as much as possible: you might end up with something like this.
- Assume that $R\circ R\subseteq R$,
- and suppose that $(x,y)\in R$ and $(y,z)\in R$.
- By definition of $R\circ R$, it follows that $(x,z)\in R\circ R$,
- but since $R\circ R\subseteq R$ we have $(x,z)\in R$.
- We have proved that if $(x,y)\in R$ and $(y,z)\in R$ then $(x,z)\in R$: hence, $R$ is transitive.
Notice how much you can do simply by using definitions to replace "high-level" concepts by simpler ones! In this case it gives you pretty much the whole proof, though you can't expect that always to happen - sometimes there is no substitute for having a "bright idea".
As you pointed out, you need to prove the converse too. See if you can get it by using the same approach.
Best Answer
In general: $$x\in h^{-1}(S)\iff h(x)\in S$$ So the following statements are equivalent:
This shows that $$(g\circ f)^{-1}(S)=f^{-1}(g^{-1}(S))$$