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.
A measurement outcome is an element of \(\mathbb {Z}/2\mathbb {Z}\), where \(0\) represents the \(+1\) outcome and \(1\) represents the \(-1\) outcome.
The \(+1\) outcome (no error detected), defined as \(0 \in \mathbb {Z}/2\mathbb {Z}\).
The \(-1\) outcome (error detected), defined as \(1 \in \mathbb {Z}/2\mathbb {Z}\).
Convert from \(\mathrm{Bool}\): \(\mathrm{false} \mapsto +1\) (i.e., \(0\)), \(\mathrm{true} \mapsto -1\) (i.e., \(1\)).
Convert to \(\mathrm{Bool}\): \(0 \mapsto \mathrm{false}\) (\(+1\)), \(1 \mapsto \mathrm{true}\) (\(-1\)). Formally, \(\mathrm{toBool}(m) := (m \neq 0)\).
The product of two measurement outcomes is their addition modulo \(2\):
18.2 Events: Initialization and Measurement
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}\).
A measurement event for measurement type \(M\) consists of:
A measurement index \(\mathrm{measurement} : M\),
A time step \(\mathrm{time} : \mathrm{TimeStep}\).
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
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\).
Checks whether a detector event is an initialization event. Returns \(\mathrm{true}\) for \(\mathrm{init}\) and \(\mathrm{false}\) for \(\mathrm{meas}\).
Checks whether a detector event is a measurement event. Returns \(\mathrm{false}\) for \(\mathrm{init}\) and \(\mathrm{true}\) for \(\mathrm{meas}\).
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}\).
Returns \(\mathrm{some}(e)\) if the detector event is \(\mathrm{init}(e)\), and \(\mathrm{none}\) if it is a measurement event.
Returns \(\mathrm{some}(e)\) if the detector event is \(\mathrm{meas}(e)\), and \(\mathrm{none}\) if it is an initialization event.
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\).
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.
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\).
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
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.
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.
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\)).
The set of all initialization events in a detector \(D\), obtained by filtering \(D.\mathrm{events}\) through \(\mathrm{getInit}\).
The set of all measurement events in a detector \(D\), obtained by filtering \(D.\mathrm{events}\) through \(\mathrm{getMeas}\).
The contribution from initialization events:
The observed parity given an outcome assignment:
A detector \(D\) is violated by outcomes if \(\mathrm{observedParity}(D, \mathrm{outcomes}) \neq D.\mathrm{expectedParity}\).
A detector \(D\) is satisfied by outcomes if \(\mathrm{observedParity}(D, \mathrm{outcomes}) = D.\mathrm{expectedParity}\).
For any detector \(D\) and outcome assignment, \(D\) is either satisfied or violated:
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.
A detector \(D\) is satisfied if and only if it is not violated:
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
The empty detector has \(\mathrm{events} = \emptyset \) and \(\mathrm{expectedParity} = 0\).
For any outcome assignment, the empty detector is satisfied.
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}\).
For any outcome assignment, the empty detector is not violated.
By simplification: the observed parity of the empty detector is \(0\), which equals the expected parity \(0\).
18.6 Single-Event Detectors
A detector consisting of a single initialization event \(e\), with \(\mathrm{events} = \{ \ \mathrm{init}(e)\ \} \) and \(\mathrm{expectedParity} = e.\mathrm{expectedParity}\).
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
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:
This corresponds to multiplying the parity checks.
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}\).
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.
Adding the empty detector on the left does nothing: \(\mathrm{combine}(\mathrm{empty}, D) = D\).
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}\).
Adding the empty detector on the right does nothing: \(\mathrm{combine}(D, \mathrm{empty}) = D\).
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}\).
Combining a detector with itself gives the empty detector: \(\mathrm{combine}(D, D) = \mathrm{empty}\).
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
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
then \(D\) is satisfied under the fault-free outcomes \(\mathrm{faultFreeOutcomes}(f)\).
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
Given an outcome assignment and a time fault \(f\), the faulted outcomes are:
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
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.
If \(m \neq f.\mathrm{measurement}\) or \(t \neq f.\mathrm{time}\), then
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
The fault syndrome of a detector \(D\) with respect to a set of faulted measurements is:
Let \(D\) be a detector and \(\mathrm{faultedMeas}\) a finite set of faulted measurement events. Suppose:
For every \(e \in D.\mathrm{measEvents}\) with \(e \in \mathrm{faultedMeas}\): \(\mathrm{outcomes}(e.\mathrm{measurement}, e.\mathrm{time}) = 1\),
For every \(e \in D.\mathrm{measEvents}\) with \(e \notin \mathrm{faultedMeas}\): \(\mathrm{outcomes}(e.\mathrm{measurement}, e.\mathrm{time}) = 0\),
\(D.\mathrm{initParity} = 0\),
\(D.\mathrm{expectedParity} = 0\).
Then \(D\) is violated if and only if the fault syndrome equals \(1\):
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
A detector collection is a finite set of detectors:
The syndrome of a detector collection given outcomes is the set of violated detectors:
The count of violated detectors: \(\mathrm{violatedCount}(DC, \mathrm{outcomes}) := |\mathrm{syndrome}(DC, \mathrm{outcomes})|\).
All detectors are satisfied if the syndrome is empty:
All detectors are satisfied if and only if every detector in the collection is individually satisfied:
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.
The empty detector collection (with no detectors) is always all satisfied.
By simplification: filtering the empty set yields the empty set, so \(\mathrm{syndrome} = \emptyset \).