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/4502fb99b0b62a89285bf5856a32dbf7264a0322771aaf5ee33a084aaa9e9167.png](_images/4502fb99b0b62a89285bf5856a32dbf7264a0322771aaf5ee33a084aaa9e9167.png)
from qlasskit.algorithms import Simon
q_algo = Simon(f)
qc = q_algo.export("qiskit")
qc.draw("mpl")
![_images/fb5ffd2c19f4003e4c45d4b0d46226c60255334a56fc579013eeac5c4c9a29a8.png](_images/fb5ffd2c19f4003e4c45d4b0d46226c60255334a56fc579013eeac5c4c9a29a8.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/281dc08dc3104cfbd71ef2c2ca968a639bf1041fbd906e44d3d3bb8633759224.png](_images/281dc08dc3104cfbd71ef2c2ca968a639bf1041fbd906e44d3d3bb8633759224.png)