Parity computation by CNOT gates (source code)

= Parity computation by CNOT gates
{title2=$W|x\rangle|y\rangle=|x\rangle|y\oplus\bigoplus_jx_j\rangle$}

Apply one <CNOT gate> from each input <qubit> to the same target. Their actions commute because controls remain unchanged and each contribution is added modulo two. This reversible circuit computes the <parity bit> with exactly one <two-qubit gate> per input, and its inverse is the same circuit. Unlike measuring the inputs to compute parity classically, the unitary preserves <quantum superposition> and can be uncomputed after phase application.