MerLean-example

18 Def 8: Detector

A detector is a collection of state initializations and measurement events that yield a deterministic result in the absence of faults. Specifically, a detector is a subset of initialization events and measurement events such that in a fault-free execution, the product of all measurement outcomes (treating \(+1\) outcomes as \(0\) and \(-1\) outcomes as \(1\) modulo \(2\)) combined with initialization parities equals a fixed value (conventionally \(+1\), or equivalently \(0 \bmod 2\)). A fault that causes a detector to report \(-1\) instead of \(+1\) is said to violate that detector.

18.1 Measurement Outcomes

Measurement outcomes in quantum mechanics are typically \(\pm 1\) eigenvalues. We represent these modulo \(2\): \(+1 \mapsto 0\), \(-1 \mapsto 1\). This convention means XOR (addition mod \(2\)) computes product parity correctly.

Definition 567 Measurement Outcome
#

A measurement outcome is an element of \(\mathbb {Z}/2\mathbb {Z}\), where \(0\) represents the \(+1\) outcome and \(1\) represents the \(-1\) outcome.

Definition 568 Plus One Outcome
#

The \(+1\) outcome (no error detected), defined as \(0 \in \mathbb {Z}/2\mathbb {Z}\).

Definition 569 Minus One Outcome
#

The \(-1\) outcome (error detected), defined as \(1 \in \mathbb {Z}/2\mathbb {Z}\).

Definition 570 Outcome from Bool

Convert from \(\mathrm{Bool}\): \(\mathrm{false} \mapsto +1\) (i.e., \(0\)), \(\mathrm{true} \mapsto -1\) (i.e., \(1\)).

Definition 571 Outcome to Bool
#

Convert to \(\mathrm{Bool}\): \(0 \mapsto \mathrm{false}\) (\(+1\)), \(1 \mapsto \mathrm{true}\) (\(-1\)). Formally, \(\mathrm{toBool}(m) := (m \neq 0)\).

Definition 572 Outcome Product
#

The product of two measurement outcomes is their addition modulo \(2\):

\[ \mathrm{product}(m_1, m_2) := m_1 + m_2. \]

18.2 Events: Initialization and Measurement

Definition 573 Initialization Event
#

An initialization event for vertex type \(V\) and edge type \(E\) consists of:

  • A qubit location \(\mathrm{qubit} : \mathrm{QubitLoc}(V, E)\),

  • A time step \(\mathrm{time} : \mathrm{TimeStep}\),

  • An expected parity \(\mathrm{expectedParity} \in \mathbb {Z}/2\mathbb {Z}\).

Definition 574 Measurement Event
#

A measurement event for measurement type \(M\) consists of:

  • A measurement index \(\mathrm{measurement} : M\),

  • A time step \(\mathrm{time} : \mathrm{TimeStep}\).

Definition 575 Standard Initialization

A standard initialization event for qubit \(q\) at time \(t\) is the initialization event \(\langle q, t, 0 \rangle \), i.e., with expected parity \(0\) (\(+1\) outcome).

18.3 Detector Events

Definition 576 Detector Event
#

A detector event is an element of the inductive type with two constructors:

  • \(\mathrm{init}(e)\): an initialization event \(e\),

  • \(\mathrm{meas}(e)\): a measurement event \(e\).

Definition 577 Is Initialization
#

Checks whether a detector event is an initialization event. Returns \(\mathrm{true}\) for \(\mathrm{init}\) and \(\mathrm{false}\) for \(\mathrm{meas}\).

Definition 578 Is Measurement
#

Checks whether a detector event is a measurement event. Returns \(\mathrm{false}\) for \(\mathrm{init}\) and \(\mathrm{true}\) for \(\mathrm{meas}\).

Definition 579 Event Time
#

Extracts the time step of a detector event: for \(\mathrm{init}(e)\) it returns \(e.\mathrm{time}\), and for \(\mathrm{meas}(e)\) it returns \(e.\mathrm{time}\).

Definition 580 Get Initialization
#

Returns \(\mathrm{some}(e)\) if the detector event is \(\mathrm{init}(e)\), and \(\mathrm{none}\) if it is a measurement event.

Definition 581 Get Measurement
#

Returns \(\mathrm{some}(e)\) if the detector event is \(\mathrm{meas}(e)\), and \(\mathrm{none}\) if it is an initialization event.

Lemma 582 getInit is Injective

