Instruction
We want to implement a gate taking input of width and whose action is defined as follows:
The function is the Hamming weight and counts the number of s in the input. Such a gate is helpful in an implementation of the recursive Fourier sampling problem (RFS), also called recursive Bernstein-Vazirani Problem.
We are given an operator on qubits which acts as follows:
We are interested in the case . We claim that with its matrix given below can be used to implement for .
This matrix looks quite similar to the matrix of the gate. Simply exchange row with row in order to obtain .
Remark: The following matric is generated by Qiskit (with Qiskit’s bit order).
An important condition has to satisfy is . Show that results in the identity.
Implement a gate using one gate and one gate. Recall that acts when the control qubit is in state \mathrm{CNOT}\mathrm{CNOT}^0M_{3}$ above?
Implement a single-controlled version of gate in Qiskit using , and controlled gates. Test your implementation and document the test cases.
Implement the gate for and input qubits as a gate array in Qiskit.
Start with ancillary qubits and apply four gates each controlled by another single input qubit. The target qubits are the ancillary qubits. Apply an OR gate with target exploiting that is equivalent to . Measure and compute.
Test your implementation with all possible values for the input.