28#include <ext/algorithm>
29#include <ext/iterator>
49class PushdownStoreAlphabet;
78template <
class InputSymbolTypeT = DefaultSymbolType,
class PushdownStoreSymbolTypeT = DefaultSymbolType,
class StateTypeT = DefaultStateType >
79class InputDrivenDPDA final :
public core::Components < InputDrivenDPDA < InputSymbolTypeT, PushdownStoreSymbolTypeT, StateTypeT >, ext::set < InputSymbolTypeT >, component::Set, InputAlphabet, ext::set < PushdownStoreSymbolTypeT >, component::Set, PushdownStoreAlphabet, PushdownStoreSymbolTypeT, component::Value, InitialSymbol, ext::set < StateTypeT >, component::Set, std::tuple < States, FinalStates >, StateTypeT, component::Value, InitialState > {
132 return this->
template accessComponent < InitialState > ( ).get ( );
141 return std::move ( this->
template accessComponent < InitialState > ( ).
get ( ) );
152 return this->
template accessComponent < InitialState > ( ).set ( std::move ( state ) );
161 return this->
template accessComponent < States > ( ).get ( );
170 return std::move ( this->
template accessComponent < States > ( ).
get ( ) );
181 return this->
template accessComponent < States > ( ).add ( std::move ( state ) );
190 this->
template accessComponent < States > ( ).set ( std::move ( states ) );
201 this->
template accessComponent < States > ( ).remove ( state );
210 return this->
template accessComponent < FinalStates > ( ).get ( );
219 return std::move ( this->
template accessComponent < FinalStates > ( ).
get ( ) );
230 return this->
template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
239 this->
template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
250 this->
template accessComponent < FinalStates > ( ).remove ( state );
259 return this->
template accessComponent < PushdownStoreAlphabet > ( ).get ( );
268 return std::move ( this->
template accessComponent < PushdownStoreAlphabet > ( ).
get ( ) );
279 return this->
template accessComponent < PushdownStoreAlphabet > ( ).add ( std::move ( symbol ) );
288 this->
template accessComponent < PushdownStoreAlphabet > ( ).add ( std::move ( symbols ) );
297 this->
template accessComponent < PushdownStoreAlphabet > ( ).set ( std::move ( symbols ) );
308 this->
template accessComponent < PushdownStoreAlphabet > ( ).remove ( symbol );
317 return this->
template accessComponent < InitialSymbol > ( ).get ( );
326 return std::move ( this->
template accessComponent < InitialSymbol > ( ).
get ( ) );
337 return this->
template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) );
346 return this->
template accessComponent < InputAlphabet > ( ).get ( );
355 return std::move ( this->
template accessComponent < InputAlphabet > ( ).
get ( ) );
366 return this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
375 this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
384 this->
template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
395 this->
template accessComponent < InputAlphabet > ( ).remove ( symbol );
508 return ext::tie(
getStates(),
getInputAlphabet(),
getInitialState(),
getFinalStates(),
getPushdownStoreAlphabet(),
getInitialSymbol(),
getPushdownStoreOperations(), transitions) <=>
std::tie(other.getStates(), other.getInputAlphabet(), other.getInitialState(), other.getFinalStates(), other.getPushdownStoreAlphabet(), other.getInitialSymbol(), other.getPushdownStoreOperations(), other.transitions);
519 return std::tie(
getStates(),
getInputAlphabet(),
getInitialState(),
getFinalStates(),
getPushdownStoreAlphabet(),
getInitialSymbol(),
getPushdownStoreOperations(), transitions) ==
std::tie(other.
getStates(), other.
getInputAlphabet(), other.
getInitialState(), other.
getFinalStates(), other.
getPushdownStoreAlphabet(), other.
getInitialSymbol(), other.
getPushdownStoreOperations(), other.transitions);
531 return out <<
"(InputDrivenDPDA"
532 <<
" states = " << instance.
getStates ( )
544template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
545InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::InputDrivenDPDA (
ext::set < StateType > states,
ext::set < InputSymbolType > inputAlphabet,
ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet,
StateType initialState,
PushdownStoreSymbolType initialSymbol,
ext::set < StateType > finalStates ) :
core::Components <
InputDrivenDPDA,
ext::set < InputSymbolType >, component::Set, InputAlphabet,
ext::set < PushdownStoreSymbolType >, component::Set, PushdownStoreAlphabet,
PushdownStoreSymbolType, component::Value, InitialSymbol,
ext::set < StateType >, component::Set, std::tuple < States, FinalStates >,
StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( pushdownStoreAlphabet ), std::move ( initialSymbol ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) {
548template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
552template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
554 if (! getInputAlphabet().count(input)) {
555 throw AutomatonException(
"Input symbol \"" +
ext::to_string ( input ) +
"\" doesn't exist.");
558 for(
const PushdownStoreSymbolType& popSymbol : pop) {
559 if (! getPushdownStoreAlphabet().count(popSymbol)) {
560 throw AutomatonException(
"Pushdown store symbol \"" +
ext::to_string ( popSymbol ) +
"\" doesn't exist.");
564 for(
const PushdownStoreSymbolType& pushSymbol : push) {
565 if (! getPushdownStoreAlphabet().count(pushSymbol)) {
566 throw AutomatonException(
"Pushdown store symbol \"" +
ext::to_string ( pushSymbol ) +
"\" doesn't exist.");
571template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
573 checkPushdownStoreOperation(input, pop, push);
574 return inputSymbolToPushdownStoreOperation.insert ( std::move( input ),
ext::make_pair(std::move ( pop ), std::move( push ) ) ).second;
577template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
583 clearPushdownStoreOperation(removedSymbol);
586 for(
const auto& added : operations) {
587 checkPushdownStoreOperation(added.first, added.second.first, added.second.second);
590 inputSymbolToPushdownStoreOperation = std::move(operations);
593template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
596 if (transition.first.second == input)
600 return inputSymbolToPushdownStoreOperation.erase(input);
603template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
605 return inputSymbolToPushdownStoreOperation;
608template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
610 return std::move ( inputSymbolToPushdownStoreOperation );
613template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
615 if (!getStates().count(from))
618 if (!getInputAlphabet().count(input))
621 if (! getPushdownStoreOperations().count(input))
624 if (! getStates().count(to))
629 if (transitions.find(key) != transitions.end()) {
630 if(transitions.find(key)->second == to)
636 transitions.insert ( std::move(key), std::move(to) );
640template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
644 if (transitions.find(key) == transitions.end())
647 if(transitions.find(key)->second != to)
650 transitions.erase(key);
654template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
659template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
661 return std::move ( transitions );
664template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
666 if( ! getStates().count(from))
671 if (transition.first.first == from) {
672 transitionsFromState.
insert(transition);
676 return transitionsFromState;
679template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
681 if( ! getStates().count(to))
686 if (transition.second == to) {
687 transitionsToState.
insert(transition);
691 return transitionsToState;
705template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
706class SetConstraint<
automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > {
718 if (transition.first.second == symbol)
753template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
754class SetConstraint<
automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > {
765 for (
const auto& pushdownStoreOperation :
automaton.getPushdownStoreOperations()) {
766 if (std::find(pushdownStoreOperation.second.first.begin(), pushdownStoreOperation.second.first.end(), symbol) != pushdownStoreOperation.second.first.end())
768 if (std::find(pushdownStoreOperation.second.second.begin(), pushdownStoreOperation.second.second.end(), symbol) != pushdownStoreOperation.second.second.end())
772 if(
automaton.getInitialSymbol() == symbol)
807template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
808class ElementConstraint<
automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::InitialSymbol > {
819 return automaton.template accessComponent < automaton::PushdownStoreAlphabet > ( ).get ( ).count ( symbol );
839template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
851 if (
automaton.getInitialState ( ) == state )
854 if (
automaton.getFinalStates ( ).count ( state ) )
858 if (t.first.first == state || t.second == state)
893template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
917 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
937template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
949 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
967template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
968struct normalize <
automaton::InputDrivenDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > > {
984 res.setPushdownStoreOperation ( std::move ( target ), std::move ( pop ), std::move ( push ) );
993 res.addTransition ( std::move ( from ), std::move ( input ), std::move ( to ) );
static ext::set< DefaultSymbolType > normalizeAlphabet(ext::set< SymbolType > &&symbols)
Definition: SymbolNormalize.h:50
static ext::vector< DefaultSymbolType > normalizeSymbols(ext::vector< SymbolType > &&symbols)
Definition: SymbolNormalize.h:86
static DefaultSymbolType normalizeSymbol(SymbolType &&symbol)
Definition: SymbolNormalize.h:68
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: components.hpp:181
Definition: components.hpp:25
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
std::pair< iterator, bool > insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: map.hpp:118
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
auto end() &
Inherited behavior of end for non-const instance.
Definition: set.hpp:129
Class extending the vector class from the standard library. Original reason is to allow printing of t...
Definition: vector.hpp:45
Definition: BarSymbol.cpp:12
typename T::StateType StateType
Definition: ToGrammarLeftRG.h:64
return res
Definition: MinimizeByPartitioning.h:145
Definition: ToGrammar.h:31
Definition: normalize.hpp:10
Definition: sigHandler.cpp:20
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
key_iterator< map_type > key_begin(const map_type &m)
Definition: iterator.hpp:1027
std::string to_string(const T &value)
To string method designated for objects that can be casted to string.
Definition: string.hpp:131
key_iterator< map_type > key_end(const map_type &m)
Definition: iterator.hpp:1041
constexpr auto make_pair(T1 &&x, T2 &&y)
Definition: pair.hpp:79
auto begin(Container &&cont) -> decltype(std::forward(cont).begin())
Definition: iterator.hpp:900
void end()
Definition: measurements.cpp:19
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693
Definition: normalize.hpp:13