Delimited Boolean words #
Defines delimit which turns arbitrary Boolean words into a self-delimiting, prefix-free code.
The input words may be empty, contain any bit pattern, or be prefixes of one another.
delimit writes each data bit b as [true, b] and ends the codeword with [false]. This means
that true introduces one data bit and false terminates the word, which makes the boundary
recognizable in one left-to-right pass, even when arbitrary data follows it. A word of length n
has a delimited code of length 2 * n + 1.
delimit_prefix_delimit states prefix-freeness: one delimited codeword is a prefix of another
exactly when their original words are equal. undelimit_delimit_append and
dropDelimited_delimit_append recover a word and the suffix following its codeword.
The guarantee concerns individual delimited words. A variable-length list of concatenated codewords needs its own delimiter if the entire list encoding is to be prefix-free.
Delimited words #
Equation lemmas for undelimit and dropDelimited. These are needed by simp because
delimit_cons rewrites delimit (b :: w) before the round-trip lemmas below can apply.