MerLean-example

6 Rem 6: Circuit Implementation of the Gauging Procedure

The gauging procedure can be implemented by a quantum circuit with no additional ancilla qubits beyond the edge qubits. After initializing the edge qubits in \(\ket {0}\), one performs the entangling circuit \(\prod _v \prod _{e \ni v} \mathrm{CX}_{v \to e}\), where \(\mathrm{CX}_{v \to e}\) is a controlled-\(X\) gate with control qubit \(v\) and target qubit \(e\). Next, one projectively measures \(X_v\) on all vertices \(v \in G\) and keeps the post-measurement state. Then one repeats the same entangling circuit \(\prod _v \prod _{e \ni v} \mathrm{CX}_{v \to e}\). Finally, one measures \(Z_e\) on all edge qubits and discards them.

Definition 138 CX Gate
#

A controlled-\(X\) gate specification for a qubit type \(Q\) consists of:

  • a control qubit \(c \in Q\),

  • a target qubit \(t \in Q\),

  • a proof that \(c \neq t\).

Definition 139 Circuit Phase
#

The circuit phases of the gauging circuit are defined as the inductive type with five constructors:

  1. InitializeEdges: Initialize edge qubits in \(\ket {0}\).

  2. FirstEntangling: Apply the first entangling circuit \(\prod _v \prod _{e \ni v} \mathrm{CX}_{v \to e}\).

  3. MeasureXVertices: Measure \(X_v\) on all vertices.

  4. SecondEntangling: Apply the second entangling circuit (identical to the first).

  5. MeasureZEdges: Measure \(Z_e\) on all edges and discard.

Definition 140 Circuit Phase Ordering
#

The natural ordering of circuit phases is given by the function \(\mathrm{toNat} : \mathrm{CircuitPhase} \to \mathbb {N}\) defined by:

\[ \mathrm{toNat}(\texttt{InitializeEdges}) = 0, \quad \mathrm{toNat}(\texttt{FirstEntangling}) = 1, \quad \mathrm{toNat}(\texttt{MeasureXVertices}) = 2, \]
\[ \mathrm{toNat}(\texttt{SecondEntangling}) = 3, \quad \mathrm{toNat}(\texttt{MeasureZEdges}) = 4. \]
Theorem 141 Number of Circuit Phases

The number of circuit phases is exactly \(5\):

\[ |\mathrm{CircuitPhase}| = 5. \]
Proof

This holds by reflexivity (definitional equality).

Lemma 142 InitializeEdges is the First Phase

For all circuit phases \(p\),

\[ \mathrm{toNat}(\texttt{InitializeEdges}) \leq \mathrm{toNat}(p). \]
Proof

We case-split on \(p\). In each case, \(\mathrm{toNat}(\texttt{InitializeEdges}) = 0 \leq \mathrm{toNat}(p)\), which follows by simplification using the definition of \(\mathrm{toNat}\).

Lemma 143 MeasureZEdges is the Last Phase

For all circuit phases \(p\),

\[ \mathrm{toNat}(p) \leq \mathrm{toNat}(\texttt{MeasureZEdges}). \]
Proof

We case-split on \(p\). In each case, \(\mathrm{toNat}(p) \leq 4 = \mathrm{toNat}(\texttt{MeasureZEdges})\), which follows by simplification using the definition of \(\mathrm{toNat}\).

Definition 144 Entangling Circuit
#

Given a simple graph \(G = (V, E)\) with decidable adjacency, the entangling circuit \(\prod _v \prod _{e \ni v} \mathrm{CX}_{v \to e}\) is a structure consisting of:

  • the underlying graph \(G\),

  • a gate specification: for each vertex \(v \in V\) and each edge \(e\) in the incidence set of \(v\), a \(\mathrm{CX}\) gate with control \(\mathrm{inl}(v) \in V \oplus \mathrm{Sym}_2(V)\) and target \(\mathrm{inr}(e) \in V \oplus \mathrm{Sym}_2(V)\).

Theorem 145 Number of CX Gates Equals Twice the Number of Edges

