1
$\begingroup$

This article provides a sample code to use Grover's algorithm to solve SAT problems. It requires importing a method called LogicalExpressionOracle. However, when I copied the code into IBM quantum lab, it says that qiskit.aqua doesn't exist anymore. So how can I import LogicalExpressionOracle?

import numpy as np
from qiskit import BasicAer
from qiskit.visualization import plot_histogram
%config InlineBackend.figure_format = 'svg'
from qiskit.aqua import QuantumInstance, run_algorithm
from qiskit.aqua.algorithms import Grover
from qiskit.aqua.components.oracles import LogicalExpressionOracle, TruthTableOracle

enter image description here

$\endgroup$

1 Answer 1

1
$\begingroup$

Use PhaseOracle from Qiskit Terra:

from qiskit.circuit.library import PhaseOracle

oracle = PhaseOracle.from_dimacs_file("file_name.cnf")
$\endgroup$
2
  • $\begingroup$ How can I create a file ending with ".cnf"? $\endgroup$
    – Yili
    Nov 22, 2022 at 18:26
  • $\begingroup$ In IBM Quantum Lab click on "New file" button, and choose Text File. Then, rename it. $\endgroup$ Nov 22, 2022 at 18:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.