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/b3f41f967d1cd70aaa5b8ca06d671fb93e619d3493b1c8bda8286363e730003e.png
from qlasskit.algorithms import Simon

q_algo = Simon(f)
qc = q_algo.export("qiskit")
qc.draw("mpl")
_images/4ce91db20dd6aa9f980bd2caa6ad0eb5d7084f0bd4ab6115a87146cde9f39fa7.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/c78e417541c261d2cd768d257c0b0dc1d9cc5b38bea87127e23e19596212719e.png