Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Types | Public Member Functions | Friends
automaton::CompactDFA< SymbolTypeT, StateTypeT > Class Template Referencefinal

Compact deterministic finite automaton. Accepts regular languages. The automaton has a list of symbols on transitions. More...

#include <CompactDFA.h>

Inheritance diagram for automaton::CompactDFA< SymbolTypeT, StateTypeT >:
[legend]
Collaboration diagram for automaton::CompactDFA< SymbolTypeT, StateTypeT >:
[legend]

Public Types

typedef SymbolTypeT SymbolType
 
typedef StateTypeT StateType
 

Public Member Functions

 CompactDFA (StateType initialState)
 Creates a new instance of the automaton with a concrete initial state. More...
 
 CompactDFA (ext::set< StateType > states, ext::set< SymbolType > inputAlphabet, StateType initialState, ext::set< StateType > finalStates)
 Creates a new instance of the automaton with a concrete set of states, input alphabet, initial state, and a set of final states. More...
 
 CompactDFA (const DFA< SymbolType, StateType > &other)
 
const StateTypegetInitialState () const &
 
StateType && getInitialState () &&
 
bool setInitialState (StateType state)
 
const ext::set< StateType > & getStates () const &
 
ext::set< StateType > && getStates () &&
 
bool addState (StateType state)
 
void setStates (ext::set< StateType > states)
 
void removeState (const StateType &state)
 
const ext::set< StateType > & getFinalStates () const &
 
ext::set< StateType > && getFinalStates () &&
 
bool addFinalState (StateType state)
 
void setFinalStates (ext::set< StateType > states)
 
void removeFinalState (const StateType &state)
 
const ext::set< SymbolType > & getInputAlphabet () const &
 
ext::set< SymbolType > && getInputAlphabet () &&
 
bool addInputSymbol (SymbolType symbol)
 
void addInputSymbols (ext::set< SymbolType > symbols)
 
void setInputAlphabet (ext::set< SymbolType > symbols)
 
void removeInputSymbol (const SymbolType &symbol)
 
bool addTransition (StateType from, ext::vector< SymbolType > input, StateType to)
 Add a transition to the automaton. More...
 
bool removeTransition (const StateType &from, const ext::vector< SymbolType > &input, const StateType &to)
 Removes a transition from the automaton. More...
 
const ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType > & getTransitions () const &
 
ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType > && getTransitions () &&
 
ext::iterator_range< typename ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType >::const_iterator > getTransitionsFromState (const StateType &from) const
 
ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateTypegetTransitionsToState (const StateType &to) const
 
auto operator<=> (const CompactDFA &other) const
 
bool operator== (const CompactDFA &other) const
 
- Public Member Functions inherited from core::Components< CompactDFA< DefaultSymbolType, DefaultStateType >, ext::set< DefaultSymbolType >, component::Set, InputAlphabet, ext::set< DefaultStateType >, component::Set, std::tuple< States, FinalStates >, DefaultStateType, component::Value, InitialState >
void accessComponent ()
 

Friends

ext::ostreamoperator<< (ext::ostream &out, const CompactDFA &instance)
 

Additional Inherited Members

- Static Public Member Functions inherited from core::Components< CompactDFA< DefaultSymbolType, DefaultStateType >, ext::set< DefaultSymbolType >, component::Set, InputAlphabet, ext::set< DefaultStateType >, component::Set, std::tuple< States, FinalStates >, DefaultStateType, component::Value, InitialState >
static void registerComponent ()
 
static void unregisterComponent ()
 

Detailed Description

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
class automaton::CompactDFA< SymbolTypeT, StateTypeT >

Compact deterministic finite automaton. Accepts regular languages. The automaton has a list of symbols on transitions.

Definition is classical definition of finite automata. A = (Q, T, I, \delta, F), Q (States) = nonempty finite set of states, T (TerminalAlphabet) = finite set of terminal symbols - having this empty won't let automaton do much though, I (InitialState) = initial state, \delta = transition function of the form A \times a -> P(Q), where A \in Q, a \in T*, and P(Q) is a powerset of states, F (FinalStates) = set of final states

Template Parameters
SymbolTypeTused for the terminal alphabet
StateTypeTused to the states, and the initial state of the automaton.

Member Typedef Documentation

◆ StateType

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
typedef StateTypeT automaton::CompactDFA< SymbolTypeT, StateTypeT >::StateType

◆ SymbolType

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
typedef SymbolTypeT automaton::CompactDFA< SymbolTypeT, StateTypeT >::SymbolType

Constructor & Destructor Documentation

◆ CompactDFA() [1/3]

