how do you prove the preimage of the image of the domain is equal to the domain and how do you prove the image of the preimage of the codomain is the codomain
Problem: Let $\displaystyle \phi:X\mapsto Y$. Prove that $\displaystyle X=\phi^{-1}\left[\phi\left(X\right)\right]$
Proof: Let $\displaystyle x\in\phi^{-1}\left[\phi\left(X\right)\right]$. Then $\displaystyle \phi(x)\in \phi\left(X\right)\implies x\in X$. Therefore $\displaystyle \phi^{-1}\left[\phi\left(X\right)\right]\subset X$. Now let $\displaystyle x\in X$, $\displaystyle \phi(x)\in\phi\left(X\right)$. Which means that $\displaystyle x\in\phi^{-1}\left[\phi\left(X\right)\right]$. Therefore $\displaystyle X\subset\phi^{-1}\left[\phi\left(X\right)\right]$. The conclusion follows.
I hope that is rigorous enough.
The second is similar.