prove cardinality rule $|A-B|=|B-A|\rightarrow|A|=|B|$ I need to prove this $|A-B|=|B-A|\rightarrow|A|=|B|$
I managed to come up with this:
let $f:A-B\to B-A$ while $f$ is bijective.
then define $g\colon A\to B$ as follows:
$$g(x)=\begin{cases}
  f(x)& x\in (A-B) \\ 
  x& \text{otherwise} \\ 
\end{cases}$$
but I'm not managing to prove this function is surjective.
Is it not? or am I on the right path? if so how do I prove it?
Thanks

Your basic intuition is correct.
First prove that $g$ is injective.
Suppose $x,y\in A$ and $x\neq y$. Let us break this into four cases (two similar):


*

*If $x\in B$ and $y\notin B$ (or vice versa) then $g(x)=x$ while $g(y)=f(y)\notin A$, therefore $g(x)\neq g(y)$.

*If $x,y\in B$ then $f(x)\neq f(y)$ since $f$ is injective, and therefore $g(x)\neq g(y)$.

*Similarly for $x,y\notin B$, we have that $g(x)=x\neq y=g(y)$.
Therefore $g$ is an injective function.
To show $g$ is surjective, pick $x\in B$. 
Either $x\in A$ and therefore $g^{-1}(x)=x$, or $x\notin A$ and therefore $f^{-1}(x)=a$ is defined; $a\in A\setminus B$; and $g(a)=f(a)=x$ as needed.
