I'm trying to implement Simon's oracle for a 2 to 1 function like described in the answer for the same question here: https://quantumcomputing.stackexchange.com/a/6587/22394
As I interpret the answer it works as follows:

  1. For all qubits copy the qubit value from the input register with CX to the corresponding qubit in the output register.
  2. For a 1 at position x in the secret apply a CX from the highest value qubit in the input register to the the x-th qubit in the output register.

But for the following given secret '01' (Big Endian Notation) it doesn't work:

Step 1: Circuit after step 1

Step 2: enter image description here

Given this secret: enter image description here

f(0) and f(1) build a pair and f(2) and f(3) build another.
According to this blueprint the output of f(0) and f(1) should be equal.
But inserting 00 -> 00 and 01 -> 01.


2 Answers 2


Not an answer to your question, but one quick and dirty way of implementing the oracle would be using the qiskit Truth Table Oracle. You just exhaustively specify inputs and outputs in a table and in the end you get a circuit which represents an oracle.

The problem with this approach is that your table grows exponentially with the number of qubits. On the other hand, you might try generating a small oracle (say for four qubits) and then examine the circuit for getting a clue about what gates were used.

The better way is trying to understand what DaftWullie described in the linked post, but I can't help with that.


You could do something like:

  1. assume the most significant bit of 𝑠 is 1.
  2. write a function that says "if the most significant bit of 𝑥 is 0, return 𝑥. if the most significant bit of 𝑥 is 1, return 𝑥⊕𝑠.

Your problem is Your most significant bit is a 0 not a 1.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.