Skip to main content
IBM Quantum Platform
Esta página corresponde a una versión anterior de Qiskit SDK Ir a la última versión

AND

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

GitHub

Bases: QuantumCircuit

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

For the AND operation the state 1|1\rangle is interpreted as True. The result qubit is flipped, if the state of all variable qubits is True. In this format, the AND operation equals a multi-controlled X gate, which is controlled on all variable qubits. Using a list of flags however, qubits can be skipped or negated. Practically, the flags allow to skip controls or to apply pre- and post-X gates to the negated qubits.

The AND gate without special flags equals the multi-controlled-X gate:

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 and 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_and.AND is deprecated as of Qiskit 2.1. It will be removed in Qiskit 3.0. Use qiskit.circuit.library.AndGate instead.

Parameters

  • num_variable_qubits (int) – The qubits of which the AND is computed. The result will be written into an additional result qubit.
  • flags (list[int] | None) – 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

Tipo: 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
¿Le ha resultado útil esta página?
Informe de un error, de una errata o solicite contenido en GitHub.