Deutsch Jozsa algorithm

from qlasskit import qlassf, Qint


@qlassf
def f(a: Qint[4]) -> bool:
    return a > 7
f.export("qiskit").draw("mpl")
_images/9b6f26a93fcbeba5678d5efe1ec56ba4e04b7ddfe5f0a3fbaa1535aa4b8910fb.png
from qlasskit.algorithms import DeutschJozsa

q_algo = DeutschJozsa(f)
qc = q_algo.export("qiskit")
qc.draw("mpl")
_images/28d186c05d2bc51d40e3a2e11fef1e9e07e0f6a6ffc7eef96637bf4cf316a739.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/3ef0e6983243e7322d09f19294f958ed83f9bce81aec887de5b6e3412346a366.png