# What is the action of $CCZ$ on $X \times I \times I$?

Confused about the action of the $$CCZ$$ gate on Pauli operators:

I understand the action of the $$CZ$$ gate: $$CZ: XI \rightarrow XX$$ $$CZ: IX \rightarrow IX$$ $$CZ: ZI \rightarrow ZI$$ $$CZ: IZ \rightarrow IZ$$ I have verified this by means of matrix multiplication. However, I then get confused when I see: $$CCZ: XII \rightarrow X(CZ)$$ $$CCZ: ZII \rightarrow ZII$$ (similar for acting on $$X_{2}$$, $$X_{3}$$, $$Z_{2}$$, $$Z_{3}$$).

I just don't understand the action of $$CCZ$$ on $$XII$$. Specifically, I don't understand the notation $$X(CZ)$$. At first I thought it was matrix multiplication but $$X$$ is $$2 \times 2$$ and $$CZ$$ is $$4 \times 4$$.

If anybody could help me understand what $$X(CZ)$$ is, that would be very helpful!

• I think the parentheses in $X(CZ)$ just tell you that this is a tensor product of two gates, where the first is the $X$ gate (2x2 matrix) and the second the $CZ$ gate (4x4 matrix) in contrast to being the tensor product of three gates ($X$, $C$ and $Z$) as in the case of $ZII$ ($Z$, $I$ and $I$). Commented Apr 4 at 12:06

$$CCZ$$ will map $$X_iI_jI_k$$ to $$(X_iI_jI_k)(CZ_{j,k})$$ by conjugation where the parenthesis indicates the regular product (i.e. gate chaining) and $$CZ_{j,k}$$ is the $$CZ$$ operator between qubit $$j$$ and $$k$$ (seen as an operator on three qubits).

This notation is confusing if you do not include indices: $$I_1X_2I_3$$ is mapped to $$(I_1X_2I_3)(CZ_{1,3})$$, which is not intuitively understood from $$X(CZ)$$ reading from left to right, expecting the left most operator to act on the first qubit.

The action of $$CCZ$$ is more complex than the one of $$CZ$$ because they do not belong to the same class of the Clifford hierarchy (see this question where its precise definition appears). $$CZ$$ is a Clifford gate (belonging to the first class) and therefore maps Pauli operators to Pauli operators. $$CCZ$$ belongs to the second class: it maps Pauli operators to elements of the first class of the hierarchy, here a product between a Pauli operator ($$X$$) and a non-Pauli operator (the $$CZ$$ gate).

• In terms of the matrix representation. $CCZ =diag(1,1,1,1,1,1,1,-1)$. Then $CZ_{1,2}=diag(1,1,0,1,-1,0)$. $CZ_{2,3}=diag(0,1,1,0,1,-1)$ and $CZ_{1,3}=diag(1,0,1,1,0,-1)$? Is this correct? So then CCZ will map $IXI$ to $X_{2} \otimes CZ_{1,3}$, which is a $24 \otimes 24$ matrix? Or does matrix representation not really work here?....I think I've got something wrong along the way Commented Apr 4 at 14:19
• $CZ_{1,2}$ might not be as clear as a notation as I thought. By $X_2 \otimes CZ_{1,3}$ I meant the operator which acts as $X$ on qubit 2 and as $CZ$ on qubits 1 and 3 (i.e. a $8\times 8$ matrix). diag(1,1,0,1,-1,0) doesn't make sense as an operator, it is not of size $2^i \times 2^i$. It is probably more rigorous to say that $IXI$ is mapped to $X_2$ followed by a $CZ$ between qubits 1 and 3 and to not try to express it as a tensor product. I will edit my answer.
– AG47
Commented Apr 4 at 14:36
• Okay, thank you! Yes, I had thought that maybe $CZ1,3$ could be expressed as $I \otimes |0\rangle \langle 0| + Z \otimes |2 \rangle \langle 2|$ (hence the $diag(1,1,0,1,-1,0)$) because I had seen CZ1,2 expressed as $I \otimes |0\rangle \langle0| + Z \otimes |1 \rangle \langle 1|$ but obviously this is not the case! Commented Apr 4 at 14:48
• @am567 You can have a look at this question to better grasp controlled operations in a system with more than two qubits: quantumcomputing.stackexchange.com/questions/4252/…
– AG47
Commented Apr 4 at 15:24

CCZ is defined by

$$CCZ \vert{x_1,x_2,x_3} \rangle = \vert x_1, x_2 \rangle Z^{x_1\cdot x_2} \vert{x_3}\rangle = (-1)^{x_1 x_2 x_3} \vert{x_1,x_2,x_3} \rangle$$

Therefore, \begin{align} (CCZ)(XII)(CCZ)\vert{x_1,x_2,x_3}\rangle = (-1)^{x_1 x_2 x_3} CCZ\vert{1 \oplus x_1,x_2, x_3} \rangle = (-1)^{x_1 x_2 x_3} (-1)^{(1 \oplus x_1) x_2 x_3} \vert 1 \oplus x_1,x_2, x_3\rangle \end{align} On the other hand, \begin{align} 𝑋(𝐶𝑍)\vert{x_1,x_2,x_3} \rangle = \vert{1 \oplus x_1} \rangle \vert {x_2}\rangle Z^{x_2} \vert{x_3} \rangle = (-1)^{x_2 \oplus x_3} \vert 1 \oplus x_1,x_2, x_3\rangle. \end{align}

These to expressions are the same because exactly one of $$x_1$$ and $$1 \oplus x_1$$ equals 1.