Show that $A\times B=B\times A$ if and only if $A=B.$ 
Could you tell me if this all right. And how is the best way to go backwards? it is by cases? 
Thanks. 
Sorry is not in latex, but I´m just learning. 
 A: This is not quite true: If $A=\varnothing$ then $A\times B = \varnothing = B\times A$ even if $B\ne\varnothing.$
However we can deal with the case where $A\ne \varnothing\ne B.$
If $A\ne B$ then something is a member of one of these sets but not of the other. So suppose $x\in A$ and $x\notin B.$ And let $y$ be some member of $B.$ Then $(x,y)\in A\times B$ but $(x,y)\notin B\times A.$
And the same sort of argument deals with the case in which $B$ has some member that is not a member of $A.$
A: As others have mentioned, you need $A$ and $B$ both to be inhabited, or else $A \times B$ and $B \times A$ are both empty.
Here's a direct proof that $A=B$, without using contradiction.
First, fix some $a \in A$ and $b \in B$.
To prove $A = B$, we'll prove $A \subseteq B$ and $B \subseteq A$.


*

*Take $x \in A$. Then $(x,b) \in A \times B$, so $(x,b) \in B \times A$, and so $x \in B$. This proves $A \subseteq B$.

*Take $x \in B$. Then $(a,x) \in A \times B$, so $(a,x) \in B \times A$, and so $x \in A$. This proves $B \subseteq A$.


And we're done!
