| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Haal.BlackBox
Description
This module defines the BlackBox type class as well as the Automaton and SUL sub classes.
Synopsis
- class SUL (aut s) Identity => Automaton (aut :: Type -> Type -> Type -> Type) s where
- class Monad m => SUL (sul :: Type -> Type -> Type) (m :: Type -> Type) where
- type StateID = Int
- type Finite i = (Enum i, Bounded i)
- type FiniteEq i = (Eq i, Finite i)
- type FiniteOrd i = (Ord i, Finite i)
- inputs :: FiniteOrd i => sul i o -> Set i
- outputs :: FiniteOrd o => sul i o -> Set o
- walk :: SUL sul m => sul i o -> [i] -> m (sul i o, [o])
- stepPure :: SUL sul Identity => sul i o -> i -> (sul i o, o)
- walkPure :: SUL sul Identity => sul i o -> [i] -> (sul i o, [o])
- resetPure :: SUL sul Identity => sul i o -> sul i o
- initial :: Automaton aut s => aut s i o -> s
- distinguish :: (Automaton aut s, FiniteOrd i, Ord s, Eq o) => aut s i o -> s -> s -> [i]
- accessSequences :: forall s i o aut. (Automaton aut s, FiniteOrd i, Ord s) => aut s i o -> Map s [i]
- localCharacterizingSet :: (Automaton aut s, FiniteOrd i, FiniteOrd s, Eq o) => aut s i o -> s -> Set [i]
- globalCharacterizingSet :: (Automaton aut s, FiniteOrd i, FiniteOrd s, Eq o) => aut s i o -> Set [i]
- reachable :: forall s i o aut. (Automaton aut s, Ord s, FiniteOrd i) => aut s i o -> Set s
Documentation
class SUL (aut s) Identity => Automaton (aut :: Type -> Type -> Type -> Type) s where Source #
The Automaton type class extends the SUL type class and adds
support for automata operations. Automatons are models, not programs,
so they are pure and operate in the Identity monad.
Methods
transitions :: (FiniteOrd i, FiniteOrd s) => aut s i o -> Map (s, i) (s, o) Source #
states :: FiniteOrd s => aut s i o -> Set s Source #
Instances
| Automaton MealyAutomaton s Source # | |
Defined in Haal.Automaton.MealyAutomaton Methods transitions :: (FiniteOrd i, FiniteOrd s) => MealyAutomaton s i o -> Map (s, i) (s, o) Source # states :: FiniteOrd s => MealyAutomaton s i o -> Set s Source # current :: MealyAutomaton s i o -> s Source # update :: MealyAutomaton s i o -> s -> MealyAutomaton s i o Source # | |
| Automaton MooreAutomaton s Source # | |
Defined in Haal.Automaton.MooreAutomaton Methods transitions :: (FiniteOrd i, FiniteOrd s) => MooreAutomaton s i o -> Map (s, i) (s, o) Source # states :: FiniteOrd s => MooreAutomaton s i o -> Set s Source # current :: MooreAutomaton s i o -> s Source # update :: MooreAutomaton s i o -> s -> MooreAutomaton s i o Source # | |
class Monad m => SUL (sul :: Type -> Type -> Type) (m :: Type -> Type) where Source #
The SUL type class defines the basic interface for a black box automaton.
It provides methods to step through the automaton and retrieve the current state.
It also requires a monad m, that may be Identity in case of a pure SUL, or IO
in case of an external program that performs IO.
Instances
| SUL (MealyAutomaton s) Identity Source # | |
Defined in Haal.Automaton.MealyAutomaton Methods step :: MealyAutomaton s i o -> i -> Identity (MealyAutomaton s i o, o) Source # reset :: MealyAutomaton s i o -> Identity (MealyAutomaton s i o) Source # | |
| SUL (MooreAutomaton s) Identity Source # | |
Defined in Haal.Automaton.MooreAutomaton Methods step :: MooreAutomaton s i o -> i -> Identity (MooreAutomaton s i o, o) Source # reset :: MooreAutomaton s i o -> Identity (MooreAutomaton s i o) Source # | |
The StateID type is an alias for an integer that represents the state of the automaton.
- It is used as a default type for the state of learned automata.
inputs :: FiniteOrd i => sul i o -> Set i Source #
Return a Set containing only the valid inputs of the SUL.
outputs :: FiniteOrd o => sul i o -> Set o Source #
Return a Set containing only the valid outputs of the SUL.
walk :: SUL sul m => sul i o -> [i] -> m (sul i o, [o]) Source #
Generalization of step that operates on a list of inputs.
distinguish :: (Automaton aut s, FiniteOrd i, Ord s, Eq o) => aut s i o -> s -> s -> [i] Source #
Returns an input sequence that distinguishes the given states in the given automaton.
accessSequences :: forall s i o aut. (Automaton aut s, FiniteOrd i, Ord s) => aut s i o -> Map s [i] Source #
Returns a map containing the shortest sequence to access each reachable state from the initial state.
localCharacterizingSet :: (Automaton aut s, FiniteOrd i, FiniteOrd s, Eq o) => aut s i o -> s -> Set [i] Source #
Returns a set of lists of inputs that can be used to distinguish between the given state and - any other state of the automaton.