Skip to main content
IBM Quantum Platform
This page is from an old version of Qiskit SDK Go to the latest version

OR

class qiskit.circuit.library.OR(num_variable_qubits, flags=None, mcx_mode='noancilla')

GitHub

Bases: QuantumCircuit

A circuit implementing the logical OR operation on a number of qubits.

For the OR operation the state 1|1\rangle is interpreted as True. The result qubit is flipped, if the state of any variable qubit is True. The OR is implemented using a multi-open-controlled X gate (i.e. flips if the state is 0|0\rangle) and applying an X gate on the result qubit. Using a list of flags, qubits can be skipped or negated.

The OR gate without special flags:

Diagram illustrating the previously described circuit.

Using flags we can negate qubits or skip them. For instance, if we have 5 qubits and want to return True if the first qubit is False or one of the last two are True we use the flags [-1, 0, 0, 1, 1].

Diagram illustrating the previously described circuit.
Deprecated since version 2.1

The class qiskit.circuit.library.boolean_logic.quantum_or.OR is deprecated as of Qiskit 2.1. It will be removed in Qiskit 3.0. Use qiskit.circuit.library.OrGate instead.

Parameters

  • num_variable_qubits (int) – The qubits of which the OR is computed. The result will be written into an additional result qubit.
  • flags (Optional[List[int]]) – A list of +1/0/-1 marking negations or omissions of qubits.
  • mcx_mode (str) – The mode to be used to implement the multi-controlled X gate.

Attributes

name

Type: str

A human-readable name for the circuit.

Example

from qiskit import QuantumCircuit
 
qc = QuantumCircuit(2, 2, name="my_circuit")
print(qc.name)
my_circuit
Was this page helpful?
Report a bug, typo, or request content on GitHub.