Documentation

CslibFrontier.Foundations.Data.List.FixedWidth

Concatenations of blocks of one length #

A substitution that replaces every letter by a block of the same positive length is injective on words as soon as it is injective on letters (List.flatMap_injective_of_forall_length_eq): the blocks can be read back one after the other. It is the case of blocks of one length of List.flatMap_inj_of_length_eq for self-delimiting codes, since the length of the concatenation gives the number of blocks. List.flatMap_singleton_injective is the case of blocks of length one, and List.length_flatMap_of_forall_length_eq gives the length of such a concatenation. Two substitutions whose blocks have the same lengths on the letters of a word give the same concatenation exactly when they agree on these letters (List.flatMap_eq_flatMap_iff_of_forall_length_eq).

theorem List.flatMap_injective_of_forall_length_eq {α : Type u_1} {β : Type u_2} {f : α → List β} {k : ℕ} (hk : 0 < k) (hlen : ∀ (a : α), (f a).length = k) (hf : Function.Injective f) :
Function.Injective fun (w : List α) => flatMap f w

A substitution by blocks of one positive length is injective on words when it is injective on letters.

theorem List.flatMap_eq_flatMap_iff_of_forall_length_eq {α : Type u_1} {β : Type u_2} {l : List α} {f g : α → List β} (h : ∀ a ∈ l, (f a).length = (g a).length) :
flatMap f l = flatMap g l ↔ ∀ a ∈ l, f a = g a

Two substitutions whose blocks have the same lengths on the letters of a word give the same word exactly when they agree on its letters.