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 #
Cobham.lenLeFlag,Cobham.lenEqFlag— length comparison flagsCobham.xorSuffix— exclusive-or of a string with the matching suffix of a second string
Main results #
The flag |b| ≤ |a|: nothing is left of b after dropping |a| bits.
Equations
Instances For
The flag |a| = |b|.
Equations
Instances For
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
Equality of strings #
Flag: every bit of x is false.
Equations
Instances For
The all-zero test is in the algebra.
Flag: the two strings are equal.