k-Factors of a List #
The contiguous length-k infixes of a list — the infix sibling of
List.sublistsLen (length-k subsequences). A generic list combinator with no
domain content; used by the subregular hierarchy and a candidate for
Mathlib/Data/List/.
Main definitions #
List.kFactors k xs— the contiguous length-kinfixes ofxs.
Main results #
List.mem_kFactors—fis ak-factor ofxsiff it is a length-kinfix (the infix analog ofList.mem_sublistsLen).List.take_append_take— truncating the right operand of an append before taking a length-nprefix is a no-op (a candidate forMathlib/Data/List/).
Truncating the right operand to length n before taking the length-n prefix of an
append is a no-op: the prefix already ignores everything past position n.
A list is an infix of another iff some shift aligns every position of S with
A (getElem?-wise): S <:+: A exactly when there is an offset δ ≤ A.length with
A[i + δ]? = S[i]? for every i < S.length. The positional companion of
mem_kFactors.
The contiguous length-k infixes of xs. Built by enumerating suffixes
and taking each one's length-k prefix; suffixes shorter than k are
filtered out. (For k = 0 every suffix qualifies, so kFactors 0 xs is
xs.length + 1 copies of []; the subregular hierarchy only uses k ≥ 1.)
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
A list is a k-factor of xs iff it is a length-k infix. The infix
analog of List.mem_sublistsLen.
Every member of kFactors k xs has length exactly k.
A k-factor of xs is a contiguous infix of xs.
The 2-factors of a :: b :: rest are [a, b] followed by the 2-factors
of b :: rest: the inductive step for chain-based characterizations of the
SL₂ and TSL₂ languages.
An empty list has no 2-factors.
A singleton list has no 2-factors.