Exact binary coding of finite alphabets #
An explicit enumeration gives a delimited, palindromic unary code for each letter. Encodings are injective, have linear length bounds, commute with word reversal, and are exactly the strings accepted by the partial decoder. Empty alphabets are supported, and only the empty word then has a valid encoding.
@[simp]
theorem
Complexity.FiniteAlphabetCode.decode_encode
{α : Type}
(c : FiniteAlphabetCode α)
(w : List α)
:
Every encoded word is decoded exactly.
Encoding distinct words gives distinct binary strings.
theorem
Complexity.FiniteAlphabetCode.length_le_encode
{α : Type}
(c : FiniteAlphabetCode α)
(w : List α)
:
Encoded size is at least the source word length.
theorem
Complexity.FiniteAlphabetCode.encode_reverse_eq
{α : Type}
(c : FiniteAlphabetCode α)
(w : List α)
:
Palindromic symbol codes commute with reversal of the whole word.
theorem
Complexity.FiniteAlphabetCode.decode_reverse_eq
{α : Type}
(c : FiniteAlphabetCode α)
(bits : List Bool)
:
Reversal preserves validity and reverses the decoded letters.
@[simp]
theorem
Complexity.FiniteAlphabetCode.map_encode
{α β : Type}
(c : FiniteAlphabetCode α)
(output : FiniteAlphabetCode β)
(f : List α → List β)
(w : List α)
:
A coded function has exactly its specified output on every encoded input.