Sign in
← Atlas
Exact & formalGatesMulti-qubit gate

CCZ (doubly-controlled Z) gate

The phase-only sibling of the Toffoli gate that applies a -1 phase exactly when all three qubits are |1⟩, symmetric in all three qubits and the natural three-qubit generalization of CZ.

multi-controlledphasethree qubitnon-clifford

Atlas stars stay in the public catalog. Saving this entry to your workspace starts an unstarred private copy.

CCZ matters wherever Grover-style diffusion or oracle marking needs a symmetric multi-controlled phase rather than a bit flip: because it treats all three qubits identically, it composes more transparently into larger multi-controlled-phase constructions than Toffoli does.

Circuit & simulation
|111⟩ phase-flipped100%
all other 7 inputs unchanged100%
What this takes and returns
Takes3 qubitsWhat joins here

Takes a 3-qubit register and states no assumption about what is on it. That is the whole condition: anything returning 3 qubits can feed it.

3 entries meet this end · 1 entry lines up on shape, composition unverified. Named below.

Returns3 qubitsWhat joins here

Returns a 3-qubit register a next stage can take. This is the end that joins.

2 entries meet this end · 14 entries line up on shape, composition unverified. Named below.

A unitary. The same register goes in and comes out, and this entry states no assumption about what is on it — which is what lets anything of the same width feed it. See all 29 →

Shapes fit before this, composition unverified 1

The widths and types line up. What is not established is everything a width does not carry — the basis convention, the normalisation, the state each was written to start from — so this is not a claim that the two compose.

How it works

Definition

CCZa,b,c=(1)abca,b,c\mathrm{CCZ}|a,b,c\rangle = (-1)^{a\wedge b\wedge c}\,|a,b,c\rangle

As an 8×88\times 8 diagonal matrix, CCZ=diag(1,1,1,1,1,1,1,1)\mathrm{CCZ} = \mathrm{diag}(1,1,1,1,1,1,1,-1) in the ordered basis 000,,111|000\rangle,\dots,|111\rangle — the identity everywhere except a sign flip on 111|111\rangle.

Action on basis states and symmetry

Only 111|111\rangle picks up a phase; the other seven computational-basis states are completely unaffected. Because the matrix is symmetric under any permutation of the three qubits, CCZ\mathrm{CCZ} has no distinguished "target" — unlike Toffoli, where swapping the target with a control changes the gate.

Decomposition

CCZ=(IIH)  CCX  (IIH)\mathrm{CCZ} = (I\otimes I\otimes H)\;\mathrm{CCX}\;(I\otimes I\otimes H)

exactly mirroring the two-qubit identity CZ=(IH)CX(IH)\mathrm{CZ} = (I\otimes H)\,\mathrm{CX}\,(I\otimes H): conjugating the Toffoli's target by Hadamard converts its controlled bit-flip (XX on the control-11 block) into a controlled phase-flip (HXH=ZHXH=Z on that same block), leaving the control-not-both-1 blocks at identity in both cases.

Key identities

  • CCZ2=I3\mathrm{CCZ}^2 = I^{\otimes 3}: applying the same doubly-controlled phase twice restores the input.
  • CCZ\mathrm{CCZ} is non-Clifford, exactly like Toffoli: it inherits the same resource cost (6 CNOT + 2 H + 7 T-family gates, via the Toffoli decomposition sandwiched by the extra pair of target Hadamards, which cancel two of Toffoli's own Hadamards).
  • CCZ\mathrm{CCZ} is the natural building block for multi-controlled-phase oracles in amplitude amplification and Grover-style search, since its full symmetry across all three qubits makes larger CnZC^nZ constructions compose more uniformly than CnXC^nX ones.
Implementation
Native
ccz.qasm
OPENQASM 3.0;
include "stdgates.inc";
qubit[3] q;
x q[0];
x q[1];
x q[2];
h q[2];
ccx q[0], q[1], q[2];
h q[2];
Quantum vs classical

Classical baseline

Use a classical state-vector or matrix simulation at the same width, precision, and measurement objective.

Quantum claim

The quantum record demonstrates a state or operator behavior; it does not make classical simulation or communication costs disappear.

How to compare

Compare fidelity, samples, gate depth, noise, memory, and the cost of preparing and reading the state.

Declared gaps

Nobody has reviewed this record for gaps yet.

Literature & references
Quantum Computation and Quantum Information: 10th Anniversary Edition2010 · Michael A. Nielsen and Isaac L. Chuang

Standard reference for gate matrices, the Clifford/non-Clifford distinction, and controlled-gate constructions used throughout this record.

doi.org/10.1017/cbo9780511976667
OpenQASM 3: A broader and deeper quantum assembly language2021 · Andrew W. Cross, Ali Javadi-Abhari, Thomas Alexander, Niel de Beaudrap, Lev S. Bishop, Steven Heidel, Colm A. Ryan, Prasahnt Sivarajah, John Smolin, Jay M. Gambetta, Blake R. Johnson

Defines the standard gate library (id, sdg, tdg, cy, crz, rxx, rzz, ccx, cx…) used natively by the code snippets on this record.

arxiv.org/abs/2104.14722