The Distinguish Unitaries quantum kata offers tasks in which you are given a unitary and have to figure out which of the list it is by designing and performing experiments on it.
Each task is wrapped in one operation preceded by the description of the task.
Your goal is to fill in the blank (marked with // ...
comments)
with some Q# code that solves the task. To verify your answer, run the cell using Ctrl+Enter (⌘+Enter on macOS).
The tasks are given in approximate order of increasing difficulty; harder ones are marked with asterisks.
Input: An operation that implements a single-qubit unitary transformation: either the identity (I gate) or the Pauli X gate (X gate). The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the I gate, 1 if the given operation is the X gate.
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T101_DistinguishIfromX
operation DistinguishIfromX (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a single-qubit unitary transformation: either the identity (I gate) or the Pauli Z gate (Z gate). The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the I gate, 1 if the given operation is the Z gate.
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T102_DistinguishIfromZ
operation DistinguishIfromZ (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a single-qubit unitary transformation: either the Z gate or the S gate. The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the Z gate, 1 if the given operation is the S gate.
You are allowed to apply the given operation and its adjoint/controlled variants at most twice.
%kata T103_DistinguishZfromS
operation DistinguishZfromS (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a single-qubit unitary transformation: either the Hadamard (H) gate or the X gate. The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the H gate, 1 if the given operation is the X gate.
You are allowed to apply the given operation and its adjoint/controlled variants at most twice.
%kata T104_DistinguishHfromX
operation DistinguishHfromX (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a single-qubit unitary transformation: either the Z gate or the minus Z gate (i.e., the gate $- |0\rangle\langle0| + |1\rangle\langle1|$). The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the Z gate, 1 if the given operation is the $-$Z gate.
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T105_DistinguishZfromMinusZ
operation DistinguishZfromMinusZ (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a single-qubit unitary transformation: either the Rz gate or the R1 gate.
This operation will take two parameters: the first parameter is the rotation angle, in radians, and the second parameter is the qubit to which the gate should be applied (matching normal Rz and R1 gates in Q#). The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the Rz gate, 1 if the given operation is the R1 gate.
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T106_DistinguishRzFromR1
operation DistinguishRzFromR1 (unitary : ((Double, Qubit) => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a single-qubit unitary transformation: either the Y gate or the sequence of Pauli Z and Pauli X gates (equivalent to applying the Z gate followed by the X gate). The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the Y gate, 1 if the given operation is the XZ gate.
You are allowed to apply the given operation and its adjoint/controlled variants at most twice.
%kata T107_DistinguishYfromXZ
operation DistinguishYfromXZ (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a single-qubit unitary transformation: either the Y gate (possibly with an extra global phase of $-1$) or the sequence of Pauli Z and Pauli X gates (possibly with an extra global phase of $-1$). The operation will have Adjoint and Controlled variants defined.
Output:
You are allowed to apply the given operation and its adjoint/controlled variants at most three times.
%kata T108_DistinguishYfromXZWithPhases
operation DistinguishYfromXZWithPhases (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Inputs:
either the $R_z(\theta)$ gate or the $R_y(\theta)$ gate.
The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the Rz gate, 1 if the given operation is the Ry gate.
You are allowed to apply the given operation and its adjoint/controlled variants any number of times.
%kata T109_DistinguishRzFromRy
operation DistinguishRzFromRy (theta : Double, unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Inputs:
either the $R_z(\theta)$ gate or the $R_1(\theta)$ gate.
The operation will have Adjoint and Controlled variants defined.
Output: 0 if the given operation is the Rz gate, 1 if the given operation is the R1 gate.
You are allowed to apply the given operation and its adjoint/controlled variants any number of times.
%kata T110_DistinguishRzFromR1WithAngle
operation DistinguishRzFromR1WithAngle (theta : Double, unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Input: An operation that implements a single-qubit unitary transformation: either the identity (I gate) or one of the Pauli gates (X, Y or Z gate). The operation will have Adjoint and Controlled variants defined.
Output:
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T111_DistinguishPaulis
operation DistinguishPaulis (unitary : (Qubit => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a two-qubit unitary transformation: either the $I \otimes X$ (the X gate applied to the second qubit) or the $\text{CNOT}$ gate with the first qubit as control and the second qubit as target.
Output: 0 if the given operation is $I \otimes X$, 1 if the given operation is the $\text{CNOT}$ gate.
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T201_DistinguishIXfromCNOT
operation DistinguishIXfromCNOT (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a two-qubit unitary transformation: either the $\text{CNOT}$ gate with the first qubit as control and the second qubit as target ($\text{CNOT}_{12}$) or the $\text{CNOT}$ gate with the second qubit as control and the first qubit as target ($\text{CNOT}_{21}$).
Output: 0 if the given operation is $\text{CNOT}_{12}$, 1 if the given operation is $\text{CNOT}_{21}$.
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T202_CNOTDirection
operation CNOTDirection (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a two-qubit unitary transformation: either the $\text{CNOT}$ gate with the first qubit as control and the second qubit as target ($\text{CNOT}_{12}$) or the $SWAP$ gate.
Output: 0 if the given operation is $\text{CNOT}_{12}$, 1 if the given operation is $\text{SWAP}$.
You are allowed to apply the given operation and its adjoint/controlled variants exactly once.
%kata T203_DistinguishCNOTfromSWAP
operation DistinguishCNOTfromSWAP (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.
Input: An operation that implements a two-qubit unitary transformation: either the identity ($I \otimes I$), the $\text{CNOT}$ gate with one of the qubits as control and the other qubit as a target, or the $SWAP$ gate.
Output:
You are allowed to apply the given operation and its adjoint/controlled variants at most twice.
%kata T204_DistinguishTwoQubitUnitaries
operation DistinguishTwoQubitUnitaries (unitary : (Qubit[] => Unit is Adj+Ctl)) : Int {
// ...
return -1;
}
Can't come up with a solution? See the explained solution in the Distinguish Unitaries Workbook.