Simon function periodicity

from qlasskit import qlassf, Qint


@qlassf
def f(a: Qint[4]) -> Qint[4]:
    return (a >> 3) + 1
f.export("qiskit").draw("mpl")
_images/2a4773ac0533c3441c9ec57bdd0b9d762ec7141c62fa3d3e284dc6430812079a.png
from qlasskit.algorithms import Simon

q_algo = Simon(f)
qc = q_algo.export("qiskit")
qc.draw("mpl")
_images/e7d5f3fe131270d9ff1fd3fc05ac0c322fc16f0172400160338e1ea79b9539b6.png
from qiskit import QuantumCircuit, transpile
from qiskit.visualization import plot_histogram
from qiskit_aer import AerSimulator

qc.measure_all()
simulator = AerSimulator()
circ = transpile(qc, simulator)
result = simulator.run(circ).result()
counts = result.get_counts(circ)

counts_readable = q_algo.decode_counts(counts)
plot_histogram(counts_readable)
_images/1e9115e4d7e3a849eb0e77b29430672ee5c6db7b7b7dd0eae70e799160b707e6.png