28#include <alib/multimap>
66template <
class SymbolTypeT = DefaultSymbolType,
class StateTypeT = DefaultStateType >
67class ArcFactoredNondeterministicZAutomaton final :
public core::Components < ArcFactoredNondeterministicZAutomaton < SymbolTypeT, StateTypeT >, ext::set < SymbolTypeT >, component::Set, InputAlphabet, ext::set < StateTypeT >, component::Set, std::tuple < States, FinalStates > > {
106 return this->
template accessComponent < States > ( ).get ( );
115 return std::move ( this->
template accessComponent < States > ( ).
get ( ) );
126 return this->
template accessComponent < States > ( ).add ( std::move ( state ) );
135 this->
template accessComponent < States > ( ).set ( std::move ( states ) );
146 this->
template accessComponent < States > ( ).remove ( state );
155 return this->
template accessComponent < FinalStates > ( ).get ( );
164 return std::move ( this->
template accessComponent < FinalStates > ( ).
get ( ) );
175 return this->
template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
184 this->
template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
195 this->
template accessComponent < FinalStates > ( ).remove ( state );
204 return this->
template accessComponent < InputAlphabet > ( ).get ( );
213 return std::move ( this->
template accessComponent < InputAlphabet > ( ).
get ( ) );
224 return this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
233 this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
242 this->
template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
253 this->
template accessComponent < InputAlphabet > ( ).remove ( symbol );
303 return std::move ( transitions );
313 if ( transition.second ==
q )
328 res.insert ( transition );
365 return out <<
"(ArcFactoredNondeterministicZAutomaton "
366 <<
" states = " << instance.
getStates ( )
390template <
class SymbolType,
class StateType >
401template<
class SymbolType,
class StateType >
402ArcFactoredNondeterministicZAutomaton < SymbolType, StateType >::ArcFactoredNondeterministicZAutomaton (
ext::set < StateType > states,
ext::set < SymbolType > inputAlphabet,
ext::set < StateType > finalStates ) :
core::Components <
ArcFactoredNondeterministicZAutomaton,
ext::set < SymbolType >, component::Set, InputAlphabet,
ext::set < StateType >, component::Set, std::tuple < States, FinalStates > > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ) ) {
405template<
class SymbolType,
class StateType >
409template <
class SymbolType,
class StateType >
411 transitions.insert ( other.getTransitions ( ).begin ( ), other.getTransitions ( ).end ( ) );
414template<
class SymbolType,
class StateType >
416 if ( lhs.template is < SymbolType > ( ) && ! getInputAlphabet ( ).count ( lhs.template get < SymbolType > ( ) ) )
421 if ( ! getStates ( ).count ( stateLhs.first ) )
423 if ( ! getStates ( ).count ( stateLhs.second ) )
427 if (! getStates().count(rhs))
430 auto upper_bound = transitions.upper_bound ( lhs );
431 auto lower_bound = transitions.lower_bound ( lhs );
432 auto iter = std::lower_bound ( lower_bound, upper_bound, rhs, [ ] (
const auto & transition,
const auto & target ) {
return transition.second < target; } );
433 if ( iter != upper_bound && rhs >= iter->second )
436 transitions.insert ( iter,
std::make_pair ( std::move ( lhs ), std::move ( rhs ) ) );
440template<
class SymbolType,
class StateType >
445template<
class SymbolType,
class StateType >
450template<
class SymbolType,
class StateType >
452 auto upper_bound = transitions.upper_bound ( lhs );
453 auto lower_bound = transitions.lower_bound ( lhs );
454 auto iter = std::find_if ( lower_bound, upper_bound, [ & ] (
const auto & transition ) {
return transition.second == next; } );
455 if ( iter == upper_bound )
458 transitions.erase ( iter );
472template<
class SymbolType,
class StateType >
485 if ( t.first == symbol )
510 if (
automaton.template accessComponent < automaton::States > ( ).get ( ).count (
ext::poly_comp ( symbol ) ) )
521template<
class SymbolType,
class StateType >
533 if (
automaton.getFinalStates ( ).count ( state ) )
539 if ( lhs.first == state || lhs.second == state )
565 if (
automaton.template accessComponent < automaton::InputAlphabet > ( ).get ( ).count (
ext::poly_comp ( state ) ) )
576template<
class SymbolType,
class StateType >
600 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
618template <
class SymbolType,
class StateType >
628 if ( transition.first.template is < SymbolType > ( ) ) {
632 res.addTransition ( std::move ( lhs ), std::move ( to ) );
638 res.addTransition ( std::move ( lshDefault ), std::move ( to ) );
static ext::set< DefaultSymbolType > normalizeAlphabet(ext::set< SymbolType > &&symbols)
Definition: SymbolNormalize.h:50
static DefaultSymbolType normalizeSymbol(SymbolType &&symbol)
Definition: SymbolNormalize.h:68
Deterministic Z-Automaton in Arc-Factored Normal Form. Computation model for unranked regular tree la...
Definition: ArcFactoredDeterministicZAutomaton.h:65
Nondeterministic Z-Automaton in Arc-Factored Normal Form. Computation model for unranked regular tree...
Definition: ArcFactoredNondeterministicZAutomaton.h:67
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: ArcFactoredNondeterministicZAutomaton.h:203
ext::set< StateType > && getFinalStates() &&
Definition: ArcFactoredNondeterministicZAutomaton.h:163
void setInputAlphabet(ext::set< SymbolType > symbols)
Definition: ArcFactoredNondeterministicZAutomaton.h:241
void setStates(ext::set< StateType > states)
Definition: ArcFactoredNondeterministicZAutomaton.h:134
const ext::set< StateType > & getFinalStates() const &
Definition: ArcFactoredNondeterministicZAutomaton.h:154
SymbolTypeT SymbolType
Definition: ArcFactoredNondeterministicZAutomaton.h:69
auto operator<=>(const ArcFactoredNondeterministicZAutomaton &other) const
Definition: ArcFactoredNondeterministicZAutomaton.h:341
void removeState(const StateType &state)
Definition: ArcFactoredNondeterministicZAutomaton.h:145
bool addInputSymbol(SymbolType symbol)
Definition: ArcFactoredNondeterministicZAutomaton.h:223
ext::multimap< ext::variant< SymbolType, ext::pair< StateType, StateType > >, StateType > && getTransitions() &&
Definition: ArcFactoredNondeterministicZAutomaton.h:302
bool removeTransition(const ext::variant< SymbolType, ext::pair< StateType, StateType > > &lhs, const StateType &next)
Removes a transition from the automaton.
Definition: ArcFactoredNondeterministicZAutomaton.h:451
void removeFinalState(const StateType &state)
Definition: ArcFactoredNondeterministicZAutomaton.h:194
void setFinalStates(ext::set< StateType > states)
Definition: ArcFactoredNondeterministicZAutomaton.h:183
void addInputSymbols(ext::set< SymbolType > symbols)
Definition: ArcFactoredNondeterministicZAutomaton.h:232
bool operator==(const ArcFactoredNondeterministicZAutomaton &other) const
Definition: ArcFactoredNondeterministicZAutomaton.h:352
ext::multimap< ext::variant< SymbolType, ext::pair< StateType, StateType > >, StateType > getTransitionsToState(const StateType &q) const
Definition: ArcFactoredNondeterministicZAutomaton.h:309
friend ext::ostream & operator<<(ext::ostream &out, const ArcFactoredNondeterministicZAutomaton &instance)
Definition: ArcFactoredNondeterministicZAutomaton.h:364
ArcFactoredNondeterministicZAutomaton()
Creates a new instance of the automaton.
Definition: ArcFactoredNondeterministicZAutomaton.h:406
const ext::multimap< ext::variant< SymbolType, ext::pair< StateType, StateType > >, StateType > & getTransitions() const &
Definition: ArcFactoredNondeterministicZAutomaton.h:293
bool addState(StateType state)
Definition: ArcFactoredNondeterministicZAutomaton.h:125
void removeInputSymbol(const SymbolType &symbol)
Definition: ArcFactoredNondeterministicZAutomaton.h:252
ext::set< StateType > && getStates() &&
Definition: ArcFactoredNondeterministicZAutomaton.h:114
StateTypeT StateType
Definition: ArcFactoredNondeterministicZAutomaton.h:70
ext::set< SymbolType > && getInputAlphabet() &&
Definition: ArcFactoredNondeterministicZAutomaton.h:212
bool addFinalState(StateType state)
Definition: ArcFactoredNondeterministicZAutomaton.h:174
const ext::set< StateType > & getStates() const &
Definition: ArcFactoredNondeterministicZAutomaton.h:105
bool addTransition(ext::variant< SymbolType, ext::pair< StateType, StateType > > lhs, StateType rhs)
Add a transition to the automaton.
Definition: ArcFactoredNondeterministicZAutomaton.h:415
ext::multimap< ext::variant< SymbolType, ext::pair< StateType, StateType > >, StateType > getTransitionsFromState(const StateType &q) const
Definition: ArcFactoredNondeterministicZAutomaton.h:323
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
Definition: ArcFactoredNondeterministicZAutomaton.h:380
Definition: components.hpp:181
static void valid(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &automaton, const StateType &state)
Definition: ArcFactoredNondeterministicZAutomaton.h:564
static bool used(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &automaton, const StateType &state)
Definition: ArcFactoredNondeterministicZAutomaton.h:532
static bool available(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &, const StateType &)
Definition: ArcFactoredNondeterministicZAutomaton.h:554
static bool used(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: ArcFactoredNondeterministicZAutomaton.h:483
static bool available(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &, const SymbolType &)
Definition: ArcFactoredNondeterministicZAutomaton.h:499
static void valid(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: ArcFactoredNondeterministicZAutomaton.h:509
static bool used(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &, const StateType &)
Definition: ArcFactoredNondeterministicZAutomaton.h:587
static bool available(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &automaton, const StateType &state)
Definition: ArcFactoredNondeterministicZAutomaton.h:599
static void valid(const automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &, const StateType &)
Definition: ArcFactoredNondeterministicZAutomaton.h:609
Definition: setComponents.hpp:26
Class extending the multimap class from the standard library. Original reason is to allow printing of...
Definition: multimap.hpp:48
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Implementation of the variant class allowing to store any type of those listed in the template parame...
Definition: variant.hpp:98
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 isAFNZA
Definition: ArcFactoredNondeterministicZAutomaton.h:399
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
std::string to_string(const T &value)
To string method designated for objects that can be casted to string.
Definition: string.hpp:131
PolyComp< T > poly_comp(const T &inst)
Definition: functional.hpp:60
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::ArcFactoredNondeterministicZAutomaton< > eval(automaton::ArcFactoredNondeterministicZAutomaton< SymbolType, StateType > &&value)
Definition: ArcFactoredNondeterministicZAutomaton.h:620
Definition: normalize.hpp:13