Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
DPDA.h
Go to the documentation of this file.
1
6/*
7 * This file is part of Algorithms library toolkit.
8 * Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10 * Algorithms library toolkit is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14
15 * Algorithms library toolkit is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19
20 * You should have received a copy of the GNU General Public License
21 * along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24#pragma once
25
26
27#include <ext/algorithm>
28
29#include <alib/set>
30#include <alib/map>
31#include <alib/vector>
32
33#include <core/components.hpp>
34
37
39
40#include <core/normalize.hpp>
43
44namespace automaton {
45
46class InputAlphabet;
47class PushdownStoreAlphabet;
48class InitialSymbol;
49class States;
50class FinalStates;
51class InitialState;
52
77template < class InputSymbolTypeT = DefaultSymbolType, class PushdownStoreSymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType >
78class DPDA final : public core::Components < DPDA < 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 > {
79public:
80 typedef InputSymbolTypeT InputSymbolType;
81 typedef PushdownStoreSymbolTypeT PushdownStoreSymbolType;
82 typedef StateTypeT StateType;
83
84private:
89
90public:
101 explicit DPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates );
102
109 explicit DPDA ( StateType initialState, PushdownStoreSymbolType initialPushdownSymbol );
110
116 const StateType & getInitialState ( ) const & {
117 return this-> template accessComponent < InitialState > ( ).get ( );
118 }
119
126 return std::move ( this-> template accessComponent < InitialState > ( ).get ( ) );
127 }
128
136 bool setInitialState ( StateType state ) {
137 return this-> template accessComponent < InitialState > ( ).set ( std::move ( state ) );
138 }
139
145 const ext::set < StateType > & getStates ( ) const & {
146 return this-> template accessComponent < States > ( ).get ( );
147 }
148
155 return std::move ( this-> template accessComponent < States > ( ).get ( ) );
156 }
157
165 bool addState ( StateType state ) {
166 return this-> template accessComponent < States > ( ).add ( std::move ( state ) );
167 }
168
175 this-> template accessComponent < States > ( ).set ( std::move ( states ) );
176 }
177
185 void removeState ( const StateType & state ) {
186 this-> template accessComponent < States > ( ).remove ( state );
187 }
188
195 return this-> template accessComponent < FinalStates > ( ).get ( );
196 }
197
204 return std::move ( this-> template accessComponent < FinalStates > ( ).get ( ) );
205 }
206
214 bool addFinalState ( StateType state ) {
215 return this-> template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
216 }
217
224 this-> template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
225 }
226
234 void removeFinalState ( const StateType & state ) {
235 this-> template accessComponent < FinalStates > ( ).remove ( state );
236 }
237
244 return this->template accessComponent < PushdownStoreAlphabet > ( ).get ( );
245 }
246
253 return std::move ( this->template accessComponent < PushdownStoreAlphabet > ( ).get ( ) );
254 }
255
264 return this->template accessComponent < PushdownStoreAlphabet > ( ).add ( std::move ( symbol ) );
265 }
266
273 this->template accessComponent < PushdownStoreAlphabet > ( ).add ( std::move ( symbols ) );
274 }
275
282 this->template accessComponent < PushdownStoreAlphabet > ( ).set ( std::move ( symbols ) );
283 }
284
293 this->template accessComponent < PushdownStoreAlphabet > ( ).remove ( symbol );
294 }
295
302 return this->template accessComponent < InitialSymbol > ( ).get ( );
303 }
304
311 return std::move ( this->template accessComponent < InitialSymbol > ( ).get ( ) );
312 }
313
322 return this->template accessComponent < InitialSymbol > ( ).set ( std::move ( symbol ) );
323 }
324
331 return this-> template accessComponent < InputAlphabet > ( ).get ( );
332 }
333
340 return std::move ( this-> template accessComponent < InputAlphabet > ( ).get ( ) );
341 }
342
351 return this-> template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
352 }
353
360 this-> template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
361 }
362
369 this-> template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
370 }
371
379 void removeInputSymbol ( const InputSymbolType & symbol ) {
380 this-> template accessComponent < InputAlphabet > ( ).remove ( symbol );
381 }
382
399
416
432
449
465 bool removeTransition ( const StateType & from, const InputSymbolType & input, const ext::vector < PushdownStoreSymbolType > & pop, const StateType & to, const ext::vector < PushdownStoreSymbolType > & push );
466
482
489
495 ext::map < ext::tuple < StateType, common::symbol_or_epsilon < InputSymbolType >, ext::vector < PushdownStoreSymbolType > >, ext::pair < StateType, ext::vector < PushdownStoreSymbolType > > > && getTransitions ( ) &&;
496
504 ext::map < ext::tuple < StateType, common::symbol_or_epsilon < InputSymbolType >, ext::vector < PushdownStoreSymbolType > >, ext::pair < StateType, ext::vector < PushdownStoreSymbolType > > > getTransitionsFromState ( const StateType & from ) const;
505
513 ext::map < ext::tuple < StateType, common::symbol_or_epsilon < InputSymbolType >, ext::vector < PushdownStoreSymbolType > >, ext::pair < StateType, ext::vector < PushdownStoreSymbolType > > > getTransitionsToState ( const StateType & to ) const;
514
522 auto operator <=> ( const DPDA & other ) const {
523 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);
524 }
525
533 bool operator == ( const DPDA & other ) const {
535 }
536
545 friend ext::ostream & operator << ( ext::ostream & out, const DPDA & instance ) {
546 return out << "(DPDA"
547 << " states = " << instance.getStates ( )
548 << " inputAlphabet = " << instance.getInputAlphabet ( )
549 << " initialState = " << instance.getInitialState ( )
550 << " finalStates = " << instance.getFinalStates ( )
551 << " pushdownStoreAlphabet = " << instance.getPushdownStoreAlphabet ( )
552 << " initialSymbol = " << instance.getInitialSymbol ( )
553 << " transitions = " << instance.getTransitions ( )
554 << ")";
555 }
556};
557
558template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
559DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::DPDA ( ext::set < StateType > states, ext::set < InputSymbolType > inputAlphabet, ext::set < PushdownStoreSymbolType > pushdownStoreAlphabet, StateType initialState, PushdownStoreSymbolType initialSymbol, ext::set < StateType > finalStates ) : core::Components < DPDA, 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 ) ) {
560}
561
562template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
563DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >::DPDA ( StateType initialState, PushdownStoreSymbolType initialPushdownSymbol) : DPDA ( ext::set < StateType > { initialState }, ext::set < InputSymbolType > { }, ext::set < PushdownStoreSymbolType > { initialPushdownSymbol }, initialState, initialPushdownSymbol, ext::set < StateType > { }) {
564}
565
566template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
568 if (! getStates().count(from)) {
569 throw AutomatonException("State \"" + ext::to_string ( from ) + "\" doesn't exist.");
570 }
571
572 if (! input.is_epsilon ( ) && ! getInputAlphabet().count ( input.getSymbol ( ) ) ) {
573 throw AutomatonException("Input symbol \"" + ext::to_string ( input ) + "\" doesn't exist.");
574 }
575
576 if (! getStates().count(to)) {
577 throw AutomatonException("State \"" + ext::to_string ( to ) + "\" doesn't exist.");
578 }
579
580 for(const PushdownStoreSymbolType & popSymbol : pop) {
581 if (! getPushdownStoreAlphabet().count(popSymbol)) {
582 throw AutomatonException("Pushdown store symbol \"" + ext::to_string ( popSymbol ) + "\" doesn't exist.");
583 }
584 }
585
586 for(const PushdownStoreSymbolType & pushSymbol : push) {
587 if (! getPushdownStoreAlphabet().count(pushSymbol)) {
588 throw AutomatonException("Pushdown store symbol \"" + ext::to_string ( pushSymbol ) + "\" doesn't exist.");
589 }
590 }
591
593 ext::pair<StateType, ext::vector<PushdownStoreSymbolType> > value = ext::make_pair(std::move(to), std::move(push));
594
595 if (transitions.find(key) != transitions.end()) {
596 if(transitions.find(key)->second == value)
597 return false;
598 else
599 throw AutomatonException ( "Transition (\"" + ext::to_string ( std::get<0>(key) ) + "\", \"" + ext::to_string ( std::get<1>(key) ) + "\", \"pop\") -> ?? already exists.");
600 }
601
602 if(std::get<1>(key).is_epsilon()) {
604 if(std::get<0>(transition.first) == std::get<0>(key)) {
605 const ext::vector<PushdownStoreSymbolType>& alpha = std::get<2>(transition.first);
606 const ext::vector<PushdownStoreSymbolType>& beta = std::get<2>(key);
607
608 const ext::vector<PushdownStoreSymbolType>& shorter = (alpha.size() < beta.size()) ? alpha : beta;
609 const ext::vector<PushdownStoreSymbolType>& longer = (alpha.size() < beta.size()) ? beta : alpha;
610
611 for(auto itS = shorter.begin(), itL = longer.begin(); itS != shorter.end(); ++itS, ++itL) {
612 if(*itS != *itL) return false;
613 }
614 return true;
615 }
616 return false;
617 }))
618 throw AutomatonException("Conflicting transition");
619 } else {
621 if(std::get<0>(transition.first) == std::get<0>(key) && ( std::get<1>(transition.first) == std::get<1>(key) || std::get<1>(transition.first).is_epsilon() )) {
622 const ext::vector<PushdownStoreSymbolType>& alpha = std::get<2>(transition.first);
623 const ext::vector<PushdownStoreSymbolType>& beta = std::get<2>(key);
624
625 const ext::vector<PushdownStoreSymbolType>& shorter = (alpha.size() < beta.size()) ? alpha : beta;
626 const ext::vector<PushdownStoreSymbolType>& longer = (alpha.size() < beta.size()) ? beta : alpha;
627
628 for(auto itS = shorter.begin(), itL = longer.begin(); itS != shorter.end(); ++itS, ++itL) {
629 if(*itS != *itL) return false;
630 }
631 return true;
632 }
633 return false;
634 }))
635 throw AutomatonException("Conflicting transition");
636 }
637
638 transitions.insert ( std::move(key), std::move(value) );
639 return true;
640}
641
642template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
644 common::symbol_or_epsilon < InputSymbolType > inputVariant(std::move(input));
645 return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push));
646}
647
648template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
650 auto inputVariant = common::symbol_or_epsilon < InputSymbolType > ( );
651 return addTransition(std::move(from), std::move(inputVariant), std::move(pop), std::move(to), std::move(push));
652}
653
654template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
658
659 if (transitions.find(key) == transitions.end())
660 return false;
661
662 if(transitions.find(key)->second != value)
663 throw AutomatonException( "Transition (\"" + ext::to_string ( from ) + "\", \"" + ext::to_string ( input ) + "\") -> \"to\" doesn't exist.");
664
665 transitions.erase(key);
666 return true;
667}
668
669template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
672 return removeTransition(from, inputVariant, pop, to, push);
673}
674
675template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
677 auto inputVariant = common::symbol_or_epsilon < InputSymbolType > ( );
678 return removeTransition(from, inputVariant, pop, to, push);
679}
680
681template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
683 return transitions;
684}
685
686template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
688 return std::move ( transitions );
689}
690
691template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
693 if( ! getStates().count(from) )
694 throw AutomatonException("State \"" + ext::to_string ( from ) + "\" doesn't exist");
695
698 if (std::get<0>(transition.first) == from) {
699 transitionsFromState.insert ( transition.first, transition.second );
700 }
701 }
702
703 return transitionsFromState;
704}
705
706template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
708 if( ! getStates().count(to))
709 throw AutomatonException("State \"" + ext::to_string ( to ) + "\" doesn't exist");
710
713 if (transition.second.first == to) {
714 transitionsToState.insert ( transition.first, transition.second );
715 }
716 }
717
718 return transitionsToState;
719}
720
721} /* namespace automaton */
722
723namespace core {
724
732template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
733class SetConstraint< automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, InputSymbolType, automaton::InputAlphabet > {
734public:
743 static bool used ( const automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const InputSymbolType & symbol ) {
745 if ( ! std::get<1>(transition.first).is_epsilon() && symbol == std::get<1>(transition.first).getSymbol())
746 return true;
747
748 return false;
749 }
750
760 return true;
761 }
762
770 }
771};
772
780template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
781class SetConstraint< automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::PushdownStoreAlphabet > {
782public:
791 static bool used ( const automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) {
792 if(automaton.getInitialSymbol() == symbol)
793 return true;
794
796 const auto & popSymbols = std::get<2>(transition.first);
797 const auto & pushSymbols = transition.second.second;
798 if(ext::contains(popSymbols.begin(), popSymbols.end(), symbol ) || ext::contains(pushSymbols.begin(), pushSymbols.end(), symbol))
799 return true;
800 }
801
802 return false;
803 }
804
813 static bool available ( const automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const PushdownStoreSymbolType & ) {
814 return true;
815 }
816
823 static void valid ( const automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const PushdownStoreSymbolType & ) {
824 }
825};
826
834template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
835class ElementConstraint< automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, PushdownStoreSymbolType, automaton::InitialSymbol > {
836public:
845 static bool available ( const automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > & automaton, const PushdownStoreSymbolType & symbol ) {
846 return automaton.template accessComponent < automaton::PushdownStoreAlphabet > ( ).get ( ).count ( symbol );
847 }
848
855 static void valid ( const automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > &, const PushdownStoreSymbolType & ) {
856 }
857};
858
866template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
867class SetConstraint< automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::States > {
868public:
878 if ( automaton.getInitialState ( ) == state )
879 return true;
880
881 if ( automaton.getFinalStates ( ).count ( state ) )
882 return true;
883
885 if ( state == std::get<0>(transition.first) || transition.second.first == state )
886 return true;
887
888 return false;
889 }
890
900 return true;
901 }
902
910 }
911};
912
920template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
921class SetConstraint< automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::FinalStates > {
922public:
932 return false;
933 }
934
944 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
945 }
946
954 }
955};
956
964template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
965class ElementConstraint< automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType >, StateType, automaton::InitialState > {
966public:
976 return automaton.template accessComponent < automaton::States > ( ).get ( ).count ( state );
977 }
978
986 }
987};
988
994template < class InputSymbolType, class PushdownStoreSymbolType, class StateType >
995struct normalize < automaton::DPDA < InputSymbolType, PushdownStoreSymbolType, StateType > > {
997 ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( value ).getInputAlphabet ( ) );
998 ext::set < DefaultSymbolType > pushdownAlphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( value ).getPushdownStoreAlphabet ( ) );
999 DefaultSymbolType initialSymbol = alphabet::SymbolNormalize::normalizeSymbol ( std::move ( value ).getInitialSymbol ( ) );
1000 ext::set < DefaultStateType > states = automaton::AutomatonNormalize::normalizeStates ( std::move ( value ).getStates ( ) );
1001 DefaultStateType initialState = automaton::AutomatonNormalize::normalizeState ( std::move ( value ).getInitialState ( ) );
1002 ext::set < DefaultStateType > finalStates = automaton::AutomatonNormalize::normalizeStates ( std::move ( value ).getFinalStates ( ) );
1003
1004 automaton::DPDA < > res ( std::move ( states ), std::move ( alphabet ), std::move ( pushdownAlphabet ), std::move ( initialState ), std::move ( initialSymbol ), std::move ( finalStates ) );
1005
1007 ext::vector < DefaultSymbolType > pop = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( std::get < 2 > ( transition.first ) ) );
1008 DefaultStateType from = automaton::AutomatonNormalize::normalizeState ( std::move ( std::get < 0 > ( transition.first ) ) );
1009 common::symbol_or_epsilon < DefaultSymbolType > input = automaton::AutomatonNormalize::normalizeSymbolEpsilon ( std::move ( std::get < 1 > ( transition.first ) ) );
1010
1011 DefaultStateType to = automaton::AutomatonNormalize::normalizeState ( std::move ( transition.second.first ) );
1012 ext::vector < DefaultSymbolType > push = alphabet::SymbolNormalize::normalizeSymbols ( std::move ( transition.second.second ) );
1013
1014 res.addTransition ( std::move ( from ), std::move ( input ), std::move ( pop ), std::move ( to ), std::move ( push ) );
1015 }
1016
1017 return res;
1018 }
1019};
1020
1021} /* namespace core */
1022
1023extern template class automaton::DPDA < >;
1024
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. Accepts subset of context free languages.
Definition: DPDA.h:78
ext::set< StateType > && getFinalStates() &&
Definition: DPDA.h:203
const PushdownStoreSymbolType & getInitialSymbol() const &
Definition: DPDA.h:301
const ext::set< PushdownStoreSymbolType > & getPushdownStoreAlphabet() const &
Definition: DPDA.h:243
const ext::set< InputSymbolType > & getInputAlphabet() const &
Definition: DPDA.h:330
DPDA(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: DPDA.h:559
void setFinalStates(ext::set< StateType > states)
Definition: DPDA.h:223
bool addPushdownStoreSymbol(PushdownStoreSymbolType symbol)
Definition: DPDA.h:263
ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, ext::vector< PushdownStoreSymbolType > >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > getTransitionsFromState(const StateType &from) const
Definition: DPDA.h:692
void setInputAlphabet(ext::set< InputSymbolType > symbols)
Definition: DPDA.h:368
bool addInputSymbol(InputSymbolType symbol)
Definition: DPDA.h:350
bool operator==(const DPDA &other) const
Definition: DPDA.h:533
bool removeTransition(const StateType &from, const common::symbol_or_epsilon< InputSymbolType > &input, const ext::vector< PushdownStoreSymbolType > &pop, const StateType &to, const ext::vector< PushdownStoreSymbolType > &push)
Removes a transition from the automaton.
Definition: DPDA.h:655
ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, ext::vector< PushdownStoreSymbolType > >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > getTransitionsToState(const StateType &to) const
Definition: DPDA.h:707
bool addTransition(StateType from, common::symbol_or_epsilon< InputSymbolType > input, ext::vector< PushdownStoreSymbolType > pop, StateType to, ext::vector< PushdownStoreSymbolType > push)
Adds a transition to the automaton.
Definition: DPDA.h:567
bool setInitialState(StateType state)
Definition: DPDA.h:136
void setStates(ext::set< StateType > states)
Definition: DPDA.h:174
bool addState(StateType state)
Definition: DPDA.h:165
void addInputSymbols(ext::set< InputSymbolType > symbols)
Definition: DPDA.h:359
bool setInitialSymbol(PushdownStoreSymbolType symbol)
Definition: DPDA.h:321
InputSymbolTypeT InputSymbolType
Definition: DPDA.h:80
void removePushdownStoreSymbol(const PushdownStoreSymbolType &symbol)
Definition: DPDA.h:292
StateType && getInitialState() &&
Definition: DPDA.h:125
PushdownStoreSymbolType && getInitialSymbol() &&
Definition: DPDA.h:310
void addPushdownStoreSymbols(ext::set< PushdownStoreSymbolType > symbols)
Definition: DPDA.h:272
void removeState(const StateType &state)
Definition: DPDA.h:185
const ext::set< StateType > & getStates() const &
Definition: DPDA.h:145
ext::set< PushdownStoreSymbolType > && getPushdownStoreAlphabet() &&
Definition: DPDA.h:252
ext::set< StateType > && getStates() &&
Definition: DPDA.h:154
PushdownStoreSymbolTypeT PushdownStoreSymbolType
Definition: DPDA.h:81
ext::set< InputSymbolType > && getInputAlphabet() &&
Definition: DPDA.h:339
void setPushdownStoreAlphabet(ext::set< PushdownStoreSymbolType > symbols)
Definition: DPDA.h:281
void removeInputSymbol(const InputSymbolType &symbol)
Definition: DPDA.h:379
const ext::map< ext::tuple< StateType, common::symbol_or_epsilon< InputSymbolType >, ext::vector< PushdownStoreSymbolType > >, ext::pair< StateType, ext::vector< PushdownStoreSymbolType > > > & getTransitions() const &
Definition: DPDA.h:682
friend ext::ostream & operator<<(ext::ostream &out, const DPDA &instance)
Definition: DPDA.h:545
const ext::set< StateType > & getFinalStates() const &
Definition: DPDA.h:194
bool addFinalState(StateType state)
Definition: DPDA.h:214
void removeFinalState(const StateType &state)
Definition: DPDA.h:234
StateTypeT StateType
Definition: DPDA.h:82
const StateType & getInitialState() const &
Definition: DPDA.h:116
Definition: symbol_or_epsilon.hpp:24
Definition: components.hpp:181
static bool available(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &automaton, const PushdownStoreSymbolType &symbol)
Definition: DPDA.h:845
static void valid(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const PushdownStoreSymbolType &)
Definition: DPDA.h:855
static void valid(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType &)
Definition: DPDA.h:985
static bool available(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &automaton, const StateType &state)
Definition: DPDA.h:975
Definition: components.hpp:25
static bool available(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const InputSymbolType &)
Definition: DPDA.h:759
static void valid(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const InputSymbolType &)
Definition: DPDA.h:769
static bool used(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &automaton, const InputSymbolType &symbol)
Definition: DPDA.h:743
static bool available(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const PushdownStoreSymbolType &)
Definition: DPDA.h:813
static bool used(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &automaton, const PushdownStoreSymbolType &symbol)
Definition: DPDA.h:791
static void valid(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const PushdownStoreSymbolType &)
Definition: DPDA.h:823
static void valid(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType &)
Definition: DPDA.h:909
static bool used(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &automaton, const StateType &state)
Definition: DPDA.h:877
static bool available(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType &)
Definition: DPDA.h:899
static bool used(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType &)
Definition: DPDA.h:931
static void valid(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &, const StateType &)
Definition: DPDA.h:953
static bool available(const automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &automaton, const StateType &state)
Definition: DPDA.h:943
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
Definition: ostream.h:14
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: set.hpp:44
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: Object.h:16
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 &param)
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
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
static automaton::DPDA< > eval(automaton::DPDA< InputSymbolType, PushdownStoreSymbolType, StateType > &&value)
Definition: DPDA.h:996
Definition: normalize.hpp:13