parity#

Functionality#

There are two versions to identify whether the number of "1" bits in an integer \(y\) is odd and even. If there are odd number of "1" bits, the parity is 1; otherwise, the parity is 0.


parity_phase.py#

Callee: ParityPhase

Given an \(n\)-qubit computational basis state \(\ket{y}_n\), this phase-version program computes a Boolean function:

\[ U_{\mathrm{ParityPhase}}: \ket{y}_n \mapsto (-1)^{\mathrm{PARITY}(y)} \ket{y}_n = e^{i \pi \mathrm{PARITY}(y)} \ket{y}_n. \]

The Boolean function is defined as:

\[\begin{split} \mathrm{PARITY}(y) \equiv \begin{cases} 1, & \text{if there are an odd number of ``1'' bits in } y \\ 0, & \text{if there are an even number of ``1'' bits in } y \end{cases} \end{split}\]

The input state is defined as \(\ket{y}_n = |q_{n-1} \cdots q_1 q_0\rangle\), where \(y\) is the decimal value of the binary string \(q_{n-1} \cdots q_0\). We regard \(q_0\) as the least significant qubit and \(q_{n-1}\) as the most significant qubit.

Test expectations:

The result is encoded as a phase flip on the corresponding basis state of \(y\). It is a global phase, which can be directly inspected on a statevector-based backend, but not directly observable by measurement (class QuantumSystemSimulation in our implementation).

Doc reference: [5]


parity_qubit.py#

Callee: ParityQubit

The qubit version stores the result into the most significant qubit involved in the entire quantum circuit:

\[ U_{\mathrm{ParityQubit}}: \ket{x}_1 \ket{y}_n \mapsto |x \oplus \mathrm{PARITY}(y)\rangle_1 \ket{y}_n. \]

Test expectations:

The result is encoded in one auxiliary qubit via XOR. When \(\ket{x}\) is initialized as \(\ket{0}\), its final state turns out to be \(\ket{\mathrm{IS2POWER}(y)}\), which can be directly observed by measurement.

Doc reference: [5]

API#

qolumbina.programs.parity.parity_phase#

class ParityPhase(input_qubits, name=None)[source]#

Bases: QuantumCircuit

Phase version of the parity oracle.

Parameters:
  • input_qubits (int) – Number of input qubits \(n\).

  • name (str | None) – Optional name of the circuit.

qolumbina.programs.parity.parity_qubit#

class ParityQubit(input_qubits, name=None)[source]#

Bases: QuantumCircuit

Qubit version of the parity oracle.

Parameters:
  • input_qubits (int) – Number of input qubits \(n\).

  • name (str | None) – Optional name of the circuit.