Deutsch Jozsa algorithm

from qlasskit import qlassf, Qint


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

q_algo = DeutschJozsa(f)
qc = q_algo.export("qiskit")
qc.draw("mpl")
_images/49a9ffc78b090428983dbd8e63bedcb1b30a668f635005a7402959d9b91376e4.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/2e27842af43e0d236f0cf867da4d7d6a1e510d275d056ee532579408b58aa83f.png