liveBook · Manning

Equality function

As explained in Quantum Programming in Depth

An equality function outputs one exactly when its two binary inputs are equal.

The equality function returns 1 exactly when two binary inputs are equal. It is the negation of XOR: x₀ EQUAL x₁ = NOT(x₀ XOR x₁). section 6.4.1

Implement the reversible, out-of-place form on three qubits:

  • Preserve inputs x₀ and x₁ while using y for the output. section 6.4.1
  • Apply CNOT(x₀, y), then CNOT(x₁, y), producing y ⊕ x₀ ⊕ x₁. section 6.4.1
  • Apply an in-place NOT to y, converting the XOR result into equality. section 6.4.1
  • Validate reversible implementations by comparing their basis-state effects with the classical truth table. section 6.4.1

How Quantum Programming in Depth covers it

How deep it goes
Derives a three-qubit decomposition from XOR and NOT, then validates it through basis-state truth tables.
Examples
Uses two CNOT gates followed by an in-place NOT on a three-qubit out-of-place computation.
What it assumes
Assumes familiarity with XOR, NOT, CNOT, out-of-place evaluation, and reversible computations.
What you can do after
Build it from scratch as a reversible three-qubit circuit using CNOT and NOT gates.
How it connects
Connects equality with XOR, NOT, CNOT gates, reversible computation, basis states, and truth tables.

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.