For all detector events \(a, b\), if \(a.\mathrm{getInit}.\mathrm{isSome}\), \(b.\mathrm{getInit}.\mathrm{isSome}\), and \(a.\mathrm{getInit} = b.\mathrm{getInit}\), then \(a = b\).

Proof

Let \(a\) and \(b\) be detector events with \(a.\mathrm{getInit}.\mathrm{isSome}\) and \(b.\mathrm{getInit}.\mathrm{isSome}\) and \(a.\mathrm{getInit} = b.\mathrm{getInit}\). We proceed by case analysis on \(a\) and \(b\). If both are \(\mathrm{init}(e_a)\) and \(\mathrm{init}(e_b)\), then by simplification of \(\mathrm{getInit}\) and injectivity of \(\mathrm{some}\), we get \(e_a = e_b\) and hence \(a = b\). The cases where \(a\) is \(\mathrm{init}\) and \(b\) is \(\mathrm{meas}\) (or vice versa) are impossible since \(\mathrm{getInit}\) of a \(\mathrm{meas}\) event is \(\mathrm{none}\), contradicting \(\mathrm{isSome}\). The case where both are \(\mathrm{meas}\) is similarly impossible.

Lemma 583 getMeas is Injective

For all detector events \(a, b\), if \(a.\mathrm{getMeas}.\mathrm{isSome}\), \(b.\mathrm{getMeas}.\mathrm{isSome}\), and \(a.\mathrm{getMeas} = b.\mathrm{getMeas}\), then \(a = b\).

Proof

Let \(a\) and \(b\) be detector events with \(a.\mathrm{getMeas}.\mathrm{isSome}\) and \(b.\mathrm{getMeas}.\mathrm{isSome}\) and \(a.\mathrm{getMeas} = b.\mathrm{getMeas}\). By case analysis: if both are \(\mathrm{meas}(e_a)\) and \(\mathrm{meas}(e_b)\), simplification and injectivity of \(\mathrm{some}\) yields \(e_a = e_b\), hence \(a = b\). All other cases lead to contradictions with the \(\mathrm{isSome}\) hypotheses.

18.4 Detectors

Definition 584 Outcome Assignment
#

An outcome assignment for measurement type \(M\) is a function \(M \to \mathrm{TimeStep} \to \mathrm{MeasurementOutcome}\), providing measurement outcomes for all measurements at all time steps.

Definition 585 Initialization Fault Record
#

An initialization fault record for vertex type \(V\) and edge type \(E\) is a function \(\mathrm{QubitLoc}(V, E) \to \mathrm{TimeStep} \to \mathrm{Bool}\), indicating whether each initialization is faulty.

Definition 586 Detector
#

A detector for types \(V\), \(E\), \(M\) (with decidable equality) is a structure consisting of:

  • \(\mathrm{events} : \mathrm{Finset}(\mathrm{DetectorEvent}(V, E, M))\) — the set of events in the detector,

  • \(\mathrm{expectedParity} \in \mathbb {Z}/2\mathbb {Z}\) — the expected parity in fault-free execution (\(0\) for \(+1\), \(1\) for \(-1\)).

Definition 587 Initialization Events of Detector
#

The set of all initialization events in a detector \(D\), obtained by filtering \(D.\mathrm{events}\) through \(\mathrm{getInit}\).

Definition 588 Measurement Events of Detector
#

The set of all measurement events in a detector \(D\), obtained by filtering \(D.\mathrm{events}\) through \(\mathrm{getMeas}\).

Definition 589 Initialization Parity
#

The contribution from initialization events:

\[ \mathrm{initParity}(D) := \sum _{e \in D.\mathrm{initEvents}} e.\mathrm{expectedParity}. \]
Definition 590 Observed Parity

The observed parity given an outcome assignment:

\[ \mathrm{observedParity}(D, \mathrm{outcomes}) := \mathrm{initParity}(D) + \sum _{e \in D.\mathrm{measEvents}} \mathrm{outcomes}(e.\mathrm{measurement}, e.\mathrm{time}). \]
Definition 591 Detector Violated
#

A detector \(D\) is violated by outcomes if \(\mathrm{observedParity}(D, \mathrm{outcomes}) \neq D.\mathrm{expectedParity}\).

Definition 592 Detector Satisfied
#

