braket.experimental.algorithms.simons.simons module

braket.experimental.algorithms.simons.simons.simons_oracle(secret_string: str) Circuit[source]

Quantum circuit implementing a particular oracle for Simon’s problem.

In the quantum setting, we first copy the input register into some ancillary qubits: |x>|0> -> |x>|x>.

We then perform the quantum analog of XOR, which means we apply an X gate to the kth qubit whenever the kth bit of string is 1. However, we only apply this X gate when the flag qubit is also |1>. Thus, our X gate becomes a CNOT gate between the flag qubit on the input register, and the kth qubit on the output.

Parameters:

secret_string (str) – the secret string

Returns:

Circuit – Circuit object that implements the oracle

braket.experimental.algorithms.simons.simons.simons_algorithm(oracle: Circuit) Circuit[source]

Build the circuit associated with Simon’s algorithm.

Parameters:

oracle (Circuit) – The oracle encoding the secret string

Returns:

Circuit – circuit associated with Simon’s algorithm

braket.experimental.algorithms.simons.simons.run_simons_algorithm(oracle: Circuit, device: Device, shots: int | None = None) QuantumTask[source]

Function to run Simon’s algorithm and return the secret string.

Parameters:
  • oracle (Circuit) – The oracle encoding the secret string

  • device (Device) – Braket device backend

  • shots (Optional[int]) – Number of measurement shots (default is None). The default number of shots is set to twice the arity of the oracle. shots must be a strictly positive integer.

Returns:

QuantumTask – Task for Simon’s algorithm.

braket.experimental.algorithms.simons.simons.get_simons_algorithm_results(task: QuantumTask) Dict[str, Any][source]

Get and print classically post-processed results from Simon’s algorithm execution.

Parameters:

task (QuantumTask) – Task for Simon’s algorithm.

Returns:

Dict[str, Any] – Dict containing the secret string and marginalized output states