Documentation

Complexitylib.Classes.P.Cobham.Internal.StringOps

Length tests and bitwise operations inside the algebra #

Two utilities the algebra needs for block-structured data: comparing the lengths of two strings, and taking the bitwise exclusive-or of two strings of equal length.

Both are built from the dispatchers of Complexitylib.Classes.P.Cobham.Internal.Blocks: a length comparison is a drop followed by an emptiness test, and the exclusive-or is one limited recursion whose step reads the matching bit of the second argument through a ruler cut to the right width.

Main definitions #

Main results #

Conjunction of two flags is [true] exactly when both are.

Disjunction of two flags is [true] exactly when one is.

Disjunction of flags is a flag.

A disjunction is always exactly one bit long.

Negation of a flag.

The flag |b| ≤ |a|: nothing is left of b after dropping |a| bits.

Equations
Instances For
    theorem Complexity.Cobham.lenLeFlag_mem {n : } {ga gb : (Fin nList Bool)List Bool} (ha : Cobham ga) (hb : Cobham gb) :
    Cobham fun (v : Fin nList Bool) => lenLeFlag (ga v) (gb v)

    The length tests are in the algebra.

    theorem Complexity.Cobham.lenEqFlag_mem {n : } {ga gb : (Fin nList Bool)List Bool} (ha : Cobham ga) (hb : Cobham gb) :
    Cobham fun (v : Fin nList Bool) => lenEqFlag (ga v) (gb v)

    Exclusive-or #

    Exclusive-or of a with the suffix of b of the same length. The bit of b paired with the head of a sits at index |b| - |x| - 1, which is the length of b.drop (|x| + 1) — a ruler the algebra can build from the recursion's own tail.

    Equations
    Instances For

      The exclusive-or is the pointwise one against the matching suffix.

      Two strings of equal length are combined bit by bit.

      theorem Complexity.Cobham.xorSuffix_mem {n : } {ga gb : (Fin nList Bool)List Bool} (ha : Cobham ga) (hb : Cobham gb) :
      Cobham fun (v : Fin nList Bool) => xorSuffix (ga v) (gb v)

      The exclusive-or is in the algebra.

      Equality of strings #

      The all-zero test is in the algebra.

      theorem Complexity.Cobham.allZeroFlag_mem {n : } {g : (Fin nList Bool)List Bool} (hg : Cobham g) :
      Cobham fun (v : Fin nList Bool) => allZeroFlag (g v)
      theorem Complexity.Cobham.eqFlag_mem {n : } {ga gb : (Fin nList Bool)List Bool} (ha : Cobham ga) (hb : Cobham gb) :
      Cobham fun (v : Fin nList Bool) => eqFlag (ga v) (gb v)

      String equality is in the algebra.