Documentation

Learning.ParityElimination

Gaussian elimination as an online learner of the parities #

The parities on the cube Fin n → Bool are the codewords of the Hadamard code (Cslib.BitString.hadamardCode): the parity of y labels the point a by the dot product y ⬝ᵥ a in the Boolean ring. The elimination learner keeps n rows, each a point of the cube with a bit, a row (0, false) being empty. It predicts at a the label of the first parity, in the order of binaryEquiv, that satisfies every row, and false when none does. At a miss at a with outcome b it writes (a, b) into the first empty row, when there is one, and at a hit it stays. Its state after a history is the rows folded from the history by this rule (ParityElimination.state), and it is an OnlineLearner of the realizable mistake-bound model of Cslib.MachineLearning.OnlineLearning.MistakeBound.

Main definitions #

Main results #

@[reducible, inline]

The rows of the elimination learner: n equations, each a point of the cube with a bit.

Equations
Instances For

    The empty row: the equation 0 = 0, which every parity satisfies.

    Equations
    Instances For
      def ParityElimination.binaryEquiv (n : ℕ) :
      (Fin n → Bool) ≃ Fin (2 ^ n)

      The order of the parities. The 2 ^ n points of the cube as the first 2 ^ n numbers, a point read as a number written in binary; the learner takes the first parity in this order that satisfies the rows.

      Equations
      Instances For
        def ParityElimination.satisfies {n : ℕ} (s : Rows n) (y : Fin n → Bool) :

        The parity y satisfies the rows when it gives every row its bit: y ⬝ᵥ a = b for the row (a, b).

        Equations
        Instances For
          def ParityElimination.pred {n : ℕ} (s : Rows n) (a : Fin n → Bool) :

          The prediction. At the point a, the label of the first parity satisfying every row, false when none does.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            def ParityElimination.step {n : ℕ} (s : Rows n) (a : Fin n → Bool) (b : Bool) :

            The transition. At a miss at the point a with outcome b, the pair (a, b) goes into the first empty row, nothing when none is empty; at a hit the rows stay.

            Equations
            • One or more equations did not get rendered due to their size.
            Instances For
              def ParityElimination.state {n : ℕ} (h : List ((Fin n → Bool) × Bool)) :

              The rows after a history: the rows folded from the history by step, from the empty rows.

              Equations
              Instances For

                The elimination learner. After the history h it predicts at a with the rows state h.

                Equations
                Instances For

                  Halving #

                  The elimination learner makes at most n mistakes on the parities: on every sequence that a parity of n bits realizes, in the realizable mistake-bound model, whatever its length. Each miss fills a row and halves the set of parities that satisfy the rows, and a set that has halved n times is the target alone. This is the mistake bound of Blum (1998, "On-line algorithms in machine learning", §4) for the parities.