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:
The Boolean function is defined as:
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:
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]