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?