Strictly piecewise languages (SP_k) #
A language L is strictly k-piecewise when membership is determined by which
subsequences (scattered, non-contiguous selections) of length at most k the input
contains. Where SL_k constrains adjacent material via contiguous
factors, SP_k constrains long-distance co-occurrence — the subregular class of
unbounded-distance phonotactics. The class is the program's vocabulary for the sublist-closed
languages of Linglib.Core.Computability.ShuffleIdeal: a language is SP at some width iff
it is sublist-closed.
Main definitions #
StrictlyPiecewiseGrammar α: a set of permitted subsequences; the widthkis supplied tolanguage, not baked into the carrier.StrictlyPiecewiseGrammar.language k: theLanguage αit generates: every subsequence ofwof length at mostkmust be permitted.Language.IsStrictlyPiecewise L k:Lis a fixed point of the width-ktest with itself as grammar;isStrictlyPiecewise_iffrecovers the ∃-grammar form.
Main results #
Language.IsStrictlyPiecewise.mem_of_sublist: SP languages are subsequence-closed.Language.IsStrictlyPiecewise.preimage_map: SP languages are closed under inverse images of letter-to-letter maps.Language.IsStrictlyPiecewise.succ:SP_k ⊆ SP_(k+1).Language.IsStrictlyPiecewise.toIsPiecewiseTestable:SP_k ⊆ PT_k.Language.IsStrictlyPiecewise.isStarFree:SP_k ⊆ SFover a finite alphabet.Language.isStrictlyPiecewise_avoid: shuffle-ideal complements are SP.Language.exists_isStrictlyPiecewise_iff_isSublistClosed: SP at some width is exactly sublist-closure.
Implementation notes #
List.Sublist (<+) is mathlib's non-contiguous "is a subsequence of", exactly the SP
primitive. Unlike SL no boundary augmentation is needed, since subsequences are blind to
position; the "≤ k" (rather than "exactly k") bound is instead what keeps words shorter than
k distinguishable, matching subseqSet.
References #
A strictly-piecewise grammar over α is a set of permitted subsequences. Unlike SL
grammars it uses no boundary alphabet, since subsequences are insensitive to position. The width
k is an argument of language.
Equations
- StrictlyPiecewiseGrammar α = Set (List α)
Instances For
The language generated at width k consists of the strings whose every subsequence of
length at most k is permitted.
Equations
- StrictlyPiecewiseGrammar.language k G = {w : List α | ∀ (s : List α), s.length ≤ k → s.Sublist w → s ∈ G}
Instances For
SP languages are subsequence-closed: deleting symbols cannot create a subsequence that was not already there.
Conjoining grammars conjoins their languages.
The grammar of the subsequences whose images are permitted generates the preimage of the language under a letter-to-letter map.
SP membership reduces to a check against List.sublistsLen — a decide-friendly
characterisation used by the decidable-membership instance below.
Equations
- StrictlyPiecewiseGrammar.decidableMemLanguage k G w = decidable_of_iff' (∀ j ≤ k, ∀ s ∈ List.sublistsLen j w, s ∈ G) ⋯
A language L is strictly k-piecewise when the width-k subsequence test with
L itself as the permitted set recovers L — the canonical-grammar fixed point;
isStrictlyPiecewise_iff recovers the ∃-grammar form.
Equations
- L.IsStrictlyPiecewise k = (StrictlyPiecewiseGrammar.language k L = L)
Instances For
Some grammar generates L at width k iff L is its own grammar.
Strictly piecewise languages are closed under inverse images of letter-to-letter maps.
SP languages are subsequence-closed.
A nonempty SP language contains the empty word.
The complement of a shuffle ideal is strictly k-piecewise as soon as the forbidden pattern
fits in the window.
Widening the window loses nothing, SP_k ⊆ SP_(k+1).
The strictly-piecewise test, that every subsequence of length at most k is permitted,
depends only on subseqSet k, so SP_k ⊆ PT_k.
Over a finite alphabet strictly piecewise languages are star-free.
Avoiding one pattern that fits in the window is piecewise testable.
Containing one pattern that fits in the window is piecewise testable.
A language is strictly piecewise at some width iff it is sublist-closed
[RHB+10]. Backwards, L is its own grammar at the width bounding the
finite forbidden basis, so that any word outside L is already refuted by a basis word it
contains.