template<class SymbolType , class StateType >
automaton::CompactDFA< SymbolType, StateType >::CompactDFA ( StateType  initialState)
explicit

Creates a new instance of the automaton with a concrete initial state.

Parameters
initialStatethe initial state of the automaton

◆ CompactDFA() [2/3]

template<class SymbolType , class StateType >
automaton::CompactDFA< SymbolType, StateType >::CompactDFA ( ext::set< StateType states,
ext::set< SymbolType inputAlphabet,
StateType  initialState,
ext::set< StateType finalStates 
)
explicit

Creates a new instance of the automaton with a concrete set of states, input alphabet, initial state, and a set of final states.

Parameters
statesthe initial set of states of the automaton
inputAlphabetthe initial input alphabet
initialStatethe initial state of the automaton
finalStatesthe initial set of final states of the automaton

◆ CompactDFA() [3/3]

template<class SymbolType , class StateType >
automaton::CompactDFA< SymbolType, StateType >::CompactDFA ( const DFA< SymbolType, StateType > &  other)
explicit
Here is the call graph for this function:

Member Function Documentation

◆ addFinalState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::CompactDFA< SymbolTypeT, StateTypeT >::addFinalState ( StateType  state)
inline

Adder of a final state.

Parameters
statethe new state to be added to a set of final states
Returns
true if the state was indeed added

◆ addInputSymbol()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::CompactDFA< SymbolTypeT, StateTypeT >::addInputSymbol ( SymbolType  symbol)
inline

Adder of a input symbol.

Parameters
symbolthe new symbol to be added to an input alphabet
Returns
true if the symbol was indeed added

◆ addInputSymbols()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::CompactDFA< SymbolTypeT, StateTypeT >::addInputSymbols ( ext::set< SymbolType symbols)
inline

Adder of input symbols.

Parameters
symbolsnew symbols to be added to an input alphabet

◆ addState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::CompactDFA< SymbolTypeT, StateTypeT >::addState ( StateType  state)
inline

Adder of a state.

Parameters
statethe new state to be added to a set of states
Returns
true if the state was indeed added

◆ addTransition()

template<class SymbolType , class StateType >
bool automaton::CompactDFA< SymbolType, StateType >::addTransition ( StateType  from,
ext::vector< SymbolType input,
StateType  to 
)

Add a transition to the automaton.

The transition is in a form A \times a -> B, where A, B \in Q and a \in T*

Parameters
currentthe source state (A)
inputthe list of input symbols (a)
nextthe target state (B)
Exceptions
AutomatonExceptionwhen transition contains state or symbol not present in the automaton components
Returns
true if the transition was indeed added
Here is the call graph for this function:

◆ getFinalStates() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::set< StateType > && automaton::CompactDFA< SymbolTypeT, StateTypeT >::getFinalStates ( ) &&
inline

Getter of final states.

Returns
the final states of the automaton
Here is the call graph for this function:

◆ getFinalStates() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::set< StateType > & automaton::CompactDFA< SymbolTypeT, StateTypeT >::getFinalStates ( ) const &
inline

Getter of final states.

Returns
the final states of the automaton
Here is the caller graph for this function:

◆ getInitialState() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
StateType && automaton::CompactDFA< SymbolTypeT, StateTypeT >::getInitialState ( ) &&
inline

Getter of the initial state.

Returns
the initial state of the automaton
Here is the call graph for this function:

◆ getInitialState() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const StateType & automaton::CompactDFA< SymbolTypeT, StateTypeT >::getInitialState ( ) const &
inline

Getter of the initial state.

Returns
the initial state of the automaton
Here is the caller graph for this function:

◆ getInputAlphabet() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::set< SymbolType > && automaton::CompactDFA< SymbolTypeT, StateTypeT >::getInputAlphabet ( ) &&
inline

Getter of the input alphabet.

Returns
the input alphabet of the automaton
Here is the call graph for this function:

◆ getInputAlphabet() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::set< SymbolType > & automaton::CompactDFA< SymbolTypeT, StateTypeT >::getInputAlphabet ( ) const &
inline

Getter of the input alphabet.

Returns
the input alphabet of the automaton
Here is the caller graph for this function:

◆ getStates() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::set< StateType > && automaton::CompactDFA< SymbolTypeT, StateTypeT >::getStates ( ) &&
inline

Getter of states.

Returns
the states of the automaton
Here is the call graph for this function:

◆ getStates() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::set< StateType > & automaton::CompactDFA< SymbolTypeT, StateTypeT >::getStates ( ) const &
inline

Getter of states.

Returns
the states of the automaton
Here is the caller graph for this function:

