Computing Library › Quantum Logic Gates
Quantum Logic Gates

Controlled-Controlled-Phase Gate

Applies a phase only to the all-ones state of three qubits, the diagonal cousin of the Toffoli.

Definition

The controlled-controlled-phase gate CCP(λ) — with the special case CCZ at λ = π — applies a phase e^{iλ} to the |111⟩ amplitude of three qubits and leaves the other seven basis amplitudes unchanged. It is diagonal and fully symmetric under any permutation of its three qubits.

Matrix

Kronos motion — three machines
CCP(λ) diagonal, basis 000..111
1111111e^{iλ}

The eight diagonal entries are all 1 except the last, which is e^{iλ}. At λ = π the final entry is -1, giving CCZ. Because CCZ = (I⊗I⊗H)·Toffoli·(I⊗I⊗H), the diagonal CCP family and the Toffoli are the same operation viewed in different bases.

Relation to Toffoli

Conjugating CCZ by Hadamards on any one qubit turns it into a Toffoli controlled on the other two. So a compiler that has a good Toffoli template gets CCZ for free, and vice versa. The symmetric diagonal form is often preferred because all three qubits play the same role.

python
import numpy as np
def ccp(lam):
    d = np.ones(8, dtype=complex)
    d[7] = np.exp(1j*lam)
    return np.diag(d)

Uses

CCZ is the marking operation in three-condition Grover oracles and a common resource in fault-tolerant compilation, where a CCZ magic state can be distilled and teleported much like a T state. Its diagonal structure means multiple CCP gates on overlapping triples commute and can be reordered freely.

See controlled-phase for the two-qubit case and multi-controlled X for the non-diagonal generalization.