Let K be a field, $U_1, U_2 \subset V$ subspaces of a vector space $V$ over $K$.
Prove that $$\dim_K(U_1)+\dim_K(U_2)=\dim_K(U_1+U_2)+\dim_K(U_1 \cap U_2)$$
for a linear map $f: H \rightarrow W$ for vector spaces $H, W$ over $K$.
I would love some hints, I know how to prove this using the basis of the subspaces, but this way is unknown to me.
Thank you in advance.