$f:A \to B$ is a function and let $A_1,A_2 \subset A$ and $B_1,B_2 \subset B$.
Prove that
(a) If $f$ is injective then $f(A_1)=f(A_2)$ implies $A_1=A_2$.
(b) If $f$ is surjective then $f^{-1}(B_1)=f^{-1}(B_2)$ implies $B_1=B_2$.
For (a) I know that the definition of injectivity is
$f(x_1)=f(x_2)$ implies $x_1=x_2$. But I have no idea how this can be related to the subsets. Any help would be much appreciated.