28#include <ext/algorithm>
48class PushdownStoreAlphabet;
77template <
class InputSymbolTypeT = DefaultSymbolType,
class PushdownStoreSymbolTypeT = DefaultSymbolType,
class StateTypeT = DefaultStateType >
78class SinglePopDPDA final :
public core::Components < SinglePopDPDA < 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 > {
117 return this->
template accessComponent < InitialState > ( ).get ( );
126 return std::move ( this->
template accessComponent < InitialState > ( ).
get ( ) );
137 return this->
template accessComponent < InitialState > ( ).set ( std::move ( state ) );
146 return this->
template accessComponent < States > ( ).get ( );
155 return std::move ( this->
template accessComponent < States > ( ).
get ( ) );
166 return this->
template accessComponent < States > ( ).add ( std::move ( state ) );
175 this->
template accessComponent < States > ( ).set ( std::move ( states ) );
186 this->
template accessComponent < States > ( ).remove ( state );
195 return this->
template accessComponent < FinalStates > ( ).get ( );
204 return std::move ( this->
template accessComponent < FinalStates > ( ).
get ( ) );
215 return this->
template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
224 this->
template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
235 this->
template accessComponent < FinalStates > ( ).remove ( state );
244 return this->
template accessComponent < PushdownStoreAlphabet > ( ).get ( );
253 return std::move ( this->
template accessComponent < PushdownStoreAlphabet > ( ).
get ( ) );
264 return this->
template accessComponent < PushdownStoreAlphabet > ( ).add ( std::move ( symbol ) );
273 this->
template accessComponent < PushdownStoreAlphabet > ( ).add ( std::move ( symbols ) );
282 this->
template accessComponent < PushdownStoreAlphabet > ( ).set ( std::move ( symbols ) );
293 this->
template accessComponent < PushdownStoreAlphabet > ( ).remove ( symbol );
302 return this->
template accessComponent < InitialSymbol > ( ).get ( );
311 return std::move ( this->
template accessComponent < InitialSymbol > ( ).
get ( ) );
322 return this->
template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) );
331 return this->
template accessComponent < InputAlphabet > ( ).get ( );
340 return std::move ( this->
template accessComponent < InputAlphabet > ( ).
get ( ) );
351 return this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
360 this->
template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
369 this->
template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
380 this->
template accessComponent < InputAlphabet > ( ).remove ( symbol );
505 return std::tie(
getStates(),
getInputAlphabet(),
getInitialState(),
getFinalStates(),
getPushdownStoreAlphabet(),
getInitialSymbol(), transitions) <=>
std::tie(other.getStates(), other.getInputAlphabet(), other.getInitialState(), other.getFinalStates(), other.getPushdownStoreAlphabet(), other.getInitialSymbol(), other.transitions);
516 return std::tie(
getStates(),
getInputAlphabet(),
getInitialState(),
getFinalStates(),
getPushdownStoreAlphabet(),
getInitialSymbol(), transitions) ==
std::tie(other.
getStates(), other.
getInputAlphabet(), other.
getInitialState(), other.
getFinalStates(), other.
getPushdownStoreAlphabet(), other.
getInitialSymbol(), other.transitions);
528 return out <<
"(SinglePopDPDA"
529 <<
" states = " << instance.
getStates ( )
540template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
541SinglePopDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::SinglePopDPDA (
ext::set < StateType > states,
ext::set < InputSymbolType > inputAlphabet,
ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet,
StateType initialState,
PushdownStoreSymbolType initialSymbol,
ext::set < StateType > finalStates ) :
core::Components <
SinglePopDPDA,
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 ) ) {
544template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
548template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
550 if (!getStates().count(from)) {
554 if ( ! input.is_epsilon ( ) && ! getInputAlphabet().count(input.getSymbol ( ) ) ) {
558 if (!getStates().count(to)) {
562 if (!getPushdownStoreAlphabet().count(pop)) {
567 if (!getPushdownStoreAlphabet().count(pushSymbol)) {
575 if (transitions.find(key) != transitions.end()) {
576 if(transitions.find(key)->second == value)
582 if ( std::get < 1 > ( key ).is_epsilon ( ) ) {
584 if(std::get<0>(transition.first) == std::get<0>(key) && std::get<2>(transition.first) == std::get<2>(key)) return true;
590 if(transitions.find(key2) != transitions.end())
594 transitions.insert ( std::move(key), std::move(value) );
598template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
601 return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push));
604template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
607 return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push));
610template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
615 if (transitions.find(key) == transitions.end())
618 if(transitions.find(key)->second != value) {
622 transitions.erase(key);
626template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
629 return removeTransition(from, inputVariant, pop, to, push);
632template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
635 return removeTransition(from, inputVariant, pop, to, push);
638template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
643template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
645 return std::move ( transitions );
659template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
660class SetConstraint<
automaton::SinglePopDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > {
672 if ( ! std::get<1>(transition.first).is_epsilon ( ) && symbol == std::get<1>(transition.first).getSymbol ( ) )
707template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
708class SetConstraint<
automaton::SinglePopDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > {
720 if (symbol == std::get<2>(transition.first) || std::find(transition.second.second.begin(), transition.second.second.end(), symbol) != transition.second.second.end())
723 if(
automaton.getInitialSymbol() == symbol)
758template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
759class ElementConstraint<
automaton::SinglePopDPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::InitialSymbol > {
770 return automaton.template accessComponent < automaton::PushdownStoreAlphabet > ( ).get ( ).count ( symbol );
790template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
802 if (
automaton.getInitialState ( ) == state )
805 if (
automaton.getFinalStates ( ).count ( state ) )
809 if (state == std::get<0>(transition.first) || transition.second.first == state)
844template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
868 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
888template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
900 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
918template <
class InputSymbolType,
class PushdownStoreSymbolType,
class StateType >
919struct normalize <
automaton::SinglePopDPDA < InputSymbolType, PushdownStoreSymbolType, StateType > > {
928 automaton::SinglePopDPDA < > res ( std::move ( states ), std::move (
alphabet ), std::move ( pushdownAlphabet ), std::move ( initialState ), std::move ( initialSymbol ), std::move ( finalStates ) );
938 res.addTransition ( std::move ( from ), std::move ( input ), std::move ( pop ), std::move ( to ), std::move ( push ) );
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 common::symbol_or_epsilon< DefaultSymbolType > normalizeSymbolEpsilon(common::symbol_or_epsilon< SymbolType > &&symbol)
Definition: AutomatonNormalize.h:81
static DefaultStateType normalizeState(StateType &&state)
Definition: AutomatonNormalize.h:76
static ext::multiset< DefaultStateType > normalizeStates(ext::multiset< StateType > &&states)
Definition: AutomatonNormalize.h:49
Deterministic pushdown automaton requiring a symbol pop from pushdown store on each transition use....
Definition: SinglePopDPDA.h:78
StateTypeT StateType
Definition: SinglePopDPDA.h:82
PushdownStoreSymbolTypeT PushdownStoreSymbolType
Definition: SinglePopDPDA.h:81
void removeInputSymbol(const InputSymbolType &symbol)
Definition: SinglePopDPDA.h:379
StateType && getInitialState() &&
Definition: SinglePopDPDA.h:125
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: SinglePopDPDA.h:243
const StateType & getInitialState() const &
Definition: SinglePopDPDA.h:116
bool setInitialState(StateType state)
Definition: SinglePopDPDA.h:136
ext::set< StateType > && getStates() &&
Definition: SinglePopDPDA.h:154
bool removeTransition(const StateType &from, const common::symbol_or_epsilon< InputSymbolType > &input, const PushdownStoreSymbolType &pop, const StateType &to, const ext::vector< PushdownStoreSymbolType > &push)
Removes a transition from the automaton.
Definition: SinglePopDPDA.h:611
ext::set< PushdownStoreSymbolType > && getPushdownStoreAlphabet() &&
Definition: SinglePopDPDA.h:252
ext::set< InputSymbolType > && getInputAlphabet() &&
Definition: SinglePopDPDA.h:339
void addInputSymbols(ext::set< InputSymbolType > symbols)
Definition: SinglePopDPDA.h:359
void removeState(const StateType &state)
Definition: SinglePopDPDA.h:185
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: SinglePopDPDA.h:330
void addPushdownStoreSymbols(ext::set< PushdownStoreSymbolType > symbols)
Definition: SinglePopDPDA.h:272
void removeFinalState(const StateType &state)
Definition: SinglePopDPDA.h:234
const ext::set< StateType > & getFinalStates() const &
Definition: SinglePopDPDA.h:194
void setFinalStates(ext::set< StateType > states)
Definition: SinglePopDPDA.h:223
PushdownStoreSymbolType && getInitialSymbol() &&
Definition: SinglePopDPDA.h:310
InputSymbolTypeT InputSymbolType
Definition: SinglePopDPDA.h:80
bool operator==(const SinglePopDPDA &other) const
Definition: SinglePopDPDA.h:515
bool addTransition(StateType from, common::symbol_or_epsilon< InputSymbolType > input, PushdownStoreSymbolType pop, StateType to, ext::vector< PushdownStoreSymbolType > push)
Adds a transition to the automaton.
Definition: SinglePopDPDA.h:549
SinglePopDPDA(ext::set< StateType > states, ext::set< InputSymbolType > inputAlphabet, ext::set< PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set< StateType > finalStates)
Creates a new instance of the automaton with a concrete set of states, input alphabet,...
Definition: SinglePopDPDA.h:541
bool addState(StateType state)
Definition: SinglePopDPDA.h:165
bool addPushdownStoreSymbol(PushdownStoreSymbolType symbol)
Definition: SinglePopDPDA.h:263
void removePushdownStoreSymbol(const PushdownStoreSymbolType &symbol)
Definition: SinglePopDPDA.h:292
void setInputAlphabet(ext::set< InputSymbolType > symbols)
Definition: SinglePopDPDA.h:368
const ext::set< StateType > & getStates() const &
Definition: SinglePopDPDA.h:145
bool addFinalState(StateType state)
Definition: SinglePopDPDA.h:214
friend ext::ostream & operator<<(ext::ostream &out, const SinglePopDPDA &instance)
Definition: SinglePopDPDA.h:527
void setStates(ext::set< StateType > states)
Definition: SinglePopDPDA.h:174
bool addInputSymbol(InputSymbolType symbol)
Definition: SinglePopDPDA.h:350
ext::set< StateType > && getFinalStates() &&
Definition: SinglePopDPDA.h:203
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: SinglePopDPDA.h:301
void setPushdownStoreAlphabet(ext::set< PushdownStoreSymbolType > symbols)
Definition: SinglePopDPDA.h:281
bool setInitialSymbol(PushdownStoreSymbolType symbol)
Definition: SinglePopDPDA.h:321
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, PushdownStoreSymbolType >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: SinglePopDPDA.h:639
Definition: symbol_or_epsilon.hpp:24
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
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Class extending the tuple class from the standard library. Original reason is to allow printing of th...
Definition: tuple.hpp:42
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: Permutation.hpp:18
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
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
any_of(T &&...) -> any_of< T... >
auto & get(ext::ptr_array< Type, N > &tpl)
Specialisation of get function for pointer arrays.
Definition: ptr_array.hpp:693
Definition: normalize.hpp:13