> {-# OPTIONS_HADDOCK show-extensions #-}
> {-|
> Module    : LTK.Decide.LT
> Copyright : (c) 2019,2021-2024 Dakotah Lambert
> License   : MIT

> This module implements an algorithm to decide whether a given FSA
> is Locally Testable (LT) based on the semigroup characterization
> of Brzozowski and Simon from their 1973 work
> "Characterizations of locally testable events".
>
> @since 0.2
> -}
> module LTK.Decide.LT (isLT, isLTM, isLTs) where

> import Data.Representation.FiniteSemigroup

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

> -- |True iff the automaton recognizes an LT stringset.
> isLT :: (Ord n, Ord e) => FSA n e -> Bool
> isLT :: forall n e. (Ord n, Ord e) => FSA n e -> Bool
isLT = GeneratedAction -> Bool
forall s. FiniteSemigroupRep s => s -> Bool
isLTs (GeneratedAction -> Bool)
-> (FSA n e -> GeneratedAction) -> FSA n e -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FSA n e -> GeneratedAction
forall n e. (Ord n, Ord e) => FSA n e -> GeneratedAction
syntacticSemigroup

A semigroup (S) [e.g. the syntactic semigroup] is locally testable iff
for all idempotent e, the generated subsemigroup eSe is an idempotent
commutative monoid.

> -- |True iff the given monoid is locally a semilattice.
> --
> -- @since 1.0
> isLTM :: (Ord n, Ord e) => SynMon n e -> Bool
> isLTM :: forall n e. (Ord n, Ord e) => SynMon n e -> Bool
isLTM = FSA ([Maybe n], [Symbol e]) e -> Bool
forall n e. (Ord n, Ord e) => FSA n e -> Bool
isLT

> -- |True iff the given semigroup is locally a semilattice.
> --
> -- @since 1.2
> isLTs :: FiniteSemigroupRep s => s -> Bool
> isLTs :: forall s. FiniteSemigroupRep s => s -> Bool
isLTs = (FSMult -> Bool) -> s -> Bool
forall s. FiniteSemigroupRep s => (FSMult -> Bool) -> s -> Bool
locally ((FSMult -> Bool) -> (FSMult -> Bool) -> FSMult -> Bool
forall a. (a -> Bool) -> (a -> Bool) -> a -> Bool
both FSMult -> Bool
forall s. FiniteSemigroupRep s => s -> Bool
isJTrivial FSMult -> Bool
forall s. FiniteSemigroupRep s => s -> Bool
isBand)