Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
EpsilonNFA.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#include <ostream>
27
28#include <alib/multimap>
29#include <alib/set>
30
31#include <core/components.hpp>
33
37
39
41
42#include <core/normalize.hpp>
45
47#include "NFA.h"
48#include "DFA.h"
49
50namespace automaton {
51
52class InputAlphabet;
53class States;
54class FinalStates;
55class InitialState;
56
73template < class SymbolTypeT = DefaultSymbolType, class StateTypeT = DefaultStateType >
74class EpsilonNFA final : public core::Components < EpsilonNFA < SymbolTypeT, StateTypeT >, ext::set < SymbolTypeT >, component::Set, InputAlphabet, ext::set < StateTypeT >, component::Set, std::tuple < States, FinalStates >, StateTypeT, component::Value, InitialState > {
75public:
76 typedef SymbolTypeT SymbolType;
77 typedef StateTypeT StateType;
78
79private:
84
85public:
91 explicit EpsilonNFA ( StateType initialState );
92
101 explicit EpsilonNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates );
102
103 /*
104 * \brief Creates a new instance of Nondeterministic finite automaton based on the Deterministic finite automaton.
105 *
106 * \param other the Nondeterministic finite automaton with multiple initial states
107 */
109
110 /*
111 * \brief Creates a new instance of Nondeterministic finite automaton based on the Deterministic finite automaton.
112 *
113 * \param other the Nondeterministic finite automaton
114 */
115 explicit EpsilonNFA ( const NFA < SymbolType, StateType > & other );
116
117 /*
118 * \brief creates a new instance of the automaton based on the deterministic finite automaton.
119 *
120 * \param other the deterministic finite automaton
121 */
122 explicit EpsilonNFA ( const DFA < SymbolType, StateType > & other );
123
129 const StateType & getInitialState ( ) const & {
130 return this->template accessComponent < InitialState > ( ).get ( );
131 }
132
139 return std::move ( this->template accessComponent < InitialState > ( ).get ( ) );
140 }
141
149 bool setInitialState ( StateType state ) {
150 return this->template accessComponent < InitialState > ( ).set ( std::move ( state ) );
151 }
152
158 const ext::set < StateType > & getStates ( ) const & {
159 return this->template accessComponent < States > ( ).get ( );
160 }
161
168 return std::move ( this->template accessComponent < States > ( ).get ( ) );
169 }
170
178 bool addState ( StateType state ) {
179 return this->template accessComponent < States > ( ).add ( std::move ( state ) );
180 }
181
188 this->template accessComponent < States > ( ).set ( std::move ( states ) );
189 }
190
198 void removeState ( const StateType & state ) {
199 this->template accessComponent < States > ( ).remove ( state );
200 }
201
208 return this->template accessComponent < FinalStates > ( ).get ( );
209 }
210
217 return std::move ( this->template accessComponent < FinalStates > ( ).get ( ) );
218 }
219
227 bool addFinalState ( StateType state ) {
228 return this->template accessComponent < FinalStates > ( ).add ( std::move ( state ) );
229 }
230
237 this->template accessComponent < FinalStates > ( ).set ( std::move ( states ) );
238 }
239
247 void removeFinalState ( const StateType & state ) {
248 this->template accessComponent < FinalStates > ( ).remove ( state );
249 }
250
257 return this->template accessComponent < InputAlphabet > ( ).get ( );
258 }
259
266 return std::move ( this->template accessComponent < InputAlphabet > ( ).get ( ) );
267 }
268
276 bool addInputSymbol ( SymbolType symbol ) {
277 return this->template accessComponent < InputAlphabet > ( ).add ( std::move ( symbol ) );
278 }
279
286 this->template accessComponent < InputAlphabet > ( ).add ( std::move ( symbols ) );
287 }
288
295 this->template accessComponent < InputAlphabet > ( ).set ( std::move ( symbols ) );
296 }
297
305 void removeInputSymbol ( const SymbolType & symbol ) {
306 this->template accessComponent < InputAlphabet > ( ).remove ( symbol );
307 }
308
323
337 bool addTransition ( StateType from, SymbolType input, StateType to );
338
351 bool addTransition ( StateType from, StateType to );
352
367
379 bool removeTransition ( const StateType & from, const SymbolType & input, const StateType & to );
380
391 bool removeTransition ( const StateType & from, const StateType & to );
392
399
405 ext::multimap < ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > && getTransitions ( ) &&;
406
412 ext::multimap < StateType, StateType > getEpsilonTransitions ( ) const;
413
419 ext::multimap < ext::pair < StateType, SymbolType >, StateType > getSymbolTransitions ( ) const;
420
428 ext::multimap < ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > getTransitionsFromState ( const StateType & from ) const;
429
437 ext::multimap < StateType, StateType > getEpsilonTransitionsFromState ( const StateType & from ) const;
438
446 ext::multimap < ext::pair < StateType, SymbolType >, StateType > getSymbolTransitionsFromState ( const StateType & from ) const;
447
455 ext::multimap < ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > getTransitionsToState ( const StateType & to ) const;
456
464 ext::multimap < StateType, StateType > getEpsilonTransitionsToState ( const StateType & to ) const;
465
473 ext::multimap < ext::pair < StateType, SymbolType >, StateType > getSymbolTransitionsToState ( const StateType & to ) const;
474
480 bool isEpsilonFree ( ) const;
481
491 bool isDeterministic ( ) const;
492
502 bool isTotal ( ) const;
503
511 auto operator <=> ( const EpsilonNFA & other ) const {
512 return std::tie ( getStates ( ), getInputAlphabet ( ), getInitialState ( ), getFinalStates ( ), transitions ) <=> std::tie ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ), other.getTransitions ( ) );
513 }
514
522 bool operator == ( const EpsilonNFA & other ) const {
523 return std::tie ( getStates ( ), getInputAlphabet ( ), getInitialState ( ), getFinalStates ( ), transitions ) == std::tie ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ), other.getTransitions ( ) );
524 }
525
534 friend ext::ostream & operator << ( ext::ostream & out, const EpsilonNFA & instance ) {
535 return out << "(EpsilonNFA"
536 << " states = " << instance.getStates ( )
537 << " inputAlphabet = " << instance.getInputAlphabet ( )
538 << " initialState = " << instance.getInitialState ( )
539 << " finalStates = " << instance.getFinalStates ( )
540 << " transitions = " << instance.getTransitions ( )
541 << ")";
542 }
543};
544
550template < class T >
551class isEpsilonNFA_impl : public std::false_type {};
552
561template < class SymbolType, class StateType >
562class isEpsilonNFA_impl < EpsilonNFA < SymbolType, StateType > > : public std::true_type {};
563
569template < class T >
571
572template<class SymbolType, class StateType >
573EpsilonNFA < SymbolType, StateType >::EpsilonNFA ( ext::set < StateType > states, ext::set < SymbolType > inputAlphabet, StateType initialState, ext::set < StateType > finalStates ) : core::Components < EpsilonNFA, ext::set < SymbolType >, component::Set, InputAlphabet, ext::set < StateType >, component::Set, std::tuple < States, FinalStates >, StateType, component::Value, InitialState > ( std::move ( inputAlphabet ), std::move ( states ), std::move ( finalStates ), std::move ( initialState ) ) {
574}
575
576template<class SymbolType, class StateType >
578}
579
580
581template<class SymbolType, class StateType >
582EpsilonNFA < SymbolType, StateType >::EpsilonNFA ( const MultiInitialStateNFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ) + ext::set < StateType > { common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ) }, other.getInputAlphabet ( ), common::createUnique ( label::InitialStateLabel::instance < StateType > ( ), other.getStates ( ) ), other.getFinalStates ( ) ) {
583 for ( const auto & transition : other.getTransitions ( ) )
584 transitions.insert ( ext::make_pair ( transition.first.first, common::symbol_or_epsilon < SymbolType > ( transition.first.second ) ), transition.second );
585
586 for ( const auto & initialState : other.getInitialStates ( ) )
587 transitions.insert ( ext::make_pair ( getInitialState ( ), common::symbol_or_epsilon < SymbolType > ( ) ), initialState );
588}
589
590
591template<class SymbolType, class StateType >
592EpsilonNFA < SymbolType, StateType >::EpsilonNFA ( const NFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) {
593 for ( const auto & transition : other.getTransitions ( ) )
594 transitions.insert ( ext::make_pair ( transition.first.first, common::symbol_or_epsilon < SymbolType > ( transition.first.second ) ), transition.second );
595}
596
597template<class SymbolType, class StateType >
598EpsilonNFA < SymbolType, StateType >::EpsilonNFA ( const DFA < SymbolType, StateType > & other ) : EpsilonNFA ( other.getStates ( ), other.getInputAlphabet ( ), other.getInitialState ( ), other.getFinalStates ( ) ) {
599 for ( const auto & transition : other.getTransitions ( ) )
600 transitions.insert ( ext::make_pair ( transition.first.first, common::symbol_or_epsilon < SymbolType > ( transition.first.second ) ), transition.second );
601}
602
603template<class SymbolType, class StateType >
605 if ( ! getStates ( ).contains ( from ) )
606 throw AutomatonException ( "State \"" + ext::to_string ( from ) + "\" doesn't exist." );
607
608 if ( ! input.is_epsilon ( ) && !getInputAlphabet ( ).contains ( input.getSymbol ( ) ) )
609 throw AutomatonException ( "Input symbol \"" + ext::to_string ( input ) + "\" doesn't exist." );
610
611 if ( ! getStates ( ).contains ( to ) )
612 throw AutomatonException ( "State \"" + ext::to_string ( to ) + "\" doesn't exist." );
613
614 auto upper_bound = transitions.upper_bound ( ext::tie ( from, input ) );
615 auto lower_bound = transitions.lower_bound ( ext::tie ( from, input ) );
616 auto iter = std::lower_bound ( lower_bound, upper_bound, to, [ ] ( const auto & transition, const auto & target ) { return transition.second < target; } );
617 if ( iter != upper_bound && to >= iter->second )
618 return false;
619
620 ext::pair < StateType, common::symbol_or_epsilon < SymbolType > > key = ext::make_pair ( std::move ( from ), std::move ( input ) );
621 transitions.insert ( iter, std::make_pair ( std::move ( key ), std::move ( to ) ) );
622 return true;
623}
624
625template<class SymbolType, class StateType >
627 common::symbol_or_epsilon < SymbolType > inputVariant ( std::move ( input ) );
628
629 return addTransition ( std::move ( from ), std::move ( inputVariant ), std::move ( to ) );
630}
631
632template<class SymbolType, class StateType >
634 auto inputVariant = common::symbol_or_epsilon < SymbolType > ( );
635
636 return addTransition ( std::move ( from ), std::move ( inputVariant ), std::move ( to ) );
637}
638
639template<class SymbolType, class StateType >
641 auto upper_bound = transitions.upper_bound ( ext::tie ( from, input ) );
642 auto lower_bound = transitions.lower_bound ( ext::tie ( from, input ) );
643 auto iter = std::find_if ( lower_bound, upper_bound, [ & ] ( const auto & transition ) { return transition.second == to; } );
644 if ( iter == upper_bound )
645 return false;
646
647 transitions.erase ( iter );
648 return true;
649}
650
651template<class SymbolType, class StateType >
653 common::symbol_or_epsilon < SymbolType > inputVariant ( std::move ( input ) );
654
655 return addTransition ( std::move ( from ), std::move ( inputVariant ), std::move ( to ) );
656}
657
658template<class SymbolType, class StateType >
660 auto inputVariant = common::symbol_or_epsilon < SymbolType > ( );
661
662 return addTransition ( std::move ( from ), std::move ( inputVariant ), std::move ( to ) );
663}
664
665template<class SymbolType, class StateType >
667 return transitions;
668}
669
670template<class SymbolType, class StateType >
672 return std::move ( transitions );
673}
674
675template<class SymbolType, class StateType >
678
679 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
680 if ( transition.first.second.is_epsilon ( ) )
681 result.insert ( transition.first.first, transition.second );
682
683 return result;
684}
685
686template<class SymbolType, class StateType >
689
690 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
691 if ( ! transition.first.second.is_epsilon ( ) )
692 result.insert ( ext::make_pair ( transition.first.first, transition.first.second.getSymbol ( ) ), transition.second );
693
694 return result;
695}
696
697template<class SymbolType, class StateType >
699 if ( ! getStates ( ).contains ( from ) )
700 throw AutomatonException ( "State \"" + ext::to_string ( from ) + "\" doesn't exist" );
701
703
704 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
705 if ( transition.first.first == from )
706 transitionsFromState.insert ( transition );
707
708 return transitionsFromState;
709}
710
711template<class SymbolType, class StateType >
713 if ( ! getStates ( ).contains ( from ) )
714 throw AutomatonException ( "State \"" + ext::to_string ( from ) + "\" doesn't exist" );
715
718 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions.equal_range ( key ) )
719 res.insert ( transition.first.first, transition.second );
720
721 return res;
722}
723
724template<class SymbolType, class StateType >
726 if ( ! getStates ( ).contains ( from ) )
727 throw AutomatonException ( "State \"" + ext::to_string ( from ) + "\" doesn't exist" );
728
730
731 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
732 if ( ( transition.first.first == from ) && ! transition.first.second.is_epsilon ( ) )
733 transitionsFromState.insert ( std::make_pair ( ext::make_pair ( transition.first.first, transition.first.second.getSymbol ( ) ), transition.second ) );
734
735 return transitionsFromState;
736}
737
738template<class SymbolType, class StateType >
740 if ( ! getStates ( ).contains ( to ) )
741 throw AutomatonException ( "State \"" + ext::to_string ( to ) + "\" doesn't exist" );
742
744
745 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
746 if ( transition.second == to )
747 transitionsToState.insert ( transition );
748
749 return transitionsToState;
750}
751
752template<class SymbolType, class StateType >
754 if ( ! getStates ( ).contains ( to ) )
755 throw AutomatonException ( "State \"" + ext::to_string ( to ) + "\" doesn't exist" );
756
758
759 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
760 if ( transition.second == to && transition.first.second.is_epsilon ( ) )
761 transitionsToState.insert ( transition.first.first, to );
762
763 return transitionsToState;
764}
765
766template<class SymbolType, class StateType >
768 if ( ! getStates ( ).contains ( to ) )
769 throw AutomatonException ( "State \"" + ext::to_string ( to ) + "\" doesn't exist" );
770
772
773 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
774 if ( transition.second == to && ! transition.first.second.is_epsilon ( ) )
775 transitionsToState.insert ( ext::pair < StateType, SymbolType > ( transition.first.first, transition.first.second.getSymbol ( ) ), to );
776
777 return transitionsToState;
778}
779
780template<class SymbolType, class StateType >
782 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : transitions )
783 if ( transition.first.second.is_epsilon ( ) )
784 return false;
785
786 return true;
787}
788
789template<class SymbolType, class StateType >
791 if ( transitions.empty ( ) )
792 return true;
793
794 for ( auto iter = transitions.begin ( ); std::next ( iter ) != transitions.end ( ); ++ iter )
795 if ( iter->first == std::next ( iter )->first )
796 return false;
797
798 return isEpsilonFree ( );
799}
800
801template<class SymbolType, class StateType >
803 return isDeterministic ( ) && transitions.size ( ) == getInputAlphabet ( ).size ( ) * getStates ( ).size ( );
804}
805
806} /* namespace automaton */
807
808namespace core {
809
816template<class SymbolType, class StateType >
817class SetConstraint< automaton::EpsilonNFA < SymbolType, StateType >, SymbolType, automaton::InputAlphabet > {
818public:
828 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : automaton.getTransitions ( ) )
829 if ( ! transition.first.second.is_epsilon ( ) && ( transition.first.second.getSymbol ( ) == symbol ) )
830 return true;
831
832 return false;
833 }
834
844 return true;
845 }
846
854 }
855};
856
863template<class SymbolType, class StateType >
864class SetConstraint< automaton::EpsilonNFA < SymbolType, StateType >, StateType, automaton::States > {
865public:
875 if ( automaton.getInitialState ( ) == state )
876 return true;
877
878 if ( automaton.getFinalStates ( ).contains ( state ) )
879 return true;
880
881 for ( const std::pair < const ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > & transition : automaton.getTransitions ( ) )
882 if ( transition.first.first == state || transition.second == state )
883 return true;
884
885 return false;
886 }
887
897 return true;
898 }
899
907 }
908};
909
916template<class SymbolType, class StateType >
917class SetConstraint< automaton::EpsilonNFA < SymbolType, StateType >, StateType, automaton::FinalStates > {
918public:
928 return false;
929 }
930
940 return automaton.template accessComponent < automaton::States > ( ).get ( ).contains ( state );
941 }
942
950 }
951};
952
959template<class SymbolType, class StateType >
960class ElementConstraint< automaton::EpsilonNFA < SymbolType, StateType >, StateType, automaton::InitialState > {
961public:
971 return automaton.template accessComponent < automaton::States > ( ).get ( ).contains ( state );
972 }
973
981 }
982};
983
989template<class SymbolType, class StateType >
990struct normalize < automaton::EpsilonNFA < SymbolType, StateType > > {
992 ext::set < DefaultSymbolType > alphabet = alphabet::SymbolNormalize::normalizeAlphabet ( std::move ( value ).getInputAlphabet ( ) );
993 ext::set < DefaultStateType > states = automaton::AutomatonNormalize::normalizeStates ( std::move ( value ).getStates ( ) );
994 DefaultStateType initialState = automaton::AutomatonNormalize::normalizeState ( std::move ( value ).getInitialState ( ) );
995 ext::set < DefaultStateType > finalStates = automaton::AutomatonNormalize::normalizeStates ( std::move ( value ).getFinalStates ( ) );
996
997 automaton::EpsilonNFA < > res ( std::move ( states ), std::move ( alphabet ), std::move ( initialState ), std::move ( finalStates ) );
998
999 for ( std::pair < ext::pair < StateType, common::symbol_or_epsilon < SymbolType > >, StateType > && transition : ext::make_mover ( std::move ( value ).getTransitions ( ) ) ) {
1000 DefaultStateType from = automaton::AutomatonNormalize::normalizeState ( std::move ( transition.first.first ) );
1002 DefaultStateType target = automaton::AutomatonNormalize::normalizeState ( std::move ( transition.second ) );
1003
1004 res.addTransition ( std::move ( from ), std::move ( input ), std::move ( target ) );
1005 }
1006
1007 return res;
1008 }
1009};
1010
1011} /* namespace core */
1012
1013extern template class automaton::EpsilonNFA < >;
1014
static ext::set< DefaultSymbolType > normalizeAlphabet(ext::set< SymbolType > &&symbols)
Definition: SymbolNormalize.h:50
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 finite automaton. Accepts regular languages.
Definition: DFA.h:71
Epsilon nondeterministic finite automaton. Accepts regular languages.
Definition: EpsilonNFA.h:74
ext::set< SymbolType > && getInputAlphabet() &&
Definition: EpsilonNFA.h:265
const ext::set< StateType > & getStates() const &
Definition: EpsilonNFA.h:158
ext::multimap< StateType, StateType > getEpsilonTransitions() const
Definition: EpsilonNFA.h:676
bool isEpsilonFree() const
Determines whether the automaton is without epsilon transitions.
Definition: EpsilonNFA.h:781
void removeState(const StateType &state)
Definition: EpsilonNFA.h:198
StateType && getInitialState() &&
Definition: EpsilonNFA.h:138
bool addTransition(StateType from, common::symbol_or_epsilon< SymbolType > input, StateType to)
Add a transition to the automaton.
Definition: EpsilonNFA.h:604
SymbolTypeT SymbolType
Definition: EpsilonNFA.h:76
void addInputSymbols(ext::set< SymbolType > symbols)
Definition: EpsilonNFA.h:285
ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< SymbolType > >, StateType > getTransitionsFromState(const StateType &from) const
Definition: EpsilonNFA.h:698
bool addInputSymbol(SymbolType symbol)
Definition: EpsilonNFA.h:276
void setInputAlphabet(ext::set< SymbolType > symbols)
Definition: EpsilonNFA.h:294
EpsilonNFA(StateType initialState)
Creates a new instance of the automaton with a concrete initial state.
Definition: EpsilonNFA.h:577
ext::set< StateType > && getStates() &&
Definition: EpsilonNFA.h:167
bool setInitialState(StateType state)
Definition: EpsilonNFA.h:149
void removeInputSymbol(const SymbolType &symbol)
Definition: EpsilonNFA.h:305
bool isDeterministic() const
Determines whether the automaton is deterministic.
Definition: EpsilonNFA.h:790
ext::set< StateType > && getFinalStates() &&
Definition: EpsilonNFA.h:216
ext::multimap< StateType, StateType > getEpsilonTransitionsFromState(const StateType &from) const
Definition: EpsilonNFA.h:712
ext::multimap< StateType, StateType > getEpsilonTransitionsToState(const StateType &to) const
Definition: EpsilonNFA.h:753
bool removeTransition(StateType from, common::symbol_or_epsilon< SymbolType > input, StateType to)
Removes a transition to the automaton.
Definition: EpsilonNFA.h:640
const ext::set< StateType > & getFinalStates() const &
Definition: EpsilonNFA.h:207
const ext::set< SymbolType > & getInputAlphabet() const &
Definition: EpsilonNFA.h:256
ext::multimap< ext::pair< StateType, SymbolType >, StateType > getSymbolTransitions() const
Definition: EpsilonNFA.h:687
const ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< SymbolType > >, StateType > & getTransitions() const &
Definition: EpsilonNFA.h:666
void removeFinalState(const StateType &state)
Definition: EpsilonNFA.h:247
void setFinalStates(ext::set< StateType > states)
Definition: EpsilonNFA.h:236
ext::multimap< ext::pair< StateType, SymbolType >, StateType > getSymbolTransitionsToState(const StateType &to) const
Definition: EpsilonNFA.h:767
StateTypeT StateType
Definition: EpsilonNFA.h:77
ext::multimap< ext::pair< StateType, SymbolType >, StateType > getSymbolTransitionsFromState(const StateType &from) const
Definition: EpsilonNFA.h:725
bool isTotal() const
Determines whether the automaton is total deterministic.
Definition: EpsilonNFA.h:802
const StateType & getInitialState() const &
Definition: EpsilonNFA.h:129
void setStates(ext::set< StateType > states)
Definition: EpsilonNFA.h:187
friend ext::ostream & operator<<(ext::ostream &out, const EpsilonNFA &instance)
Definition: EpsilonNFA.h:534
bool addFinalState(StateType state)
Definition: EpsilonNFA.h:227
ext::multimap< ext::pair< StateType, common::symbol_or_epsilon< SymbolType > >, StateType > getTransitionsToState(const StateType &to) const
Definition: EpsilonNFA.h:739
bool addState(StateType state)
Definition: EpsilonNFA.h:178
bool operator==(const EpsilonNFA &other) const
Definition: EpsilonNFA.h:522
Nondeterministic finite automaton with multiple initial states. Accepts regular languages.
Definition: MultiInitialStateNFA.h:69
Nondeterministic finite automaton. Accepts regular languages.
Definition: NFA.h:66
Definition: EpsilonNFA.h:551
Definition: symbol_or_epsilon.hpp:24
Definition: components.hpp:181
static bool available(const automaton::EpsilonNFA< SymbolType, StateType > &automaton, const StateType &state)
Definition: EpsilonNFA.h:970
static void valid(const automaton::EpsilonNFA< SymbolType, StateType > &, const StateType &)
Definition: EpsilonNFA.h:980
Definition: components.hpp:25
static bool available(const automaton::EpsilonNFA< SymbolType, StateType > &automaton, const StateType &state)
Definition: EpsilonNFA.h:939
static void valid(const automaton::EpsilonNFA< SymbolType, StateType > &, const StateType &)
Definition: EpsilonNFA.h:949
static bool used(const automaton::EpsilonNFA< SymbolType, StateType > &, const StateType &)
Definition: EpsilonNFA.h:927
static bool used(const automaton::EpsilonNFA< SymbolType, StateType > &automaton, const SymbolType &symbol)
Definition: EpsilonNFA.h:827
static bool available(const automaton::EpsilonNFA< SymbolType, StateType > &, const SymbolType &)
Definition: EpsilonNFA.h:843
static void valid(const automaton::EpsilonNFA< SymbolType, StateType > &, const SymbolType &)
Definition: EpsilonNFA.h:853
static bool available(const automaton::EpsilonNFA< SymbolType, StateType > &, const StateType &)
Definition: EpsilonNFA.h:896
static bool used(const automaton::EpsilonNFA< SymbolType, StateType > &automaton, const StateType &state)
Definition: EpsilonNFA.h:874
static void valid(const automaton::EpsilonNFA< SymbolType, StateType > &, const StateType &)
Definition: EpsilonNFA.h:906
Definition: setComponents.hpp:26
Class extending the multimap class from the standard library. Original reason is to allow printing of...
Definition: multimap.hpp:48
iterator insert(const T &key, const R &value)
Insert variant with explicit key and value parameters.
Definition: multimap.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
Definition: Object.h:16
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
for(const StateType &state :fsm.getStates()) renamingData.insert(std Rename::RenamedAutomaton< T > result(renamingData.at(fsm.getInitialState()))
Definition: Rename.h:253
Definition: ToGrammar.h:31
constexpr bool isEpsilonNFA
Definition: EpsilonNFA.h:570
Definition: Permutation.hpp:18
T createUnique(T object, const Alphabets &... alphabets)
Definition: createUnique.hpp:46
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
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::EpsilonNFA< > eval(automaton::EpsilonNFA< SymbolType, StateType > &&value)
Definition: EpsilonNFA.h:991
Definition: normalize.hpp:13