30#include <alib/multiset>
71template <
class SymbolTypeT = DefaultSymbolType,
class StateTypeT = DefaultStateType >
72class UnorderedDFTA final :
public core::Components < UnorderedDFTA < SymbolTypeT, StateTypeT >, ext::set < common::ranked_symbol < SymbolTypeT > >, component::Set, InputAlphabet, ext::set < StateTypeT >, component::Set, std::tuple < States, FinalStates > > {
104 return this->
template accessComponent < States > ( ).get ( );
113 return std::move ( this->
template accessComponent < States > ( ).
get ( ) );
124 return this->
template accessComponent < States > ( ).add ( std::move ( state ) );
133 this->
template accessComponent < States > ( ).set ( std::move ( states ) );
144 this->
template accessComponent < States > ( ).remove ( state );
153 return this->
template accessComponent < FinalStates > ( ).get ( );
162 return std::move ( this->
template accessComponent < FinalStates > ( ).
get ( ) );
173 return this->
template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
182 this->
template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
193 this->
template accessComponent < FinalStates > ( ).remove ( state );
202 return this->
template accessComponent < InputAlphabet > ( ).get ( );
211 return std::move ( this->
template accessComponent < InputAlphabet > ( ).
get ( ) );
222 return this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
231 this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
240 this->
template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
251 this->
template accessComponent < InputAlphabet > ( ).remove ( symbol );
297 return std::move ( transitions );
307 if ( transition.second ==
q )
321 if ( std::find ( transition.first.second.begin ( ), transition.first.second.end ( ),
q ) != transition.first.second.end ( ) )
322 res.insert ( transition );
359 return out <<
"(UnorderedDFTA"
360 <<
" states = " << instance.
getStates ( )
384template <
class SymbolType,
class StateType >
395template<
class SymbolType,
class StateType >
396UnorderedDFTA < SymbolType, StateType >::UnorderedDFTA (
ext::set < StateType > states,
ext::set < common::ranked_symbol < SymbolType > > inputAlphabet,
ext::set < StateType > finalStates ) :
core::Components <
UnorderedDFTA,
ext::set <
common::ranked_symbol < SymbolType > >, component::Set, InputAlphabet,
ext::set < StateType >, component::Set, std::tuple < States, FinalStates > > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ) ) {
399template<
class SymbolType,
class StateType >
403template<
class SymbolType,
class StateType >
405 if ( prevStates.size ( ) != symbol.getRank ( ) )
408 if (! getInputAlphabet().count(symbol))
411 if (! getStates().count(next))
414 for (
const StateType & it : prevStates) {
415 if (! getStates().count(it))
420 if ( transitions.find ( key ) != transitions.end ( ) ) {
421 if ( transitions.find ( key )->second == next )
427 transitions.insert ( std::move ( key ), std::move ( next ) );
431template<
class SymbolType,
class StateType >
435 if ( transitions.find ( key ) == transitions.end ( ) )
438 if ( transitions.find ( key )->second != next )
441 transitions.erase(key);
455template<
class SymbolType,
class StateType >
468 if (t.first.first == symbol)
502template<
class SymbolType,
class StateType >
514 if (
automaton.getFinalStates ( ).count ( state ) )
518 if(
ext::contains(t.first.second.begin(), t.first.second.end(), state ) || t.second == state)
552template<
class SymbolType,
class StateType >
576 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
594template <
class SymbolType,
class StateType >
608 res.addTransition ( std::move ( input ), std::move ( from ), std::move ( to ) );
static common::ranked_symbol< DefaultSymbolType > normalizeRankedSymbol(common::ranked_symbol< SymbolType > &&symbol)
Definition: SymbolNormalize.h:81
static ext::set< common::ranked_symbol< DefaultSymbolType > > normalizeRankedAlphabet(ext::set< common::ranked_symbol< SymbolType > > &&symbols)
Definition: SymbolNormalize.h:59
Definition: AutomatonException.h:15
static DefaultStateType normalizeState(StateType &&state)
Definition: AutomatonNormalize.h:76
static ext::multiset< DefaultStateType > normalizeStates(ext::multiset< StateType > &&states)
Definition: AutomatonNormalize.h:49
Deterministic unordered finite tree automaton without epsilon transitions. Accepts regular tree langu...
Definition: UnorderedDFTA.h:72
bool addFinalState(StateType state)
Definition: UnorderedDFTA.h:172
bool removeTransition(const common::ranked_symbol< SymbolType > &symbol, const ext::multiset< StateType > &states, const StateType &next)
Removes a transition from the automaton.
Definition: UnorderedDFTA.h:432
void addInputSymbols(ext::set< common::ranked_symbol< SymbolType > > symbols)
Definition: UnorderedDFTA.h:230
const ext::map< ext::pair< common::ranked_symbol< SymbolType >, ext::multiset< StateType > >, StateType > & getTransitions() const &
Definition: UnorderedDFTA.h:287
ext::set< common::ranked_symbol< SymbolType > > && getInputAlphabet() &&
Definition: UnorderedDFTA.h:210
ext::map< ext::pair< common::ranked_symbol< SymbolType >, ext::multiset< StateType > >, StateType > getTransitionsToState(const StateType &q) const
Definition: UnorderedDFTA.h:303
bool addTransition(common::ranked_symbol< SymbolType > symbol, ext::multiset< StateType > prevStates, StateType next)
Add a transition to the automaton.
Definition: UnorderedDFTA.h:404
ext::map< ext::pair< common::ranked_symbol< SymbolType >, ext::multiset< StateType > >, StateType > getTransitionsFromState(const StateType &q) const
Definition: UnorderedDFTA.h:317
const ext::set< StateType > & getFinalStates() const &
Definition: UnorderedDFTA.h:152
void setStates(ext::set< StateType > states)
Definition: UnorderedDFTA.h:132
ext::map< ext::pair< common::ranked_symbol< SymbolType >, ext::multiset< StateType > >, StateType > && getTransitions() &&
Definition: UnorderedDFTA.h:296
const ext::set< StateType > & getStates() const &
Definition: UnorderedDFTA.h:103
const ext::set< common::ranked_symbol< SymbolType > > & getInputAlphabet() const &
Definition: UnorderedDFTA.h:201
void setInputAlphabet(ext::set< common::ranked_symbol< SymbolType > > symbols)
Definition: UnorderedDFTA.h:239
bool operator==(const UnorderedDFTA &other) const
Definition: UnorderedDFTA.h:346
friend ext::ostream & operator<<(ext::ostream &out, const UnorderedDFTA &instance)
Definition: UnorderedDFTA.h:358
void removeInputSymbol(const common::ranked_symbol< SymbolType > &symbol)
Definition: UnorderedDFTA.h:250
bool addState(StateType state)
Definition: UnorderedDFTA.h:123
ext::set< StateType > && getStates() &&
Definition: UnorderedDFTA.h:112
SymbolTypeT SymbolType
Definition: UnorderedDFTA.h:74
UnorderedDFTA()
Creates a new instance of the automaton.
Definition: UnorderedDFTA.h:400
void removeFinalState(const StateType &state)
Definition: UnorderedDFTA.h:192
ext::set< StateType > && getFinalStates() &&
Definition: UnorderedDFTA.h:161
StateTypeT StateType
Definition: UnorderedDFTA.h:75
bool addInputSymbol(common::ranked_symbol< SymbolType > symbol)
Definition: UnorderedDFTA.h:221
auto operator<=>(const UnorderedDFTA &other) const
Definition: UnorderedDFTA.h:335
void setFinalStates(ext::set< StateType > states)
Definition: UnorderedDFTA.h:181
void removeState(const StateType &state)
Definition: UnorderedDFTA.h:143
Definition: UnorderedDFTA.h:374
Definition: ranked_symbol.hpp:20
Definition: components.hpp:181
static void valid(const automaton::UnorderedDFTA< SymbolType, StateType > &, const common::ranked_symbol< SymbolType > &)
Definition: UnorderedDFTA.h:492
static bool used(const automaton::UnorderedDFTA< SymbolType, StateType > &automaton, const common::ranked_symbol< SymbolType > &symbol)
Definition: UnorderedDFTA.h:466
static bool available(const automaton::UnorderedDFTA< SymbolType, StateType > &, const common::ranked_symbol< SymbolType > &)
Definition: UnorderedDFTA.h:482
static void valid(const automaton::UnorderedDFTA< SymbolType, StateType > &, const StateType &)
Definition: UnorderedDFTA.h:542
static bool used(const automaton::UnorderedDFTA< SymbolType, StateType > &automaton, const StateType &state)
Definition: UnorderedDFTA.h:513
static bool available(const automaton::UnorderedDFTA< SymbolType, StateType > &, const StateType &)
Definition: UnorderedDFTA.h:532
static void valid(const automaton::UnorderedDFTA< SymbolType, StateType > &, const StateType &)
Definition: UnorderedDFTA.h:585
static bool available(const automaton::UnorderedDFTA< SymbolType, StateType > &automaton, const StateType &state)
Definition: UnorderedDFTA.h:575
static bool used(const automaton::UnorderedDFTA< SymbolType, StateType > &, const StateType &)
Definition: UnorderedDFTA.h:563
Definition: setComponents.hpp:26
Class extending the map class from the standard library. Original reason is to allow printing of the ...
Definition: map.hpp:48
Definition: multiset.hpp:44
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: BarSymbol.cpp:12
typename T::StateType StateType
Definition: ToGrammarLeftRG.h:64
typename T::SymbolType SymbolType
Definition: ReachableStates.h:176
return res
Definition: MinimizeByPartitioning.h:145
q
Definition: SingleInitialStateEpsilonTransition.h:85
Definition: ToGrammar.h:31
constexpr bool isUnorderedDFTA
Definition: UnorderedDFTA.h:393
Definition: normalize.hpp:10
constexpr tuple< Elements &... > tie(Elements &... args) noexcept
Helper of extended tuple of references construction. The tuple is constructed to reffer to values in ...
Definition: tuple.hpp:218
reference_mover< T > make_mover(T ¶m)
Move adaptor construction function specialized to lvalue reference parameter.
Definition: iterator.hpp:468
bool contains(InputIt first, InputIt last, const Element &elem)
Linear version of search in a range of values.
Definition: algorithm.hpp:170
std::string to_string(const T &value)
To string method designated for objects that can be casted to string.
Definition: string.hpp:131
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693
static automaton::UnorderedDFTA< > eval(automaton::UnorderedDFTA< SymbolType, StateType > &&value)
Definition: UnorderedDFTA.h:596
Definition: normalize.hpp:13