For any entangling circuit associated to a graph \(G\),

\[ \sum _{v \in V} \deg (v) = 2|E|. \]
Proof

This follows directly from the handshaking lemma (SimpleGraph.sum_degrees_eq_twice_card_edges).

Theorem 146 Vertex Contributes Degree-Many Gates

For any vertex \(v \in V\),

\[ |\mathrm{incidenceFinset}(v)| = \deg (v). \]
Proof

This follows directly from SimpleGraph.card_incidenceFinset_eq_degree.

Definition 147 \(X\)-Measurement Specification
#

An \(X\)-measurement specification for a qubit type \(Q\) consists of:

  • a finite set \(\mathcal{Q} \subseteq Q\) of qubits to measure in the Pauli-\(X\) basis,

  • a function \(\mathrm{keep} : Q \to \mathrm{Bool}\) indicating whether to keep each qubit after measurement.

Definition 148 \(Z\)-Measurement Specification
#

A \(Z\)-measurement specification for a qubit type \(Q\) consists of:

  • a finite set \(\mathcal{Q} \subseteq Q\) of qubits to measure in the Pauli-\(Z\) basis,

  • a function \(\mathrm{keep} : Q \to \mathrm{Bool}\) indicating whether to keep each qubit after measurement.

Definition 149 Gauging Circuit

The complete gauging circuit for a simple graph \(G = (V,E)\) is a structure consisting of:

  • the underlying graph \(G\),

  • a first entangling circuit \(\mathcal{E}_1\) of type \(\mathrm{EntanglingCircuit}(G)\),

  • an \(X\)-measurement specification on the vertices \(V\),

  • a second entangling circuit \(\mathcal{E}_2\) of type \(\mathrm{EntanglingCircuit}(G)\),

  • a \(Z\)-measurement specification on the edge set \(\mathrm{Sym}_2(V)\),

subject to the following conditions:

  1. \(\mathcal{E}_1 = \mathcal{E}_2\) (the two entangling circuits are identical),

  2. the \(X\)-measurement covers all vertices: \(\mathrm{qubits} = V\),

  3. the \(X\)-measurement keeps all qubits: \(\mathrm{keep}(v) = \mathrm{true}\) for all \(v\),

  4. the \(Z\)-measurement covers all edges: \(\mathrm{qubits} = E_G\),

  5. the \(Z\)-measurement discards all qubits: \(\mathrm{keep}(e) = \mathrm{false}\) for all \(e\).

Theorem 150 Entangling Circuits Are Identical

For any gauging circuit \(C\), the two entangling circuits are identical:

\[ C.\mathcal{E}_1 = C.\mathcal{E}_2. \]
Proof

This follows directly from the field entangling_identical of the gauging circuit structure.

Theorem 151 Edge Qubits Are Initialized

For any gauging circuit \(C\) and any edge \(e \in E_G\), the initial state of the edge qubit is \(\ket {0}\):

\[ \mathrm{initialState}(\texttt{EdgeQubit}) = \texttt{zero}. \]
Proof

This holds by reflexivity (definitional equality from the \(\mathrm{initialState}\) function).

Theorem 152 \(X\)-Measurement Covers All Vertices

For any gauging circuit \(C\),

\[ C.\mathrm{xMeasurement}.\mathrm{qubits} = V. \]
Proof

This follows directly from the field x_covers_all.

Theorem 153 \(X\)-Measurement Keeps State

For any gauging circuit \(C\) and vertex \(v\),

\[ C.\mathrm{xMeasurement}.\mathrm{keep}(v) = \mathrm{true}. \]
Proof

This follows directly from the field x_keeps.

Theorem 154 \(Z\)-Measurement Covers All Edges

For any gauging circuit \(C\),

\[ C.\mathrm{zMeasurement}.\mathrm{qubits} = E_G. \]
Proof

This follows directly from the field z_covers_all.

Theorem 155 \(Z\)-Measurement Discards Edge Qubits

