Documentation

CslibFrontier.Foundations.Data.BitString.CyclicDifference

Cyclic differences of Boolean tuples #

The cyclic difference records the exclusive or of each coordinate and its successor, including the last-to-first edge. This is the tuple operation in [KKR18], Definition 14 (arXiv v6, printed p. 0:6). Coordinates remain ordered; no symmetry of a relation is assumed. The empty tuple is included, and every cyclic difference has even parity.

Main definitions #

Main results #

def Cslib.BitString.cyclicDifference {n : ℕ} (x : Fin n → Bool) :
Fin n → Bool

Exclusive ors of neighboring coordinates, with cyclic last-to-first adjacency.

Instances For
    theorem Cslib.BitString.cyclicDifference_eq_add {n : ℕ} (x : Fin n → Bool) :
    cyclicDifference x = x + fun (i : Fin n) => x ((finRotate n) i)

    Cyclic differences are the sum of a tuple and its one-step cyclic shift.

    theorem Cslib.BitString.cyclicDifference_const (n : ℕ) (b : Bool) :
    (cyclicDifference fun (x : Fin n) => b) = fun (x : Fin n) => false

    Constant tuples have zero cyclic difference, including at arity zero.

    theorem Cslib.BitString.cyclicDifference_not {n : ℕ} (x : Fin n → Bool) :
    (cyclicDifference fun (i : Fin n) => !x i) = cyclicDifference x

    Complementary tuples have identical cyclic differences.

    Taking cyclic differences is linear over the Boolean ring.

    A cyclic difference has an even number of true coordinates.

    theorem Cslib.BitString.cyclicDifference_eq_zero_iff {n : ℕ} (x : Fin n → Bool) :
    (cyclicDifference x = fun (x : Fin n) => false) ↔ ∃ (b : Bool), x = fun (x : Fin n) => b

    Zero differences force a tuple to be constant. The empty tuple is included.

    theorem Cslib.BitString.cyclicDifference_eq_iff {n : ℕ} (x y : Fin n → Bool) :
    cyclicDifference x = cyclicDifference y ↔ x = y ∨ x = fun (i : Fin n) => !y i

    The only ambiguity in recovering a tuple from its cyclic differences is complementation.

    def Cslib.BitString.cyclicIntegral {n : ℕ} (d : Fin n → Bool) :
    Fin n → Bool

    Recover a tuple with initial value zero by summing preceding cyclic differences.

    Instances For

      The prefix sum changes by the bit at the newly included coordinate.

      @[simp]

      The prefix sum starts at zero.

      Every even-parity tuple is the cyclic difference of its prefix-sum tuple.

      The image of cyclic difference is exactly the even-parity tuples, including arity zero.

      def Cslib.BitString.IsSelfComplementary {ι : Type u_1} (R : Set (ι → Bool)) :

      Invariance of a Boolean relation under simultaneous complementation of all coordinates. This is Definition 13 of [KKR18], with empty relations allowed.

      Instances For

        The relation of cyclic differences, retaining the original coordinate order.

        Instances For

          Cyclic differences preserve nonemptiness of relations.

          Every tuple of a cyclic-difference relation has even parity.

          A self-complementary relation is recovered exactly from its cyclic differences.

          The preimage of any difference relation is self-complementary.