What is Simon’s algorithm? #
Simon’s algorithm is a quantum algorithm that solves a problem related to finding periodicity in functions. It provides an exponential speedup over the best-known classical algorithms for the same problem and has applications in cryptography and computer science theory.
Simon’s algorithm works by implementing an unknown function, f, using quantum logic. This requires a unitary operator, Uf, that encodes the function’s action as a transformation on quantum states.
- quantum subroutine is typically run O(n) times to obtain a sufficient number of linearly independent equations to solve for the secret string to get a list of linearly independent bitstrings.
- Solve the system of equations produced by the bitstrings
The classical algorithm for Simon’s problem repeats queries until a collision is found. On average, a collision is more likely to be found after three tries, and there’s a greater than 50% chance of collisions for an input domain of eight numbers. Simon’s algorithm is a precursor to the Quantum Fourier Transform, which inspired Shor’s Algorithm.
The classical solution of Simon’s algorithm involves finding two inputs, x and y, where f(x) = f(y). This allows the user to determine s = x⊕y, where addition is done bitwise, mod 2. The user can also show that no two inputs produce the same output
To solve Simon’s problem classically, one needs to find two different inputs x and y for which f(x)=f(y), since one can then determine s=x⊕y (where addition is done bitwise, mod 2), or otherwise show that no two inputs produce the same output.
Notation Consistency: The secret string is referred to as both ‘k’ and ‘s’ throughout the explanation. It would be better to use a single, consistent notation (e.g., ‘s’) to avoid confusion.
Below is a short video showing how the circuit looks for the 2-Qubit Selection with a “01” input for the secret message from the user. The corresponding QASM code is generated and can be modified and made to run on the available backend systems to obtain results, visualizations, and probabilities.
`
Qubit Selection for Algorithm #
After a user selects their preferred Qubit from the dropdown menu, a circuit is loaded in the main composer area after clicking on the “Load circuit” button for the selected Qubit.
Next, if a user selects 3-qubit, a corresponding 3-digit binary selection should be made, and similarly for other Qubit selections as well.
Secret Message Selection: Here, a secret message holds a hidden property (the secret string s) that the algorithm aims to discover about a function. Here, the input secret message always needs to be in binary format, i.e., in 0 and 1 format.
Imagine you have a black-box function that takes n bits as input and outputs another n bits. This function has a special property: it always outputs the same value if two input strings differ only by a specific “secret” n-bit string (let’s call it s). In other words, f(x) = f(y) only if x ⊕ s = y, where ⊕ represents bitwise XOR.
The goal of Simon’s algorithm is to find this secret string s, given only access to the black-box function (like an oracle) and the knowledge of the function’s property.
Here is how the 2-Qubit selection works w.r.t Oracle arrangement:
In Simon’s algorithm, the oracle plays a crucial role in revealing the function’s hidden period (secret string). Here’s how it works specifically for a 2-qubit selection:
The Oracle’s Task:
The oracle is a black-box function that takes two qubits as input (|x⟩|y⟩
) and performs a specific operation based on Simon’s problem for a 2-qubit selection. Here’s the breakdown:
-
Input Qubits:
- The first qubit (
|x⟩
) represents the variable input to the function. It can be in a superposition state (|0⟩ + |1⟩
), meaning it can be 0 or 1 simultaneously. - The second qubit (
|y⟩
) is typically initialized to the zero state (|0⟩
). It acts as a scratchpad for the oracle’s operation.
- The first qubit (
-
Hidden Period:
- In a 2-qubit selection, the function has a hidden period of one bit (
s
). This means f(x) = f(x れません s) for any input value x. (⊕ denotes bitwise XOR).
- In a 2-qubit selection, the function has a hidden period of one bit (
-
Oracle’s Operation:
- The oracle manipulates the qubits based on the hidden period. Here’s the key step:
- If the first qubit’s value (x) differs from the hidden bit (s), the oracle flips the second qubit’s state (from |0⟩ to |1⟩ or vice versa).
- If x and s are the same (x ⊕ s = 0), the oracle leaves the second qubit unchanged (remains |0⟩).
- The oracle manipulates the qubits based on the hidden period. Here’s the key step:
Example:
- The hidden period (s) is 1 (s = |1⟩).
- When the input is
|0⟩|0⟩
(x = 0), the oracle flips the second qubit (|0⟩
to|1⟩
) because 0 ⊕ 1 = 1. - When the input is
|1⟩|0⟩
(x = 1), The oracle leaves the second qubit as|0⟩
since 1 ⊕ 1 = 0.
How it Helps Find the Period:
The algorithm can identify a pattern by querying the oracle with different superpositions of the first qubit and analyzing the second qubit’s state after the oracle’s operation. It can find two input states (differing only by the hidden bit) that both result in the same output from the oracle (the second qubit remains |0⟩). This reveals information about the hidden period, allowing the algorithm to determine the secret bit string (s).