For any gauging circuit \(C\) and edge \(e \in \mathrm{Sym}_2(V)\),

\[ C.\mathrm{zMeasurement}.\mathrm{keep}(e) = \mathrm{false}. \]
Proof

This follows directly from the field z_discards.

Definition 156 Circuit Qubit
#

The circuit qubit type for a graph \(G = (V,E)\) is an inductive type with two constructors:

  • \(\mathrm{vertex}(v)\) for \(v \in V\): an original code (vertex) qubit,

  • \(\mathrm{edge}(e)\) for \(e \in \mathrm{Sym}_2(V)\): an auxiliary (edge) qubit.

Definition 157 All Qubits in Circuit

The set of all qubits used in a gauging circuit \(C\) for graph \(G\) is

\[ \mathrm{allQubits}(C) = \{ \mathrm{vertex}(v) \mid v \in V\} \cup \{ \mathrm{edge}(e) \mid e \in E_G\} . \]
Theorem 158 No Additional Ancilla

For any gauging circuit \(C\) and any qubit \(q \in \mathrm{allQubits}(C)\), either

\[ (\exists \, v,\; q = \mathrm{vertex}(v)) \quad \lor \quad (\exists \, e \in E_G,\; q = \mathrm{edge}(e)). \]

That is, every qubit in the circuit is either a vertex qubit or an edge qubit; no additional ancilla qubits are required.

Proof

Let \(q \in \mathrm{allQubits}(C)\). By simplification using the definition of \(\mathrm{allQubits}\), membership in the union, and membership in the image, we know that \(q\) belongs to the image of \(\mathrm{vertex}\) over \(V\) or the image of \(\mathrm{edge}\) over \(E_G\). We consider two cases:

Case 1 (\(q\) is in the vertex image): We obtain a vertex \(v\) such that \(q = \mathrm{vertex}(v)\). The left disjunct holds with witness \(v\).

Case 2 (\(q\) is in the edge image): We obtain an edge \(e\) and a proof \(e \in E_G\) such that \(q = \mathrm{edge}(e)\). The right disjunct holds with witnesses \(e\) and the membership proof.

Definition 159 Is Edge Qubit
#

A circuit qubit \(q\) is an edge qubit if it has the form \(\mathrm{edge}(e)\) for some \(e\). Formally,

\[ \mathrm{isEdge}(q) = \begin{cases} \mathrm{true} & \text{if } q = \mathrm{edge}(e), \\ \mathrm{false} & \text{if } q = \mathrm{vertex}(v). \end{cases} \]
Theorem 160 Ancilla Qubits Are Exactly the Edge Qubits

For any gauging circuit \(C\),

\[ \{ q \in \mathrm{allQubits}(C) \mid \mathrm{isEdge}(q)\} = \{ \mathrm{edge}(e) \mid e \in E_G\} . \]
Proof

By extensionality, it suffices to show membership equivalence for an arbitrary qubit \(q\). We simplify using the definitions of \(\mathrm{allQubits}\), membership in filtered sets, union, image, and \(\mathrm{isEdge}\).

\((\Rightarrow )\): Suppose \(q \in \mathrm{allQubits}(C)\) and \(\mathrm{isEdge}(q) = \mathrm{true}\). We case-split on \(q\):

  • If \(q = \mathrm{vertex}(v)\), then \(\mathrm{isEdge}(q) = \mathrm{false}\), contradicting the filter condition.

  • If \(q = \mathrm{edge}(e)\), we case-split on membership in \(\mathrm{allQubits}\). If \(q\) came from the vertex image, we obtain \(v\) with \(\mathrm{vertex}(v) = \mathrm{edge}(e)\), which is absurd by the injectivity of constructors. If \(q\) came from the edge image, we directly obtain the desired membership.

\((\Leftarrow )\): Suppose there exists \(e \in E_G\) with \(q = \mathrm{edge}(e)\). Then \(q\) is in the right component of the union in \(\mathrm{allQubits}(C)\), and substituting \(q = \mathrm{edge}(e)\) gives \(\mathrm{isEdge}(q) = \mathrm{true}\) by reflexivity.

