# Does XNOR of three variable equals XOR of same three variables

I came across following excerpt:

$(x'y'+xy)'z'+(x'y'+xy)z=x\oplus y\oplus z$

What I see is left hand side is XNOR of $x,y$ and on right, $z$ and I get XOR of of $x,y$ and $z$ !!! In other word,

$XNOR(XNOR(x,y),z)=XOR(XOR(x,y),z)$

Somehow I am surprised by the result, as I didnt came across this earlier, no text stated this explicitly and was unexpected. It was unexpected because, I knew some other equalities and inequalities stated below, so was never thought of existence of above equality.

$XNOR(x,y)=NOT(XOR(x,y))$ $NAND(NAND(x,y),z)\neq AND(AND(x,y),z)$ $NOR(NOR(x,y),z)\neq AND(OR(x,y),z)$

Q1. Am I interpreting it correct as XNORs of three variables equals XOR of same three variables?
Q2. If yes, can someone shed more light about why such relationship is not true for other gates? Is just that their definition does not permit such relationship? Or Is it beacause ExOR is not basic gate, while AND and OR are?

PS: Sorry for naive, possibly stupid question.

The full excerpt:

$(x'y'+xy)'z'+(x'y'+xy)z$
$(x'y')'(xy)'z'+x'y'z+xyz$
$(x+y)(x'+y')z'+x'y'z+xyz$
$xy'z'+x'yz'+x'y'z+xyz$
$=x\oplus y\oplus z$

## 1 Answer

XOR is addition modulo 2, and XNOR computes the sum modulo 2 of its inputs and 1. Since $$(x+y+1)+z+1 \equiv x+y+z \pmod{2},$$ We see that XORing three variables is the same as XNORing them. The same holds for any odd number of variables. When XNORing an even number of variables, you get the negation of their XOR.

Nothing of this sort happens for AND or OR. There isn't any particular reason. You should think of it the other way around: XOR satisfies this surprising property, but other gates do not. XOR is special. It has absolutely nothing to do with AND and OR being "basic gates", whatever that means (mathematically, probably not much).

• Cant say enough thanks...I believe it would have taken some more years for me to come across the fact that XNOR is (addition + 1) modulo 2 and its connection with the fact asked in question. I honestly believe all texts should specify such subtle facts and all teachers should teach these things in lectures or at least state the existence of such facts so that students can explore on their own. Otherwise only time can reveal such things. Surprisingly wikipedia xnor page also does not state this thing. – anir Jan 29 '18 at 15:06