Shuffle ideals and sublist-closed languages #
The shuffle ideal of a word w is the language {v | w <+ v} of words containing w as a
subsequence, and a language is sublist-closed when it is downward closed under the sublist
order. This file proves that shuffle ideals are regular, and that over a finite alphabet a
sublist-closed language is the complement of finitely many shuffle ideals (by Higman's lemma
[Hig52]) and hence regular (Haines' theorem).
Main definitions #
Language.shuffleIdeal w: the words containingwas a subsequence.Language.IsSublistClosed L:Lis downward closed under<+.List.maxMatch w x: the length of the longest prefix ofwoccurring as a subsequence ofx.
Main results #
Language.isRegular_shuffleIdeal: shuffle ideals are regular.Language.IsSublistClosed.exists_finset_compl_eq_biSup_shuffleIdeal: the finite forbidden basis.Language.IsSublistClosed.isRegular: Haines' theorem.
Shuffle ideals #
The shuffle ideal of w: the words admitting w as a subsequence. Also called the
principal shuffle ideal of w, or the simple language Σ*a₁Σ* ⋯ aₙΣ* over w = a₁ ⋯ aₙ
in the piecewise-testable literature.
Equations
- Language.shuffleIdeal w = {v : List α | w.Sublist v}
Instances For
shuffleIdeal carries concatenation to language product.
Shuffle ideals are two-sided ideals: they absorb ⊤ on either side.
The classical regular-expression description of the shuffle ideal of a₁ ⋯ aₙ:
Σ*a₁Σ* ⋯ aₙΣ*.
Sublist-closed languages #
A language is sublist-closed when deleting symbols never leaves it.
Equations
- L.IsSublistClosed = ∀ ⦃v w : List α⦄, v.Sublist w → w ∈ L → v ∈ L
Instances For
Greedy matching #
The length of the longest prefix of w occurring as a subsequence of x.
Equations
- w.maxMatch x = Nat.findGreatest (fun (m : ℕ) => (List.take m w).Sublist x) w.length
Instances For
Greedy matching is optimal: w scatters into x ++ v exactly when the part of w left
over after its longest x-matchable prefix scatters into v.
Regularity of shuffle ideals #
A shuffle ideal is regular: its left quotients are the shuffle ideals of the suffixes of
w, of which there are at most |w| + 1, so Myhill–Nerode applies.
The finite forbidden basis #
Finite forbidden basis: over a finite alphabet a sublist-closed language is avoidance of
finitely many forbidden subsequences — the finite-basis property of well-quasi-orders
(WellQuasiOrdered.exists_finset_eq_biUnion) at Higman's lemma.
Effective basis: a superlist-closed language recognised by a DFA is generated by its members of length at most the state count, with no appeal to Higman's lemma — pumping a shortest long member yields a shorter member below it.
Haines' theorem #
Haines' theorem: over a finite alphabet every sublist-closed language is regular. It is the complement of the finitely many shuffle ideals of its minimal forbidden subsequences, and each of those is regular.