A detector \(D\) is satisfied by outcomes if \(\mathrm{observedParity}(D, \mathrm{outcomes}) = D.\mathrm{expectedParity}\).

Theorem 593 Satisfied or Violated

For any detector \(D\) and outcome assignment, \(D\) is either satisfied or violated:

\[ D.\mathrm{isSatisfied}(\mathrm{outcomes}) \lor D.\mathrm{isViolated}(\mathrm{outcomes}). \]
Proof

Unfolding the definitions of \(\mathrm{isSatisfied}\) and \(\mathrm{isViolated}\), this reduces to the fact that for any two elements \(a, b \in \mathbb {Z}/2\mathbb {Z}\), either \(a = b\) or \(a \neq b\), which holds by decidable equality.

Theorem 594 Satisfied iff Not Violated

A detector \(D\) is satisfied if and only if it is not violated:

\[ D.\mathrm{isSatisfied}(\mathrm{outcomes}) \iff \neg D.\mathrm{isViolated}(\mathrm{outcomes}). \]
Proof

Unfolding the definitions, we prove both directions. For the forward direction: assume \(\mathrm{observedParity} = \mathrm{expectedParity}\) and suppose for contradiction that \(\mathrm{observedParity} \neq \mathrm{expectedParity}\); this is a direct contradiction. For the backward direction: assume \(\neg (\mathrm{observedParity} \neq \mathrm{expectedParity})\) and suppose for contradiction that \(\mathrm{observedParity} \neq \mathrm{expectedParity}\); again a contradiction.

18.5 Empty Detector

Definition 595 Empty Detector
#

The empty detector has \(\mathrm{events} = \emptyset \) and \(\mathrm{expectedParity} = 0\).

Theorem 596 Empty Detector is Always Satisfied

For any outcome assignment, the empty detector is satisfied.

Proof

By simplification: the empty detector has no initialization events and no measurement events, so \(\mathrm{initParity} = 0\) and the sum over measurement events is \(0\). Thus \(\mathrm{observedParity} = 0 = \mathrm{expectedParity}\).

Theorem 597 Empty Detector is Never Violated

For any outcome assignment, the empty detector is not violated.

Proof

By simplification: the observed parity of the empty detector is \(0\), which equals the expected parity \(0\).

18.6 Single-Event Detectors

Definition 598 Single Initialization Detector

A detector consisting of a single initialization event \(e\), with \(\mathrm{events} = \{ \ \mathrm{init}(e)\ \} \) and \(\mathrm{expectedParity} = e.\mathrm{expectedParity}\).

Definition 599 Single Measurement Detector

A detector consisting of a single measurement event \(e\) with expected outcome \(p\), with \(\mathrm{events} = \{ \ \mathrm{meas}(e)\ \} \) and \(\mathrm{expectedParity} = p\).

18.7 Combining Detectors

Definition 600 Detector Combination
#

The combination of two detectors \(D_1\) and \(D_2\) is defined by taking the symmetric difference of their event sets and the XOR (sum mod \(2\)) of their expected parities:

\[ \mathrm{combine}(D_1, D_2) := \langle D_1.\mathrm{events} \mathbin {\triangle } D_2.\mathrm{events},\; D_1.\mathrm{expectedParity} + D_2.\mathrm{expectedParity} \rangle . \]

This corresponds to multiplying the parity checks.

Theorem 601 Detector Extensionality
#

Two detectors \(D_1\) and \(D_2\) are equal if and only if \(D_1.\mathrm{events} = D_2.\mathrm{events}\) and \(D_1.\mathrm{expectedParity} = D_2.\mathrm{expectedParity}\).

Proof

For the forward direction, if \(D_1 = D_2\) then both components are equal by reflexivity. For the backward direction, given equality of both components, we case-split on the structures and apply structural equality.

Theorem 602 Empty Combine Left

Adding the empty detector on the left does nothing: \(\mathrm{combine}(\mathrm{empty}, D) = D\).

Proof

We use detector extensionality and verify both components. For events: \(\emptyset \mathbin {\triangle } D.\mathrm{events} = D.\mathrm{events}\) since \(\bot \mathbin {\triangle } x = x\). For expected parity: \(0 + D.\mathrm{expectedParity} = D.\mathrm{expectedParity}\).

Theorem 603 Combine Empty Right

Adding the empty detector on the right does nothing: \(\mathrm{combine}(D, \mathrm{empty}) = D\).

Proof

