When does $xxyy = xyxy$ not imply $xy = yx$ in a ring? This is a follow-up to a graded question on some homework. In attempting to prove that a ring R such that $x^2 = x$ for all $x \in R$ is commutative, I tried using the fact that $xy = x^2y^2 = (xy)^2$ for all $x, y\in R$, so $xxyy = xyxy$. I thought this was enough information to know for sure that $xy=yx$, but apparently it isn't. What is the problem with this conclusion?
 A: You cannot simply cancel off $x$ and $y$. To get $xy=yx$ from $xxyy=xyxy$.
Here's a counter-example:
$x = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$ and $y = \begin{bmatrix} 0 & 1 \\ 0 & 1 \end{bmatrix}$.
Notice that $xy = \begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}$ so $xyxy = 0$.
Also, $x^2=0$ so $x^2y^2=0=xyxy$.
But notice that $yx=0 \not= xy$.
How did this happen? Well, cancelation doesn't work when we have zero divisors hanging 
around. 
Notice that $yx=0$ (and with both $x$ and $y$ not zero) says that $y$ and $x$ are zero divisors. But in the ring of $2 \times 2$ matrices, things that multiply to be zero in one order don't necessarily work that way in the other order as well.
A: The problem is much simpler than it looks but requires a trick. The ring $R$ you are looking at is called a Boolean ring. In any case, for this ring $R$ ANY element squared is itself. So take $x,y \in R$ and consider $$(x+y)^2$$ Try expanding this out and also using the properties of $R$ and see if you can see why that implies $xy=yx$.
EDIT: This did not fully answer your question. It does not hold because your step $x^2y^2=(xy)^2$ is incorrect. This is only true if $R$ is commutative--which is what you are trying to show in the first place. So your question is the same as saying when does $x^2y^2=(xy)^2$ and that is only when $x$ and $y$ commute with each other. Though what you probably want is this to hold for any $x,y \in R$, in which case this implies that it holds generally only when $R$ is commutative. 
A: You're instinct is that $ab = ac$ implies $b=c$, which is true with normal multiplication, but can't be done in a general ring $R$, because there doesn't need to be an inverse of $a$ in $R$, so you can't necessarily multiply both sides by $a^{-1}$. But if $R$ is a division ring (every element has an inverse) you can do this.... unfortunately non trivial Boolean rings aren't division rings, so you have to find another way to prove this.
A: I too think you were seduced by cancellation, and I have an simpler demonstration that cancellation fails dramatically in rings such that $x^2=x$.
The ring could be the field of two elements $\Bbb F_2$, and we would be done. Now suppose it has more than two elements. Then it has an $x$ not $0$ or $1$ such that $x^2=x$. But if you believe nonzero elements can be cancelled, and try to cancel $x$ off of $xx=x$ you get $x=1$, a contradiction. The upshot is that nothing cancels properly except $1$!
Rings in which you can do cancellation of any nonzero element are called domains. Rings such that $x^2=x$ for all $x$ are called Boolean rings. As you can see we have basically proven that the only Boolean domain is the field $\Bbb F_2$.
The right observation to begin with is the one given by mathematics2x2life.
