Documentation

QEC1.Definitions.Def_8_Detector

Def_8: Detector #

Statement #

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 D of initialization events and measurement events such that:

  1. In a fault-free execution, the product of all measurement outcomes in D (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 mod 2).

  2. This determinism holds regardless of the quantum state being processed (for measurements of stabilizer generators) or is guaranteed by the initialization (for measurements immediately following initialization).

Intuitively, a detector is a parity check on measurement outcomes that should always yield +1 if no errors occurred. A fault that causes a detector to report −1 instead is said to violate that detector.

Main Definitions #

Key Properties #

Measurement Outcomes #

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

@[reducible, inline]

A measurement outcome represented mod 2: 0 for +1, 1 for -1

Equations
Instances For

    The +1 outcome (no error detected)

    Equations
    Instances For

      The -1 outcome (error detected)

      Equations
      Instances For

        Convert to Bool: 0 → false (+1), 1 → true (-1)

        Equations
        Instances For

          Product of outcomes is addition mod 2

          Equations
          Instances For

            Events: Initialization and Measurement #

            A detector monitors both initialization events (where qubits are prepared in known states) and measurement events (where observables are measured).

            structure InitializationEvent (V : Type u_1) (E : Type u_2) :
            Type (max u_1 u_2)

            An initialization event: preparing a qubit at a specific time

            • qubit : QubitLoc V E

              The qubit being initialized

            • time : TimeStep

              The time of initialization

            • expectedParity : ZMod 2

              The expected parity of this initialization (0 for standard basis state)

            Instances For
              def instDecidableEqInitializationEvent.decEq {V✝ : Type u_1} {E✝ : Type u_2} [DecidableEq V✝] [DecidableEq E✝] (x✝ x✝¹ : InitializationEvent V✝ E✝) :
              Decidable (x✝ = x✝¹)
              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                structure MeasurementEvent (M : Type u_1) :
                Type u_1

                A measurement event: measuring an observable at a specific time

                • measurement : M

                  The measurement index (which check/observable is measured)

                • time : TimeStep

                  The time of measurement

                Instances For
                  def instDecidableEqMeasurementEvent.decEq {M✝ : Type u_1} [DecidableEq M✝] (x✝ x✝¹ : MeasurementEvent M✝) :
                  Decidable (x✝ = x✝¹)
                  Equations
                  Instances For
                    def InitializationEvent.standard {V : Type u_1} {E : Type u_2} (q : QubitLoc V E) (t : TimeStep) :

                    Create an initialization event with +1 expected outcome

                    Equations
                    Instances For
                      @[simp]
                      theorem InitializationEvent.standard_qubit {V : Type u_1} {E : Type u_2} (q : QubitLoc V E) (t : TimeStep) :
                      (standard q t).qubit = q
                      @[simp]
                      theorem InitializationEvent.standard_time {V : Type u_1} {E : Type u_2} (q : QubitLoc V E) (t : TimeStep) :
                      (standard q t).time = t
                      @[simp]
                      theorem InitializationEvent.standard_expectedParity {V : Type u_1} {E : Type u_2} (q : QubitLoc V E) (t : TimeStep) :
                      @[simp]
                      theorem MeasurementEvent.measurement_accessor {M : Type u_1} (m : M) (t : TimeStep) :
                      { measurement := m, time := t }.measurement = m

                      Get the time of a measurement event

                      @[simp]
                      theorem MeasurementEvent.time_accessor {M : Type u_1} (m : M) (t : TimeStep) :
                      { measurement := m, time := t }.time = t

                      Detector Events #

                      A detector event is either an initialization or a measurement.

                      inductive DetectorEvent (V : Type u_1) (E : Type u_2) (M : Type u_3) :
                      Type (max (max u_1 u_2) u_3)

                      A detector event: either an initialization or a measurement

                      Instances For
                        def DetectorEvent.isInit {V : Type u_1} {E : Type u_2} {M : Type u_3} :

                        Check if this is an initialization event

                        Equations
                        Instances For
                          def DetectorEvent.isMeas {V : Type u_1} {E : Type u_2} {M : Type u_3} :

                          Check if this is a measurement event

                          Equations
                          Instances For
                            @[simp]
                            theorem DetectorEvent.isInit_init {V : Type u_1} {E : Type u_2} {M : Type u_3} (e : InitializationEvent V E) :
                            @[simp]
                            theorem DetectorEvent.isInit_meas {V : Type u_1} {E : Type u_2} {M : Type u_3} (e : MeasurementEvent M) :
                            @[simp]
                            theorem DetectorEvent.isMeas_init {V : Type u_1} {E : Type u_2} {M : Type u_3} (e : InitializationEvent V E) :
                            @[simp]
                            theorem DetectorEvent.isMeas_meas {V : Type u_1} {E : Type u_2} {M : Type u_3} (e : MeasurementEvent M) :
                            def DetectorEvent.time {V : Type u_1} {E : Type u_2} {M : Type u_3} :

                            Get the time of a detector event

                            Equations
                            Instances For
                              @[simp]
                              theorem DetectorEvent.time_init {V : Type u_1} {E : Type u_2} {M : Type u_3} (e : InitializationEvent V E) :
                              (init e).time = e.time
                              @[simp]
                              theorem DetectorEvent.time_meas {V : Type u_1} {E : Type u_2} {M : Type u_3} (e : MeasurementEvent M) :
                              (meas e).time = e.time
                              def DetectorEvent.getInit {V : Type u_1} {E : Type u_2} {M : Type u_3} :

                              Get the initialization event if this is one

                              Equations
                              Instances For
                                def DetectorEvent.getMeas {V : Type u_1} {E : Type u_2} {M : Type u_3} :

                                Get the measurement event if this is one

                                Equations
                                Instances For
                                  theorem DetectorEvent.getInit_injective {V : Type u_1} {E : Type u_2} {M : Type u_3} (a b : DetectorEvent V E M) :
                                  a.getInit.isSome = trueb.getInit.isSome = truea.getInit = b.getInita = b

                                  getInit is injective on init events

                                  theorem DetectorEvent.getMeas_injective {V : Type u_1} {E : Type u_2} {M : Type u_3} (a b : DetectorEvent V E M) :
                                  a.getMeas.isSome = trueb.getMeas.isSome = truea.getMeas = b.getMeasa = b

                                  getMeas is injective on meas events

                                  Detectors #

                                  A detector is a set of events that together form a parity check with deterministic outcome in fault-free execution.

                                  @[reducible, inline]
                                  abbrev OutcomeAssignment (M : Type u_1) :
                                  Type u_1

                                  An outcome assignment: provides measurement outcomes for all measurements at all times

                                  Equations
                                  Instances For
                                    @[reducible, inline]
                                    abbrev InitFaultRecord (V : Type u_1) (E : Type u_2) :
                                    Type (max u_2 u_1)

                                    An initialization fault record: whether each initialization is faulty

                                    Equations
                                    Instances For
                                      structure Detector (V : Type u_1) (E : Type u_2) (M : Type u_3) [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                      Type (max (max u_1 u_2) u_3)

                                      A detector: a set of events with an expected fault-free parity.

                                      The key property is that in fault-free execution, the XOR of all measurement outcomes in the detector (combined with initialization parities) equals the expected value. When faults occur, the observed parity may differ from expected.

                                      • events : Finset (DetectorEvent V E M)

                                        The set of events in this detector

                                      • expectedParity : ZMod 2

                                        The expected parity in fault-free execution (0 for +1, 1 for -1)

                                      Instances For
                                        instance instDecidableEqDetector {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                        Equations
                                        def Detector.initEvents {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) :

                                        Get all initialization events in a detector

                                        Equations
                                        Instances For
                                          def Detector.measEvents {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) :

                                          Get all measurement events in a detector

                                          Equations
                                          Instances For
                                            def Detector.initParity {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) :

                                            The contribution from initialization events: sum of their expected parities

                                            Equations
                                            Instances For
                                              def Detector.observedParity {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) :

                                              The observed parity: sum of measurement outcomes plus initialization parities

                                              Equations
                                              Instances For
                                                def Detector.isViolated {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) :

                                                A detector is violated if observed parity differs from expected

                                                Equations
                                                Instances For
                                                  def Detector.isSatisfied {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) :

                                                  A detector is satisfied if observed parity equals expected

                                                  Equations
                                                  Instances For
                                                    instance Detector.decIsViolated {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) :
                                                    Decidable (D.isViolated outcomes)
                                                    Equations
                                                    instance Detector.decIsSatisfied {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) :
                                                    Decidable (D.isSatisfied outcomes)
                                                    Equations
                                                    theorem Detector.satisfied_or_violated {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) :
                                                    D.isSatisfied outcomes D.isViolated outcomes

                                                    A detector is either satisfied or violated

                                                    theorem Detector.satisfied_iff_not_violated {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) :
                                                    D.isSatisfied outcomes ¬D.isViolated outcomes

                                                    Satisfied and violated are mutually exclusive

                                                    Empty Detector #

                                                    def Detector.empty {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                                    Detector V E M

                                                    The empty detector with expected parity 0

                                                    Equations
                                                    Instances For
                                                      @[simp]
                                                      theorem Detector.empty_events {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                                      @[simp]
                                                      @[simp]
                                                      theorem Detector.empty_initEvents {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                                      @[simp]
                                                      theorem Detector.empty_measEvents {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                                      @[simp]
                                                      theorem Detector.empty_initParity {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                                      @[simp]
                                                      theorem Detector.empty_observedParity {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (outcomes : OutcomeAssignment M) :
                                                      @[simp]
                                                      theorem Detector.empty_isSatisfied {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (outcomes : OutcomeAssignment M) :

                                                      The empty detector is always satisfied

                                                      @[simp]
                                                      theorem Detector.empty_not_isViolated {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (outcomes : OutcomeAssignment M) :

                                                      The empty detector is never violated

                                                      Single-Event Detectors #

                                                      def Detector.singleInit {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (e : InitializationEvent V E) :
                                                      Detector V E M

                                                      A detector consisting of a single initialization event

                                                      Equations
                                                      Instances For
                                                        def Detector.singleMeas {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (e : MeasurementEvent M) (expectedOutcome : ZMod 2 := 0) :
                                                        Detector V E M

                                                        A detector consisting of a single measurement event

                                                        Equations
                                                        Instances For
                                                          @[simp]
                                                          theorem Detector.singleMeas_events {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (e : MeasurementEvent M) (p : ZMod 2) :

                                                          Combining Detectors #

                                                          def Detector.combine {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D₁ D₂ : Detector V E M) :
                                                          Detector V E M

                                                          Combine two detectors by taking symmetric difference of events and XOR of parities. This corresponds to multiplying the parity checks.

                                                          Equations
                                                          Instances For
                                                            instance Detector.instAdd {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                                            Add (Detector V E M)

                                                            Notation for detector combination

                                                            Equations
                                                            @[simp]
                                                            theorem Detector.combine_events {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D₁ D₂ : Detector V E M) :
                                                            (D₁.combine D₂).events = symmDiff D₁.events D₂.events
                                                            @[simp]
                                                            theorem Detector.combine_expectedParity {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D₁ D₂ : Detector V E M) :
                                                            theorem Detector.ext_iff {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] {D₁ D₂ : Detector V E M} :
                                                            D₁ = D₂ D₁.events = D₂.events D₁.expectedParity = D₂.expectedParity

                                                            Two detectors are equal iff their components are equal

                                                            theorem Detector.empty_combine {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) :

                                                            Adding empty detector does nothing (from the left)

                                                            theorem Detector.combine_empty {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) :

                                                            Adding empty detector does nothing (from the right)

                                                            theorem Detector.combine_self {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) :

                                                            Combining a detector with itself gives empty

                                                            Fault-Free Execution #

                                                            The key property of detectors is determinism in fault-free execution.

                                                            def Detector.faultFreeOutcomes {M : Type u_3} (expectedMeasOutcome : MTimeStepZMod 2) :

                                                            Fault-free outcomes: all measurements return their expected values. For stabilizer measurements, this means +1 (represented as 0). This function represents the outcomes in an ideal fault-free execution.

                                                            Equations
                                                            Instances For
                                                              theorem Detector.faultFree_isSatisfied {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (expectedMeasOutcome : MTimeStepZMod 2) (h_consistent : D.initParity + eD.measEvents, expectedMeasOutcome e.measurement e.time = D.expectedParity) :
                                                              D.isSatisfied (faultFreeOutcomes expectedMeasOutcome)

                                                              A detector with consistent expected outcomes is satisfied in fault-free execution. This captures the defining property of detectors: determinism without faults.

                                                              Effect of Faults on Detectors #

                                                              Faults can flip measurement outcomes, causing detectors to be violated.

                                                              Apply a time fault to outcomes: if the fault is active, flip the outcome

                                                              Equations
                                                              Instances For
                                                                theorem Detector.applyTimeFault_flips {M : Type u_3} [DecidableEq M] (outcomes : OutcomeAssignment M) (f : TimeFault M) (e : MeasurementEvent M) (hf : f.isFlipped = true) (he : e.measurement = f.measurement) (ht : e.time = f.time) :
                                                                applyTimeFault outcomes f e.measurement e.time = outcomes e.measurement e.time + 1

                                                                A single time fault at a measurement in the detector flips its contribution

                                                                theorem Detector.applyTimeFault_unchanged {M : Type u_3} [DecidableEq M] (outcomes : OutcomeAssignment M) (f : TimeFault M) (m : M) (t : TimeStep) (h : m f.measurement t f.time) :
                                                                applyTimeFault outcomes f m t = outcomes m t

                                                                A time fault outside the detector doesn't affect outcomes for events not at that location

                                                                Detector Violation Analysis #

                                                                We characterize when faults violate detectors.

                                                                def Detector.faultSyndrome {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (faultedMeas : Finset (MeasurementEvent M)) :

                                                                The syndrome of a fault on a detector: how much the parity is shifted

                                                                Equations
                                                                Instances For
                                                                  theorem Detector.isViolated_iff_odd_syndrome {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (D : Detector V E M) (outcomes : OutcomeAssignment M) (faultedMeas : Finset (MeasurementEvent M)) (h_outcomes : eD.measEvents, e faultedMeasoutcomes e.measurement e.time = 1) (h_no_fault : eD.measEvents, efaultedMeasoutcomes e.measurement e.time = 0) (h_init : D.initParity = 0) (h_expected : D.expectedParity = 0) :
                                                                  D.isViolated outcomes D.faultSyndrome faultedMeas = 1

                                                                  A fault violates a detector iff the syndrome is odd (1 mod 2)

                                                                  Detector Collection #

                                                                  A fault-tolerant procedure typically has multiple detectors.

                                                                  structure DetectorCollection (V : Type u_1) (E : Type u_2) (M : Type u_3) [DecidableEq V] [DecidableEq E] [DecidableEq M] :
                                                                  Type (max (max u_1 u_2) u_3)

                                                                  A detector collection: a set of detectors for a fault-tolerant procedure

                                                                  Instances For
                                                                    def DetectorCollection.syndrome {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (DC : DetectorCollection V E M) (outcomes : OutcomeAssignment M) :

                                                                    The syndrome: which detectors are violated by given outcomes

                                                                    Equations
                                                                    Instances For
                                                                      def DetectorCollection.violatedCount {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (DC : DetectorCollection V E M) (outcomes : OutcomeAssignment M) :

                                                                      Count of violated detectors

                                                                      Equations
                                                                      Instances For
                                                                        def DetectorCollection.allSatisfied {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (DC : DetectorCollection V E M) (outcomes : OutcomeAssignment M) :

                                                                        All detectors are satisfied (syndrome is empty)

                                                                        Equations
                                                                        Instances For
                                                                          @[simp]
                                                                          theorem DetectorCollection.allSatisfied_iff {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (DC : DetectorCollection V E M) (outcomes : OutcomeAssignment M) :
                                                                          DC.allSatisfied outcomes DDC.detectors, D.isSatisfied outcomes
                                                                          @[simp]
                                                                          theorem DetectorCollection.empty_allSatisfied {V : Type u_1} {E : Type u_2} {M : Type u_3} [DecidableEq V] [DecidableEq E] [DecidableEq M] (outcomes : OutcomeAssignment M) :
                                                                          { detectors := }.allSatisfied outcomes

                                                                          Empty collection has all detectors satisfied

                                                                          Summary #

                                                                          This formalization captures the detector concept from fault-tolerant quantum error correction:

                                                                          1. Measurement Outcomes: Represented mod 2 (0 for +1, 1 for -1), with XOR computing product parity.

                                                                          2. Events: Either initialization events (preparing qubits) or measurement events (measuring observables).

                                                                          3. Detectors: Sets of events with an expected fault-free parity. The key property is that in fault-free execution, the XOR of all measurement outcomes (plus initialization parities) equals the expected value.

                                                                          4. Violation: A detector is violated when the observed parity differs from expected. This indicates that a fault has occurred.

                                                                          5. Fault Analysis: The syndrome of a fault on a detector counts (mod 2) how many faulted measurements are in the detector. A detector is violated iff this count is odd.

                                                                          Key properties proven: