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

Extended nondeterministic finite automaton. Accepts regular languages. The automaton has a regular expression on transitions. More...

#include <ExtendedNFA.h>

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

Public Types

typedef SymbolTypeT SymbolType
 
typedef StateTypeT StateType
 

Public Member Functions

 ExtendedNFA (StateType initialState)
 Creates a new instance of the automaton with a concrete initial state. More...
 
 ExtendedNFA (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...
 
 ExtendedNFA (const CompactNFA< SymbolType, StateType > &other)
 
 ExtendedNFA (const MultiInitialStateEpsilonNFA< SymbolType, StateType > &other)
 
 ExtendedNFA (const EpsilonNFA< SymbolType, StateType > &other)
 
 ExtendedNFA (const MultiInitialStateNFA< SymbolType, StateType > &other)
 
 ExtendedNFA (const NFA< SymbolType, StateType > &other)
 
 ExtendedNFA (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, regexp::UnboundedRegExpStructure< SymbolType > input, StateType to)
 Add a transition to the automaton. More...
 
bool removeTransition (const StateType &from, const regexp::UnboundedRegExpStructure< SymbolType > &input, const StateType &to)
 Removes a transition from the automaton. More...
 
const ext::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateType > & getTransitions () const &
 
ext::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateType > && getTransitions () &&
 
ext::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateTypegetTransitionsFromState (const StateType &from) const
 
ext::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateTypegetTransitionsToState (const StateType &to) const
 
auto operator<=> (const ExtendedNFA &other) const
 
bool operator== (const ExtendedNFA &other) const
 
- Public Member Functions inherited from core::Components< ExtendedNFA< 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 ExtendedNFA &instance)
 

Additional Inherited Members

- Static Public Member Functions inherited from core::Components< ExtendedNFA< 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::ExtendedNFA< SymbolTypeT, StateTypeT >

Extended nondeterministic finite automaton. Accepts regular languages. The automaton has a regular expression 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 RegExpsOver(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::ExtendedNFA< SymbolTypeT, StateTypeT >::StateType

◆ SymbolType

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

Constructor & Destructor Documentation

◆ ExtendedNFA() [1/8]

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

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

Parameters
initialStatethe initial state of the automaton

◆ ExtendedNFA() [2/8]

template<class SymbolType , class StateType >
automaton::ExtendedNFA< SymbolType, StateType >::ExtendedNFA ( 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

◆ ExtendedNFA() [3/8]

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

◆ ExtendedNFA() [4/8]

Here is the call graph for this function:

◆ ExtendedNFA() [5/8]

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

◆ ExtendedNFA() [6/8]

Here is the call graph for this function:

◆ ExtendedNFA() [7/8]

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

◆ ExtendedNFA() [8/8]

template<class SymbolType , class StateType >
automaton::ExtendedNFA< SymbolType, StateType >::ExtendedNFA ( 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< SymbolType, StateType >::addTransition ( StateType  from,
regexp::UnboundedRegExpStructure< 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 RegExpsOver(T)

Parameters
currentthe source state (A)
inputthe regexp (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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateType > && automaton::ExtendedNFA< 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::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateType > & automaton::ExtendedNFA< 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::multimap< ext::pair< StateType, regexp::UnboundedRegExpStructure< SymbolType > >, StateType > automaton::ExtendedNFA< 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()

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::ExtendedNFA< SymbolTypeT, StateTypeT >::operator<=> ( const ExtendedNFA< 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::ExtendedNFA< SymbolTypeT, StateTypeT >::operator== ( const ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< SymbolType, StateType >::removeTransition ( const StateType from,
const regexp::UnboundedRegExpStructure< 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 RegExpsOver(T)

Parameters
currentthe source state (A)
inputthe regexp (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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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::ExtendedNFA< 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 ExtendedNFA< 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: