Length-k infixes of a list #
List.kFactors k xs lists the contiguous length-k infixes of xs, the infix sibling of
List.sublistsLen (length-k subsequences): List.mem_kFactors characterizes membership as
f <:+: xs ∧ f.length = k, and List.kFactors_cons is the recursion that computes it. The
name is the subregular literature's "k-factor"; mathlib has no length-k infix enumerator.
Main definitions #
List.kFactors: the contiguous length-kinfixes of a list, in order of occurrence.
Main results #
List.mem_kFactors: membership is being a length-kinfix, mirroringList.mem_sublistsLen.List.kFactors_nil,List.kFactors_cons,List.kFactors_two_cons_cons: the recursion, and itsk = 2form used by chain characterizations of the strictly 2-local languages.List.mem_kFactors_append: ak-factor of a concatenation lies in one of the two words or across the seam between them.List.kFactors_map: mapping a function over a list maps it over thek-factors.
The contiguous length-k infixes of xs, in order of occurrence: the length-k prefixes
of the suffixes long enough to have one.
Equations
- List.kFactors k xs = List.map (fun (x : List α) => List.take k x) (List.filter (fun (x : List α) => decide (k ≤ x.length)) xs.tails)
Instances For
theorem
List.mem_kFactors
{α : Type u_1}
{k : ℕ}
{xs f : List α}
:
f ∈ kFactors k xs ↔ f <:+: xs ∧ f.length = k
A list is a k-factor of xs iff it is a length-k infix.
@[simp]
The 2-factors of a :: b :: rest are [a, b] followed by those of b :: rest.
A k-factor of u ++ v lies in u, in v, or across the seam, in the last k - 1 letters
of u followed by the first k - 1 letters of v.