> {-# OPTIONS_HADDOCK show-extensions #-}
> {-|
> Module    : LTK.Decide.SPL
> Copyright : (c) 2025 Dakotah Lambert
> License   : MIT

> A language is strictly piecewise-local if whenever
> a word w is accepted, and a word u has the same subsequences
> of length up to j of substrings of length up to k
> (i.e. generalized j,k-subsequences),
> then u, too, must be accepted.
> -}
> module LTK.Decide.SPL (isSPL, isSPLM, isSPLs) where

> import Data.Representation.FiniteSemigroup

> import LTK.FSA
> import LTK.Algebra(SynMon)

> -- |True iff the language is strictly piecewise-local,
> -- characterized by a set of forbidden subsequences of substrings.
> --
> -- @since 1.3
> isSPL :: (Ord n, Ord e) => FSA n e -> Bool
> isSPL :: forall n e. (Ord n, Ord e) => FSA n e -> Bool
isSPL = OrderedSemigroup GeneratedAction -> Bool
forall s. FiniteSemigroupRep s => OrderedSemigroup s -> Bool
isSPLs (OrderedSemigroup GeneratedAction -> Bool)
-> (FSA n e -> OrderedSemigroup GeneratedAction) -> FSA n e -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FSA n e -> OrderedSemigroup GeneratedAction
forall n e.
(Ord n, Ord e) =>
FSA n e -> OrderedSemigroup GeneratedAction
syntacticOSemigroup

> -- |True iff the language is strictly piecewise-local,
> -- characterized by a set of forbidden subsequences of substrings.
> --
> -- @since 1.3
> isSPLM :: (Ord n, Ord e) => SynMon n e -> Bool
> isSPLM :: forall n e. (Ord n, Ord e) => SynMon n e -> Bool
isSPLM = FSA ([Maybe n], [Symbol e]) e -> Bool
forall n e. (Ord n, Ord e) => FSA n e -> Bool
isSPL

> -- |True iff the semigroup satisifes
> -- \(x^{\omega}\leq x^{\omega}yx^{\omega}\).
> --
> -- @since 1.3
> isSPLs :: FiniteSemigroupRep s => OrderedSemigroup s -> Bool
> isSPLs :: forall s. FiniteSemigroupRep s => OrderedSemigroup s -> Bool
isSPLs OrderedSemigroup s
s = Bool -> (Bool -> Bool) -> Maybe Bool -> Bool
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Bool
False Bool -> Bool
forall a. a -> a
id (Maybe Bool -> Bool) -> Maybe Bool -> Bool
forall a b. (a -> b) -> a -> b
$ String -> OrderedSemigroup s -> Maybe Bool
forall s.
FiniteSemigroupRep s =>
String -> OrderedSemigroup s -> Maybe Bool
isVariety String
"[x*<x*yx*]" OrderedSemigroup s
s