By detector extensionality: \(D.\mathrm{events} \mathbin {\triangle } \emptyset = D.\mathrm{events}\) since \(x \mathbin {\triangle } \bot = x\), and \(D.\mathrm{expectedParity} + 0 = D.\mathrm{expectedParity}\).

Theorem 604 Combine Self

Combining a detector with itself gives the empty detector: \(\mathrm{combine}(D, D) = \mathrm{empty}\).

Proof

By detector extensionality: \(D.\mathrm{events} \mathbin {\triangle } D.\mathrm{events} = \emptyset \) by the self-symmetric-difference property, and \(D.\mathrm{expectedParity} + D.\mathrm{expectedParity} = 0\) by the characteristic-\(2\) property.

18.8 Fault-Free Execution

Definition 605 Fault-Free Outcomes
#

The fault-free outcomes given expected measurement outcomes is simply the identity function on the expected outcomes: \(\mathrm{faultFreeOutcomes}(f) := f\).

Let \(D\) be a detector and let \(f : M \to \mathrm{TimeStep} \to \mathbb {Z}/2\mathbb {Z}\) be an expected measurement outcome function. If \(D\) is consistent in the sense that

\[ D.\mathrm{initParity} + \sum _{e \in D.\mathrm{measEvents}} f(e.\mathrm{measurement}, e.\mathrm{time}) = D.\mathrm{expectedParity}, \]

then \(D\) is satisfied under the fault-free outcomes \(\mathrm{faultFreeOutcomes}(f)\).

Proof

Unfolding the definitions of \(\mathrm{isSatisfied}\), \(\mathrm{observedParity}\), and \(\mathrm{faultFreeOutcomes}\), the goal becomes exactly the consistency hypothesis.

18.9 Effect of Faults on Detectors

Definition 607 Apply Time Fault
#

Given an outcome assignment and a time fault \(f\), the faulted outcomes are:

\[ \mathrm{applyTimeFault}(\mathrm{outcomes}, f)(m, t) := \begin{cases} \mathrm{outcomes}(m, t) + 1 & \text{if } m = f.\mathrm{measurement} \land t = f.\mathrm{time} \land f.\mathrm{isFlipped}, \\ \mathrm{outcomes}(m, t) & \text{otherwise}. \end{cases} \]
Lemma 608 Time Fault Flips Outcome

If a time fault \(f\) has \(f.\mathrm{isFlipped} = \mathrm{true}\), and a measurement event \(e\) has \(e.\mathrm{measurement} = f.\mathrm{measurement}\) and \(e.\mathrm{time} = f.\mathrm{time}\), then

\[ \mathrm{applyTimeFault}(\mathrm{outcomes}, f)(e.\mathrm{measurement}, e.\mathrm{time}) = \mathrm{outcomes}(e.\mathrm{measurement}, e.\mathrm{time}) + 1. \]
Proof

By simplification of the definition of \(\mathrm{applyTimeFault}\) using the hypotheses \(e.\mathrm{measurement} = f.\mathrm{measurement}\), \(e.\mathrm{time} = f.\mathrm{time}\), and \(f.\mathrm{isFlipped} = \mathrm{true}\), the conditional evaluates to the flipped branch.

Lemma 609 Time Fault Unchanged

If \(m \neq f.\mathrm{measurement}\) or \(t \neq f.\mathrm{time}\), then

\[ \mathrm{applyTimeFault}(\mathrm{outcomes}, f)(m, t) = \mathrm{outcomes}(m, t). \]
Proof

We unfold \(\mathrm{applyTimeFault}\) and split on the conditional. If the condition holds, we obtain \(m = f.\mathrm{measurement}\) and \(t = f.\mathrm{time}\), which contradicts the hypothesis that \(m \neq f.\mathrm{measurement}\) or \(t \neq f.\mathrm{time}\) (by case analysis on the disjunction). If the condition does not hold, the result follows by reflexivity.

18.10 Detector Violation Analysis

Definition 610 Fault Syndrome

The fault syndrome of a detector \(D\) with respect to a set of faulted measurements is:

\[ \mathrm{faultSyndrome}(D, \mathrm{faultedMeas}) := |D.\mathrm{measEvents} \cap \mathrm{faultedMeas}| \pmod{2}. \]