◆ getTransitions() [1/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType > && automaton::CompactDFA< SymbolType, StateType >::getTransitions ( ) &&

Get the transition function of the automaton in its natural form.

Returns
transition function of the automaton

◆ getTransitions() [2/2]

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
const ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType > & automaton::CompactDFA< SymbolType, StateType >::getTransitions ( ) const &

Get the transition function of the automaton in its natural form.

Returns
transition function of the automaton
Here is the caller graph for this function:

◆ getTransitionsFromState()

template<class SymbolType , class StateType >
ext::iterator_range< typename ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType >::const_iterator > automaton::CompactDFA< SymbolType, StateType >::getTransitionsFromState ( const StateType from) const

Get a subset of the transition function of the automaton, with the source state fixed in the transitions natural representation.

Parameters
fromfilter the transition function based on this state as a source state
Returns
a subset of the transition function of the automaton with the source state fixed
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTransitionsToState()

template<class SymbolType , class StateType >
ext::map< ext::pair< StateType, ext::vector< SymbolType > >, StateType > automaton::CompactDFA< SymbolType, StateType >::getTransitionsToState ( const StateType to) const

Get a subset of the transition function of the automaton, with the target state fixed in the transitions natural representation.

Parameters
tofilter the transition function based on this state as a source state
Returns
a subset of the transition function of the automaton with the target state fixed
Here is the call graph for this function:

◆ operator<=>()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
auto automaton::CompactDFA< SymbolTypeT, StateTypeT >::operator<=> ( const CompactDFA< SymbolTypeT, StateTypeT > &  other) const
inline

The three way comparison implementation

Parameters
otherthe other instance
Returns
the ordering between this object and the other.
Here is the call graph for this function:

◆ operator==()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::CompactDFA< SymbolTypeT, StateTypeT >::operator== ( const CompactDFA< SymbolTypeT, StateTypeT > &  other) const
inline

The equality comparison implementation.

Parameters
otherthe other object to compare with.
Returns
true if this and other objects are equal, false othervise
Here is the call graph for this function:

◆ removeFinalState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::CompactDFA< SymbolTypeT, StateTypeT >::removeFinalState ( const StateType state)
inline

Remover of a final state.

Parameters
statea state to be removed from a set of final states
Returns
true if the state was indeed removed

◆ removeInputSymbol()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::CompactDFA< SymbolTypeT, StateTypeT >::removeInputSymbol ( const SymbolType symbol)
inline

Remover of an input symbol.

Parameters
symbola symbol to be removed from an input alphabet
Returns
true if the symbol was indeed removed

◆ removeState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::CompactDFA< SymbolTypeT, StateTypeT >::removeState ( const StateType state)
inline

Remover of a state.

Parameters
statea state to be removed from a set of states
Returns
true if the state was indeed removed

◆ removeTransition()

template<class SymbolType , class StateType >
bool automaton::CompactDFA< SymbolType, StateType >::removeTransition ( const StateType from,
const ext::vector< SymbolType > &  input,
const StateType to 
)

Removes a transition from the automaton.

The transition is in a form A \times a -> B, where A, B \in Q and a \in T*

Parameters
currentthe source state (A)
inputthe list of input symbols (a)
nextthe target state (B)
Returns
true if the transition was indeed removed
Here is the call graph for this function:

◆ setFinalStates()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::CompactDFA< SymbolTypeT, StateTypeT >::setFinalStates ( ext::set< StateType states)
inline

Setter of final states.

Parameters
statescompletely new set of final states

◆ setInitialState()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
bool automaton::CompactDFA< SymbolTypeT, StateTypeT >::setInitialState ( StateType  state)
inline

Setter of the initial state.

Parameters
statenew initial state of the automaton
Returns
true if the initial state was indeed changed

◆ setInputAlphabet()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::CompactDFA< SymbolTypeT, StateTypeT >::setInputAlphabet ( ext::set< SymbolType symbols)
inline

Setter of input alphabet.

Parameters
symbolscompletely new input alphabet

◆ setStates()

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
void automaton::CompactDFA< SymbolTypeT, StateTypeT >::setStates ( ext::set< StateType states)
inline

Setter of states.

Parameters
statescompletely new set of states

Friends And Related Function Documentation

◆ operator<<

template<class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType>
ext::ostream & operator<< ( ext::ostream out,
const CompactDFA< SymbolTypeT, StateTypeT > &  instance 
)
friend

Print this object as raw representation to ostream.

Parameters
outostream where to print
instanceobject to print
Returns
modified output stream

The documentation for this class was generated from the following file: