Let $f : A\to B$. If $\{B_1,B_2,\dots,B_n\}$ is a partition of $B$, prove that $\{f^{-1}(B_1),f^{-1}(B_2),\dots,f^{-1}(B_n)\}$ is partition of $A$.
I approached it like following:
Since $f^{-1}$ exists $f$ must be one one and onto. So for each $x$ in $A$ there is one distinct image in $B$ under $A$. Converse, "for each $y$ in $B$ there is distinct pre-image under $f$". This implies that we can define a set $A_i \subseteq A$ which is the set of all elements in A whose image lies in $B_i$ under the $f$ i.e., $A_i=_f^{-1}(B_i)$. Since $f$ is onto $f$ covers all of $B$ and hence union of $A_i$s is equal to $A$.
Since $B_i$ is non-empty set, there exist a $y$ in $B_i$ such that $f(x)=y$. This means that $x$ is pre-image of $y$ under $f$. Hence $x$ belongs to $A_i$. So $A_i$ is non empty set.
Now since $B_i \cap B_j$ is empty if $i\ne j$, them there is no $y$ such that it belongs to both $B_i$ and $B_j$. Now $f$ is one one so there is no pre-image $x$ such that it belongs to both $A_i$ and $A_j$. So $A_i \cap A_j$ is empty. Hence set of all $A_i$s form a partition of $A$.
I think my logic is correct but can someone help me writing it in formal way. Also since there is one one correspondence between equivalence relations and partitions, how to approach this using relations.