We are trying to implement a "sum over 4 booleans = k" in the spirit of Grover search. First, we have 4 qubits, one for each boolean q00, q01, q02, q03,; then 4 qubits to computed intermediate sum (q11 and q10 to store "q00+q01" where q11 is the carry, etc); then 3 qubits to binary represent the int result q22.q21.q20 (varying between 0 to 3); and then a final qubit to test the result = k (here we want k=1 so 001 is the good result, then 2 X gate on q21 and q22 will bring 111 via the C3Not into q40. Finally q60 is for Grover extraction.

First we describe the sum (Oracle), then Grover Amplification (separated with a barrier); and done 2 iterations before measurements.

The histogram result is quite strange despite we found the standard 4 solutions, 0000 and 1111 appear also. Can someone explain this behaviour?

Circuit sum over boolean = k Histogram k=1


1 Answer 1


We found the mistake. In the first figure, when we compute q2x from q1x by : 1/ purple ccnot for the carry 2/ blue cnot for the summation we unroll them in the wrong way (purple then blue instead blue then purple).


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.