Controlled gates #
Gate.controlled U is the (1 + n)-qubit gate that applies the n-qubit
gate U on the target register exactly when the control qubit is in |1>,
and does nothing when it is in |0> [CEMM98, cemm6.tex:127]. As a matrix it
is the block decomposition c-U = |0><0| ⊗ 1 + |1><1| ⊗ U.
The projectors proj0 and proj1 are HilbertOperators, not gates.
The one-qubit projector |0><0| = [[1, 0], [0, 0]].
Equations
- QuantumAlg.Gate.proj0 = !![1, 0; 0, 0]
Instances For
The one-qubit projector |1><1| = [[0, 0], [0, 1]].
Equations
- QuantumAlg.Gate.proj1 = !![0, 0; 0, 1]
Instances For
@[simp]
@[simp]
Raw controlled-operator matrix.
Equations
Instances For
The controlled gate c-U.
Equations
Instances For
@[simp]
theorem
QuantumAlg.Gate.controlled_applyVec_ket0_tensor
{n : ℕ}
(U : Gate n)
(psi : StateVector n)
:
On the |0> control branch c-U does nothing.
@[simp]
theorem
QuantumAlg.Gate.controlled_applyVec_ket1_tensor
{n : ℕ}
(U : Gate n)
(psi : StateVector n)
:
U.controlled.op.applyVec (PureState.ket1.vec.tensor psi) = PureState.ket1.vec.tensor (U.applyVec psi)
On the |1> control branch c-U applies U.
@[simp]
On the |0> control branch c-U does nothing.
@[simp]
On the |1> control branch c-U applies U.
theorem
QuantumAlg.Gate.controlled_mem_unitaryGroup
{n : ℕ}
{U : Gate n}
(_hU : U.op ∈ Matrix.unitaryGroup (Fin (2 ^ n)) ℂ)
:
c-U is unitary.
Sanity check: the controlled Pauli-X gate is exactly CNOT.