Skip to content

Conversation

a-matsuo
Copy link
Contributor

@a-matsuo a-matsuo commented Jan 20, 2021

Summary

Added LogicalExpressionOracle into the circuit library which creates an oracle circuit from a logical expression like ~x & (y | z). It also supports a string in the DIMACS format.

Details and comments

This is an ongoing project from Qiskit/qiskit-aqua#1376.

@a-matsuo a-matsuo requested a review from a team as a code owner January 20, 2021 08:40
Copy link
Contributor

@Cryoris Cryoris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general, I left a few comments 🙂

from qiskit.circuit import QuantumCircuit, QuantumRegister


class LogicalExpressionOracle(QuantumCircuit):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't LogicalExpressionOracle be an Instruction?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be a circuit, since it's going in the circuit library 🙂 also then it's directly compatible with the GroverOperator which takes a circuit as oracle

@1ucian0
Copy link
Member

1ucian0 commented Jan 20, 2021

Do we need the the single-char expression input format? It seems trivial to write not x and (y or z) instead of ~x & (y | z) and the first one is already supported.

If so, maybe is better to extend UntaryOp.op and BiOp.op to the compiler instead of having _expression_to_source.

Also, the DIMACS expression string is converted to a single-char expression string which is converted to a word expression string which parsed and converted to a tweedledum network. We could remove one step of this if we have no single-char expressions or if we just python parse directly.

Even further, I think tweedledum has support for DIMACS expressions... @boschmitt ?

@Cryoris
Copy link
Contributor

Cryoris commented Jan 20, 2021

Is there a "word-format" for xor? Or does this only exist for the char-format (^)?

@1ucian0
Copy link
Member

1ucian0 commented Jan 20, 2021

Is there a "word-format" for xor? Or does this only exist for the char-format (^)?

No XOR, but CNF does not have XOR neither, right?

@1ucian0 1ucian0 self-assigned this Jan 20, 2021
@Cryoris
Copy link
Contributor

Cryoris commented Jan 20, 2021

No XOR, but CNF does not have XOR neither, right?

Yeah but the current LogicalExpressionOracle in Aqua also supports XOR and the classicalfunction already supports it. How about just supporting then: and not or ^ which I think is what the classicalfunction supports right now, is it?

@a-matsuo
Copy link
Contributor Author

@Cryoris @1ucian0
Thank you for your informative comments! I fixed the parts you guys commented. The class supports and not or ^ now. (no single-char expression except ^.

@Cryoris
Copy link
Contributor

Cryoris commented Apr 1, 2021

Included in #5830.

@Cryoris Cryoris closed this Apr 1, 2021
@a-matsuo a-matsuo deleted the dimacs_oracle branch June 8, 2022 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants