We were ask to prove that $|A \cup B| = |A| + |B| – |A \cap B|$.
It was easy to prove it using a Venn diagram, but I think we might
be expected to do if more formally. Is there a formal way?
$A\cup B = (A\setminus B) \cup (B\setminus A) \cup (A\cap B)$. These three sets are disjoint, so
|A\cup B| = |A\setminus B| + |B\setminus A| + |(A\cap B)|
But $A\setminus B = A\setminus(A\cap B)$, so $|A\setminus B|=|A|-|A\cap B|$. A similar equality holds for $|B \setminus A|$. Substitution of these into the displayed equation above yields your result.
Of course, one might need to formally show that $|A\setminus (A\cap B)| = |A|-|A\cap B|$. I can’t decide if this is any less obvious than the original proposition…