Deutsch Jozsa algorithm
from qlasskit import qlassf, Qint
@qlassf
def f(a: Qint[4]) -> bool:
return a > 7
f.export("qiskit").draw("mpl")
from qlasskit.algorithms import DeutschJozsa
q_algo = DeutschJozsa(f)
qc = q_algo.export("qiskit")
qc.draw("mpl")
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)