Let \(D\) be a detector and \(\mathrm{faultedMeas}\) a finite set of faulted measurement events. Suppose:

  1. For every \(e \in D.\mathrm{measEvents}\) with \(e \in \mathrm{faultedMeas}\): \(\mathrm{outcomes}(e.\mathrm{measurement}, e.\mathrm{time}) = 1\),

  2. For every \(e \in D.\mathrm{measEvents}\) with \(e \notin \mathrm{faultedMeas}\): \(\mathrm{outcomes}(e.\mathrm{measurement}, e.\mathrm{time}) = 0\),

  3. \(D.\mathrm{initParity} = 0\),

  4. \(D.\mathrm{expectedParity} = 0\).

Then \(D\) is violated if and only if the fault syndrome equals \(1\):

\[ D.\mathrm{isViolated}(\mathrm{outcomes}) \iff \mathrm{faultSyndrome}(D, \mathrm{faultedMeas}) = 1. \]
Proof

Unfolding the definitions of \(\mathrm{isViolated}\), \(\mathrm{observedParity}\), and \(\mathrm{faultSyndrome}\), and using the hypotheses \(\mathrm{initParity} = 0\) and \(\mathrm{expectedParity} = 0\), the goal reduces to showing that the sum of measurement outcomes equals \(|D.\mathrm{measEvents} \cap \mathrm{faultedMeas}|\) in \(\mathbb {Z}/2\mathbb {Z}\), and that this quantity being nonzero is equivalent to it being \(1\).

For the sum equality, we split the sum over \(D.\mathrm{measEvents}\) into elements that are in \(\mathrm{faultedMeas}\) and those that are not. By hypothesis (1), the faulted elements each contribute \(1\), so their sum equals the cardinality of \(D.\mathrm{measEvents} \cap \mathrm{faultedMeas}\) (using the filter characterization). By hypothesis (2), the non-faulted elements each contribute \(0\), so their sum is \(0\). Adding these gives the desired equality.

For the equivalence between nonzero and equal to \(1\): in \(\mathbb {Z}/2\mathbb {Z}\), every element is either \(0\) or \(1\) (by exhaustive case analysis on \(\mathrm{Fin}\, 2\)). For the forward direction, if the value is nonzero then it must be \(1\). For the backward direction, if the value is \(1\) then \(1 \neq 0\) holds by computation.

18.11 Detector Collection

Definition 612 Detector Collection
#

A detector collection is a finite set of detectors:

\[ \mathrm{DetectorCollection}(V, E, M) := \{ \mathrm{detectors} : \mathrm{Finset}(\mathrm{Detector}(V, E, M)) \} . \]
Definition 613 Syndrome

The syndrome of a detector collection given outcomes is the set of violated detectors:

\[ \mathrm{syndrome}(DC, \mathrm{outcomes}) := \{ D \in DC.\mathrm{detectors} \mid D.\mathrm{isViolated}(\mathrm{outcomes}) \} . \]
Definition 614 Violated Count

The count of violated detectors: \(\mathrm{violatedCount}(DC, \mathrm{outcomes}) := |\mathrm{syndrome}(DC, \mathrm{outcomes})|\).

Definition 615 All Satisfied

All detectors are satisfied if the syndrome is empty:

\[ \mathrm{allSatisfied}(DC, \mathrm{outcomes}) :\iff \mathrm{syndrome}(DC, \mathrm{outcomes}) = \emptyset . \]
Lemma 616 All Satisfied Characterization

All detectors are satisfied if and only if every detector in the collection is individually satisfied:

\[ DC.\mathrm{allSatisfied}(\mathrm{outcomes}) \iff \forall D \in DC.\mathrm{detectors},\; D.\mathrm{isSatisfied}(\mathrm{outcomes}). \]
Proof

Unfolding \(\mathrm{allSatisfied}\) and \(\mathrm{syndrome}\), the condition \(\mathrm{syndrome} = \emptyset \) is equivalent (via Finset.filter_eq_empty_iff) to the statement that no detector in the collection is violated. For the forward direction, if no detector is violated, then by the equivalence \(\mathrm{isSatisfied} \iff \neg \mathrm{isViolated}\) each detector is satisfied. For the backward direction, if each detector is satisfied, then by the same equivalence none is violated.

Theorem 617 Empty Collection All Satisfied

The empty detector collection (with no detectors) is always all satisfied.

Proof

By simplification: filtering the empty set yields the empty set, so \(\mathrm{syndrome} = \emptyset \).