Theorem 161 Circuit Has Five Phases

The circuit consists of exactly five phases:

\[ |\mathrm{CircuitPhase}| = 5. \]
Proof

This follows directly from CircuitPhase.num_phases.

Theorem 162 Phase Ordering

The five phases execute in strict order:

\begin{align*} \mathrm{toNat}(\texttt{InitializeEdges}) & {\lt} \mathrm{toNat}(\texttt{FirstEntangling}), \\ \mathrm{toNat}(\texttt{FirstEntangling}) & {\lt} \mathrm{toNat}(\texttt{MeasureXVertices}), \\ \mathrm{toNat}(\texttt{MeasureXVertices}) & {\lt} \mathrm{toNat}(\texttt{SecondEntangling}), \\ \mathrm{toNat}(\texttt{SecondEntangling}) & {\lt} \mathrm{toNat}(\texttt{MeasureZEdges}). \end{align*}
Proof

By simplification using the definition of \(\mathrm{toNat}\), this reduces to \(0 {\lt} 1 \land 1 {\lt} 2 \land 2 {\lt} 3 \land 3 {\lt} 4\), which follows by integer arithmetic.

Definition 163 Default Gauging Circuit

Given a simple graph \(G = (V,E)\), the default gauging circuit \(\mathrm{mkGaugingCircuit}(G)\) is the gauging circuit where:

  • both entangling circuits use \(\mathrm{CX}\) gates with \(\mathrm{control} = \mathrm{inl}(v)\) and \(\mathrm{target} = \mathrm{inr}(e)\) for each vertex-edge incidence pair,

  • the \(X\)-measurement covers all vertices with \(\mathrm{keep} = \mathrm{true}\),

  • the \(Z\)-measurement covers all edges of \(G\) with \(\mathrm{keep} = \mathrm{false}\).

All required conditions (identical entangling circuits, full coverage, keep/discard properties) hold by reflexivity.

Definition 164 Circuit Sequence
#

The circuit sequence is the ordered list of circuit phases:

\[ [\texttt{InitializeEdges},\; \texttt{FirstEntangling},\; \texttt{MeasureXVertices},\; \texttt{SecondEntangling},\; \texttt{MeasureZEdges}]. \]
Theorem 165 Circuit Sequence Length

The circuit sequence has length \(5\):

\[ |\mathrm{circuitSequence}| = 5. \]
Proof

This holds by reflexivity.

Theorem 166 Circuit Sequence Is Strictly Ordered

The circuit sequence is pairwise strictly increasing in phase order.

Proof

This is verified by computation (the decide tactic).

Definition 167 Number of CX Gates
#

The number of CX gates in one round of the entangling circuit for a graph \(G = (V,E)\) is

\[ \mathrm{numCXGates}(G) = \sum _{v \in V} \deg (v). \]
Theorem 168 CX Gates Equals Twice the Number of Edges

For any graph \(G\),

\[ \mathrm{numCXGates}(G) = 2|E|. \]
Proof

Unfolding the definition of \(\mathrm{numCXGates}\), this reduces to \(\sum _{v \in V} \deg (v) = 2|E|\), which follows from the handshaking lemma (sum_degrees_eq_twice_card_edges).

Definition 169 Total CX Gates
#

The total number of CX gates in the full gauging circuit (both entangling rounds) is

\[ \mathrm{totalCXGates}(G) = 2 \cdot \mathrm{numCXGates}(G). \]
Theorem 170 Total CX Gates Equals Four Times the Number of Edges

For any graph \(G\),

\[ \mathrm{totalCXGates}(G) = 4|E|. \]
Proof

Unfolding the definition of \(\mathrm{totalCXGates}\), we have \(\mathrm{totalCXGates}(G) = 2 \cdot \mathrm{numCXGates}(G)\). Rewriting using the result \(\mathrm{numCXGates}(G) = 2|E|\), we obtain \(2 \cdot 2|E| = 4|E|\), which follows by integer arithmetic.