mimiqcircuits.operations.gates.generalized.polynomialoracle

Polynomial Oracle gate.

Classes

PolynomialOracle(*args)

Quantum oracle for a polynomial of two registers.

class PolynomialOracle(*args)[source]

Bases: Gate

Quantum oracle for a polynomial of two registers.

Applies a \(\pi\) phase to every basis state \(|x\rangle|y\rangle\) with \(a xy + b x + c y + d = 0\), where \(x\) and \(y\) are the integer values of the two registers. Each register is little-endian: its first qubit is the least significant bit. The gate is its own inverse.

PolynomialOracle(a, b, c, d) with four arguments returns a lazy expression that takes the two register sizes later.

The oracle has no matrix representation. It decomposes into one multi-controlled Z per solution, so the decomposition is only practical when there are few solutions. A decomposition without solutions is a single GateID on the last qubit, which keeps the oracle’s width.

Parameters:
  • nx (int) – Number of qubits in the \(x\) register.

  • ny (int) – Number of qubits in the \(y\) register.

  • a (int) – Coefficient of \(xy\).

  • b (int) – Coefficient of \(x\).

  • c (int) – Coefficient of \(y\).

  • d (int) – Constant term.

Raises:

ValueError – If a coefficient is not an integer, or the number of arguments is neither 4 nor 6.

Examples

>>> from mimiqcircuits import *
>>> c = Circuit()
>>> c.push(PolynomialOracle(5, 5, 1, 2, 3, 4), *range(1, 11))
11-qubit circuit with 1 instruction:
└── PolynomialOracle(1, 2, 3, 4) @ q[1:5], q[6:10]

>>> # lazy form: the register sizes are given later
>>> PolynomialOracle(1, 2, 3, 4)(5, 5)
PolynomialOracle(1, 2, 3, 4)
inverse()[source]

Return the inverse of the gate.

Gates with a known inverse return it directly (for example GateS().inverse() is GateSDG()); otherwise the gate is wrapped in Inverse.

supports_canonical_rewrite()[source]

Return True: the oracle decomposes into multi-controlled Z gates.