Simon’s Algorithm was first proposed by Daniel Simon in 1994. It was the first quantum algorithm that was exponentially faster than the best classical algorithm and was also an inspiration for Shor’s Algorithm.
Goal:
We are given a hidden function , such that if and only if or for a secret string . Our goal is to find .
Remarks:
An example with :
0000 | 1001 | 1111 | 1000 | 0001 | 1101 |
0001 | 1000 | 1101 | 1001 | 0000 | 1111 |
0010 | 1011 | 1010 | 1010 | 0011 | 1000 |
0011 | 1010 | 1000 | 1011 | 0010 | 1010 |
0100 | 1101 | 0011 | 1100 | 0101 | 0001 |
0101 | 1100 | 0001 | 1101 | 0100 | 0011 |
0110 | 1111 | 0110 | 1110 | 0111 | 0100 |
0111 | 1110 | 0100 | 1111 | 0110 | 0110 |
It can be easily checked that this is a two-to-one function since exactly two different inputs are mapped to a unique output.
Classic Solution:
If we can find and such that and , then we can obtain . Therefore, the question now becomes how many different inputs do we have to try in order to find two inputs with the same output?
We have different inputs, and half of them ( inputs) produce unique outputs.
In fact, we can show that all classic solutions have at least query complexity.
Quantum Solution:
We initialize quantum systems and with qubits each in the state .
Pass each of the qubits in through a Hadamard gate.
Pass and through the oracle .
Measure on the computational basis.
Pass each of the qubits in through a Hadamard gate again.
Measure on the computational basis and record the outcome string .
Repeat procedure 1-6 until we have linearly independent ’s.
Then can be solved by equations:
Remarks:
Quantum Implementation:
To illustrate how to implement the quantum circuit, we use the example given in the above table.
To design a based on :
The final is
The code of this oracle is in Appendix(1.1)
With , the full quantum circuit of Simon’s Algorithm for the example is
The code of this algorithm is in Appendix(1.2)
Experimental Results:
To test the performance of our implementation, we run the quantum circuit on the Quantum Leaf CloudBaiduSim2Water simulator. The server simulates the code for 1024 times and provides the histogram of raw outputs.
The raw outcomes are in Appendix(1.3)
However, we are only interested in the last bits measured on system . After performing some data cleansing, we can obtain the desired histogram.
The transformed outcomes are in Appendix(1.4)
Notice that we obtain more than needed data in this simulation. So, we may randomly choose linearly independent outcomes for further post-processing. Assume the obtained outcomes are . We can solve for with the equation
where . After Gaussian elimination, the augmented matrix becomes
A non-trial solution (i.e. ) to this equation is .
If we pick any other set of linearly independent outcomes, the result is the same. In this way, we have shown the correctness of our quantum implementation.
How to use Quantum Leaf?
Run
.1.1 Code of for Simon’s Algorithm
OPENQASM 2.0;
include "qelib1.inc";
qreg q[8];
creg c[8];
//
x q[4];
x q[5];
x q[6];
x q[7];
//
cx q[0], q[6];
//
cx q[1], q[4];
//
cx q[2], q[7];
//
cx q[3], q[6];
//
cx q[4], q[5];
//
cx q[7], q[5];
1.2 Code of Simon’s Algorithm
OPENQASM 2.0;
include "qelib1.inc";
qreg q[8];
creg c[8];
//
h q[0];
h q[1];
h q[2];
h q[3];
//
x q[4];
x q[5];
x q[6];
x q[7];
//
cx q[0], q[6];
//
cx q[1], q[4];
//
cx q[2], q[7];
//
cx q[3], q[6];
//
cx q[4], q[5];
//
cx q[7], q[5];
//
//
h q[0];
h q[1];
h q[2];
h q[3];
//
measure q[4] -> c[4];
measure q[5] -> c[5];
measure q[6] -> c[6];
measure q[7] -> c[7];
measure q[0] -> c[0];
measure q[1] -> c[1];
measure q[2] -> c[2];
measure q[3] -> c[3];
1.3 Raw outcomes of Simon’s Algorithm
{
"00010000": 9,
"00010010": 21,
"00010100": 17,
"00010110": 11,
"00011001": 17,
"00011011": 18,
"00011101": 23,
"00011111": 20,
"00100000": 14,
"00100010": 10,
"00100100": 20,
"00100110": 16,
"00101001": 22,
"00101011": 13,
"00101101": 16,
"00101111": 12,
"01010000": 20,
"01010010": 19,
"01010100": 13,
"01010110": 15,
"01011001": 17,
"01011011": 23,
"01011101": 11,
"01011111": 16,
"01100000": 14,
"01100010": 20,
"01100100": 13,
"01100110": 18,
"01101001": 22,
"01101011": 17,
"01101101": 11,
"01101111": 20,
"10000000": 13,
"10000010": 19,
"10000100": 12,
"10000110": 14,
"10001001": 20,
"10001011": 16,
"10001101": 14,
"10001111": 14,
"10110000": 13,
"10110010": 16,
"10110100": 16,
"10110110": 15,
"10111001": 17,
"10111011": 18,
"10111101": 12,
"10111111": 12,
"11000000": 15,
"11000010": 17,
"11000100": 16,
"11000110": 20,
"11001001": 19,
"11001011": 15,
"11001101": 13,
"11001111": 13,
"11110000": 13,
"11110010": 16,
"11110100": 15,
"11110110": 11,
"11111001": 21,
"11111011": 19,
"11111101": 18,
"11111111": 14
}
1.4 Transformed outcomes of Simon’s Algorithm
{
"0000": 111,
"0010": 138,
"0100": 122,
"0110": 120,
"1001": 155,
"1011": 139,
"1101": 118,
"1111": 121,
}
— Oct 30, 2021
Made with ❤ at Earth.