liveBook · Manning

Parity

As explained in Quantum Programming in Depth

Parity is the property of being even or odd, here determined for a computational-basis state by the parity of its bit values.

Parity classifies a computational-basis bit string by the number of 1s: even counts have parity 0, and odd counts have parity 1. Thus |00⟩ and |11⟩ are even, while |01⟩ and |10⟩ are odd. section 4.6

For a superposition whose basis states all share one parity, a joint measurement can reveal that parity without collapsing the superposition to an individual basis state. Measuring the qubits separately would destroy the superposition. section 4.6 section 4.9

A parity measurement can be implemented as follows:

  • Allocate an auxiliary qubit, apply a CNOT from each input qubit to it, and measure or reset the auxiliary qubit; the result is 0 for even parity and 1 for odd parity. section 4.6.3
  • Test the operation on repeatedly prepared states, verify the returned parity, and check that the input state remains unchanged. section 4.6.3
  • Use the built-in MeasureAllZ operation as an alternative Q# implementation for measuring the parity of an array of qubits. section 4.6.3

N-queens oracle

When each row already contains exactly one queen, count the queens in each column modulo 2 using XOR gates. A valid placement gives odd parity in every column; an invalid placement has at least one empty column with even parity. section 8.2.1

Figure 4.8 Measuring the parity of a quantum state. You are given a state that is a superposition of basis states with the same parity: \(\ket{00}\) and \(\ket{11}\) or \(\ket{01}\) and \(\ket{10}\). The goal is to perform a measurement to learn the parity of this state in a way that doesn’t change the state.
figure

Use the figure to compare the even-parity superposition of |00⟩ and |11⟩ with the odd-parity superposition of |01⟩ and |10⟩, and to frame the state-preserving measurement goal. section 4.6

How Quantum Programming in Depth covers it

How deep it goes
Defines parity, explains state-preserving measurement, and implements testing, but stops short of general measurement theory.
Examples
Uses two-qubit parity states, Q# measurement operations, state-preservation tests, and an N-queens oracle.
What it assumes
Assumes computational-basis notation, qubits, superposition, CNOT gates, and basic quantum-state preparation.
What you can do after
Apply parity measurements to identify a state class while preserving its superposition.
How it connects
Connects computational basis, quantum state preparation, joint measurement, XOR gates, and Grover’s algorithm.

Also explained in

Compare how 2 books explain parity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantum Programming in Depth. The section links point to the parts of the book it draws on.