# How to construct a two-qubit circuit implementing the oracle for Simon's algorithm, in qiskit?

I want to create a two-qubit quantum circuit for a function with these inputs and outputs:

f(00)=10

f(01)=10

f(10)=01

f(11)=01

I do not know how to think about this problem systematically and come up with a quantum circuit. Please note that I am using Qiskit so consider the Qiskit order.

• Thanks for the comment @MarcoFellous-Asiani. It is going to be an oracle for Simon's Algorithm. Does it make a difference? May 10, 2023 at 10:27

In Simon's algorithm, the oracle maps $$|0\rangle|x\rangle$$ to $$|f(x)\rangle|x\rangle$$. In your case: $$|00\rangle|00\rangle \rightarrow |10\rangle|00\rangle$$ $$|00\rangle|01\rangle \rightarrow |10\rangle|01\rangle$$ $$|00\rangle|10\rangle \rightarrow |01\rangle|10\rangle$$ $$|00\rangle|11\rangle \rightarrow |01\rangle|11\rangle$$

Note: Like Qiskit, I'm using little-endian bit ordering.

This is a unitary operation and can be easily implemented:

circ = QuantumCircuit(4)

circ.cx(1, 2)
circ.cx(2, 3)
circ.x(3)


And to test the output of this circuit, you can use this code snippet:

from qiskit.quantum_info import Statevector

sv = Statevector.from_label('00++').evolve(circ)
sv.draw('latex')

• It is going to be an oracle for Simon's Algorithm. Does it make a difference? May 10, 2023 at 10:26
• Yes! I updated my answer accordingly. May 10, 2023 at 16:53
• Thanks. It seems to be correct. How did you come up with such a circuit? I am trying to develop my intuition about quantum circuits. May 12, 2023 at 8:13